Пример #1
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)
Пример #2
0
        def __init__(self, game_id, *a, **k):
            Panel.__init__(
                self, width=550, height=340,
                zindex=10000,
                *a, **k
            )
            self.game_id = game_id
            self.x = (self.overlay.width - 550) // 2
            self.y = (self.overlay.height - 340) // 2

            self.btncancel = btncancel = Button(
                u'关闭', parent=self, x=440, y=25, width=90, height=40
            )

            self.labels = pyglet.graphics.Batch()

            Label(
                u'邀请游戏', font_size=12, x=275, y=306,
                anchor_x='center', anchor_y='bottom',
                color=Colors.green.heavy + (255, ),
                shadow=(2, 207, 240, 156, 204),
                batch=self.labels,
            )

            @btncancel.event
            def on_click():
                self.delete()

            Executive.call('get_hallinfo', ui_message, None)
Пример #3
0
            def __init__(self, game_id, *a, **k):
                Panel.__init__(
                    self, width=550, height=340,
                    zindex=10000,
                    *a, **k
                )
                self.game_id = game_id
                self.x = (self.overlay.width - 550) // 2
                self.y = (self.overlay.height - 340) // 2

                self.btncancel = btncancel = Button(
                    u'取消', parent=self, x=440, y=25, width=90, height=40
                )

                self.labels = pyglet.graphics.Batch()

                Label(
                    u'旁观游戏', font_size=12, x=275, y=306,
                    anchor_x='center', anchor_y='bottom',
                    color=Colors.green.heavy + (255, ),
                    shadow=(2, 207, 240, 156, 204),
                    batch=self.labels,
                )

                @btncancel.event
                def on_click():
                    self.delete()

                Executive.call('query_gameinfo', ui_message, game_id)
Пример #4
0
 def on_item_dblclick(li):
     # TODO:
     if li.started:
         #Executive.call('observe_user', ui_message, li.game_id)
         self.ObserveGamePanel(li.game_id, parent=self.overlay)
     else:
         Executive.call('join_game', ui_message, li.game_id)
Пример #5
0
 def on_item_dblclick(li):
     # TODO:
     if li.started:
         #Executive.call('observe_user', ui_message, li.game_id)
         self.ObserveGamePanel(li.game_id, parent=self.overlay)
     else:
         Executive.call('join_game', ui_message, li.game_id)
Пример #6
0
 def on_click():
     if self.ready:
         Executive.call('cancel_ready', ui_message, [])
         self.ready = False
         self.btn_getready.caption = u'准备'
         self.btn_getready.update()
     else:
         Executive.call('get_ready', ui_message, [])
         #self.btn_getready.state = Button.DISABLED
         self.ready = True
         self.btn_getready.caption = u'取消准备'
         self.btn_getready.update()
Пример #7
0
 def on_click():
     if self.ready:
         Executive.call('cancel_ready', ui_message, [])
         self.ready = False
         self.btn_getready.caption = u'准备'
         self.btn_getready.update()
     else:
         Executive.call('get_ready', ui_message, [])
         #self.btn_getready.state = Button.DISABLED
         self.ready = True
         self.btn_getready.caption = u'取消准备'
         self.btn_getready.update()
Пример #8
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.bg = common_res.bg_gamehall

        self.gamelist = self.GameList(self)

        chat = self.chat_box = GameHallScreen.ChatBox(parent=self)
        chat.text = u'您现在处于游戏大厅!\n'
        self.playerlist = GameHallScreen.OnlineUsers(parent=self)
        self.noticebox = GameHallScreen.NoticeBox(parent=self)
        self.statusbox = GameHallScreen.StatusBox(parent=self)

        Executive.call('get_hallinfo', ui_message, None)
Пример #9
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.bg = common_res.bg_gamehall

        self.gamelist = self.GameList(self)

        chat = self.chat_box = GameHallScreen.ChatBox(parent=self)
        chat.text = u'您现在处于游戏大厅!\n'
        self.playerlist = GameHallScreen.OnlineUsers(parent=self)
        self.noticebox = GameHallScreen.NoticeBox(parent=self)
        self.statusbox = GameHallScreen.StatusBox(parent=self)

        Executive.call('get_hallinfo', ui_message, None)
Пример #10
0
        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)
Пример #11
0
        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)
