def __init__(self, parent=None): Control.__init__(self, parent=parent, **r2d((0, 0, 820, 720))) self.btn_getready = Button( parent=self, caption=u'准备', **r2d((360, 80, 100, 35)) ) self.ready = False l = [] class MyPP(PlayerPortrait): # this class is INTENTIONALLY put here # to make cached avatars get gc'd cached_avatar = {} for x, y, color in parent.ui_class.portrait_location: l.append(MyPP('NONAME', parent=self, x=x, y=y, color=color)) self.portraits = l @self.btn_getready.event def on_click(): if self.ready: Executive.call('cancel_ready', ui_message, []) self.ready = False self.btn_getready.caption = u'准备' self.btn_getready.update() else: Executive.call('get_ready', ui_message, []) #self.btn_getready.state = Button.DISABLED self.ready = True self.btn_getready.caption = u'取消准备' self.btn_getready.update()
def __init__(self, texture, prompt, parent, *a, **k): self.texture = texture self.prompt = prompt width = texture.width height = texture.height x = (parent.width - width) // 2 y = (parent.height - height) // 2 self._x = x self._y = y Control.__init__(self, *a, x=x, y=y, width=width, height=height, parent=parent, zindex=999999, **k) ta = TextArea( parent=self, # font_size=12, x=2, y=2, width=width, height=100, ) ta.append(prompt) h = ta.content_height ta.height = h self.ta_height = h
def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__( self, x=0, y=0, width=0, height=0, zindex=2, **k )
def __init__(self, texture, prompt, parent, *a, **k): self.texture = texture self.prompt = prompt width = texture.width height = texture.height + 80 x = (parent.width - width) // 2 y = (parent.height - height) // 2 self._x = x self._y = y Control.__init__(self, *a, x=x, y=y, width=width, height=height, parent=parent, zindex=999999, **k) ta = TextArea( parent=self, # font_size=12, x=2, y=2, width=width, height=100, ) ta.append(prompt) h = ta.content_height ta.height = h self.ta_height = h
def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__( self, x=0, y=0, width=0, height=0, zindex=2, **k ) self.animations = []
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, card, x=0.0, y=0.0, *args, **kwargs): Control.__init__(self, *args, **kwargs) self._w, self._h = 33, 46 self.x, self.y = x, y self.selected = False self.hover = False self.card = card self.img = card.ui_meta.image_small self.init_balloon(card.ui_meta.description)
def __init__(self, x0, y0, x1, y1, *args, **kwargs): Control.__init__(self, *args, **kwargs) from math import sqrt, atan2, pi self.x, self.y = x0, y0 dx, dy = x1 - x0, y1 - y0 scale = sqrt(dx * dx + dy * dy) / common_res.ray.width self.angle = atan2(dy, dx) / pi * 180 self.scale = SineInterp(0.0, scale, 0.4) self.alpha = ChainInterp(FixedInterp(1.0, 1), CosineInterp(1.0, 0.0, 0.5), on_done=lambda self, desc: self.delete())
def __init__(self, x0, y0, x1, y1, *args, **kwargs): Control.__init__(self, *args, **kwargs) from math import sqrt, atan2, pi self.x, self.y = x0, y0 dx, dy = x1 - x0, y1 - y0 scale = sqrt(dx * dx + dy * dy) / L("c-ray").width self.angle = atan2(dy, dx) / pi * 180 self.scale = SineInterp(0.0, scale, 0.4) self.alpha = ChainInterp( FixedInterp(1.0, 1), CosineInterp(1.0, 0.0, 0.5), on_done=lambda self, desc: self.delete() )
def __init__(self, card, x=0.0, y=0.0, *args, **kwargs): Control.__init__(self, *args, **kwargs) self._w, self._h = 91, 125 self.shine = False self.gray = False self.x, self.y, = x, y self.shine_alpha = 0.0 self.alpha = 1.0 self.card = card self.ft_anim = False self.update()
def __init__(self, card, x=0.0, y=0.0, *args, **kwargs): Control.__init__(self, *args, **kwargs) self._w, self._h = 91, 125 self.shine = False self.gray = False self.x, self.y = x, y self.shine_alpha = 0.0 self.alpha = 1.0 self.card = card self.ft_anim = False self.update()
def __init__(self, game, *a, **k): self.game = game game.event_observer = UIEventHook Control.__init__(self, *a, **k) self.char_portraits = None self.deck_indicator = DeckIndicator(parent=self, x=30, y=680, width=50, height=25) self.handcard_area = HandCardArea(parent=self, x=238, y=9, zindex=3, width=93 * 5 + 42, height=145) self.deck_area = PortraitCardArea( parent=self, width=1, height=1, x=self.width // 2, y=self.height // 2, zindex=4 ) self.btn_afk = Button(parent=self, caption=u"让⑨帮你玩", zindex=1, color=Colors.blue, **r2d((730, 640, 75, 25))) self.gameintro_icon = GameIntroIcon(parent=self, game=game, **r2d((780, 610, 25, 25))) self.afk = False @self.btn_afk.event def on_click(): v = not self.afk self.afk = v self.btn_afk.color = (Colors.blue, Colors.orange)[v] self.btn_afk.update() @self.handcard_area.event def on_selection_change(): self.dispatch_event("on_selection_change") self.dropcard_area = DropCardArea(parent=self, x=0, y=324, zindex=3, width=820, height=125) class Animations(pyglet.graphics.Batch, Control): def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__(self, x=0, y=0, width=0, height=0, zindex=2, **k) def hit_test(self, x, y): return False self.animations = Animations(parent=self) self.selecting_player = 0
def __init__(self, parent=None): Control.__init__(self, parent=parent, **r2d((0, 0, 820, 720))) self.btn_getready = Button( parent=self, caption=u'准备', **r2d((360, 80, 100, 35)) ) self.btn_invite = Button( parent=self, caption=u'邀请', **r2d((360, 40, 100, 35)) ) self.ready = False l = [] class MyPP(PlayerPortrait): # this class is INTENTIONALLY put here # to make cached avatars get gc'd cached_avatar = {} for x, y, color in parent.ui_class.portrait_location: l.append(MyPP('NONAME', parent=self, x=x, y=y, color=color)) self.portraits = l @self.btn_getready.event def on_click(): if self.ready: Executive.call('cancel_ready', ui_message, []) self.ready = False self.btn_getready.caption = u'准备' self.btn_getready.update() else: Executive.call('get_ready', ui_message, []) #self.btn_getready.state = Button.DISABLED self.ready = True self.btn_getready.caption = u'取消准备' self.btn_getready.update() @self.btn_invite.event # noqa def on_click(): GameScreen.InvitePanel(self.parent.game.gameid, parent=self)
def __init__(self, parent=None): Control.__init__(self, parent=parent, **r2d((0, 0, 820, 720))) self.btn_getready = Button(parent=self, caption=u"准备", **r2d((360, 80, 100, 35))) self.btn_invite = Button(parent=self, caption=u"邀请", **r2d((360, 40, 100, 35))) self.ready = False l = [] class MyPP(PlayerPortrait): # this class is INTENTIONALLY put here # to make cached avatars get gc'd cached_avatar = {} for x, y, color in parent.ui_class.portrait_location: l.append(MyPP("NONAME", parent=self, x=x, y=y, color=color)) self.portraits = l @self.btn_getready.event def on_click(): if self.ready: Executive.call("cancel_ready", ui_message, []) self.ready = False self.btn_getready.caption = u"准备" self.btn_getready.update() else: Executive.call("get_ready", ui_message, []) # self.btn_getready.state = Button.DISABLED self.ready = True self.btn_getready.caption = u"取消准备" self.btn_getready.update() @self.btn_invite.event # noqa def on_click(): GameScreen.InvitePanel(self.parent.game.gameid, parent=self)
def __init__(self, game, *a, **k): self.selection_change = ObservableEvent() self.game = game Control.__init__(self, can_focus=True, *a, **k) self.keystrokes = '\x00' self.char_portraits = None self.deck_indicator = DeckIndicator( parent=self, x=30, y=660, width=50, height=25, ) self.handcard_area = HandCardArea( parent=self, view=self, x=238, y=9, zindex=3, width=93*5+42, height=145, ) self.deck_area = PortraitCardArea( parent=self, width=1, height=1, x=self.width//2, y=self.height//2, zindex=4, ) self.btn_afk = OptionButton( parent=self, zindex=1, conf=( (u'让⑨帮你玩', Colors.blue, False), (u'⑨在帮你玩', Colors.orange, True), ), **r2d((30, 625, 75, 25)) ) self.gameintro_icon = GameIntroIcon( parent=self, game=game, **r2d((690, 630, 25, 25)) ) self.dropcard_area = DropCardArea( parent=self, x=0, y=324, zindex=3, width=820, height=125, ) class Animations(pyglet.graphics.Batch, Control): def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__( self, x=0, y=0, width=0, height=0, zindex=2, **k ) self.animations = [] def delete(self): Control.delete(self) for a in self.animations: a.delete() def hit_test(self, x, y): return False self.animations = Animations(parent=self) self.selecting_player = 0 self.action_params = {}
def delete(self): Control.delete(self) for a in self.animations: a.delete()
def __init__(self, fold_size=4, *args, **kwargs): Control.__init__(self, *args, **kwargs) self.width, self.height = 35*4, 46 self.fold_size = fold_size self.selectable = False
def __init__(self, fold_size=5, *args, **kwargs): Control.__init__(self, *args, **kwargs) self.fold_size = fold_size self.view = kwargs['parent']
def __init__(self, fold_size=4, view=None, *args, **kwargs): Control.__init__(self, *args, **kwargs) self.width, self.height = 35*4, 46 self.fold_size = fold_size self.selectable = False self.view = view
def __init__(self, fold_size=5, *args, **kwargs): Control.__init__(self, *args, **kwargs) self.fold_size = fold_size
def __init__(self, game, *a, **k): self.selection_change = ObservableEvent() self.game = game Control.__init__(self, can_focus=True, *a, **k) self.keystrokes = '\x00' self.char_portraits = None self.deck_indicator = DeckIndicator( parent=self, x=30, y=660, width=50, height=25, ) self.handcard_area = HandCardArea( parent=self, view=self, x=238, y=9, zindex=3, width=93 * 5 + 42, height=145, ) self.deck_area = PortraitCardArea( parent=self, width=1, height=1, x=self.width // 2, y=self.height // 2, zindex=4, ) self.btn_afk = OptionButton(parent=self, zindex=1, conf=( (u'让⑨帮你玩', Colors.blue, False), (u'⑨在帮你玩', Colors.orange, True), ), **r2d((30, 625, 75, 25))) self.gameintro_icon = GameIntroIcon(parent=self, game=game, **r2d((690, 630, 25, 25))) self.dropcard_area = DropCardArea( parent=self, x=0, y=324, zindex=3, width=820, height=125, ) class Animations(pyglet.graphics.Batch, Control): def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__(self, x=0, y=0, width=0, height=0, zindex=2, **k) self.animations = [] def delete(self): Control.delete(self) for a in self.animations: a.delete() def hit_test(self, x, y): return False self.animations = Animations(parent=self) self.selecting_player = 0 self.action_params = {}
def __init__(self, game, *a, **k): Control.__init__(self, *a, **k) intro = getattr(game.ui_meta, 'description', None) intro and self.init_balloon(intro, width=480)
def __init__(self, game, *a, **k): self.game = game game.event_observer = UIEventHook Control.__init__(self, *a, **k) self.char_portraits = None self.deck_indicator = DeckIndicator( parent=self, x=30, y=680, width=50, height=25, ) self.handcard_area = HandCardArea( parent=self, x=238, y=9, zindex=3, width=93 * 5 + 42, height=145, ) self.deck_area = PortraitCardArea( parent=self, width=1, height=1, x=self.width // 2, y=self.height // 2, zindex=4, ) self.btn_afk = Button(parent=self, caption=u'让⑨帮你玩', zindex=1, color=Colors.blue, **r2d((730, 640, 75, 25))) self.gameintro_icon = GameIntroIcon(parent=self, game=game, **r2d((780, 610, 25, 25))) self.afk = False @self.btn_afk.event def on_click(): v = not self.afk self.afk = v self.btn_afk.color = (Colors.blue, Colors.orange)[v] self.btn_afk.update() @self.handcard_area.event def on_selection_change(): self.dispatch_event('on_selection_change') self.dropcard_area = DropCardArea( parent=self, x=0, y=324, zindex=3, width=820, height=125, ) class Animations(pyglet.graphics.Batch, Control): def __init__(self, **k): pyglet.graphics.Batch.__init__(self) Control.__init__(self, x=0, y=0, width=0, height=0, zindex=2, **k) def hit_test(self, x, y): return False self.animations = Animations(parent=self) self.selecting_player = 0
def __init__(self, game, *a, **k): Control.__init__(self, *a, **k) intro = getattr(game.ui_meta, 'description', None) if intro: balloon = BalloonPrompt(self) balloon.set_balloon(intro, width=480)
def __init__(self, *a, **k): Control.__init__(self, *a, **k) self.selection = []