def update(self): p = self.player if not p: return nick = p.account.username if self.dropped: if self.fleed: prefix = u'(逃跑)' else: prefix = u'(掉线)' nick = prefix + nick self.caption = nick char = self.character if char: meta = char.ui_meta self.bg = meta.port_image self.update_bg() self.set_charname(meta.char_name) if self._last_balloon != meta.description: self.init_balloon(meta.description, (2, 74, 145, 96)) self._last_balloon = meta.description self.bot_reserve = 74 self.gray_tex = None Frame.update(self) self.update_position() self.update_color() self.tagarrange()
def update(self): p = self.player if not p: return nick = u"<%s>" % p.account.username if self.dropped: if self.fleed: prefix = u'(逃跑)' else: prefix = u'(掉线)' nick = prefix + nick self.caption = nick char = self.character if char: meta = char.ui_meta self.bg = L(meta.port_image) self.update_bg() self.set_charname(meta.name) desc = char_desc(char) if self._last_balloon != desc: self.balloon.set_balloon(desc, (2, 74, 145, 96)) self._last_balloon = desc self.bot_reserve = 74 self.gray_tex = None Frame.update(self) self.update_position() self.update_color() self.tagarrange()
def update(self): p = self.player if not p: return nick = u"<%s>" % p.account.username if self.dropped: if self.fleed: prefix = u"(逃跑)" else: prefix = u"(掉线)" nick = prefix + nick self.caption = nick char = self.character if char: meta = char.ui_meta self.bg = L(meta.port_image) self.update_bg() self.set_charname(meta.name) desc = char_desc(char) if self._last_balloon != desc: self.balloon.set_balloon(desc, (2, 74, 145, 96)) self._last_balloon = desc self.bot_reserve = 74 self.gray_tex = None Frame.update(self) self.update_position() self.update_color() self.tagarrange()
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 batch_draw(gcps): glPushMatrix() glLoadIdentity() Frame.batch_draw(gcps) GameCharacterPortrait.batch_draw_status(gcps) glPopMatrix() cl = [] map(cl.extend, [p.control_list for p in gcps]) Control.do_draw(cl)
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 _fill_batch(self, batch): Frame._fill_batch(self, batch) self._gcp_framevlist = batch.add(16, GL_QUADS, self.frame_group, 'c4B', 'v2f') self._highlight_disabled = batch.add(4, GL_QUADS, self.top_group, 'c4B', 'v2f') self._highlight = batch.add(4, GL_QUADS, self.top_group, 'c4B', 'v2f') self.selected = self.selected self.disabled = self.disabled GameCharacterPortrait.update_position(self) GameCharacterPortrait.update_color(self)
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=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 update_color(self): Frame.update_color(self) C = Colors.get4i c = self.color heavy, light = C(c.heavy), C(c.light) self._gcp_framevlist.colors = flatten([ [255, 255, 255, 255] * 4, # equip box [heavy] * 4, # equip box border [light] * 4, # cardnum box [heavy] * 4, # cardnum box border ])
def update_color(self): Frame.update_color(self) C = Colors.get4i c = self.color heavy = C(c.heavy); light = C(c.light) self._gcp_framevlist.colors = flatten([ [255, 255, 255, 255] * 4, # equip box [heavy] * 4, # equip box border [light] * 4, # cardnum box [heavy] * 4, # cardnum box border ])
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 update_position(self): Frame.update_position(self) w, h = self.width, self.height ax, ay = self.abs_coords() self._gcp_framevlist.vertices[:] = flatten([ rectv2f(2, 2, w-4, 54-2, ax, ay), # equip box rrectv2f(2.5, 2.5, 4*36, 52, ax, ay), # equip box border rectv2f(w-2-32, 66, 32, 22, ax, ay), # cardnum box rrectv2f(w-2-32, 66, 32, 22, ax, ay), # cardnum box border ]) full = rectv2f(0, 0, w, h, ax, ay) self._highlight_disabled.vertices[:] = full self._highlight.vertices[:] = full if self.actor_frame: self.actor_frame.set_position(self.x - 6, self.y - 4) if self.turn_frame: self.turn_frame.set_position(self.x - 6, self.y - 4)
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, 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)
def delete(self): Frame.delete(self) self.portcard_area.delete()
def set_color(self, color): Frame.set_color(self, color) GameCharacterPortrait.update_color(self)
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, **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 set_postion(self, x, y): Frame.set_position(self, x, y) GameCharacterPortrait.update_position(self)
def set_color(self, color): Frame.set_color(self, color) self.inputbox.color = color
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)