Esempio n. 1
0
    def on_message(self, _type, *args):
        if _type == 'server_dropped':
            ConfirmBox(u'已经与服务器断开链接,请重新启动游戏!', parent=Screen.cur_overlay)

        elif _type == 'invite_request':
            uid, uname, gid, gtype = args[0]
            from gamepack import gamemodes as modes

            gtype = modes.get(gtype, None)
            gtype = gtype and gtype.ui_meta.name

            invite_text = u'%s 邀请你一起玩 %s 模式' % (uname, gtype)

            from utils import notify
            notify(u'东方符斗祭 - 邀请提醒', invite_text)

            box = ConfirmBox(
                invite_text,
                parent=self, buttons=((u'确定', True), (u'取消', False)), default=False
            )

            @box.event
            def on_confirm(val, uid=uid):
                Executive.call('invite_grant', ui_message, [gid, val])

        else:
            Overlay.on_message(self, _type, *args)
Esempio n. 2
0
 def on_message(self, _type, *args):
     if _type == 'server_connected':
         login = LoginScreen()
         login.switch()
     elif _type == 'server_connect_failed':
         self.highlight_layer.enable_click()
         log.error('Server connect failed.')
         ConfirmBox(u'服务器连接失败!', parent=self)
     elif _type == 'version_mismatch':
         self.highlight_layer.enable_click()
         log.error('Version mismatch')
         ConfirmBox(u'您的版本与服务器版本不符,无法进行游戏!', parent=self)
     else:
         Screen.on_message(self, _type, *args)
Esempio n. 3
0
    def display_box(msg):
        from client.ui.controls import ConfirmBox
        b = ConfirmBox(msg, parent=us)

        @b.event
        def on_confirm(val):
            sss.switch()
Esempio n. 4
0
        def on_click():
            box = ConfirmBox(u'真的要离开吗?', buttons=ConfirmBox.Presets.OKCancel, parent=self)

            @box.event
            def on_confirm(val):
                if val:
                    Executive.call('exit_game', ui_message, [])
Esempio n. 5
0
    def on_switch(self):
        SoundManager.switch_bgm(common_res.bgm_hall)
        from options import options

        options.testing and ConfirmBox(
            u'测试模式开启,现在可以登陆测试服务器。\n'
            u'测试模式下可能无法登陆正常服务器,\n'
            u'测试服务器也会随时重新启动。',
            parent=self, zindex=99999,
        )
Esempio n. 6
0
        def on_click():
            text = (
                u'试玩的玩家有以下限制:\n'
                u'\n'
                u'随机的id,不记录游戏数和节操\n'
                u'固定的头像、自定义签名\n'
                u'无法使用文文新闻和邀请功能\n'
                u'无法断线重连'
            )

            confirm = ConfirmBox(text, buttons=ConfirmBox.Presets.OKCancel, parent=self)

            @confirm.event
            def on_confirm(val):
                val and Executive.call('auth', ui_message, ['-1', 'guest'])
Esempio n. 7
0
    def on_message(self, _type, *args):
        if _type == 'auth_success':
            UserSettings.last_id = self.dialog.txt_username.text
            GameHallScreen().switch()

        elif _type == 'auth_failure':
            log.error('Auth failure')
            status = args[0]
            tbl = dict(
                not_available=u'您的帐号目前不可用,请联系管理员询问!',
                already_logged_in=u'请不要重复登录!',
                invalid_credential=u'认证失败!',
            )
            ConfirmBox(tbl.get(status, status), parent=self)
        else:
            Screen.on_message(self, _type, *args)
Esempio n. 8
0
    def on_message(self, _type, *args):
        rst = handle_chat(_type, args)
        if rst:
            self.chat_box.append(rst)
            return

        elif _type == 'game_joined':
            GameScreen(args[0]).switch()

        elif _type == 'gamehall_error':
            log.error('GameHall Error: %s' % args[0])  # TODO
            mapping = {
                'cant_join_game': u'无法加入游戏!'
            }
            ConfirmBox(mapping.get(args[0], args[0]), parent=self)

        elif _type == 'observe_refused':
            uname = args[0]
            self.chat_box.append(u'|R%s 回绝了你的旁观请求|r\n' % uname)

        else:
            Screen.on_message(self, _type, *args)
Esempio n. 9
0
    def on_message(self, _type, *args):
        rst = handle_chat(_type, args)
        if rst:
            self.chat_box.append(rst)
            return

        elif _type == 'game_started':
            from utils import notify
            notify(u'东方符斗祭 - 游戏提醒', u'游戏已开始,请注意。')
            self.remove_control(self.panel)
            self.add_control(self.gameui)
            self.gameui.init()
            self.game.start()

        elif _type == 'end_game':
            self.remove_control(self.gameui)
            self.add_control(self.panel)
            g = args[0]

        elif _type == 'client_game_finished':
            g = args[0]
            g.ui_meta.ui_class.show_result(g)

        elif _type in ('game_left', 'fleed'):
            GameHallScreen().switch()

        elif _type == 'game_joined':
            # last game ended, this is the auto
            # created game
            self.game = args[0]
            self.panel.btn_getready.state = Button.NORMAL
            self.gameui = self.ui_class(
                parent=False, game=self.game,
                **r2d((0, 0, 820, 720))
            )
            SoundManager.switch_bgm(common_res.bgm_hall)
            self.backdrop = common_res.bg_ingame.get()
            self.set_color(Colors.green)
            self.events_box.clear()

        elif _type == 'game_crashed':
            ConfirmBox(
                u'游戏逻辑已经崩溃,请退出房间!\n'
                u'这是不正常的状态,你可以报告bug。\n'
                u'游戏ID:%d' % self.game.gameid,
                parent=self
            )
            from __main__ import do_crashreport
            do_crashreport()

        elif _type == 'observe_request':
            uid, uname = args[0]
            box = ConfirmBox(
                u'玩家 %s 希望旁观你的游戏,是否允许?\n'
                u'旁观玩家可以看到你的手牌。' % uname,
                parent=self, buttons=((u'允许', True), (u'不允许', False)), default=False
            )

            @box.event
            def on_confirm(val, uid=uid):
                Executive.call('observe_grant', ui_message, [uid, val])

        elif _type == 'observer_enter':
            obuid, obname, uname = args[0]
            self.chat_box.append(
                u'|B|R>> |r|c0000ffff%s|r[|c9100ffff%d|r]|r趴在了|c0000ffff%s|r身后\n' % (obname, obuid, uname)
            )

        elif _type == 'observer_leave':
            obuid, obname, uname = args[0]
            self.chat_box.append(
                u'|B|R>> |r|c0000ffff%s|r飘走了\n' % obname
            )

        else:
            Screen.on_message(self, _type, *args)