Пример #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, [])
Пример #13
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)
Пример #14
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.bg = common_res.bg_gamehall.get()

        self.gamelist = self.GameList(self)

        chat = self.chat_box = GameHallScreen.ChatBox(parent=self)
        chat.text = u"您现在处于游戏大厅!\n"
        self.playerlist = GameHallScreen.OnlineUsers(parent=self)
        self.noticebox = GameHallScreen.NoticeBox(parent=self)
        self.statusbox = GameHallScreen.StatusBox(parent=self)

        VolumeTuner(parent=self, x=850, y=660)

        b = Button(parent=self, x=750, y=660, width=80, height=35, color=Colors.orange, caption=u"卡牌查看器")

        @b.event
        def on_click():
            openurl("http://thb.io")

        Executive.call("get_hallinfo", ui_message, None)
Пример #15
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, [])
Пример #16
0
    def __init__(self, *args, **kwargs):
        Screen.__init__(self, *args, **kwargs)
        self.bg = common_res.bg_gamehall.get()

        self.gamelist = self.GameList(self)

        chat = self.chat_box = GameHallScreen.ChatBox(parent=self)
        chat.text = u'您现在处于游戏大厅!\n'
        self.playerlist = GameHallScreen.OnlineUsers(parent=self)
        self.noticebox = GameHallScreen.NoticeBox(parent=self)
        self.statusbox = GameHallScreen.StatusBox(parent=self)

        VolumeTuner(parent=self, x=850, y=660)

        b = Button(parent=self,
            x=750, y=660, width=80, height=35,
            color=Colors.orange, caption=u'卡牌查看器',
        )

        @b.event
        def on_click():
            openurl('http://thb.io')

        Executive.call('get_hallinfo', ui_message, None)
Пример #17
0
    requests.post(
        "http://www.thbattle.net/interconnect/crashreport",
        data={"gameid": gameid, "active": int(active), "userid": userid, "username": username},
        files={"file": content},
    )


from client.ui.entry import start_ui

try:
    start_ui()
except:
    import pyglet

    pyglet.app.exit()

    if options.fastjoin:
        import pdb

        pdb.post_mortem()

    Executive.call("app_exit")
    log.error(u"游戏崩溃,正在报告bug,请稍等下……")
    do_crashreport()

    raise


Executive.call("app_exit")
Пример #18
0
def start_ui():
    # ATI workarounds
    import pyglet
    from pyglet import gl

    @hook(gl)
    def glDrawArrays(ori, *a, **k):
        from pyglet.gl import glBegin, glEnd, GL_QUADS
        glBegin(GL_QUADS)
        glEnd()
        return ori(*a, **k)

    # ---------------

    from client.ui.base import init_gui, ui_schedule, ui_message

    init_gui()

    # This forces all game resources to initialize,
    # else they will be imported firstly by GameManager,
    # then resources will be loaded at a different thread,
    # resulting white planes.
    # UPDATE: no more threading now, but retain notice above.
    from client.ui.resource import resource
    import gamepack
    gamepack.init_ui_resources()

    from client.ui.resloader import Resource
    Resource.load_resources()

    from client.ui.base.baseclasses import main_window
    main_window.set_icon(resource.icon)
    main_window.set_visible(True)

    # custom errcheck
    import pyglet.gl.lib as gllib
    orig_errcheck = gllib.errcheck

    import ctypes

    def my_errcheck(result, func, arguments):
        from pyglet import gl
        error = gl.glGetError()
        if error and error != 1286:
            # HACK: The 1286(INVALID_FRAMEBUFFER_OPERATION) error again!
            # This time I DIDN'T EVEN USE FBO! ATI!!
            msg = ctypes.cast(gl.gluErrorString(error), ctypes.c_char_p).value
            raise gl.GLException((error, msg))
        return result

    gllib.errcheck = my_errcheck
    # ------------------------------------

    from screens import UpdateScreen, ServerSelectScreen

    us = UpdateScreen()
    us.switch()
    from client.core import Executive
    sss = ServerSelectScreen()

    errmsgs = {
        'update_disabled': u'自动更新已被禁止',
        'error': u'更新过程出现错误,您可能无法正常进行游戏!',
    }

    def display_box(msg):
        from client.ui.controls import ConfirmBox
        b = ConfirmBox(msg, parent=us)

        @b.event
        def on_confirm(val):
            sss.switch()

    def update_callback(msg):
        # executes in logic thread
        # well, intented to be
        # ui and logic now run in the same thread.

        from options import options
        if msg == 'up2date':
            ui_schedule(sss.switch)
        elif msg == 'update_disabled' and options.fastjoin:
            import gevent

            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, [])

            gevent.spawn(func)

        elif msg in errmsgs:
            ui_schedule(display_box, errmsgs[msg])
        else:
            os.execv(sys.executable, [sys.executable] + sys.argv)

    Executive.call('update', update_callback,
                   lambda *a: ui_schedule(us.update_message, *a))

    # workaround for pyglet's bug
    if sys.platform == 'win32':
        import pyglet.app.win32
        pyglet.app.win32.Win32EventLoop._next_idle_time = None

    pyglet.app.run()
