def __init__(self, parent): Frame.__init__( self, x=35, y=20, width=240, height=180, caption=u'帐号信息', parent=parent, ) self.textarea = TextArea( parent=self, x=2, y=10+2, width=240-4, height=180-24-2-10 )
def __init__(self, parent): Frame.__init__( self, parent=parent, caption=u'游戏信息', x=820, y=350, width=204, height=370, bot_reserve=0, bg=common_res.bg_eventsbox.get(), ) self.box = TextArea( parent=self, x=2, y=2, width=200, height=370-24-2 )
def __init__(self, parent): Frame.__init__( self, parent=parent, caption=u'当前在线玩家', x=750, y=220, width=240, height=420, bot_reserve=10, ) self.box = TextArea( parent=self, x=2, y=12, width=240-4, height=420-24-2-10 )
def __init__(self, parent): Frame.__init__( self, parent=parent, caption=u'游戏信息', x=820, y=350, width=204, height=370, bot_reserve=0, bg=common_res.bg_eventsbox, ) self.box = TextArea( parent=self, x=2, y=2, width=200, height=370-24-2 )
def __init__(self, *a, **k): Frame.__init__( self, u'登陆', x=350, y=165, width=325, height=184, bot_reserve=50, *a, **k ) def L(text, x, y, *a, **k): self.add_label( text, x=x, y=y, font_size=9, color=(0, 0, 0, 255), bold=True, anchor_x='left', anchor_y='bottom', *a, **k ) L(u'用户名:', 368 - 350, 286 - 165) L(u'密码:', 368 - 350, 250 - 165) self.txt_username = TextBox( parent=self, x=438-350, y=282-165, width=220, height=20, text=UserSettings.last_id, ) self.txt_pwd = PasswordTextBox( parent=self, x=438-350, y=246-165, width=220, height=20, text='', ) self.btn_login = Button( parent=self, caption=u'进入幻想乡', x=50, y=10, width=100, height=30 ) self.btn_reg = Button( parent=self, caption=u'乡民登记', color=Colors.orange, x=175, y=10, width=100, height=30 ) @self.btn_login.event def on_click(): self.do_login() @self.txt_pwd.event def on_enter(): self.do_login() @self.btn_reg.event # noqa def on_click(): import sys import os if sys.platform == 'win32': os.startfile('http://www.thbattle.net', 'open') elif sys.platform.startswith('linux'): os.system('xdg-open http://www.thbattle.net')
def __init__(self, *a, **k): Frame.__init__( self, u'登陆', x=350, y=165, width=325, height=184, bot_reserve=50, *a, **k ) def L(text, x, y, *a, **k): self.add_label( text, x=x, y=y, font_size=9, color=(0, 0, 0, 255), bold=True, anchor_x='left', anchor_y='bottom', *a, **k ) L(u'用户名:', 368 - 350, 286 - 165) L(u'密码:', 368 - 350, 250 - 165) self.txt_username = TextBox( parent=self, x=438-350, y=282-165, width=220, height=20, text=UserSettings.last_id, ) self.txt_pwd = PasswordTextBox( parent=self, x=438-350, y=246-165, width=220, height=20, text='', ) self.btn_login = Button( parent=self, caption=u'进入幻想乡', x=50, y=10, width=100, height=30 ) self.btn_reg = Button( parent=self, caption=u'乡民登记', color=Colors.orange, x=175, y=10, width=100, height=30 ) @self.btn_login.event def on_click(): self.do_login() @self.txt_pwd.event def on_enter(): self.do_login() @self.btn_reg.event # noqa def on_click(): openurl('http://www.thbattle.net')
def __init__(self, parent): Frame.__init__(self, x=750, y=20, width=240, height=180, caption=u"花果子念报", parent=parent) ta = self.textarea = TextArea(parent=self, x=2, y=10 + 2, width=240 - 4, height=180 - 24 - 2 - 10) ta.text = u"正在获取最新新闻……" def update(rst): if rst: _, content = rst try: ta.text = content.decode("utf-8") return except Exception as e: import traceback traceback.print_exc(e) ta.text = u"|R无法显示新闻!|r" from settings import HALL_NOTICE_URL Executive.call("fetch_resource", update, HALL_NOTICE_URL)
def __init__(self, p): Frame.__init__( self, parent=p, caption=u'当前大厅内的游戏', x=35, y=220, width=700, height=420, bot_reserve=30, bg=common_res.bg_gamelist, ) gl = self.gamelist = ListView(parent=self, x=2, y=30, width=696, height=420-30-25) gl.set_columns([ (u'No.', 100), (u'游戏名称', 200), (u'游戏类型', 200), (u'人数', 50), (u'当前状态', 80), ]) self.btn_create = Button(parent=self, caption=u'创建游戏', x=690-270, y=6, width=70, height=20) self.btn_quickstart = Button(parent=self, caption=u'快速加入', x=690-180, y=6, width=70, height=20) self.btn_refresh = Button(parent=self, caption=u'刷新列表', x=690-90, y=6, width=70, height=20) @self.btn_create.event def on_click(): self.CreateGamePanel(parent=self.overlay) @self.btn_quickstart.event # noqa def on_click(): Executive.call('quick_start_game', ui_message, 'THBattle') @self.btn_refresh.event # noqa def on_click(): Executive.call('get_hallinfo', ui_message, None) @self.gamelist.event def on_item_dblclick(li): # TODO: if li.started: #Executive.call('observe_user', ui_message, li.game_id) self.ObserveGamePanel(li.game_id, parent=self.overlay) else: Executive.call('join_game', ui_message, li.game_id)
def __init__(self, p): Frame.__init__( self, parent=p, caption=u'当前大厅内的游戏', x=35, y=220, width=700, height=420, bot_reserve=30, bg=common_res.bg_gamelist.get(), ) gl = self.gamelist = ListView(parent=self, x=2, y=30, width=696, height=420-30-25) gl.set_columns([ (u'No.', 100), (u'游戏名称', 200), (u'游戏类型', 200), (u'人数', 50), (u'当前状态', 80), ]) self.btn_create = Button(parent=self, caption=u'创建游戏', x=690-270, y=6, width=70, height=20) self.btn_quickstart = Button(parent=self, caption=u'快速加入', x=690-180, y=6, width=70, height=20) self.btn_refresh = Button(parent=self, caption=u'刷新列表', x=690-90, y=6, width=70, height=20) @self.btn_create.event def on_click(): self.CreateGamePanel(parent=self.overlay) @self.btn_quickstart.event # noqa def on_click(): Executive.call('quick_start_game', ui_message, 'THBattle') @self.btn_refresh.event # noqa def on_click(): Executive.call('get_hallinfo', ui_message, None) @self.gamelist.event def on_item_dblclick(li): # TODO: if li.started: #Executive.call('observe_user', ui_message, li.game_id) self.ObserveGamePanel(li.game_id, parent=self.overlay) else: Executive.call('join_game', ui_message, li.game_id)
def __init__(self, p): Frame.__init__( self, parent=p, caption=u"当前大厅内的游戏", x=35, y=220, width=700, height=420, bot_reserve=30, bg=common_res.bg_gamelist.get(), ) gl = self.gamelist = ListView(parent=self, x=2, y=30, width=696, height=420 - 30 - 25) gl.set_columns([(u"No.", 100), (u"游戏名称", 200), (u"游戏类型", 200), (u"人数", 50), (u"当前状态", 80)]) self.btn_create = Button(parent=self, caption=u"创建游戏", x=690 - 270, y=6, width=70, height=20) self.btn_quickstart = Button(parent=self, caption=u"快速加入", x=690 - 180, y=6, width=70, height=20) self.btn_refresh = Button(parent=self, caption=u"刷新列表", x=690 - 90, y=6, width=70, height=20) @self.btn_create.event def on_click(): self.CreateGamePanel(parent=self.overlay) @self.btn_quickstart.event # noqa def on_click(): Executive.call("quick_start_game", ui_message, "THBattle") @self.btn_refresh.event # noqa def on_click(): Executive.call("get_hallinfo", ui_message, None) @self.gamelist.event def on_item_dblclick(li): # TODO: if li.started: # Executive.call('observe_user', ui_message, li.game_id) self.ObserveGamePanel(li.game_id, parent=self.overlay) else: Executive.call("join_game", ui_message, li.game_id)
def __init__(self, *a, **k): Frame.__init__(self, u"登陆", x=350, y=165, width=325, height=184, bot_reserve=50, *a, **k) def L(text, x, y, *a, **k): self.add_label( text, x=x, y=y, font_size=9, color=(0, 0, 0, 255), bold=True, anchor_x="left", anchor_y="bottom", *a, **k ) L(u"用户名:", 368 - 350, 286 - 165) L(u"密码:", 368 - 350, 250 - 165) self.txt_username = TextBox( parent=self, x=438 - 350, y=282 - 165, width=220, height=20, text=UserSettings.last_id ) self.txt_pwd = PasswordTextBox(parent=self, x=438 - 350, y=246 - 165, width=220, height=20, text="") self.btn_login = Button(parent=self, caption=u"进入幻想乡", x=50, y=10, width=100, height=30) self.btn_reg = Button(parent=self, caption=u"乡民登记", color=Colors.orange, x=175, y=10, width=100, height=30) @self.btn_login.event def on_click(): self.do_login() @self.txt_pwd.event def on_enter(): self.do_login() @self.btn_reg.event # noqa def on_click(): openurl("http://www.thbattle.net")
def __init__(self, parent): Frame.__init__( self, x=750, y=20, width=240, height=180, caption=u'花果子念报', parent=parent, ) ta = self.textarea = TextArea( parent=self, x=2, y=10+2, width=240-4, height=180-24-2-10 ) ta.text = u'正在获取最新新闻……' def update(rst): if rst: _, content = rst try: ta.text = content.decode('utf-8') return except Exception as e: import traceback traceback.print_exc(e) ta.text = u'|R无法显示新闻!|r' from settings import HALL_NOTICE_URL Executive.call('fetch_resource', update, HALL_NOTICE_URL)
def __init__(self, **k): Frame.__init__( self, caption=u'系统/聊天信息', bot_reserve=33, **k ) self.box = TextArea( parent=self, x=2, y=33+2, width=self.width, height=self.height-24-2-33 ) self.inputbox = TextBox( parent=self, x=6, y=6, width=self.width-12, height=22, ) self.history_cursor = -1 self.last_input = u'' @self.inputbox.event def on_text_motion(motion): hist = self.history cursor = self.history_cursor box = self.inputbox from pyglet.window import key if motion == key.MOTION_UP: cursor += 1 if not cursor: self.last_input = box.text text = hist[cursor] if text: self.history_cursor = cursor box.text = text box.caret.position = len(text) if motion == key.MOTION_DOWN: if cursor < 0: return cursor -= 1 if cursor < 0: self.history_cursor = -1 box.text = self.last_input return text = hist[cursor] if text: box.text = text box.caret.position = len(text) self.history_cursor = cursor else: self.history_cursor = -1 @self.inputbox.event def on_enter(): text = unicode(self.inputbox.text) self.inputbox.text = u'' if not text: return self.add_history(text) if text.startswith(u'`') and len(text) > 1: text = text[1:] if not text: return Executive.call('speaker', ui_message, text) elif text.startswith(u'/'): from . import commands cmdline = shlex.split(text[1:]) msg = commands.process_command(cmdline) msg and self.append(msg) else: Executive.call('chat', ui_message, text)
def __init__(self, x=0.0, y=0.0, color=Colors.blue, tag_placement='me', *args, **kwargs): self.player = None self.character = None self._disabled = False self._selected = False self.taganims = [] self.tag_placement = tag_placement self._color = color self.bg = None self._last_balloon = None Frame.__init__(self, width=149, height=195, bot_reserve=20, color=color, thin_shadow=True, **kwargs) self.x, self.y = x, y self.charname_lbl = self.add_label( u'', 7, self.height - 30, width=16, multiline=True, font_size=9, anchor_x='left', anchor_y='top', color=(255, 255, 255, 255), shadow=(1, 0, 0, 0, 179), ) from .view import THBattleUI v = self.parent while not isinstance(v, THBattleUI): v = v.parent self.view = v self.portcard_area = PortraitCardArea( parent=self.view, x=self.x, y=self.y, width=self.width, height=self.height, zindex=100, ) self.equipcard_area = EquipCardArea( parent=self, x=3, y=6, ) w, h = self.width, self.height self.identity_btn = b = Button( u'?', parent=self, x=w - 42 - 4, y=h - 24 - 10 - 18, width=42, height=18, ) self.cur_idtag = 0 @b.event def on_click(): g = Game.getgame() tbl = g.ui_meta.identity_table colortbl = g.ui_meta.identity_color keys = tbl.keys() try: i = (keys.index(self.cur_idtag) + 1) % len(keys) except ValueError: i = 0 next = keys[i] b.caption = tbl[next] color = getattr(Colors, colortbl[next]) b.color = color self.set_color(color) b.update() self.update() self.cur_idtag = next @self.equipcard_area.event def on_selection_change(): self.view.dispatch_event('on_selection_change') def tagarrange_bottom(): x, y = self.x, self.y w, h = self.width, self.height x += w + 1 y -= 27 for a in self.taganims: # they are pyglet.sprite.Sprite instances x -= 27 a.set_position(x, y) def tagarrange_me(): x, y = self.x, self.y w, h = self.width, self.height x += w + 6 y += 142 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) x += 27 def tagarrange_right(): x, y = self.x, self.y w, h = self.width, self.height x += w + 3 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 def tagarrange_left(): x, y = self.x, self.y w, h = self.width, self.height x -= 28 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 self._tagarrange_funcs = { 'bottom': tagarrange_bottom, 'me': tagarrange_me, 'left': tagarrange_left, 'right': tagarrange_right, } showncard_btn = ImageButton( common_res.buttons.port_showncard, parent=self, x=self.width - 22, y=90, ) @showncard_btn.event # noqa def on_click(): p = self.character if not p: return if not p.showncardlists: return # before the 'real' game_start last = ShownCardPanel.current if last: last.delete() if last.character is p: return ShownCardPanel(p, parent=self.view)
def __init__(self, x=0.0, y=0.0, color=Colors.blue, tag_placement='me', *args, **kwargs): self.player = None self.character = None self._disabled = False self._selected = False self.taganims = [] self.tag_placement = tag_placement self._color = color self.bg = None self._last_balloon = None Frame.__init__( self, width=149, height=195, bot_reserve=20, color=color, thin_shadow=True, **kwargs ) self.x, self.y = x, y self.charname_lbl = self.add_label( u'', 7, self.height-30, width=16, multiline=True, font_size=9, anchor_x='left', anchor_y='top', color=(255, 255, 255, 255), shadow=(1, 0, 0, 0, 179), ) from .view import THBattleUI v = self.parent while not isinstance(v, THBattleUI): v = v.parent self.view = v self.portcard_area = PortraitCardArea( parent=self.view, x=self.x, y=self.y, width=self.width, height=self.height, zindex=100, ) self.equipcard_area = EquipCardArea( parent=self, x=3, y=6, ) w, h = self.width, self.height self.identity_btn = b = Button( u'?', parent=self, x=w-42-4, y=h-24-10-18, width=42, height=18, ) self.cur_idtag = 0 @b.event def on_click(): g = Game.getgame() tbl = g.ui_meta.identity_table colortbl = g.ui_meta.identity_color keys = tbl.keys() try: i = (keys.index(self.cur_idtag) + 1) % len(keys) except ValueError: i = 0 next = keys[i] b.caption = tbl[next] color = getattr(Colors, colortbl[next]) b.color = color self.set_color(color) b.update() self.update() self.cur_idtag = next @self.equipcard_area.event def on_selection_change(): self.view.dispatch_event('on_selection_change') def tagarrange_bottom(): x, y = self.x, self.y w, h = self.width, self.height x += w + 1 y -= 27 for a in self.taganims: # they are pyglet.sprite.Sprite instances x -= 27 a.set_position(x, y) def tagarrange_me(): x, y = self.x, self.y w, h = self.width, self.height x += w + 6 y += 142 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) x += 27 def tagarrange_right(): x, y = self.x, self.y w, h = self.width, self.height x += w + 3 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 def tagarrange_left(): x, y = self.x, self.y w, h = self.width, self.height x -= 28 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 self._tagarrange_funcs = { 'bottom': tagarrange_bottom, 'me': tagarrange_me, 'left': tagarrange_left, 'right': tagarrange_right, } showncard_btn = ImageButton( common_res.buttons.port_showncard, parent=self, x=self.width - 22, y=90, ) @showncard_btn.event # noqa def on_click(): p = self.character if not p: return if not p.showncardlists: return # before the 'real' game_start last = ShownCardPanel.current if last: last.delete() if last.character is p: return ShownCardPanel(p, parent=self.view)
def __init__(self, x=0.0, y=0.0, color=Colors.blue, tag_placement='me', *args, **kwargs): self.bg = None self.character = None self._color = color self._disabled = False self._last_balloon = None self.player = None self._selected = False self.taganims = [] self.tag_placement = tag_placement Frame.__init__( self, width=149, height=195, bot_reserve=20, color=color, thin_shadow=True, **kwargs ) self.balloon = BalloonPrompt(self, self.balloon_show) self.view = view = self.parent self.x, self.y = x, y self.charname_lbl = self.add_label( u'', 7, self.height-30, width=16, multiline=True, font_size=9, anchor_x='left', anchor_y='top', color=(255, 255, 255, 255), shadow=(1, 0, 0, 0, 179), ) self.portcard_area = PortraitCardArea( parent=view, x=self.x, y=self.y, width=self.width, height=self.height, zindex=100, ) self.equipcard_area = EquipCardArea( view=view, parent=self, x=3, y=6, ) w, h = self.width, self.height tbl = view.game.ui_meta.identity_table colortbl = view.game.ui_meta.identity_color conf = [(tbl[k], getattr(Colors, colortbl[k]), k) for k in tbl] self.identity_btn = b = OptionButton( conf=conf, default=0, parent=self, x=w-42-4, y=h-24-10-18, width=42, height=18, ) @b.event def on_value_changed(v): self.set_color(b.color) def tagarrange_bottom(): x, y = self.x, self.y w = self.width x += w + 1 y -= 27 for a in self.taganims: # they are pyglet.sprite.Sprite instances x -= 27 a.set_position(x, y) def tagarrange_me(): x, y = self.x, self.y w = self.width x += w + 6 y += 142 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) x += 27 def tagarrange_right(): x, y = self.x, self.y w = self.width x += w + 3 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 def tagarrange_left(): x, y = self.x, self.y x -= 28 y += 1 for a in self.taganims: # they are pyglet.sprite.Sprite instances a.set_position(x, y) y += 27 self._tagarrange_funcs = { 'bottom': tagarrange_bottom, 'me': tagarrange_me, 'left': tagarrange_left, 'right': tagarrange_right, } showncard_btn = ImageButton( L('c-buttons-port_showncard'), parent=self, x=self.width - 22, y=90, ) @showncard_btn.event # noqa def on_click(): p = self.character if not p: return if not p.showncardlists: return # before the 'real' game_start last = ShownCardPanel.current if last: last.delete() if last.character is p: return ShownCardPanel(p, parent=self.view)