Esempio n. 1
0
 def xfw_cmd(self, cmd, *args):
     try:
         if IS_DEVELOPMENT and cmd in _LOG_COMMANDS:
             debug('[XFW] xfw_cmd: {} {}'.format(cmd, args))
         if cmd == COMMAND.XFW_COMMAND_LOG:
             if swf.g_xvmlogger is None:
                 swf.g_xvmlogger = Logger(PATH.XVM_LOG_FILE_NAME)
             swf.g_xvmlogger.add(*args)
         elif cmd == COMMAND.XFW_COMMAND_INITIALIZED:
             swf.xfwInitialized = True
         elif cmd == COMMAND.XFW_COMMAND_SWF_LOADED:
             xfw_mods_info.swf_loaded(args[0])
             g_eventBus.handleEvent(HasCtxEvent(XFWEVENT.SWF_LOADED, args[0]))
         elif cmd == COMMAND.XFW_COMMAND_GETMODS:
             return self.getMods()
         elif cmd == COMMAND.XFW_COMMAND_LOADFILE:
             return load_file(args[0])
         elif cmd == XFWCOMMAND.XFW_COMMAND_GETGAMEREGION:
             return GAME_REGION
         elif cmd == XFWCOMMAND.XFW_COMMAND_GETGAMELANGUAGE:
             return GAME_LANGUAGE
         elif cmd == XFWCOMMAND.XFW_COMMAND_CALLBACK:
             e = swf._events.get(args[0], None)
             if e:
                 e.fire({
                   "name": args[0],
                   "type": args[1],
                   "x": int(args[2]),
                   "y": int(args[3]),
                   "stageX": int(args[4]),
                   "stageY": int(args[5]),
                   "buttonIdx": int(args[6]),
                   "delta": int(args[7])
                 })
         elif cmd == XFWCOMMAND.XFW_COMMAND_MESSAGEBOX:
             # title, message
             DialogsInterface.showDialog(dialogs.SimpleDialogMeta(
                 args[0],
                 args[1],
                 dialogs.I18nInfoDialogButtons('common/error')),
                 (lambda x: None))
         elif cmd == XFWCOMMAND.XFW_COMMAND_SYSMESSAGE:
             # message, type
             # Types: gui.SystemMessages.SM_TYPE:
             #   'Error', 'Warning', 'Information', 'GameGreeting', ...
             SystemMessages.pushMessage(
                 args[0],
                 type=SystemMessages.SM_TYPE.of(args[1]))
         else:
             handlers = g_eventBus._EventBus__scopes[EVENT_BUS_SCOPE.DEFAULT][XFWCOMMAND.XFW_CMD]
             for handler in handlers.copy():
                 try:
                     (result, status) = handler(cmd, *args)
                     if status:
                         return result
                 except TypeError:
                     err(traceback.format_exc())
             log('WARNING: unknown command: {}'.format(cmd))
     except:
         err(traceback.format_exc())
Esempio n. 2
0
 def __me_onErrorReceived(self, error):
     if error.isModal():
         DialogsInterface.showDialog(
             dialogs.SimpleDialogMeta(
                 error.getTitle(), error.getMessage(),
                 dialogs.I18nInfoDialogButtons('common/error')),
             lambda *args: None)
     else:
         SystemMessages.pushMessage(error.getMessage(),
                                    type=SystemMessages.SM_TYPE.Error)