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])
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 __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.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() ShadowedLabel( u'创建游戏房间', font_size=12, x=275, y=306, anchor_x='center', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow_color=(207, 240, 156, 204), thin_shadow=True, batch=batch, ), ShadowedLabel( u'房间名称:', font_size=9, x=30, y=275, anchor_x='left', anchor_y='bottom', color=Colors.green.heavy + (255, ), shadow_color=(207, 240, 156, 204), thin_shadow=True, 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 def on_click(): self.delete()