add initial tutorial menu
This commit is contained in:
@@ -16,7 +16,7 @@ class commandManager():
|
||||
self.env = environment
|
||||
# commands
|
||||
self.env['commands'] = {}
|
||||
self.env['commandsIgnore'] = {}
|
||||
self.env['commandsIgnore'] = {}
|
||||
for commandFolder in self.env['general']['commandFolderList']:
|
||||
self.env['runtime']['commandManager'].loadCommands(commandFolder)
|
||||
if self.env['runtime']['settingsManager'].getSetting('general', 'commandPath') != '':
|
||||
@@ -182,19 +182,34 @@ class commandManager():
|
||||
return
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
if self.env['general']['tutorialMode']:
|
||||
if self.env['runtime']['helpManager'].isTutorialMode():
|
||||
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
description = self.env['commands'][section][command].getDescription()
|
||||
description = self.getCommandDescription(section, command)
|
||||
self.env['runtime']['outputManager'].presentText(description, interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
self.env['commands'][section][command].run()
|
||||
self.runCommand(command, section)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
|
||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def runCommand(self, command, section = 'commands'):
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
print(command, section)
|
||||
self.env['commands'][section][command].run()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||
self.clearCommandQueued()
|
||||
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
||||
|
||||
|
||||
def getCommandDescription(self, command, section = 'commands'):
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
return self.env['commands'][section][command].getDescription()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('commandManager.getCommandDescription:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def isCommandQueued(self):
|
||||
return self.env['commandInfo']['currCommand'] != ''
|
||||
|
||||
|
@@ -54,13 +54,16 @@ class fenrirManager():
|
||||
startTime = time.time()
|
||||
if eventReceived:
|
||||
self.prepareCommand()
|
||||
if not (self.wasCommand or self.environment['general']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
if not self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
if self.environment['runtime']['helpManager'].handleTutorialMode():
|
||||
self.wasCommand = True
|
||||
if not (self.wasCommand or self.environment['runtime']['helpManager'].isTutorialMode()) or self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
if self.wasCommand:
|
||||
self.wasCommand = False
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
if self.environment['general']['tutorialMode']:
|
||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
if self.environment['input']['keyForeward'] > 0:
|
||||
self.environment['input']['keyForeward'] -=1
|
||||
|
@@ -12,7 +12,7 @@ generalData = {
|
||||
'currUser':'',
|
||||
'prevUser':'',
|
||||
'managerList':['eventManager','punctuationManager','cursorManager','applicationManager','commandManager'
|
||||
,'screenManager','inputManager','outputManager','debug'],
|
||||
,'screenManager','inputManager','outputManager','helpManager','debug'],
|
||||
'commandFolderList':['commands','onInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice'
|
||||
,'onApplicationChange','onSwitchApplicationProfile',],
|
||||
,'onApplicationChange','onSwitchApplicationProfile','help',],
|
||||
}
|
||||
|
75
src/fenrir/core/helpManager.py
Executable file
75
src/fenrir/core/helpManager.py
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
|
||||
|
||||
class helpManager():
|
||||
def __init__(self):
|
||||
self.helpDict = None
|
||||
self.tutorialListIndex = None
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.createHelpDict()
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
def toggleTutorialMode(self):
|
||||
self.setTutorialMode(not self.env['general']['tutorialMode'])
|
||||
def setTutorialMode(self, newTutorialMode):
|
||||
self.env['general']['tutorialMode'] = newTutorialMode
|
||||
def isTutorialMode(self):
|
||||
return self.env['general']['tutorialMode']
|
||||
def getCommandHelpText(self, command, section = 'commands'):
|
||||
commandName = command.lower()
|
||||
commandName = commandName.split('__-__')[0]
|
||||
commandName = commandName.replace('_',' ')
|
||||
commandName = commandName.replace('_',' ')
|
||||
helptext = commandName + ', Shortcut , Description' + self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands')
|
||||
return helptext
|
||||
def createHelpDict(self, section = 'commands'):
|
||||
self.helpDict = {}
|
||||
for command in sorted(self.env['commands'][section].keys()):
|
||||
self.helpDict[len(self.helpDict)] = self.getCommandHelpText(command, section)
|
||||
if len(self.helpDict) > 0:
|
||||
self.tutorialListIndex = 0
|
||||
def getHelpForCurrentIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return ''
|
||||
return self.helpDict[self.tutorialListIndex]
|
||||
def nextIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return
|
||||
self.tutorialListIndex += 1
|
||||
if self.tutorialListIndex >= len(self.helpDict):
|
||||
self.tutorialListIndex = 0
|
||||
def prevIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return
|
||||
self.tutorialListIndex -= 1
|
||||
if self.tutorialListIndex < 0:
|
||||
self.tutorialListIndex = len(self.helpDict) - 1
|
||||
def handleTutorialMode(self):
|
||||
if self.env['runtime']['inputManager'].noKeyPressed():
|
||||
return
|
||||
if self.env['input']['currInput'] in [['KEY_F1', 'KEY_FENRIR']]:
|
||||
self.env['runtime']['commandManager'].runCommand('TOGGLE_TUTORIAL_MODE', 'help')
|
||||
return True
|
||||
if not self.isTutorialMode():
|
||||
return
|
||||
if self.env['input']['currInput'] in [['KEY_ESC']]:
|
||||
self.env['runtime']['commandManager'].runCommand('TOGGLE_TUTORIAL_MODE', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_UP']]:
|
||||
self.env['runtime']['commandManager'].runCommand('PREV_HELP', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_DOWN']]:
|
||||
self.env['runtime']['commandManager'].runCommand('NEXT_HELP', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_SPACE']]:
|
||||
self.env['runtime']['commandManager'].runCommand('CURR_HELP', 'help')
|
||||
return True
|
||||
return False
|
@@ -15,6 +15,7 @@ from core import screenManager
|
||||
from core import punctuationManager
|
||||
from core import cursorManager
|
||||
from core import applicationManager
|
||||
from core import helpManager
|
||||
from core import environment
|
||||
from core import inputData
|
||||
from core.settingsData import settingsData
|
||||
@@ -328,7 +329,8 @@ class settingsManager():
|
||||
environment['runtime']['cursorManager'].initialize(environment)
|
||||
environment['runtime']['applicationManager'] = applicationManager.applicationManager()
|
||||
environment['runtime']['applicationManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['helpManager'] = helpManager.helpManager()
|
||||
environment['runtime']['helpManager'].initialize(environment)
|
||||
if environment['runtime']['screenManager'] == None:
|
||||
environment['runtime']['screenManager'] = screenManager.screenManager()
|
||||
environment['runtime']['screenManager'].initialize(environment)
|
||||
|
Reference in New Issue
Block a user