Beispiel #1
0
    def populateUI(self, parentUI):
        self.__ui = parentUI
        self.__ui.addExternalCallbacks({BTMS_COMMANDS.PopulateUI(): self.__onPopulateUI,
         BTMS_COMMANDS.ChangeFocus(): self.__onChangeFocus,
         BTMS_COMMANDS.AddToFriends(): self.__onAddToFriends,
         BTMS_COMMANDS.RemoveFromFriends(): self.__onRemoveFromFriends,
         BTMS_COMMANDS.AddToIgnored(): self.__onAddToIgnored,
         BTMS_COMMANDS.RemoveFromIgnored(): self.__onRemoveFromIgnored,
         BTMS_COMMANDS.AddMuted(): self.__onSetMuted,
         BTMS_COMMANDS.RemoveMuted(): self.__onUnsetMuted,
         BTMS_COMMANDS.upHistory(): self.__upHistory,
         BTMS_COMMANDS.downHistory(): self.__downHistory,
         BTMS_COMMANDS.GetLatestHistory(): self.__getLatestHistory,
         BTMS_COMMANDS.GetLastMessages(): self.__getLatestMessages})
        self.__flashCall(BTMS_COMMANDS.RefreshUI())
        self.__view = BattleChannelView(self.__sharedHistory)
        self.__view.populateUI(parentUI)
        if self.__channelsCtrl:
            for controller in self.__channelsCtrl.getControllersIterator():
                controller.setView(self.__view)

            self.__updateHistoryControls()
        if BATTLE_CHANNEL.isInitialized(self.__initialized):
            self.enable()
Beispiel #2
0
 def __onPopulateUI(self, *args):
     settings = g_settings.battle
     userSettings = g_settings.userPrefs
     parser = CommandArgsParser(self.__onPopulateUI.__name__)
     parser.parse(*args)
     parser.addArgs([settings.messageLifeCycle.lifeTime,
      settings.messageLifeCycle.alphaSpeed,
      settings.inactiveStateAlpha,
      CHAT_MESSAGE_MAX_LENGTH_IN_BATTLE,
      settings.hintText,
      self.__getToolTipText(),
      userSettings.storeReceiverInBattle,
      not userSettings.disableBattleChat])
     self.__flashRespond(parser.args())
     if self.__sharedHistory.isEnabled():
         self.__sharedHistory.syncCursor(True)
     self.__flashCall(BTMS_COMMANDS.isHistoryEnabled(), [bool(self.__sharedHistory.isEnabled()),
      self.__sharedHistory.numberOfMessages(),
      g_settings.battle.alphaForLastMessages,
      g_settings.battle.recoveredLatestMessages,
      g_settings.battle.lifeTimeRecoveredMessages])
     self.__updateHistoryControls()
Beispiel #3
0
 def dispossessUI(self):
     self.__flashCall(BTMS_COMMANDS.ClearMessages())
     if self.__ui:
         self.__ui.removeExternalCallbacks(BTMS_COMMANDS.PopulateUI(), BTMS_COMMANDS.CheckCooldownPeriod(), BTMS_COMMANDS.SendMessage(), BTMS_COMMANDS.ChangeFocus(), BTMS_COMMANDS.AddToFriends(), BTMS_COMMANDS.RemoveFromFriends(), BTMS_COMMANDS.AddToIgnored(), BTMS_COMMANDS.RemoveFromIgnored(), BTMS_COMMANDS.AddMuted(), BTMS_COMMANDS.RemoveMuted(), BTMS_COMMANDS.upHistory(), BTMS_COMMANDS.downHistory(), BTMS_COMMANDS.GetLatestHistory())
     if self.__view:
         self.__view.dispossessUI()
         self.__view = None
     self.__ui = None
Beispiel #4
0
 def __showErrorMessage(self, message):
     formatted = g_settings.htmlTemplates.format('battleErrorMessage',
                                                 ctx={'error': message})
     self.__sharedHistory.addMessage(formatted)
     self.__flashCall(BTMS_COMMANDS.ShowActionFailureMessage(),
                      [formatted, FILL_COLORS.BLACK])
Beispiel #5
0
 def __ms_onUserPreferencesUpdated(self):
     self.__flashCall(BTMS_COMMANDS.UserPreferencesUpdated(), [g_settings.userPrefs.storeReceiverInBattle, FILL_COLORS.BROWN, self.__getToolTipText()])
     if self.__view:
         self.__view.updateReceiversData()
Beispiel #6
0
 def enable(self):
     import BattleReplay
     if BattleReplay.g_replayCtrl.isPlaying:
         return
     self.__flashCall(BTMS_COMMANDS.ChannelsInit())
Beispiel #7
0
 def populateUI(self, proxy):
     super(BattleChannelView, self).populateUI(proxy)
     self.uiHolder.addExternalCallbacks({BTMS_COMMANDS.CheckCooldownPeriod(): self.__onCheckCooldownPeriod,
      BTMS_COMMANDS.SendMessage(): self.__onSendChannelMessage,
      BTMS_COMMANDS.ReceiverChanged(): self.__onReceiverChanged})
Beispiel #8
0
 def __showWarningMessage(self, actionMessage):
     formatter = getMessageFormatter(actionMessage)
     formatted = formatter.getFormattedMessage()
     fillColor = formatter.getFillColor()
     self.__sharedHistory.addMessage(formatted, fillColor=fillColor)
     self.__flashCall(BTMS_COMMANDS.ShowActionFailureMessage(), [formatted, fillColor])
Beispiel #9
0
 def addMessage(self, message, isCurrentPlayer=False):
     self.__flashCall(BTMS_COMMANDS.ReceiveMessage(),
                      [self._channelID, message, isCurrentPlayer])
Beispiel #10
0
 def setJoined(self):
     args = self.getRecvConfig()[:]
     args.insert(0, self._channelID)
     self.__flashCall(BTMS_COMMANDS.JoinToChannel(), args)
Beispiel #11
0
 def __ms_onUserPreferencesUpdated(self):
     self.__flashCall(BTMS_COMMANDS.UserPreferencesUpdated(), [g_settings.userPrefs.storeReceiverInBattle])
Beispiel #12
0
 def __showErrorMessage(self, message):
     self.__flashCall(BTMS_COMMANDS.ShowActionFailureMessage(), [g_settings.htmlTemplates.format('battleErrorMessage', ctx={'error': message})])
Beispiel #13
0
 def addClientMessage(self, message, isCurrentPlayer = False):
     self.__flashCall(BTMS_COMMANDS.ReceiveMessage(), [0, message, isCurrentPlayer])