Example #1
0
    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
Example #2
0
    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
Example #3
0
 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
     )
Example #4
0
            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()
Example #5
0
    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()
Example #6
0
 def __init__(self, *args, **kwargs):
     Screen.__init__(self, *args, **kwargs)
     ta = TextArea(
         parent=self, width=600, height=450,
         x=(self.width-600)//2, y=(self.height-450)//2
     )
     self.textarea = ta
Example #7
0
    class EventsBox(Frame):
        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 append(self, v):
            self.box.append(v)

        def clear(self):
            self.box.text = u'\u200b'
Example #8
0
    class EventsBox(Frame):
        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 append(self, v):
            self.box.append(v)

        def clear(self):
            self.box.text = u'\u200b'
Example #9
0
 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
     )
Example #10
0
 def more_init(self):
     self.remaining_indicator = TextArea(
         parent=self,
         x=25,
         y=620,
         width=100,
         height=50,
         font_size=12,
     )
Example #11
0
 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
     )
Example #12
0
 def more_init(self):
     self.remaining_indicator = TextArea(
         parent=self,
         x=25,
         y=560,
         width=100,
         height=50,
         font_size=12,
     )
     self.game_event += self.handle_remaining_indicator
Example #13
0
 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
     )
Example #14
0
            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()
Example #15
0
    def process_user_input(self, ilet):
        meta = ilet.character.ui_meta
        self.texture = L(meta.port_image)

        Label(
            text=meta.name, x=2, y=80, font_size=12,
            anchor_x='left', anchor_y='bottom',
            color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230),
            batch=self.lbls,
        )

        ta = TextArea(
            parent=self,
            font_size=9,
            x=0, y=0, width=self.width, height=80 - 2,
        )

        ta.append(ilet.dialog)

        def on_mouse_press(*a, **k):
            ilet.set_result(0)
            ilet.done()
            end_transaction(self.trans)

        self.event(on_mouse_press)
        ta.event(on_mouse_press)

        self.should_draw = True

        if ilet.voice:
            self.player = SoundManager.play(ilet.voice)

        b = SmallProgressBar(parent=self, x=self.width - 140, y=0, width=140)
        b.value = LinearInterp(1.0, 0.0, ilet.timeout)
Example #16
0
        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)
Example #17
0
    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)
Example #18
0
class ChatBoxFrame(Frame):
    history_limit = 1000
    history = deque([None] * history_limit)

    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 append(self, v):
        self.box.append(v)

    def add_history(self, text):
        self.history_cursor = -1
        hist = self.__class__.history
        hist.rotate(1)
        hist[0] = text
        hist[-1] = None

    def set_color(self, color):
        Frame.set_color(self, color)
        self.inputbox.color = color
Example #19
0
    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)