def getHotKeyVkList(command):
    key, satelliteKeys = CommandMapping.g_instance.getCommandKeys(command)
    keys = [
        BigWorld.keyToString(satelliteKey) for satelliteKey in satelliteKeys
    ]
    keys.append(BigWorld.keyToString(key))
    return keys
Example #2
0
    def save(self):
        tmpList = []
        for fireKey, listKeyInfo in self.__mapping.iteritems():
            for command, satelliteKeys, isDefault in listKeyInfo:
                if isDefault:
                    continue
                if len(satelliteKeys):
                    continue
                commandName = self.getName(command)
                listSatelliteKeyNames = []
                for key in satelliteKeys:
                    listSatelliteKeyNames.append('KEY_' +
                                                 BigWorld.keyToString(key))

                strSatelliteKeyNames = ''
                for keyName in listSatelliteKeyNames:
                    strSatelliteKeyNames += keyName + ' '

                strSatelliteKeyNames = strSatelliteKeyNames.strip()
                fireKeyName = 'KEY_' + BigWorld.keyToString(fireKey)
                tmpList.append(
                    (commandName, fireKeyName, strSatelliteKeyNames))

        if len(tmpList):
            section = Settings.g_instance.userPrefs
            section.deleteSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            section = section.createSection(
                CommandMapping.__USER_CONFIG_SECTION_NAME)
            for commandName, fireKeyName, strSatelliteKeynames in tmpList:
                subsec = section.createSection(commandName)
                subsec.writeString('fireKey', fireKeyName)
                subsec.writeString('satelliteKeys', strSatelliteKeyNames)

            Settings.g_instance.save()
Example #3
0
    def save(self):
        tmpList = []
        for fireKey, listKeyInfo in self.__mapping.iteritems():
            for command, satelliteKeys, isDefault in listKeyInfo:
                if isDefault:
                    continue
                if len(satelliteKeys):
                    continue
                commandName = self.getName(command)
                listSatelliteKeyNames = []
                for key in satelliteKeys:
                    listSatelliteKeyNames.append('KEY_' + BigWorld.keyToString(key))

                strSatelliteKeyNames = ''
                for keyName in listSatelliteKeyNames:
                    strSatelliteKeyNames += keyName + ' '

                strSatelliteKeyNames = strSatelliteKeyNames.strip()
                fireKeyName = 'KEY_' + BigWorld.keyToString(fireKey)
                tmpList.append((commandName, fireKeyName, strSatelliteKeyNames))

        if len(tmpList):
            section = Settings.g_instance.userPrefs
            section.deleteSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            section = section.createSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            for commandName, fireKeyName, strSatelliteKeynames in tmpList:
                subsec = section.createSection(commandName)
                subsec.writeString('fireKey', fireKeyName)
                subsec.writeString('satelliteKeys', strSatelliteKeyNames)

            Settings.g_instance.save()
def _getHotKeyList(command):
    keys = []
    key, satelliteKeys = CommandMapping.g_instance.getCommandKeys(command)
    for satelliteKey in satelliteKeys:
        keys.append(
            makeString(
                READABLE_KEY_NAMES.key(BigWorld.keyToString(satelliteKey))))

    keys.append(makeString(READABLE_KEY_NAMES.key(BigWorld.keyToString(key))))
    return keys
Example #5
0
 def buildCmdMapping(self):
     cmdMap = CommandMapping.g_instance
     self.__viewCmdMapping = []
     for command in self.__viewCmds:
         key = cmdMap.get(command)
         self.__viewCmdMapping.append(command)
         self.__viewCmdMapping.append(BigWorld.keyToString(key) if key is not None else 'NONE')
Example #6
0
 def buildCmdMapping(self):
     cmdMap = CommandMapping.g_instance
     self.__viewCmdMapping = []
     for command in self.__viewCmds:
         key = cmdMap.get(command)
         self.__viewCmdMapping.append(command)
         self.__viewCmdMapping.append(
             BigWorld.keyToString(key) if key is not None else 'NONE')
Example #7
0
 def handleKeyEvent(self, event):
     print 'handleKeyEvent', BigWorld.keyToString(event.key), event.isKeyDown()
     if event.key == Keys.KEY_SPACE:
         self.component.colour = (random.random() * 255,
          random.random() * 255,
          random.random() * 255,
          255)
         return True
     return False
Example #8
0
 def handleMouseButtonEvent(self, comp, event):
     print 'handleMouseButtonEvent', BigWorld.keyToString(event.key), event.isKeyDown(),
     if self.component.focus == False:
         print 'Setting focus to True!'
         self.component.focus = True
         self.component.colour = (128, 128, 12, 255)
     else:
         print "We're already in focus."
     return True
