Exemple #1
0
 def __onReceiverChanged(self, *args):
     parser = CommandArgsParser(self.__onReceiverChanged.__name__, 1,
                                [long])
     clientID, = parser.parse(*args)
     controller = self.__getController(clientID)
     if controller:
         BattleChannelView._lastReceiver = controller.getSettings().name
Exemple #2
0
    def __getLatestHistory(self, *args):
        toLastMessage = None
        if len(args) > 0:
            parser = CommandArgsParser(self.__getLatestHistory.__name__, 1, [bool])
            toLastMessage, = parser.parse(*args)
        if toLastMessage is not None and toLastMessage == True:
            self.__sharedHistory.syncCursor(True)
            self.__updateHistoryControls()
        historyList = self.__sharedHistory.getHistory()
        if len(historyList) == 0:
            return
        else:
            if toLastMessage is not None and toLastMessage == True:
                self.__flashCall(BTMS_COMMANDS.ClearMessages(), [])
            numberOfMessages = self.__sharedHistory.numberOfMessages()
            idx = len(historyList)
            for value, isCurrentPlayer in historyList:
                numberOfMessages -= 1
                idx -= 1
                self.__flashCall(BTMS_COMMANDS.ShowHistoryMessages(), [value,
                 isCurrentPlayer,
                 numberOfMessages,
                 idx])

            return
Exemple #3
0
    def __getLatestHistory(self, *args):
        toLastMessage = None
        if len(args) > 0:
            parser = CommandArgsParser(self.__getLatestHistory.__name__, 1, [bool])
            toLastMessage, = parser.parse(*args)
        if toLastMessage is not None and toLastMessage is True:
            self.__sharedHistory.syncCursor(True)
            self.__updateHistoryControls()
        historyList = self.__sharedHistory.getHistory()
        if len(historyList) == 0:
            return
        else:
            if toLastMessage is not None and toLastMessage is True:
                self.__flashCall(BTMS_COMMANDS.ClearMessages(), [])
            numberOfMessages = self.__sharedHistory.numberOfMessages()
            idx = len(historyList)
            for message, fillColor in historyList:
                numberOfMessages -= 1
                idx -= 1
                self.__flashCall(BTMS_COMMANDS.ShowHistoryMessages(), [message,
                 fillColor,
                 numberOfMessages,
                 idx])

            return
Exemple #4
0
 def __onSendChannelMessage(self, *args):
     parser = CommandArgsParser(self.__onSendChannelMessage.__name__, 2,
                                [long])
     clientID, rawMsgText = parser.parse(*args)
     controller = self.__getController(clientID)
     if controller:
         controller.sendMessage(rawMsgText)
    def onRequestItemRange(self, *args):
        parser = CommandArgsParser(self.onRequestItemRange.__name__, 2, [int, int])
        startIndex, endIndex = parser.parse(*args)
        for item in self.list[startIndex:endIndex + 1]:
            parser.addArgs(item)

        self.respond(parser.args())
Exemple #6
0
 def __onReceiverChanged(self, *args):
     parser = CommandArgsParser(self.__onReceiverChanged.__name__, 1,
                                [long])
     channelID, = parser.parse(*args)
     if self._channelID == channelID:
         LOG_DEBUG('BattleChannelView.__onReceiverChanged', self._receiver)
         BattleChannelView._lastReceiver = self._receiver
Exemple #7
0
 def __downHistory(self, *args):
     parser = CommandArgsParser(self.__downHistory.__name__, 1, [bool])
     (toLastMessage,) = parser.parse(*args)
     if toLastMessage == False:
         self.__sharedHistory.syncCursor(False)
         self.__sharedHistory.next()
     else:
         self.__sharedHistory.syncCursor(True)
     self.__updateHistoryControls()
     self.__getLatestHistory()
 def __downHistory(self, *args):
     parser = CommandArgsParser(self.__downHistory.__name__, 1, [bool])
     toLastMessage, = parser.parse(*args)
     if toLastMessage is False:
         self.__sharedHistory.syncCursor(False)
         self.__sharedHistory.next()
     else:
         self.__sharedHistory.syncCursor(True)
     self.__updateHistoryControls()
     self.__getLatestHistory()
 def __onSendChannelMessage(self, *args):
     controller = self._controller()
     if controller is None:
         return
     else:
         parser = CommandArgsParser(self.__onSendChannelMessage.__name__, 2, [long])
         channelID, rawMsgText = parser.parse(*args)
         if self._channelID == channelID:
             LOG_DEBUG('BattleChannelView.__onSendChannelMessage', channelID)
             controller.sendMessage(rawMsgText)
         return
