improve tutorial mode

This commit is contained in:
chrys 2017-07-16 16:10:37 +02:00
parent 6173fe8a4d
commit 5d45d806c1
6 changed files with 40 additions and 42 deletions

View File

@ -122,7 +122,7 @@ driver=vcsaDriver
encoding=cp850
screenUpdateDelay=0.05
suspendingScreen=
autodetectSuspendingScreen=True
autodetectSuspendingScreen=False
[keyboard]
driver=evdevDriver

View File

@ -1,28 +0,0 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('Toggle the Tutorial mode')
def run(self):
text = ''
if self.env['runtime']['helpManager'].isTutorialMode():
text = _('You are leaving the tutorial mode. Press that shortcut again to enter the tutorial mode again.')
else:
text = _('you entered the tutorial mode. In that mode the commands are not executed. but you get a description of what the shortcut does. To leave the tutorial mode, press that shortcut again.')
self.env['runtime']['helpManager'].toggleTutorialMode()
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
def setCallback(self, callback):
pass

View File

@ -181,7 +181,7 @@ class commandManager():
return
if self.commandExists(command, section):
try:
if self.env['runtime']['helpManager'].isTutorialMode():
if self.env['runtime']['helpManager'].isTutorialMode() and section != 'help':
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
description = self.getCommandDescription(command, section)
self.env['runtime']['outputManager'].presentText(description, interrupt=True)

View File

@ -54,9 +54,9 @@ class fenrirManager():
startTime = time.time()
if eventReceived:
self.prepareCommand()
if not self.environment['runtime']['screenManager'].isSuspendingScreen():
if self.environment['runtime']['helpManager'].handleTutorialMode():
self.wasCommand = True
#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():
@ -70,7 +70,7 @@ class fenrirManager():
self.environment['input']['keyForeward'] -=1
#self.environment['runtime']['screenManager'].update('onInput')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
self.handleCommands()
self.handleCommands()
def handleScreenChange(self):
self.environment['runtime']['screenManager'].update('onScreenChange')
'''
@ -117,18 +117,20 @@ class fenrirManager():
return
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
if len(self.environment['input']['prevDeepestInput']) <= len(self.environment['input']['currInput']):
if len(self.environment['input']['prevDeepestInput']) >= len(self.environment['input']['currInput']):
self.wasCommand = command != '' or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['runtime']['inputManager'].isScriptKeyPressed()
if command == '':
return
self.environment['runtime']['commandManager'].queueCommand(command)
def handleCommands(self):
if not self.environment['runtime']['commandManager'].isCommandQueued():
return
if len(self.environment['input']['prevDeepestInput']) > len(self.environment['input']['currInput']):
return
if self.environment['runtime']['helpManager'].isTutorialMode():
self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'help')
self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands')
def shutdownRequest(self):
self.environment['runtime']['eventManager'].stopMainEventLoop()

View File

@ -14,13 +14,26 @@ class helpManager():
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
if newTutorialMode:
self.createHelpDict()
self.env['bindings'][str([1, ['KEY_ESC']])] = 'TOGGLE_TUTORIAL_MODE'
self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_HELP'
self.env['bindings'][str([1, ['KEY_DOWN']])] = 'NEXT_HELP'
self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_HELP'
else:
try:
del(self.env['bindings'][str([1, ['KEY_ESC']])])
del(self.env['bindings'][str([1, ['KEY_UP']])])
del(self.env['bindings'][str([1, ['KEY_DOWN']])])
del(self.env['bindings'][str([1, ['KEY_SPACE']])])
except:
pass
def isTutorialMode(self):
return self.env['general']['tutorialMode']
def getCommandHelpText(self, command, section = 'commands'):
@ -28,11 +41,17 @@ class helpManager():
commandName = commandName.split('__-__')[0]
commandName = commandName.replace('_',' ')
commandName = commandName.replace('_',' ')
commandDescription = self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands')
if command == 'TOGGLE_TUTORIAL_MODE':
commandDescription = _('toggles the tutorial mode')
else:
commandDescription = self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands')
if commandDescription == '':
commandDescription = 'no Description available'
commandShortcut = self.env['runtime']['commandManager'].getShortcutForCommand( command)
commandShortcut = commandShortcut.replace('KEY_',' ')
commandShortcut = commandShortcut.replace('[','')
commandShortcut = commandShortcut.replace(']','')
commandShortcut = commandShortcut.replace("'",'')
if commandShortcut == '':
commandShortcut = 'unbound'
helptext = commandName + ', Shortcut ' + commandShortcut + ', Description ' + commandDescription
@ -43,6 +62,8 @@ class helpManager():
self.helpDict[len(self.helpDict)] = self.getCommandHelpText(command, section)
if len(self.helpDict) > 0:
self.tutorialListIndex = 0
else:
self.tutorialListIndex = None
def getHelpForCurrentIndex(self):
if self.tutorialListIndex == None:
return ''
@ -60,6 +81,7 @@ class helpManager():
if self.tutorialListIndex < 0:
self.tutorialListIndex = len(self.helpDict) - 1
def handleTutorialMode(self):
return
if self.env['runtime']['inputManager'].noKeyPressed():
return
if self.env['input']['currInput'] in [['KEY_F1', 'KEY_FENRIR']]:

View File

@ -72,6 +72,8 @@ class settingsManager():
self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True)
self.env['bindings'][str(shortcut)] = commandName
kbConfig.close()
# fix bindings
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
def loadSoundIcons(self, soundIconPath):
siConfig = open(soundIconPath + '/soundicons.conf',"r")