split termination out
This commit is contained in:
parent
4434e781fc
commit
ecad919ca5
@ -46,18 +46,19 @@ class eventManager():
|
|||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
self.terminateAllProcesses()
|
||||||
|
#self._eventQueue.clear()
|
||||||
|
def terminateAllProcesses(self):
|
||||||
for proc in self._eventProcesses:
|
for proc in self._eventProcesses:
|
||||||
try:
|
try:
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
#self._eventQueue.clear()
|
|
||||||
def proceedEventLoop(self):
|
def proceedEventLoop(self):
|
||||||
event = self._eventQueue.get()
|
event = self._eventQueue.get()
|
||||||
self.eventDispatcher(event)
|
|
||||||
print(event)
|
print(event)
|
||||||
return(event['Type'] != fenrirEventType.StopMainLoop)
|
self.eventDispatcher(event)
|
||||||
|
|
||||||
def eventDispatcher(self, event):
|
def eventDispatcher(self, event):
|
||||||
if not event:
|
if not event:
|
||||||
return
|
return
|
||||||
@ -65,6 +66,7 @@ class eventManager():
|
|||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.StopMainLoop:
|
elif event['Type'] == fenrirEventType.StopMainLoop:
|
||||||
self._mainLoopRunning.value = 0
|
self._mainLoopRunning.value = 0
|
||||||
|
return
|
||||||
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.KeyboardInput:
|
elif event['Type'] == fenrirEventType.KeyboardInput:
|
||||||
@ -78,10 +80,9 @@ class eventManager():
|
|||||||
elif event['Type'] == fenrirEventType.ScreenChanged:
|
elif event['Type'] == fenrirEventType.ScreenChanged:
|
||||||
pass
|
pass
|
||||||
def startMainEventLoop(self):
|
def startMainEventLoop(self):
|
||||||
while(True):
|
while(self._mainLoopRunning.value == 1):
|
||||||
if not self.proceedEventLoop():
|
self.proceedEventLoop()
|
||||||
self._mainLoopRunning.value = 0
|
|
||||||
break
|
|
||||||
def stopMainEventLoop(self, Force = False):
|
def stopMainEventLoop(self, Force = False):
|
||||||
if Force:
|
if Force:
|
||||||
self._mainLoopRunning.value = 0
|
self._mainLoopRunning.value = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user