Exemple #1
0
class LogitechBattleMessenger(object):

    def __init__(self):
        self.messenger = None



    def __del__(self):
        LOG_DEBUG('Deleted:', self)



    def create(self, uiHolder):
        from messenger.gui.Scaleform.BattleEntry import BattleEntry
        self.messenger = BattleEntry()
        self.messenger.show()
        self.messenger.enableRecord(False)
        self.messenger.invoke('populateUI', uiHolder)



    def destroy(self):
        self.messenger.close(MESSENGER_SCOPE.UNKNOWN)
        self.messenger.invoke('dispossessUI')
        self.messenger = None
class LogitechBattleMessenger(object):
    def __init__(self):
        self.messenger = None

    def __del__(self):
        LOG_DEBUG('Deleted:', self)

    def create(self, uiHolder):
        from messenger.gui.Scaleform.BattleEntry import BattleEntry
        self.messenger = BattleEntry()
        self.messenger.show()
        self.messenger.enableRecord(False)
        self.messenger.invoke('populateUI', uiHolder)

    def destroy(self):
        self.messenger.close(MESSENGER_SCOPE.UNKNOWN)
        self.messenger.invoke('dispossessUI')
        self.messenger = None
class LogitechMonitorBattleColoredScreen(LogitechMonitorBattleColoredScreenMeta, IDebugPanel, _ITimerView, _IFragsView):

    def __init__(self, frame):
        super(LogitechMonitorBattleColoredScreen, self).__init__(frame)
        self._colorManager = _ColorSchemeManager()
        self.__debugCtrl = DebugController()
        self.__timerPresenter = _TimerPresenter(weakref.proxy(self))
        self.__fragsPresenter = _FragsPresenter(weakref.proxy(self))
        self.__messenger = MessengerBattleEntry()
        self.__isPostmortem = False

    def _onLoaded(self):
        self.__debugCtrl.setViewComponents(weakref.proxy(self))
        self.__debugCtrl.start()
        self._colorManager.populateUI(weakref.proxy(self._flashObject))
        self.__timerPresenter.start()
        self.__fragsPresenter.start()
        vehStateCtrl = g_sessionProvider.getVehicleStateCtrl()
        self.__isPostmortem = vehStateCtrl and vehStateCtrl.isInPostmortem
        if self.__isPostmortem:
            self.__onPostMortemSwitched()
        if vehStateCtrl is not None:
            vehStateCtrl.onPostMortemSwitched += self.__onPostMortemSwitched
        CommandMapping.g_instance.onMappingChanged += self.setCommands
        self.setCommands()
        self.__messenger.show()
        self.__messenger.enableRecord(False)
        self.__messenger.populateUI(weakref.proxy(self._flashObject))
        return

    def _onUnloaded(self):
        self.__debugCtrl.stop()
        self.__debugCtrl.clearViewComponents()
        self.__timerPresenter.stop()
        self.__fragsPresenter.stop()
        ctrl = g_sessionProvider.getVehicleStateCtrl()
        if ctrl is not None:
            ctrl.onPostMortemSwitched -= self.__onPostMortemSwitched
        CommandMapping.g_instance.onMappingChanged -= self.setCommands
        self._colorManager.dispossessUI()
        self.__messenger.close(MESSENGER_SCOPE.UNKNOWN)
        self.__messenger.dispossessUI()
        return

    def setCommands(self, *args):
        if self.__isPostmortem:
            return
        else:
            cmdMap = CommandMapping.g_instance
            viewCmdMapping = []
            for command in _VIEW_CMDS:
                commandName = cmdMap.getName(command)
                key = cmdMap.get(commandName)
                viewCmdMapping.append(commandName)
                viewCmdMapping.append(BigWorld.keyToString(key) if key is not None else 'NONE')

            self.as_setCommandMapping(viewCmdMapping)
            return

    def updateDebugInfo(self, ping, fps, isLaggingNow, fpsReplay = -1):
        self.as_updateDebugInfo(fps, ping, isLaggingNow)

    def updateTimer(self, timerDisplayData):
        self.as_setTotalTime(timerDisplayData.level, timerDisplayData.minutes, timerDisplayData.seconds)

    def updateFrags(self, fragsDisplayData):
        label = '{}/{}'.format(fragsDisplayData.allyFrags, fragsDisplayData.enemyFrags)
        self.as_updateFrags(fragsDisplayData.progress, label)

    def __onPostMortemSwitched(self):
        if not g_sessionProvider.getCtx().isPlayerObserver():
            self.__isPostmortem = True
            self.as_hideCommandMapping(True)