Пример #1
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.buttons  = buttons = []
        from settings import ServerList as sl, NOTICE

        class BalloonImageButton(ImageButton, BalloonPrompt):
            pass

        class NoticePanel(Panel):
            fill_color = (1.0, 1.0, 0.9, 0.5)
            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()

        for s in sl.values():
            btn = BalloonImageButton(
                common_res.buttons.serverbtn,
                parent=self, x=s['x'], y=s['y'],
            )
            btn.init_balloon(s['description'])
            btn.set_handler('on_click', lambda s=s: self.do_connect(s['address']))
            buttons.append(btn)

        NoticePanel(
            NOTICE,
            parent=self,
            width=800, height=600,
            x=(self.width-800)//2, y=(self.height-600)//2
        )

        mute = Button(
            u'静音',
            parent=self,
            x=self.width-90, y=60,
            width=60, height=30,
            color=Colors.orange,
        )

        @mute.event
        def on_click():
            mute.delete()
            SoundManager.mute()
Пример #2
0
            def on_mouse_motion(self, x, y, dx, dy):
                for s in ServerList.values():
                    if inpoly(x, y, s["polygon"]):
                        self.hl_alpha = 1
                        if self.highlight is not s:
                            self.highlight = s
                            self.init_balloon(s["description"], polygon=s["polygon"])
                            x, y, w, h = s["box"]
                            tex = self.worldmap_shadow.get_region(x, y, w, h)
                            self.hldraw = (x, y, tex)
                            self.window.set_mouse_cursor(self.hand_cursor)

                        break
                else:
                    if self.highlight:
                        self.highlight = None
                        self.hl_alpha = LinearInterp(1.0, 0, 0.3)
                        self.window.set_mouse_cursor(None)

                    self.init_balloon("", (0, 0, 0, 0))
Пример #3
0
            def on_mouse_motion(self, x, y, dx, dy):
                for s in ServerList.values():
                    if inpoly(x, y, s['polygon']):
                        self.hl_alpha = 1
                        if self.highlight is not s:
                            self.highlight = s
                            self.init_balloon(s['description'], polygon=s['polygon'])
                            x, y, w, h = s['box']
                            tex = self.worldmap_shadow.get_region(x, y, w, h)
                            self.hldraw = (x, y, tex)
                            self.window.set_mouse_cursor(self.hand_cursor)

                        break
                else:
                    if self.highlight:
                        self.highlight = None
                        self.hl_alpha = LinearInterp(1.0, 0, 0.3)
                        self.window.set_mouse_cursor(None)

                    self.init_balloon('', (0, 0, 0, 0))
Пример #4
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.buttons = buttons = []
        from settings import ServerList as sl, NOTICE

        class BalloonImageButton(ImageButton, BalloonPrompt):
            pass

        class NoticePanel(Panel):
            fill_color = (1.0, 1.0, 0.9, 0.5)

            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()

        for s in sl.values():
            btn = BalloonImageButton(
                common_res.buttons.serverbtn,
                parent=self,
                x=s['x'],
                y=s['y'],
            )
            btn.init_balloon(s['description'])
            btn.set_handler('on_click',
                            lambda s=s: self.do_connect(s['address']))
            buttons.append(btn)

        NoticePanel(NOTICE,
                    parent=self,
                    width=800,
                    height=600,
                    x=(self.width - 800) // 2,
                    y=(self.height - 600) // 2)

        mute = Button(
            u'静音',
            parent=self,
            x=self.width - 90,
            y=60,
            width=60,
            height=30,
            color=Colors.orange,
        )

        @mute.event
        def on_click():
            mute.delete()
            SoundManager.mute()