wait for input, move many scripts to input trigger

This commit is contained in:
chrys
2016-10-01 00:51:32 +02:00
parent f1c3e25d91
commit 9afe310620
8 changed files with 17 additions and 15 deletions

View File

@ -17,24 +17,27 @@ class command():
return ''
def run(self):
currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']]
if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return
if self.env['runtime']['inputManager'].noKeyPressed():
return
#if self.env['runtime']['inputManager'].noKeyPressed():
# return
# detect an change on the screen, we just want to cursor arround, so no change should appear
if self.env['screenData']['newDelta'] != '':
print('0',currChar )
return
if self.env['screenData']['newNegativeDelta'] != '':
print('1',currChar)
return
# is it a horizontal change?
if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y'] or\
self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
print('2',currChar, self.env['screenData']['newCursor']['x'],self.env['screenData']['oldCursor']['x'],self.env['screenData']['newCursor']['y'] , self.env['screenData']['oldCursor']['y'])
return
currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']]
if not currChar.strip(" \t\n") == '':
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True)
print(currChar)
def setCallback(self, callback):
pass

View File

@ -23,7 +23,6 @@ class screenManager():
def update(self, trigger = 'onUpdate'):
self.env['runtime']['screenDriver'].getCurrScreen()
if not self.isSuspendingScreen():
if trigger == 'onUpdate':
self.env['runtime']['applicationManager'].getCurrentApplication()

View File

@ -37,11 +37,12 @@ class fenrir():
def handleProcess(self):
#startTime = time.time()
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
print(eventReceived)
if eventReceived:
self.prepareCommand()
if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen():
self.environment['runtime']['inputManager'].writeEventBuffer()
time.sleep(0.005)
if self.environment['runtime']['inputManager'].noKeyPressed():
if self.wasCommand:
self.wasCommand = False
@ -50,9 +51,8 @@ class fenrir():
self.environment['runtime']['inputManager'].clearEventBuffer()
if self.environment['input']['keyForeward'] > 0:
self.environment['input']['keyForeward'] -=1
else:
self.environment['runtime']['screenManager'].update('onInput')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
self.environment['runtime']['screenManager'].update('onInput')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
else:
self.environment['runtime']['screenManager'].update('onUpdate')
if self.environment['runtime']['applicationManager'].isApplicationChange():