Hi,
I forked your MacOSX script into one for windows, but I removed all OSX
specific stuff.
I modified the GameController and the EngineWrapper classes and I
implemented the Speaker class. I think that is the right choise writing
the launcher in python.
Here is the patch to the git repository.
The script uses the Screen Reader API for the speech output, so to run
properly you need these dlls and the ctypes and pywin32 python packages.
This is the URL to the ZIP of the Screen Reader API:
https://dl.dropboxusercontent.com/u/28833196/ScreenReaderAPI.zip
The missing part, the graphical interface (or another) I'll write later.
S2
--
Cuando tus fuerzas terminan, las de Dios comienzan...
--
You received this message because you are subscribed to the Google Groups "AGRIP
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/agrip-project/51A20ED1.2060708%40gmail.com?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/audioquake/app-skel/Contents/Windows/AudioQuake.py
b/audioquake/app-skel/Contents/Windows/AudioQuake.py
index 7b0310f..0eb0e5a 100644
--- a/audioquake/app-skel/Contents/Windows/AudioQuake.py
+++ b/audioquake/app-skel/Contents/Windows/AudioQuake.py
@@ -2,16 +2,30 @@
import sys, os # chdir hack
import subprocess, threading, Queue # launching the game
-from GUI import Window, Button, application, Task
-from GUI.StdMenus import basic_menus, fundamental_cmds
+import ctypes
-import pyttsx
+class Speaker:
+ def __init__(self):
+ self._speaker = ctypes.windll.ScreenReaderAPI
+
+ def say(self, str):
+ self._speaker.sayStringA(str, 0)
+
+ def stop(self):
+ self._speaker.stopSpeech()
class EngineWrapper(threading.Thread):
def __init__(self, command_line, out_queue):
threading.Thread.__init__(self)
- self._command_line = command_line
+ self._command_line = ''
+ if type(command_line) == tuple:
+ for param in list(command_line):
+ self._command_line += param + ' '
+ else:
+ self._command_line = command_line
+
+ self._command_line = self._command_line.strip()
self._out_queue = out_queue
def _shut_up(self):
@@ -52,7 +66,7 @@ class EngineWrapper(threading.Thread):
class GameController(object):
_opts_default = (
- "./zquake-glsdl",
+ "./zquake-vidnull",
"-window",
"+set sensitivity 0")
@@ -62,20 +76,19 @@ class GameController(object):
"+map agtut01")
def __init__(self):
- self._messages_task = None
+ self._stoped_speaking = None
self._running = False
self._in_queue = Queue.Queue()
- self._speaker = pyttsx.init()
- self._speaker.startLoop(False)
+ self._speaker = Speaker()
def quit(self):
pass # TODO: terminate the engine if the GUI quits
def _game_ended(self):
assert self._running
- assert self._messages_task is not None
- self._messages_task.stop()
- self._messages_task = None
+ assert self._stoped_speaking == False
+ self._stoped_speaking = True
+
self._speaker.stop()
self._running = False
@@ -83,35 +96,34 @@ class GameController(object):
if self._running:
return
self._running = True
- assert self._messages_task is None
+ assert self._stoped_speaking is None
+ self._stoped_speaking = False
engine_wrapper = EngineWrapper(command_line, self._in_queue)
engine_wrapper.start()
def get_messages(speaker, queue, callback):
- try:
- message = queue.get_nowait()
- if message is None:
- callback()
- else:
- assert message is False or
type(message) is str
- # We may have been told to cancel the
current utterance
- if message is False:
- speaker.stop()
+ print 'DEBUG: get_messages ran'
+ while self._stoped_speaking is not True:
+ try:
+ message = queue.get_nowait()
+ if message is None:
+ callback()
else:
- speaker.say(message)
- speaker.iterate()
- except Queue.Empty:
- pass
+ assert message is False or
type(message) is str
+ # We may have been told to
cancel the current utterance
+ if message is False:
+ speaker.stop()
+ else:
+ speaker.say(message)
+ except Queue.Empty:
+ pass
# Keep checking for and saying new messages
- self._messages_task = Task(
- lambda: get_messages(
- self._speaker,
- self._in_queue,
- self._game_ended),
- 0.1,
- True,
- True)
+ t = threading.Thread(target=lambda: get_messages(
+ self._speaker,
+ self._in_queue,
+ self._game_ended))
+ t.start()
def launch_default(self):
self._launch_core(self._opts_default)
@@ -119,81 +131,15 @@ class GameController(object):
def launch_tutorial(self):
self._launch_core(self._opts_default + self._opts_tutorial)
-
-class LauncherSingletonWindow(Window):
- def __init__(self, application, *args, **kwargs):
- super(LauncherSingletonWindow, self).__init__(
- title = "Launcher",
- resizable = False,
- zoomable = False,
- *args,
- **kwargs)
-
- self._application = application
- self._game_controller = GameController()
-
- self.auto_position = False
- self.position = (200, 250)
- self.size = (140, 170)
- self.resizable = 0
- self.zoomable = 0
-
- self.add(Button(
- position = (10, 10),
- size = (120, 25),
- title = "Play Quake",
- action = self._btn_default
- ))
-
- self.add(Button(
- position = (10, 40),
- size = (120, 25),
- title = "Play Tutorial",
- action = self._btn_tutorial
- ))
-
- self.add(Button(
- position = (10, 70),
- size = (120, 25),
- title = "README",
- action = self._btn_readme
- ))
-
- self.add(Button(
- position = (10, 100),
- size = (120, 25),
- title = "Licence",
- action = self._btn_licence
- ))
-
- self.add(Button(
- position = (10, 140),
- size = (120, 25),
- title = "Quit Launcher",
- action = self._close_cmd
- ))
-
- def _close_cmd(self):
- self._game_controller.quit()
- self._application.quit_cmd()
-
- def _btn_default(self):
- self._game_controller.launch_default()
-
- def _btn_tutorial(self):
- self._game_controller.launch_tutorial()
-
- def _btn_readme(self):
- subprocess.call(('open', '-a', 'TextEdit', 'README.md'))
-
- def _btn_licence(self):
- subprocess.call(('open', '-a', 'TextEdit', 'LICENCE.md'))
-
+# OSX Specific stuff removed
if __name__ == '__main__':
- os.chdir(os.path.dirname(sys.argv[0]))
- app = application()
- app.menus = basic_menus(include = fundamental_cmds)
- launcher = LauncherSingletonWindow(app)
- launcher.show()
- app.run()
+ print sys.argv[0]
+ dirname = os.path.dirname(sys.argv[0])
+ if dirname is not None or dirname is not '':
+ pass
+ else:
+ os.chdir(dirname)
+ gcon = GameController()
+ gcon.launch_tutorial()
+