make nice shortcut presentation work
This commit is contained in:
parent
a5b7694e59
commit
be19a67fcd
@ -26,4 +26,5 @@ environment = {
|
|||||||
'output': outputData,
|
'output': outputData,
|
||||||
'soundIcons': {},
|
'soundIcons': {},
|
||||||
'bindings': {},
|
'bindings': {},
|
||||||
|
'rawBindings': {},
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,40 @@ class helpManager():
|
|||||||
pass
|
pass
|
||||||
def isTutorialMode(self):
|
def isTutorialMode(self):
|
||||||
return self.env['general']['tutorialMode']
|
return self.env['general']['tutorialMode']
|
||||||
|
def getFormattedShortcutForCommand(self, command):
|
||||||
|
shortcut = []
|
||||||
|
rawShortcut = []
|
||||||
|
try:
|
||||||
|
rawShortcut = list(self.env['bindings'].keys())[list(self.env['bindings'].values()).index(command)]
|
||||||
|
rawShortcut = self.env['rawBindings'][rawShortcut]
|
||||||
|
# prefer numbers for multitap
|
||||||
|
if rawShortcut[0] in range(2, 9):
|
||||||
|
formattedKey = str(rawShortcut[0]) +' times '
|
||||||
|
shortcut.append(formattedKey)
|
||||||
|
# prefer metha keys
|
||||||
|
for k in ['KEY_FENRIR', 'KEY_SCRIPT', 'KEY_CTRL', 'KEY_SHIFT', 'KEY_ALT', 'KEY_META']:
|
||||||
|
if k in rawShortcut[1]:
|
||||||
|
formattedKey = k
|
||||||
|
formattedKey = formattedKey.lower()
|
||||||
|
formattedKey = formattedKey.replace('key_kp', ' keypad ')
|
||||||
|
formattedKey = formattedKey.replace('key_', ' ')
|
||||||
|
shortcut.append(formattedKey)
|
||||||
|
rawShortcut[1].remove(k)
|
||||||
|
# handle other keys
|
||||||
|
for k in rawShortcut[1]:
|
||||||
|
formattedKey = k
|
||||||
|
formattedKey = formattedKey.lower()
|
||||||
|
formattedKey = formattedKey.replace('key_kp', ' keypad ')
|
||||||
|
formattedKey = formattedKey.replace('key_', ' ')
|
||||||
|
shortcut.append(formattedKey)
|
||||||
|
except Exception as e:
|
||||||
|
return ''
|
||||||
|
shortcut = str(shortcut)
|
||||||
|
shortcut = shortcut.replace('[','')
|
||||||
|
shortcut = shortcut.replace(']','')
|
||||||
|
shortcut = shortcut.replace("'",'')
|
||||||
|
return shortcut
|
||||||
|
|
||||||
def getCommandHelpText(self, command, section = 'commands'):
|
def getCommandHelpText(self, command, section = 'commands'):
|
||||||
commandName = command.lower()
|
commandName = command.lower()
|
||||||
commandName = commandName.split('__-__')[0]
|
commandName = commandName.split('__-__')[0]
|
||||||
@ -45,10 +79,7 @@ class helpManager():
|
|||||||
commandDescription = self.env['runtime']['commandManager'].getCommandDescription(command, section = 'commands')
|
commandDescription = self.env['runtime']['commandManager'].getCommandDescription(command, section = 'commands')
|
||||||
if commandDescription == '':
|
if commandDescription == '':
|
||||||
commandDescription = 'no Description available'
|
commandDescription = 'no Description available'
|
||||||
commandShortcut = self.env['runtime']['commandManager'].getShortcutForCommand(command, formatKeys = True)
|
commandShortcut = self.getFormattedShortcutForCommand(command)
|
||||||
commandShortcut = commandShortcut.replace('[','')
|
|
||||||
commandShortcut = commandShortcut.replace(']','')
|
|
||||||
commandShortcut = commandShortcut.replace("'",'')
|
|
||||||
if commandShortcut == '':
|
if commandShortcut == '':
|
||||||
commandShortcut = 'unbound'
|
commandShortcut = 'unbound'
|
||||||
helptext = commandName + ', Shortcut ' + commandShortcut + ', Description ' + commandDescription
|
helptext = commandName + ', Shortcut ' + commandShortcut + ', Description ' + commandDescription
|
||||||
|
@ -324,6 +324,7 @@ class inputManager():
|
|||||||
continue
|
continue
|
||||||
self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True)
|
self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
self.env['bindings'][str(shortcut)] = commandName
|
self.env['bindings'][str(shortcut)] = commandName
|
||||||
|
self.env['rawBindings'][str(shortcut)] = shortcut
|
||||||
kbConfig.close()
|
kbConfig.close()
|
||||||
# fix bindings
|
# fix bindings
|
||||||
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
||||||
|
Loading…
Reference in New Issue
Block a user