Example #1
0
    def init(self):
        SoundManager.se_suppress()
        self.game_event = ObservableEvent()

        self.game_event += self.on_game_event

        n = len(self.game.players)
        ports = self.char_portraits = [
            GameCharacterPortrait(parent=self, color=color,
                                  x=x, y=y, tag_placement=tp)
            for x, y, tp, color in self.gcp_location[:n]
        ]

        pl = self.game.players
        shift = pl.index(self.game.me)
        for i, c in enumerate(ports):
            self.game_event += c.on_game_event
            p = pl[(shift + i) % n]
            c.player = p
            c.update()

        ports[0].equipcard_area.selectable = True  # it's TheChosenOne

        self.begin_select_player()
        self.end_select_player()
        self.skill_box = SkillSelectionBox(
            parent=self, x=161, y=9, width=70, height=22*6-4
        )

        SoundManager.switch_bgm('thb-bgm_game')

        self.more_init()
Example #2
0
    def init(self):
        ports = self.char_portraits = [
            GameCharacterPortrait(parent=self,
                                  color=color,
                                  x=x,
                                  y=y,
                                  tag_placement=tp)
            for x, y, tp, color in self.gcp_location[:len(self.game.players)]
        ]

        pl = self.game.players
        shift = pl.index(self.game.me)
        for i, c in enumerate(ports):
            p = pl[(shift + i) % self.game.n_persons]
            c.player = p
            c.update()

        ports[0].equipcard_area.selectable = True  # it's TheChosenOne

        self.begin_select_player()
        self.end_select_player()
        self.skill_box = SkillSelectionBox(parent=self,
                                           x=161,
                                           y=9,
                                           width=70,
                                           height=22 * 6 - 4)

        SoundManager.switch_bgm(gres.bgm_game)
Example #3
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
        )
Example #4
0
def notify(title, msg, level=BASIC):
    from user_settings import UserSettings as us
    if level <= us.notify_level:
        _notify(title, msg)
        if us.sound_notify:
            from client.ui.soundmgr import SoundManager

            SoundManager.play('c-sound-input')
Example #5
0
def notify(title, msg, level=BASIC):
    from user_settings import UserSettings as us

    if level <= us.notify_level:
        _notify(title, msg)
        if us.sound_notify:
            from client.ui.soundmgr import SoundManager

            SoundManager.play("c-sound-input")
Example #6
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,
        )
Example #7
0
    def on_message(self, _type, *args):
        rst = handle_chat(_type, args)
        if rst:
            self.chat_box.append(rst)

        elif _type == 'game_started':
            self.remove_control(self.panel)
            self.gameui.init()
            self.add_control(self.gameui)
            self.game.start()
            # utils.hub_interrupt(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 = 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
            self.set_color(Colors.green)
            self.events_box.clear()

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

        elif _type == 'observe_request':
            uid, uname = args[0]
            box = ConfirmBox(
                u'玩家 %s 希望旁观你的游戏,是否允许?\n旁观玩家可以看到你的手牌。' % 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])

        else:
            Screen.on_message(self, _type, *args)
Example #8
0
    def on_message(self, _type, *args):
        rst = handle_chat(_type, args)
        if rst:
            self.chat_box.append(rst)

        elif _type == 'game_started':
            self.remove_control(self.panel)
            self.gameui.init()
            self.add_control(self.gameui)
            self.game.start()
            # utils.hub_interrupt(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 = 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
            self.set_color(Colors.green)
            self.events_box.clear()

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

        elif _type == 'observe_request':
            uid, uname = args[0]
            box = ConfirmBox(u'玩家 %s 希望旁观你的游戏,是否允许?\n旁观玩家可以看到你的手牌。' % 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])

        else:
            Screen.on_message(self, _type, *args)
Example #9
0
 def func():
     from client.ui.soundmgr import SoundManager
     SoundManager.mute()
     gevent.sleep(0.3)
     ui_schedule(sss.switch)
     gevent.sleep(0.3)
     Executive.call('connect_server', ui_message, ('127.0.0.1', 9999), ui_message)
     gevent.sleep(0.3)
     Executive.call('auth', ui_message, ['Proton1', 'abcde'])
     gevent.sleep(0.3)
     Executive.call('quick_start_game', ui_message, 'THBattle')
     gevent.sleep(0.3)
     Executive.call('get_ready', ui_message, [])
Example #10
0
 def func():
     from client.ui.soundmgr import SoundManager
     SoundManager.mute()
     gevent.sleep(0.3)
     sss.switch()
     gevent.sleep(0.3)
     Executive.connect_server(('127.0.0.1', 9999), ui_message)
     gevent.sleep(0.3)
     Executive.auth('Proton1', 'abcde')
     gevent.sleep(0.3)
     Executive.quick_start_game()
     gevent.sleep(0.3)
     Executive.get_ready()
Example #11
0
 def func():
     from client.ui.soundmgr import SoundManager
     SoundManager.mute()
     gevent.sleep(0.3)
     sss.switch()
     gevent.sleep(0.3)
     Executive.connect_server(('127.0.0.1', 9999), ui_message)
     gevent.sleep(0.3)
     Executive.auth('Proton1', 'abcde')
     gevent.sleep(0.3)
     Executive.quick_start_game()
     gevent.sleep(0.3)
     Executive.get_ready()
