def __init__(self, trans, *a, **k): self.trans = trans cards = trans.cards self.inputlet = None w = 20 + (91 + 10) * 4 + 20 h = 20 + 125 + 20 + 125 + 20 + 20 self.lbl = Label( text=u"等待其他玩家操作", x=w//2, y=300, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230), anchor_x='center', anchor_y='bottom' ) Panel.__init__(self, width=1, height=1, zindex=5, *a, **k) parent = self.parent self.x, self.y = (parent.width - w)//2, (parent.height - h)//2 + 20 self.width, self.height = w, h self.update() self.mapping = mapping = {} for i, c in enumerate(cards): y, x = divmod(i, 4) x, y = 20 + (91 + 10) * x, 20 + (125 + 20) * (1 - y) cs = CardSprite(c, parent=self, x=x, y=y) cs.associated_card = c mapping[id(c)] = cs @cs.event def on_mouse_dblclick(x, y, button, modifier, cs=cs): if cs.gray: return ilet = self.inputlet if not ilet: return ilet.set_card(cs.associated_card) ilet.done()
def __init__(self, trans, parent, *a, **k): Panel.__init__( self, x=1, y=1, width=1, height=1, zindex=5, parent=parent, *a, **k ) self.lbls = pyglet.graphics.Batch() self.trans = trans
def __init__(self, g, *a, **k): Panel.__init__(self, width=550, height=340, zindex=15, *a, **k) parent = self.parent self.x = (parent.width - 550) // 2 self.y = (parent.height - 340) // 2 self.textarea = ta = TextArea( parent=self, x=30, y=30, width=550-30, height=340-60, font_size=12, ) ta.text = u'' winners = g.winners for p in g.players: s = u'|G%s|r(|R%s|r, |c0000ffff%s|r, %s)\n' % ( p.ui_meta.name, p.account.username.replace('|', '||'), g.ui_meta.identity_table[p.identity.type], u'|R胜利|r' if p in winners else u'失败' ) ta.append(s) if g.me in winners: self.pic = L('thb-win') else: self.pic = L('thb-lose') close = Button( u'关闭', parent=self, x=440, y=25, width=90, height=40, zindex=10, ) @close.event def on_click(): self.delete()
def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None g = Game.getgame() choices = trans.mapping[g.me] w, h = 500 + 1 * 160, 390 + 1 * 113 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w) / 2, (ph - h) / 2 self.inputlet = None choices = self.choices = [ c for c in choices if c.char_cls and not getattr(c, 'chosen', False) ] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, 4) x, y = 15 + 160 * x, 45 + 113 * (3 - y) gs = GirlSelector(c, selectors, parent=self, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs)
def __init__(self, game_id, *a, **k): Panel.__init__( self, width=550, height=340, zindex=10000, *a, **k ) self.game_id = game_id self.x = (self.overlay.width - 550) // 2 self.y = (self.overlay.height - 340) // 2 self.btncancel = btncancel = Button( u'取消', parent=self, x=440, y=25, width=90, height=40 ) self.labels = pyglet.graphics.Batch() Label( u'旁观游戏', font_size=12, x=275, y=306, anchor_x='center', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(2, 207, 240, 156, 204), batch=self.labels, ) @btncancel.event def on_click(): self.delete() Executive.call('query_gameinfo', ui_message, game_id)
def __init__(self, game_id, *a, **k): Panel.__init__( self, width=550, height=340, zindex=10000, *a, **k ) self.game_id = game_id self.x = (self.overlay.width - 550) // 2 self.y = (self.overlay.height - 340) // 2 self.btncancel = btncancel = Button( u'关闭', parent=self, x=440, y=25, width=90, height=40 ) self.labels = pyglet.graphics.Batch() Label( u'邀请游戏', font_size=12, x=275, y=306, anchor_x='center', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(2, 207, 240, 156, 204), batch=self.labels, ) @btncancel.event def on_click(): self.delete() Executive.call('get_hallinfo', ui_message, None)
def __init__(self, g, *a, **k): Panel.__init__(self, width=550, height=340, zindex=10000, *a, **k) parent = self.parent self.x = (parent.width - 550) // 2 self.y = (parent.height - 340) // 2 self.textarea = ta = TextArea( parent=self, x=30, y=30, width=550-30, height=340-60, font_size=12, ) ta.text = u'' winners = g.winners for p in g.players: s = u'|G%s|r(|R%s|r, |c0000ffff%s|r, %s)\n' % ( p.ui_meta.char_name, p.account.username.replace('|', '||'), g.ui_meta.identity_table[p.identity.type], u'|R胜利|r' if p in winners else u'失败' ) ta.append(s) if g.me in winners: self.pic = gres.win else: self.pic = gres.lose close = Button( u'关闭', parent=self, x=440, y=25, width=90, height=40 ) @close.event def on_click(): self.delete()
def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None g = Game.getgame() choices = trans.mapping[g.me] w, h = 500 + 1*160, 390 + 1*113 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw-w)/2, (ph-h)/2 self.inputlet = None choices = self.choices = [c for c in choices if c.char_cls and not getattr(c, 'chosen', False)] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, 4) x, y = 15 + 160*x, 45 + 113*(3-y) gs = GirlSelector(c, selectors, parent=self, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs)
def __init__(self, character, *a, **k): self.character = character ShownCardPanel.current = self categories = character.showncardlists h = 30 + len(categories) * 145 + 10 w = 100 + 6 * 93.0 + 30 self.lbls = lbls = pyglet.graphics.Batch() Panel.__init__(self, width=1, height=1, zindex=5, *a, **k) y = 30 i = 0 for cat in reversed(categories): Label( text=CardList.ui_meta.lookup[cat.type], x=30, y=y + 62 + 145 * i, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 130), anchor_x='left', anchor_y='center', batch=lbls, ) ca = DropCardArea( parent=self, x=100, y=y + 145 * i, fold_size=6, width=6 * 93, height=125, ) for c in cat: cs = CardSprite(c, parent=ca) cs.associated_card = c ca.update() i += 1 p = self.parent self.x, self.y = (p.width - w) // 2, (p.height - h) // 2 self.width, self.height = w, h self.update() btn = ImageButton( common_res.buttons.close_blue, parent=self, x=w - 20, y=h - 20, ) @btn.event def on_click(): self.delete()
def __init__(self, text, *a, **k): Panel.__init__(self, *a, **k) self.zindex = 100 w, h = self.width, self.height ta = TextArea(parent=self, font_size=12, x=2, y=60, width=w - 4, height=h - 4 - 60) ta.append(text) btn = Button(u"关闭", parent=self, x=(w - 120) // 2, y=20, width=120, height=40) @btn.event def on_click(): self.delete()
def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None self.selecting = False g = Game.getgame() choices = trans.mapping[g.me] n_choices = len(choices) cols = 5 if n_choices > 16 else 4 rows = max((n_choices - 1) / cols + 1, 4) w, h = 20 + cols * 160, 51 + rows * 113 + 30 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w) / 2, (ph - h) / 2 self.inputlet = None choices = self.choices = [ c for c in choices if c.char_cls and not getattr(c, 'chosen', False) ] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, cols) x, y = 15 + 160 * x, 45 + 113 * (rows - 1 - y) gs = GirlSelector(c, selectors, parent=self, hover_pic=self.hover_pic, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) self.label = Label(text='等待其他玩家操作', x=w // 2, y=51 + rows * 113, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230), anchor_x='center', anchor_y='bottom')
def __init__(self, character, *a, **k): self.character = character ShownCardPanel.current = self categories = character.showncardlists h = 30 + len(categories)*145 + 10 w = 100 + 6*93.0+30 self.lbls = lbls = pyglet.graphics.Batch() Panel.__init__(self, width=1, height=1, zindex=5, *a, **k) y = 30 i = 0 for cat in reversed(categories): Label( text=CardList.ui_meta.lookup[cat.type], x=30, y=y+62+145*i, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 130), anchor_x='left', anchor_y='center', batch=lbls, ) ca = DropCardArea( parent=self, x=100, y=y+145*i, fold_size=6, width=6*93, height=125, ) for c in cat: cs = CardSprite(c, parent=ca) cs.associated_card = c ca.update() i += 1 p = self.parent self.x, self.y = (p.width - w)//2, (p.height - h)//2 self.width, self.height = w, h self.update() btn = ImageButton( common_res.buttons.close_blue, parent=self, x=w-20, y=h-20, ) @btn.event def on_click(): self.delete()
def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None self.selecting = False g = Game.getgame() choices = trans.mapping[g.me] n_choices = len(choices) cols = 5 if n_choices > 16 else 4 rows = max((n_choices - 1) / cols + 1, 4) w, h = 20 + cols*160, 51 + rows*113 + 30 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w)/2, (ph - h)/2 self.inputlet = None choices = self.choices = [c for c in choices if c.char_cls and not getattr(c, 'chosen', False)] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, cols) x, y = 15 + 160*x, 45 + 113*(rows - 1 - y) gs = GirlSelector(c, selectors, parent=self, hover_pic=self.hover_pic, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) self.label = Label( text='等待其他玩家操作', x=w//2, y=51+rows*113, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230), anchor_x='center', anchor_y='bottom' )
def __init__(self, text, *a, **k): Panel.__init__(self, *a, **k) self.zindex = 100 w, h = self.width, self.height ta = TextArea( parent=self, font_size=12, x=2, y=60, width=w-4, height=h-4-60 ) ta.append(text) btn = Button( u'关闭', parent=self, x=(w-120)//2, y=20, width=120, height=40, ) @btn.event def on_click(): self.delete()
def delete(self): Panel.delete(self) ShownCardPanel.current = None
def draw(self): Panel.draw(self) self.lbls.draw()
def __init__(self, trans, *a, **k): self.trans = trans Panel.__init__(self, width=1, height=1, zindex=5, *a, **k)
def __init__(self, *a, **k): w, h = 550, 485 Panel.__init__( self, width=w, height=h, zindex=1000, *a, **k ) self.x = (self.overlay.width - w) // 2 self.y = (self.overlay.height - h) // 2 self.btncreate = btncreate = Button( u'创建游戏', parent=self, x=440, y=75, width=90, height=40 ) self.btncancel = btncancel = Button( u'取消', parent=self, x=440, y=25, width=90, height=40 ) btncreate.state = Button.DISABLED txtbox = self.txtgamename = TextBox( parent=self, x=95, y=395, width=420, height=22, ) uname = Executive.gamemgr.account.username f = pyglet.font.load('AncientPix', 9) un1 = textsnap(uname, f, 140) if un1 != uname: uname = textsnap(uname, f, 120) + u'…' txtbox.text = uname + u'的游戏' self.labels = batch = pyglet.graphics.Batch() Label( u'创建游戏房间', font_size=12, x=275, y=431, anchor_x='center', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(1, 207, 240, 156, 204), batch=batch, ), Label( u'房间名称:', font_size=9, x=30, y=400, anchor_x='left', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(1, 207, 240, 156, 204), batch=batch, ) from gamepack import gamemodes as modes self.selectors = selectors = [] def on_select(): btncreate.state = Button.NORMAL for i, (gname, gcls) in enumerate(modes.items()): y, x = divmod(i, 3) x, y = 30 + 170*x, 275 - 125*y s = ImageSelector( gcls.ui_meta.logo, selectors, parent=self, x=x, y=y ) intro = getattr(gcls.ui_meta, 'description', None) intro and s.init_balloon(intro, width=480) s.gametype = gname s.event(on_select) selectors.append(s) @btncreate.event def on_click(): gtype = ImageSelector.get_selected(selectors).gametype f = pyglet.font.load('AncientPix', 9) roomname = textsnap(txtbox.text, f, 200) Executive.call('create_game', ui_message, [gtype, roomname]) @btncancel.event # noqa def on_click(): self.delete()
def draw(self): Panel.draw(self) self.label.draw()
def __init__(self, trans, *a, **k): self.trans = trans self.lbls = pyglet.graphics.Batch() Panel.__init__(self, width=1, height=1, zindex=5, *a, **k)
def draw(self): Panel.draw(self) pic = self.pic glColor3f(1, 1, 1) self.pic.blit(self.width - pic.width - 10, self.height - pic.height - 10)
def __init__(self, selection_mode=0, *a, **k): self.selection_mode = selection_mode self.lbls = pyglet.graphics.Batch() self.selection = [] Panel.__init__(self, width=1, height=1, *a, **k)
def __init__(self, *a, **k): Panel.__init__( self, width=550, height=340, zindex=1000, *a, **k ) self.x = (self.overlay.width - 550) // 2 self.y = (self.overlay.height - 340) // 2 self.btncreate = btncreate = Button( u'创建游戏', parent=self, x=440, y=75, width=90, height=40 ) self.btncancel = btncancel = Button( u'取消', parent=self, x=440, y=25, width=90, height=40 ) btncreate.state = Button.DISABLED txtbox = self.txtgamename = TextBox( parent=self, x=95, y=270, width=420, height=22, ) uname = Executive.gamemgr.account.username f = pyglet.font.load('AncientPix', 9) un1 = textsnap(uname, f, 140) if un1 != uname: uname = textsnap(uname, f, 120) + u'…' txtbox.text = uname + u'的游戏' self.labels = batch = pyglet.graphics.Batch() Label( u'创建游戏房间', font_size=12, x=275, y=306, anchor_x='center', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(1, 207, 240, 156, 204), batch=batch, ), Label( u'房间名称:', font_size=9, x=30, y=275, anchor_x='left', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow=(1, 207, 240, 156, 204), batch=batch, ) from gamepack import gamemodes as modes self.selectors = selectors = [] def on_select(): btncreate.state = Button.NORMAL for i, (gname, gcls) in enumerate(modes.items()): y, x = divmod(i, 3) x, y = 30 + 170*x, 150 - 125*y s = ImageSelector( gcls.ui_meta.logo, selectors, parent=self, x=x, y=y ) intro = getattr(gcls.ui_meta, 'description', None) intro and s.init_balloon(intro, width=480) s.gametype = gname s.event(on_select) selectors.append(s) @btncreate.event def on_click(): gtype = ImageSelector.get_selected(selectors).gametype f = pyglet.font.load('AncientPix', 9) roomname = textsnap(txtbox.text, f, 200) Executive.call('create_game', ui_message, [gtype, roomname]) @btncancel.event # noqa def on_click(): self.delete()
def draw(self): Panel.draw(self) self.labels.draw()