Example #9
0
 def handleMouseButtonEvent(self, comp, event):
     print 'handleMouseButtonEvent', BigWorld.keyToString(event.key), event.isKeyDown(),
     if self.component.focus == False:
         print 'Setting focus to True!'
         self.component.focus = True
         self.component.colour = (128, 128, 12, 255)
     else:
         print "We're already in focus."
     return True
Example #10
0
def writeHotKeys(data):
    for key in data:
        for keyType in ('key', 'button'):
            if keyType.capitalize() not in key:
                continue
            data[key] = []
            for keySet in data[key.replace(keyType.capitalize(), keyType)]:
                if isinstance(keySet, list):
                    data[key].append([])
                    for hotKey in keySet:
                        hotKeyName = BigWorld.keyToString(hotKey)
                        data[key][-1].append(hotKeyName if 'KEY_' in
                                             hotKeyName else 'KEY_' +
                                             hotKeyName)
                else:
                    hotKeyName = BigWorld.keyToString(keySet)
                    data[key].append(hotKeyName if 'KEY_' in
                                     hotKeyName else 'KEY_' + hotKeyName)
Example #11
0
 def handleKeyEvent(self, event):
     print 'handleKeyEvent', BigWorld.keyToString(event.key), event.isKeyDown()
     if event.key == Keys.KEY_SPACE:
         self.component.colour = (random.random() * 255,
          random.random() * 255,
          random.random() * 255,
          255)
         return True
     return False
Example #12
0
    def setCommands(self, *args):
        cmdMap = CommandMapping.g_instance
        viewCmdMapping = []
        for command in self.__viewCmds:
            key = cmdMap.get(command)
            viewCmdMapping.append(command)
            viewCmdMapping.append(BigWorld.keyToString(key) if key is not None else 'NONE')

        self.call('battle.ingameHelp.setCommandMapping', viewCmdMapping)
Example #13
0
    def setCommands(self, *args):
        cmdMap = CommandMapping.g_instance
        viewCmdMapping = []
        for command in self.__viewCmds:
            key = cmdMap.get(command)
            viewCmdMapping.append(command)
            viewCmdMapping.append(
                BigWorld.keyToString(key) if key is not None else 'NONE')

        self.call('battle.ingameHelp.setCommandMapping', viewCmdMapping)
def __getVK(command):
    key = getKey(command)
    if canGetVirtualKey(key):
        vk = BigWorld.mapVirtualKey(key, MappingType.MAPVK_VSC_TO_VK)
        if vk != 0:
            if vk in SCALEFORM_TO_BW:
                key = SCALEFORM_TO_BW[vk]
            else:
                key = BigWorld.mapVirtualKey(vk, MappingType.MAPVK_VK_TO_CHAR)
                return (unichr(key).upper(), True)
    return (BigWorld.keyToString(key), False)
Example #15
0
def getReadableKey(command):
    key = getKey(command)
    if canGetVirtualKey(key):
        vk = BigWorld.mapVirtualKey(key, MappingType.MAPVK_VSC_TO_VK)
        if vk != 0:
            if vk in SCALEFORM_TO_BW:
                key = SCALEFORM_TO_BW[vk]
            else:
                key = BigWorld.mapVirtualKey(vk, MappingType.MAPVK_VK_TO_CHAR)
                return makeString(unichr(key).upper())
    return makeString(READABLE_KEY_NAMES.key(BigWorld.keyToString(key)))
def _buildReverseKeysLookup():
    preferredSynonyms = ('NONE', 'LEFTMOUSE', 'RIGHTMOUSE', 'MIDDLEMOUSE')
    for name in preferredSynonyms:
        value = BigWorld.stringToKey(name)
        if value != 0 or name == 'NONE':
            _reverseKeysLookup[value] = name
        TRACE_MSG('Synonym "%s" is missing from BigWorlds key list' % (name, ))

    for name in Keys.__dict__.keys():
        value = BigWorld.stringToKey(name[4:])
        if value == 0:
            continue
        if _reverseKeysLookup.has_key(value):
            if _reverseKeysLookup[value] not in preferredSynonyms:
                TRACE_MSG(
                    'Unexpected synonym for "%s": "%s"' %
                    (_reverseKeysLookup[value], BigWorld.keyToString(value)))
        _reverseKeysLookup[value] = BigWorld.keyToString(value)

    for aliasName, aliasKeys in keyAliases.iteritems():
        _reverseKeysLookup[aliasKeys] = aliasName