Exemple #10
0
 def __onSendChannelMessage(self, *args):
     controller = self._controller()
     if controller is None:
         return
     else:
         parser = CommandArgsParser(self.__onSendChannelMessage.__name__, 2,
                                    [long])
         channelID, rawMsgText = parser.parse(*args)
         if self._channelID == channelID:
             LOG_DEBUG('BattleChannelView.__onSendChannelMessage',
                       channelID)
             controller.sendMessage(rawMsgText)
         return
 def __onCheckCooldownPeriod(self, *args):
     parser = CommandArgsParser(self.__onCheckCooldownPeriod.__name__, 1, [long])
     (clientID,) = parser.parse(*args)
     controller = self.__getController(clientID)
     if not controller:
         return 
     (result, errorMsg,) = controller.canSendMessage()
     parser.addArgs([clientID, result])
     self.__flashRespond(parser.args())
     if not result:
         message = g_settings.htmlTemplates.format('battleErrorMessage', ctx={'error': errorMsg})
         history = self.__sharedHistory()
         if history:
             history.addMessage(message, False)
         self.__flashCall(BTMS_COMMANDS.ReceiveMessage(), [clientID, message, False])
Exemple #12
0
 def __getLatestMessages(self, *args):
     data = -1
     if len(args) > 0:
         parser = CommandArgsParser(self.__getLatestMessages.__name__, 1, [long])
         (data,) = parser.parse(*args)
     self.__sharedHistory.syncCursor(True)
     historyList = self.__sharedHistory.getHistory()
     if data > 0:
         numberOfMessages = self.__sharedHistory.numberOfMessages()
         idx = len(historyList)
         if idx >= numberOfMessages:
             numberOfMessages -= 1
             historyList = historyList[(-numberOfMessages):]
     self.__flashCall(BTMS_COMMANDS.ClearMessages(), [])
     for (value, isCurrentPlayer,) in historyList:
         self.__flashCall(BTMS_COMMANDS.ShowLatestMessages(), [value, isCurrentPlayer])
Exemple #13
0
 def __getLatestMessages(self, *args):
     data = -1
     if len(args) > 0:
         parser = CommandArgsParser(self.__getLatestMessages.__name__, 1, [long])
         data, = parser.parse(*args)
     self.__sharedHistory.syncCursor(True)
     historyList = self.__sharedHistory.getHistory()
     if data > 0:
         numberOfMessages = self.__sharedHistory.numberOfMessages()
         idx = len(historyList)
         if idx >= numberOfMessages:
             numberOfMessages -= 1
             historyList = historyList[-numberOfMessages:]
     self.__flashCall(BTMS_COMMANDS.ClearMessages(), [])
     for message, fillColor in historyList:
         self.__flashCall(BTMS_COMMANDS.ShowLatestMessages(), [message, fillColor])
 def __onCheckCooldownPeriod(self, *args):
     controller = self._controller()
     if controller is None:
         return
     else:
         parser = CommandArgsParser(self.__onCheckCooldownPeriod.__name__, 1, [long])
         channelID, = parser.parse(*args)
         if channelID == self._channelID:
             LOG_DEBUG('BattleChannelView.__onCheckCooldownPeriod', channelID)
             result, errorMsg = controller.canSendMessage()
             parser.addArgs([channelID, result])
             self.__flashRespond(parser.args())
             if not result:
                 message = g_settings.htmlTemplates.format('battleErrorMessage', ctx={'error': errorMsg})
                 self.__flashCall(BTMS_COMMANDS.ReceiveMessage(), [channelID, message, False])
         return
Exemple #15
0
 def __getLatestMessages(self, *args):
     data = -1
     if len(args) > 0:
         parser = CommandArgsParser(self.__getLatestMessages.__name__, 1, [long])
         data, = parser.parse(*args)
     self.__sharedHistory.syncCursor(True)
     historyList = self.__sharedHistory.getHistory()
     if data > 0:
         numberOfMessages = self.__sharedHistory.numberOfMessages()
         idx = len(historyList)
         if idx >= numberOfMessages:
             numberOfMessages -= 1
             historyList = historyList[-numberOfMessages:]
     self.__flashCall(BTMS_COMMANDS.ClearMessages(), [])
     for message, fillColor in historyList:
         self.__flashCall(BTMS_COMMANDS.ShowLatestMessages(), [message, fillColor])