Пример #19
0
 def on_click(uid=acc.userid, un=acc.username):
     Executive.call('observe_user', ui_message, uid)
     self.overlay.chat_box.append(
         u'|R已经向%s发送了旁观请求,请等待回应……|r\n' % un)
     self.delete()
Пример #20
0
 def do_login(self):
     u, pwd = self.txt_username.text, self.txt_pwd.text
     Executive.call('auth', ui_message, [u, pwd])
Пример #21
0
 def on_click():
     Executive.call('get_hallinfo', ui_message, None)
Пример #22
0
 def do_connect(self, addr):
     for b in self.buttons:
         b.state = Button.DISABLED
     Executive.call('connect_server', ui_message, addr, ui_message)
Пример #23
0
 def on_click():
     gtype = ImageSelector.get_selected(selectors).gametype
     f = pyglet.font.load('AncientPix', 9)
     roomname = textsnap(txtbox.text, f, 200)
     Executive.call('create_game', ui_message, [gtype, roomname])
Пример #24
0
 def on_confirm(val, uid=uid):
     Executive.call('observe_grant', ui_message, [uid, val])
Пример #25
0
 def on_confirm(val, uid=uid):
     Executive.call('invite_grant', ui_message, [gid, val])
Пример #26
0
 def do_connect(self, addr):
     Executive.call("connect_server", ui_message, addr, ui_message)
Пример #27
0
 def on_confirm(val):
     if val:
         Executive.call('exit_game', ui_message, [])
Пример #28
0
 def on_confirm(val, uid=uid):
     Executive.call("invite_grant", ui_message, [gid, val])
Пример #29
0
 def on_confirm(val):
     if val:
         Executive.call('exit_game', ui_message, [])
Пример #30
0
 def do_connect(self, addr):
     for b in self.buttons:
         b.state = Button.DISABLED
     Executive.call('connect_server', ui_message, addr, ui_message)
Пример #31
0
def kickob(uid):
    Executive.call('kick_observer', None, uid)
    return u'指令已发出'
Пример #32
0
 def on_click(uid=acc.userid, un=acc.username):
     Executive.call('observe_user', ui_message, uid)
     self.overlay.chat_box.append(u'|R已经向%s发送了旁观请求,请等待回应……|r\n' % un)
     self.delete()
Пример #33
0
 def on_click(s=s, uid=uid, un=uname):
     Executive.call('invite_user', ui_message, uid)
     self.overlay.chat_box.append(u'|R已经邀请了%s,请等待回应……|r\n' % un)
     s.state = Button.DISABLED
Пример #34
0
 def on_click():
     Executive.call('get_hallinfo', ui_message, None)
Пример #35
0
 def do_login(self):
     u, pwd = self.txt_username.text, self.txt_pwd.text
     Executive.call('auth', ui_message, [u, pwd])
Пример #36
0
 def do_connect(self, addr):
     Executive.call('connect_server', ui_message, addr, ui_message)
Пример #37
0
 def on_click(s=s, uid=uid, un=uname):
     Executive.call("invite_user", ui_message, uid)
     self.overlay.chat_box.append(u"|R已经邀请了%s,请等待回应……|r\n" % un)
     s.state = Button.DISABLED
Пример #38
0
 def on_click():
     gtype = ImageSelector.get_selected(selectors).gametype
     f = pyglet.font.load('AncientPix', 9)
     roomname = textsnap(txtbox.text, f, 200)
     Executive.call('create_game', ui_message,
                    [gtype, roomname])
Пример #39
0
 def on_click():
     Executive.call('quick_start_game', ui_message, 'THBattle')
Пример #40
0
        'http://www.thbattle.net/interconnect/crashreport',
        data={
            'gameid': gameid,
            'active': int(active),
            'userid': userid,
            'username': username,
        },
        files={'file': content},
    )