Example #17
0
    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
Example #18
0
def processHotKeys(data, keys, mode):
    add = lambda key: key if 'KEY_' in key else 'KEY_' + key
    if mode == 'read':
        process = lambda key: getattr(Keys, add(key))
    elif mode == 'write':
        process = lambda key: add(BigWorld.keyToString(key))
    else:
        assert False, 'unknown hotkey conversion mode'
    make = lambda keySet: [
        make(key) if isinstance(key, list) else process(key) for key in keySet
    ]
    for dataKey in keys:  # configs have 'Key', code checks for 'key'. >_<
        newKey = dataKey.replace('key', 'Key')
        if (newKey if mode == 'read' else dataKey) not in data:
            continue
        data[(dataKey if mode == 'read' else newKey)] = make(
            data.pop((newKey if mode == 'read' else dataKey)))
Example #19
0
def _buildReverseKeysLookup():
    preferredSynonyms = ('NONE', 'LEFTMOUSE', 'RIGHTMOUSE', 'MIDDLEMOUSE')
    for name in preferredSynonyms:
        value = BigWorld.stringToKey(name)
        if value != 0 or name == 'NONE':
            _reverseKeysLookup[value] = name
        else:
            TRACE_MSG('Synonym "%s" is missing from BigWorlds key list' % (name,))

    for name in Keys.__dict__.keys():
        value = BigWorld.stringToKey(name[4:])
        if value == 0:
            continue
        if _reverseKeysLookup.has_key(value):
            if _reverseKeysLookup[value] not in preferredSynonyms:
                TRACE_MSG('Unexpected synonym for "%s": "%s"' % (_reverseKeysLookup[value], BigWorld.keyToString(value)))
        else:
            _reverseKeysLookup[value] = BigWorld.keyToString(value)

    for aliasName, aliasKeys in keyAliases.iteritems():
        _reverseKeysLookup[aliasKeys] = aliasName
Example #20
0
 def handleKeyEvent(self, event):
     self.label3.text = 'handleKeyEvent (%s, %s)' % (BigWorld.keyToString(event.key), event.isKeyDown())
     return False
def _getReadableKey(key):
    """Get a human readable key name.
    """
    return makeString(READABLE_KEY_NAMES.all('KEY_%s' % BigWorld.keyToString(key)))
Example #22
0
	def keyToString(key):
		key = BigWorld.keyToString(key)
		if not key:
			raise LookupError('Key could not be recognized.')
		return 'KEY_' + key
Example #23
0
def getReadableKey(command):
    """Get a human readable key name from assigned to specified command.
    """
    key = getKey(command)
    return makeString(READABLE_KEY_NAMES.key(BigWorld.keyToString(key)))
Example #24
0
def getReadableKey(command):
    key = getKey(command)
    return makeString(READABLE_KEY_NAMES.key(BigWorld.keyToString(key)))
Example #25
0
def getBigworldNameFromKey(bigworldKey):
    return 'KEY_%s' % BigWorld.keyToString(bigworldKey)
Example #26
0
 def _getAlias(key):
     alias = 'KEY_' + BigWorld.keyToString(key)
     if getattr(Keys, alias, None) is None:
         raise LookupError('Key could not be recognized.')
     return alias
Example #27
0
def getBigworldNameFromKey(bigworldKey):
    return 'KEY_%s' % BigWorld.keyToString(bigworldKey)
def _getReadableKey(key):
    """Get a human readable key name.
    """
    return makeString(
        READABLE_KEY_NAMES.all('KEY_%s' % BigWorld.keyToString(key)))
 def _iAmJoinedSquad(self, squadNum):
     key = _getKey(CommandMapping.CMD_VOICECHAT_ENABLE)
     state = _getVIOPState(key)
     message = '#messenger:client/dynSquad/inviteAccepted/myself/%s' % state
     self.__sendMessage(message, squadNum=squadNum, keyName=BigWorld.keyToString(key))
Example #30
0
 def handleKeyEvent(self, event):
     self.label3.text = 'handleKeyEvent (%s, %s)' % (BigWorld.keyToString(event.key), event.isKeyDown())
     return False
 def _squadCreatedImRecruit(self, squadNum):
     key = _getKey(CommandMapping.CMD_VOICECHAT_ENABLE)
     state = _getVIOPState(key)
     message = '#messenger:client/dynSquad/created/recruit/%s' % state
     self.__sendMessage(message, squadNum=squadNum, keyName=BigWorld.keyToString(key))