Пример #1
0
    def __init__(self, choice, group, x=0, y=0, *a, **k):

        self.choice = choice
        cc = choice.char_cls
        meta = cc.ui_meta
        pimg = L(meta.port_image)

        self.x = x
        self.y = y
        ImageSelector.__init__(self, pimg, group, *a, **k)

        self.balloon.set_balloon(char_desc(cc))
Пример #2
0
    def __init__(self, choice, group, x=0, y=0, *a, **k):

        self.choice = choice
        cc = choice.char_cls
        meta = cc.ui_meta
        pimg = L(meta.port_image)
        self.char_name = meta.char_name
        self.char_maxlife = cc.maxlife

        self.x = x
        self.y = y
        ImageSelector.__init__(self, pimg, group, *a, **k)

        self.balloon.set_balloon(meta.description)
Пример #3
0
    def __init__(self, choice, group, x=0, y=0, *a, **k):

        self.choice = choice
        cc = choice.char_cls
        meta = cc.ui_meta
        pimg = L(meta.port_image)

        self.x = x
        self.y = y
        ImageSelector.__init__(
            self, pimg, group, *a, **k
        )

        self.balloon.set_balloon(char_desc(cc))
Пример #4
0
    def __init__(self, choice, group, x=0, y=0, *a, **k):

        self.choice = choice
        cc = choice.char_cls
        meta = cc.ui_meta
        pimg = L(meta.port_image)
        self.char_name = meta.char_name
        self.char_maxlife = cc.maxlife

        self.x = x
        self.y = y
        ImageSelector.__init__(
            self, pimg, group, *a, **k
        )

        self.balloon.set_balloon(meta.description)
Пример #5
0
 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])
Пример #6
0
            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()
Пример #7
0
 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])
Пример #8
0
            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()