from client.ui.entry import start_ui

try:
    start_ui()
except:
    import pyglet
    pyglet.app.exit()

    if options.fastjoin:
        import pdb
        pdb.post_mortem()

    Executive.call('app_exit')
    log.error(u'游戏崩溃,正在报告bug,请稍等下……')
    do_crashreport()

    raise

Executive.call('app_exit')
Пример #41
0
 def on_confirm(val):
     val and Executive.call('auth', ui_message, ['-1', 'guest'])
Пример #42
0
        data={
            'gameid': gameid,
            'active': int(active),
            'userid': userid,
            'username': username,
        },
        files={'file': content},
    )


from client.ui.entry import start_ui

try:
    start_ui()
except:
    import pyglet
    pyglet.app.exit()

    if options.fastjoin:
        import pdb
        pdb.post_mortem()

    Executive.call('app_exit')
    log.error(u'游戏崩溃,正在报告bug,请稍等下……')
    do_crashreport()

    raise


Executive.call('app_exit')
Пример #43
0
 def on_confirm(val):
     val and Executive.call("auth", ui_message, ["-1", "guest"])
Пример #44
0
 def on_click():
     Executive.call('quick_start_game', ui_message, 'THBattle')
Пример #45
0
 def on_confirm(val, uid=uid):
     Executive.call('observe_grant', ui_message, [uid, val])
Пример #46
0
 def on_click():
     Executive.call("quick_start_game", ui_message, "THBattle")
Пример #47
0
def start_ui():
    # ATI workarounds
    import pyglet
    from pyglet import gl
    @hook(gl)
    def glDrawArrays(ori, *a, **k):
        from pyglet.gl import glBegin, glEnd, GL_QUADS
        glBegin(GL_QUADS)
        glEnd()
        return ori(*a, **k)

    # ---------------

    from client.ui.base import init_gui, ui_schedule, ui_message

    init_gui()

    # This forces all game resources to initialize,
    # else they will be imported firstly by GameManager,
    # then resources will be loaded at a different thread,
    # resulting white planes.
    # UPDATE: no more threading now, but retain notice above.
    from client.ui.resource import resource
    import gamepack
    gamepack.init_ui_resources()

    from client.ui.resloader import Resource
    Resource.load_resources()

    from client.ui.base.baseclasses import main_window
    main_window.set_icon(resource.icon)
    main_window.set_visible(True)

    # custom errcheck
    import pyglet.gl.lib as gllib
    orig_errcheck = gllib.errcheck

    import ctypes
    def my_errcheck(result, func, arguments):
        from pyglet import gl
        error = gl.glGetError()
        if error and error != 1286:
            # HACK: The 1286(INVALID_FRAMEBUFFER_OPERATION) error again!
            # This time I DIDN'T EVEN USE FBO! ATI!!
            msg = ctypes.cast(gl.gluErrorString(error), ctypes.c_char_p).value
            raise gl.GLException((error, msg))
        return result

    gllib.errcheck = my_errcheck
    # ------------------------------------

    from screens import UpdateScreen, ServerSelectScreen

    us = UpdateScreen()
    us.switch()
    from client.core import Executive
    sss = ServerSelectScreen()

    errmsgs = {
        'update_disabled': u'自动更新已被禁止',
        'error': u'更新过程出现错误,您可能无法正常进行游戏!',
    }

    def display_box(msg):
        from client.ui.controls import ConfirmBox
        b = ConfirmBox(msg, parent=us)
        @b.event
        def on_confirm(val):
            sss.switch()

    def update_callback(msg):
        # executes in logic thread
        # well, intented to be
        # ui and logic now run in the same thread.

        from options import options
        if msg == 'up2date':
            ui_schedule(sss.switch)
        elif msg == 'update_disabled' and options.fastjoin:
            import gevent
            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, [])

            gevent.spawn(func)
                
        elif msg in errmsgs:
            ui_schedule(display_box, errmsgs[msg])
        else:
            os.execv(sys.executable, [sys.executable] + sys.argv)

    Executive.call('update', update_callback, lambda *a: ui_schedule(us.update_message, *a))

    # workaround for pyglet's bug
    if sys.platform == 'win32':
        import pyglet.app.win32
        pyglet.app.win32.Win32EventLoop._next_idle_time = None

    pyglet.app.run()
Пример #48
0
def kickob(uid):
    Executive.call('kick_observer', None, uid)
    return u'指令已发出'