Beispiel #1
0
 def testtimerCallback(self, dic):
     plug2 = Plugin.GetPlugin("Test2")
     plug2.Invoke("TestSharedFunction", dic["first"], dic["second"])
     Debug.Log(dic["first"])
     Debug.Log(dic["second"])
     Plugin.DumpObjToFile("testtimerCallback.dict", dic, 3, 20, True, True)
     Plugin.KillTimers()
Beispiel #2
0
    def init(self):
        import options
        from UnityEngine import Debug

        L = lambda s: Debug.Log("PyWrap: " + s)
        L("init")

        self.events = []

        # should set them
        options.no_update
        options.show_hidden_mode

        options.freeplay = False

        if options.no_update:
            import autoupdate
            autoupdate.Autoupdate = autoupdate.DummyAutoupdate

        L("before gevent")
        from gevent import monkey
        monkey.patch_socket()
        monkey.patch_os()
        monkey.patch_select()
        L("after gevent")

        from game import autoenv
        autoenv.init('Client')

        import thb.ui.ui_meta  # noqa, init ui_meta

        from client.core.executive import Executive
        self.executive = ExecutiveWrapper(Executive, self)
Beispiel #3
0
def inject_static_linked_extensions():
    try:
        import gevent_ares
        import gevent_core
        import gevent_semaphore
        import msgpack_packer
        import msgpack_unpacker

        sys.modules['gevent.ares'] = gevent_ares
        # sys.modules['gevent.core'] = gevent_core
        sys.modules['gevent._semaphore'] = gevent_semaphore
        sys.modules['msgpack._packer'] = msgpack_packer
        sys.modules['msgpack._unpacker'] = msgpack_unpacker

        import gevent
        import msgpack

        gevent.ares = gevent_ares
        gevent.core = gevent_core
        gevent._semaphore = gevent_semaphore
        msgpack._packer = msgpack_packer
        msgpack._unpacker = msgpack_unpacker

    except Exception:
        from UnityEngine import Debug
        from traceback import format_exc
        Debug.Log('Inject static extension failed.\n\n' + format_exc())
Beispiel #4
0
    def emit(self, rec):
        msg = self.format(rec)

        try:
            from UnityEngine import Debug
            if rec.levelno <= logging.DEBUG:
                Debug.LogDebug(msg)
            elif rec.levelno <= logging.INFO:
                Debug.LogInfo(msg)
            elif rec.levelno <= logging.ERROR:
                Debug.LogError(msg)
            else:
                Debug.LogError(msg)
        except:
            # f**k
            pass
Beispiel #5
0
def _dbgprint(ins):
    s = [
        'NOP',
        'DUP',
        'GET',
        'CREATE',
        'MOVE',
        'FADE',
        'GRAY',
        'UNGRAY',
        'FATETELL',
        'AREA_HAND',
        'AREA_DECK',
        'AREA_DROP',
        'AREA_PORT0',
        'AREA_PORT1',
        'AREA_PORT2',
        'AREA_PORT3',
        'AREA_PORT4',
        'AREA_PORT5',
        'AREA_PORT6',
        'AREA_PORT7',
        'AREA_PORT8',
        'AREA_PORT9',
    ]
    rst = []
    for i in ins:
        if isinstance(i, int):
            rst.append(s[i])
        else:
            rst.append(repr(i))

    from UnityEngine import Debug
    Debug.Log(repr(rst))
Beispiel #6
0
    def connect_server(self, host, port):
        from UnityEngine import Debug
        Debug.Log(repr((host, port)))

        @gevent.spawn
        def do():
            Q = self.warpgate.queue_system_event
            Q('connect', self.executive.connect_server((host, port), Q))
Beispiel #7
0
    def init(self):
        import options
        from UnityEngine import Debug

        L = lambda s: Debug.Log("PyWrap: " + s)
        L("init")

        self.events = []

        # should set them
        options.no_update
        options.no_crashreport
        options.show_hidden_mode

        options.freeplay = False

        if options.no_update:
            import autoupdate
            autoupdate.Autoupdate = autoupdate.DummyAutoupdate

        L("before gevent")
        from gevent import monkey
        monkey.patch_socket()
        monkey.patch_os()
        monkey.patch_select()
        L("after gevent")

        from game import autoenv
        autoenv.init('Client')

        import gamepack.thb.ui.ui_meta  # noqa, init ui_meta

        # For debug
        @gevent.spawn
        def beat():
            while True:
                gevent.sleep(1)
                # self.events.append(("tick",))

        from client.core.executive import Executive
        self.executive = ExecutiveWrapper(Executive, self)
Beispiel #8
0
    def print_exception(self, context, type, value, tb):
        text = ''.join(traceback.format_exception(type, value, tb))
        del tb
        if context is not None:
            if not isinstance(context, str):
                try:
                    context = self.format_context(context)
                except:
                    text += 'Error formatting context\n' + traceback.format_exc(
                    )
                    context = repr(context)
            text += ('\n%s failed with %s\n\n' % (
                context,
                getattr(type, '__name__', 'exception'),
            ))

        try:
            from UnityEngine import Debug
            Debug.LogError(text)
        except:
            # f**k
            pass
Beispiel #9
0
 def write(self, data):
     from UnityEngine import Debug
     Debug.Log(data)
Beispiel #10
0
 def On_ServerShutdown(self):
     Debug.Log("On_ServerShutdown hooked from Python")
Beispiel #11
0
 def On_PluginInit(self):
     Debug.Log("On_PluginInit hooked from Python")
Beispiel #12
0
 def On_ServerInit(self):
     Debug.Log("On_ServerInit hooked from Python")
     dic = Plugin.CreateDict()
     dic.Add("first", "timer is:")
     dic.Add("second", "working")
     Plugin.CreateTimer("testtimer", 5000, dic).Start()
Beispiel #13
0
 def On_AllPluginsLoaded(self):
     Debug.Log("The knights who say NI!")