Example #12
0
 def func():
     from client.ui.soundmgr import SoundManager
     SoundManager.mute()
     gevent.sleep(0.3)
     ui_schedule(sss.switch)
     gevent.sleep(0.3)
     Executive.call('connect_server', ui_message,
                    ('127.0.0.1', 9999), ui_message)
     gevent.sleep(0.3)
     Executive.call('auth', ui_message, ['Proton1', 'abcde'])
     gevent.sleep(0.3)
     Executive.call('quick_start_game', ui_message, 'THBattle')
     gevent.sleep(0.3)
     Executive.call('get_ready', ui_message, [])
Example #13
0
 def func():
     from client.ui.soundmgr import SoundManager
     SoundManager.mute()
     gevent.sleep(0.3)
     sss.switch()
     gevent.sleep(0.3)
     Executive.connect_server(('127.0.0.1', 9999), ui_message)
     gevent.sleep(0.3)
     Executive.auth(options.fastjoin, 'feisuzhu')
     gevent.sleep(0.3)
     Executive.quick_start_game()
     gevent.sleep(0.3)
     Executive.use_ingame_item('imperial-id:boss')
     gevent.sleep(0.3)
     Executive.get_ready()
Example #14
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 #15
0
        def func():
            from client.ui.soundmgr import SoundManager

            SoundManager.mute()
            gevent.sleep(0.3)
            sss.switch()
            gevent.sleep(0.3)
            Executive.connect_server(("127.0.0.1", 9999), ui_message)
            gevent.sleep(0.3)
            Executive.auth(options.fastjoin, "feisuzhu")
            gevent.sleep(0.3)
            Executive.quick_start_game()
            gevent.sleep(0.3)
            Executive.use_ingame_item("imperial-id:boss")
            gevent.sleep(0.3)
            Executive.get_ready()
Example #16
0
    def on_text(self, text):
        # The easter egg
        ks = self.keystrokes
        ks = (ks + text)[:40]
        self.keystrokes = ks

        from gamepack.thb.characters import characters as chars

        for c in chars:
            try:
                alter = c.ui_meta.figure_image_alter
            except:
                continue

            for i in xrange(len(ks)):
                if alter.decrypt(ks[-i:]):
                    SoundManager.play(cres.sound.input)
Example #17
0
    def on_text(self, text):
        # The easter egg
        ks = self.keystrokes
        ks = (ks + text)[:40]
        self.keystrokes = ks

        from gamepack.thb.characters import characters as chars

        for c in chars:
            try:
                alter = c.ui_meta.figure_image_alter
            except:
                continue

            for i in xrange(len(ks)):
                if alter.decrypt(ks[-i:]):
                    SoundManager.play(cres.sound.input)
Example #18
0
    def on_text(self, text):
        # The easter egg
        ks = self.keystrokes
        ks = (ks + text)[:40]
        self.keystrokes = ks

        from thb.characters.baseclasses import Character

        for c in Character.character_classes.itervalues():
            try:
                alter = c.ui_meta.figure_image_alter
            except:
                continue

            for i in xrange(len(ks)):
                if L(alter).decrypt(ks[-i:]):
                    SoundManager.play('c-sound-input')
Example #19
0
    def on_text(self, text):
        # The easter egg
        ks = self.keystrokes
        ks = (ks + text)[:40]
        self.keystrokes = ks

        from gamepack.thb.characters.baseclasses import Character

        for c in Character.character_classes.itervalues():
            try:
                alter = c.ui_meta.figure_image_alter
            except:
                continue

            for i in xrange(len(ks)):
                if L(alter).decrypt(ks[-i:]):
                    SoundManager.play('c-sound-input')
Example #20
0
    def init(self):
        ports = self.char_portraits = [
            GameCharacterPortrait(parent=self, color=color, x=x, y=y, tag_placement=tp)
            for x, y, tp, color in self.gcp_location[: len(self.game.players)]
        ]

        pl = self.game.players
        shift = pl.index(self.game.me)
        for i, c in enumerate(ports):
            p = pl[(shift + i) % self.game.n_persons]
            c.player = p
            c.update()

        ports[0].equipcard_area.selectable = True  # it's TheChosenOne

        self.begin_select_player()
        self.end_select_player()
        self.skill_box = SkillSelectionBox(parent=self, x=161, y=9, width=70, height=22 * 6 - 4)

        SoundManager.switch_bgm(gres.bgm_game)
Example #21
0
def vol(val):
    if val == 'on':
        val = 100
    elif val == 'off':
        val = 0
    elif val.isdigit():
        val = min(int(val), 100)
        val = max(val, 0)
    else:
        return registered_commands['?']('vol')

    if not val:
        SoundManager.mute()
        return u'已静音。'
    else:
        SoundManager.unmute()
        SoundManager.set_volume(val / 100.0)
        return u'音量已设置为 %d' % val
Example #22
0
 def on_switch(self):
     SoundManager.switch_bgm(common_res.bgm_hall)
Example #23
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.gameui.init()
            self.add_control(self.gameui)
            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
            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)
Example #24
0
 def on_click():
     mute.delete()
     SoundManager.mute()
Example #25
0
 def set_live(self):
     SoundManager.se_unsuppress()
     self.update_portraits_hard()
     self.update_handcard_area()
     self.refresh_input_state()
Example #26
0
 def set_live(self):
     SoundManager.se_unsuppress()
     self.update_portraits_hard()
     self.update_handcard_area()
     self.refresh_input_state()
Example #27
0
 def on_switch(self):
     SoundManager.switch_bgm(common_res.bgm_hall)
Example #28
0
 def on_click():
     mute.delete()
     SoundManager.mute()
Example #29
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)