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 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 #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
    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 #6
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 #7
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 #8
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 #9
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