Exemple #16
0
 def onRequestItemAt(self, *args):
     parser = CommandArgsParser(self.onRequestItemAt.__name__, 1, [int])
     index, = parser.parse(*args)
     item = self.requestItemAt(index)
     if item:
         parser.addArgs(item)
     else:
         parser.addArgs(self.emptyItem())
     self.respond(parser.args())
 def onRequestItemAt(self, *args):
     parser = CommandArgsParser(self.onRequestItemAt.__name__, 1, [int])
     index, = parser.parse(*args)
     item = self.requestItemAt(index)
     if item:
         parser.addArgs(item)
     else:
         parser.addArgs(self.emptyItem())
     self.respond(parser.args())
Exemple #18
0
    def onRequestItemRange(self, *args):
        parser = CommandArgsParser(self.onRequestItemRange.__name__, 2,
                                   [int, int])
        startIndex, endIndex = parser.parse(*args)
        for item in self.list[startIndex:endIndex + 1]:
            parser.addArgs(item)

        self.respond(parser.args())
Exemple #19
0
 def __onPopulateUI(self, *args):
     LOG_DEBUG('[BattleMessanger]', '__onPopulateUI')
     settings = g_settings.battle
     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,
      settings.toolTipText,
      g_settings.userPrefs.storeReceiverInBattle])
     self.__flashRespond(parser.args())
Exemple #20
0
 def __onCheckCooldownPeriod(self, *args):
     parser = CommandArgsParser(self.__onCheckCooldownPeriod.__name__, 1, [long])
     clientID, = parser.parse(*args)
     controller = self.__getController(clientID)
     if not controller:
         return
     result, errorMsg = controller.canSendMessage()
     parser.addArgs([clientID, result])
     self.__flashRespond(parser.args())
     if not result:
         message = g_settings.htmlTemplates.format('battleErrorMessage', ctx={'error': errorMsg})
         history = self.__sharedHistory()
         if history:
             history.addMessage(message)
         self.__flashCall(BTMS_COMMANDS.ReceiveMessage(), [clientID, message, FILL_COLORS.BLACK])
Exemple #21
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()
Exemple #22
0
 def __onCheckCooldownPeriod(self, *args):
     controller = self._controller()
     if controller is None:
         return
     else:
         parser = CommandArgsParser(self.__onCheckCooldownPeriod.__name__,
                                    1, [long])
         channelID, = parser.parse(*args)
         if channelID == self._channelID:
             LOG_DEBUG('BattleChannelView.__onCheckCooldownPeriod',
                       channelID)
             result, errorMsg = controller.canSendMessage()
             parser.addArgs([channelID, result])
             self.__flashRespond(parser.args())
             if not result:
                 message = g_settings.htmlTemplates.format(
                     'battleErrorMessage', ctx={'error': errorMsg})
                 self.__flashCall(BTMS_COMMANDS.ReceiveMessage(),
                                  [channelID, message, False])
         return
Exemple #23
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()
 def __onSendChannelMessage(self, *args):
     parser = CommandArgsParser(self.__onSendChannelMessage.__name__, 2, [long])
     (clientID, rawMsgText,) = parser.parse(*args)
     controller = self.__getController(clientID)
     if controller:
         controller.sendMessage(rawMsgText)
 def __onReceiverChanged(self, *args):
     parser = CommandArgsParser(self.__onReceiverChanged.__name__, 1, [long])
     (clientID,) = parser.parse(*args)
     controller = self.__getController(clientID)
     if controller:
         BattleChannelView._lastReceiver = controller.getSettings().name
Exemple #26
0
 def __onGetScreenSize(self, *args):
     parser = CommandArgsParser(self.__onGetScreenSize.__name__)
     parser.parse(*args)
     parser.addArgs(list(GUI.screenResolution()))
     self.uiHolder.respond(parser.args())
 def onRequestLength(self, *args):
     parser = CommandArgsParser(self.onRequestLength.__name__)
     parser.parse(*args)
     parser.addArg(self.length())
     self.respond(parser.args())
Exemple #28
0
 def onRequestLength(self, *args):
     parser = CommandArgsParser(self.onRequestLength.__name__)
     parser.parse(*args)
     parser.addArg(self.length())
     self.respond(parser.args())
 def __onGetScreenSize(self, *args):
     parser = CommandArgsParser(self.__onGetScreenSize.__name__)
     parser.parse(*args)
     parser.addArgs(list(GUI.screenResolution()))
     self.uiHolder.respond(parser.args())
 def __onReceiverChanged(self, *args):
     parser = CommandArgsParser(self.__onReceiverChanged.__name__, 1, [long])
     channelID, = parser.parse(*args)
     if self._channelID == channelID:
         LOG_DEBUG('BattleChannelView.__onReceiverChanged', self._receiver)
         BattleChannelView._lastReceiver = self._receiver