示例#1
0
 def pushNewMessage(self, spaceID):
     if spaceID == GuiGlobalSpaceID.LOBBY:
         currentTime = datetime.datetime.now()
         if currentTime >= self.timeDelta:
             self.timeDelta = currentTime + datetime.timedelta(minutes=60)
             pushMessage(self.getDonateMessage(), type=SM_TYPE.Warning)
             logInfo("A donation message has been sent to the user. Repeated in 60 minutes.")
示例#2
0
 def _populate(self):
     super(BaseModMeta, self)._populate()
     self.settings = self.getSettings()
     g_playerEvents.onAvatarReady += self.onEnterBattlePage
     g_playerEvents.onAvatarBecomeNonPlayer += self.onExitBattlePage
     if self._isDAAPIInited():
         self.flashObject.setCompVisible(False)
         if self.isDebug:
             logInfo("battle module '%s' loaded" % self.getAlias())
示例#3
0
 def getSettings(self):
     settings_name = ALIAS_TO_CONFIG_NAME.get(self.getAlias())
     if settings_name is not None:
         data = getattr(settings, settings_name, None)
         if self.isDebug:
             logInfo("Settings Name: %s - Settings Data: %s" %
                     (settings_name, str(data)))
         if data is not None:
             return data
     return settings
示例#4
0
 def onArenaCreated(self):
     if self.settings.log_total[GLOBAL.ENABLED]:
         try:
             dossier = g_currentVehicle.getDossier()
             if dossier:
                 damage = dossier.getRandomStats().getAvgDamage()
                 assist = dossier.getRandomStats().getDamageAssistedEfficiencyWithStan()
                 if damage is not None:
                     damage = round(damage)
                     DAMAGE_LOG.AVG_DAMAGE_DATA = damage
                     logInfo("set vehicle efficiency (avgDamage: {}, avgAssist: {})".format(damage, assist))
         except AttributeError:
             DAMAGE_LOG.AVG_DAMAGE_DATA = GLOBAL.ZERO
 def updateDispersion(self, avatar, dispersionAngle):
     if avatar.isVehicleAlive:
         dispersionAngle = round(dispersionAngle * 100, 2)
         if self.max_angle == GLOBAL.F_ZERO:
             descr = avatar.getVehicleDescriptor()
             self.max_angle = round(descr.gun.shotDispersionAngle * 100, 2)
             if self.isDebug:
                 logInfo("DispersionTimer - set max dispersion angle %s" %
                         self.max_angle)
         if self.max_angle > dispersionAngle:
             self.max_angle = dispersionAngle
             if self.isDebug:
                 logInfo("DispersionTimer - renew max dispersion angle %s" %
                         self.max_angle)
         timing = round(avatar.vehicleTypeDescriptor.gun.aimingTime,
                        1) * log(dispersionAngle / self.max_angle)
         self.macro["timer"] = timing
         self.macro["percent"] = int(self.max_angle / dispersionAngle * 100)
         if timing <= GLOBAL.ZERO:
             self.as_updateTimerTextS(self.timer_done % self.macro)
         else:
             self.as_updateTimerTextS(self.timer_regular % self.macro)
示例#6
0
    def start(self):
        if self.isFileValid:
            logInfo('MOD {0}: {1}'.format(MESSAGES.START, self.mod_version))
            self.componentsLoader.start()
            self.configLoader.start()
            packages.BATTLE_PACKAGES += ("armagomen.battle_observer.battle", )
            packages.LOBBY_PACKAGES += ("armagomen.battle_observer.lobby", )
        else:
            from gui.Scaleform.daapi.view import dialogs
            from gui import DialogsInterface
            locked = MESSAGES.LOCKED_BY_FILE_NAME.format(self.fileName)
            logWarning(locked)

            def loadBlocked(spaceID):
                if spaceID in (GuiGlobalSpaceID.LOGIN, GuiGlobalSpaceID.LOBBY):
                    title = '{0} is locked'.format(MOD_NAME)
                    btn = DialogButtons('Close')
                    DialogsInterface.showDialog(
                        dialogs.SimpleDialogMeta(title, locked, btn),
                        lambda proceed: None)
                    ServicesLocator.appLoader.onGUISpaceEntered -= loadBlocked

            ServicesLocator.appLoader.onGUISpaceEntered += loadBlocked
示例#7
0
 def readConfig(self, configName):
     """Read settings_core file from JSON"""
     direct_path = os.path.join(self.path, configName)
     logInfo('START UPDATE USER CONFIGURATION: {}'.format(configName))
     file_list = ['{}.json'.format(name) for name in LOAD_LIST]
     listdir = os.listdir(direct_path)
     for num, module_name in enumerate(LOAD_LIST, GLOBAL.ZERO):
         file_name = file_list[num]
         file_path = os.path.join(direct_path, file_name)
         internal_cfg = getattr(self.settings, module_name)
         if file_name in listdir:
             try:
                 if self.updateData(self.getFileData(file_path), internal_cfg):
                     self.createFileInDir(file_path, internal_cfg)
             except Exception as error:
                 self.loadError(file_path, error.message)
                 logWarning('readConfig: {} {}'.format(file_name, repr(error)))
                 continue
         else:
             self.createFileInDir(file_path, internal_cfg)
         self.settings.onModSettingsChanged(internal_cfg, module_name)
     logInfo('CONFIGURATION UPDATE COMPLETED: {}'.format(configName))
     if self.configInterface is not None:
         self.configInterface.onUserConfigUpdateComplete()
示例#8
0
 def onExit(self):
     if self.isFileValid:
         if settings.main[MAIN.AUTO_CLEAR_CACHE]:
             self.clearClientCache()
         logInfo('MOD {0}: {1}'.format(MESSAGES.FINISH, self.mod_version))
示例#9
0
 def removeDirs(normpath, dir_name):
     if os.path.exists(normpath):
         rmtree(normpath, ignore_errors=True, onerror=None)
         logInfo('CLEANING CACHE: {0}'.format(dir_name))
示例#10
0
 def _dispose(self):
     if settings.main[MAIN.DEBUG] and self._isDAAPIInited():
         logInfo("hangar module '%s' dispose" % self.getAlias())
     super(BaseModMeta, self)._dispose()
示例#11
0
 def _populate(self):
     super(BaseModMeta, self)._populate()
     if settings.main[MAIN.DEBUG] and self._isDAAPIInited():
         logInfo("hangar module '%s' loaded" % self.getAlias())
示例#12
0
 def _dispose(self):
     g_playerEvents.onAvatarReady -= self.onEnterBattlePage
     g_playerEvents.onAvatarBecomeNonPlayer -= self.onExitBattlePage
     super(BaseModMeta, self)._dispose()
     if self.isDebug:
         logInfo("battle module '%s' destroyed" % self.getAlias())