diff options
| author | troido <troido@hotmail.com> | 2018-04-18 23:27:34 +0200 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2018-04-18 23:27:34 +0200 |
| commit | 757ad925b47d24b1d0714671b8f04147a5748480 (patch) | |
| tree | bc67553d76ac3301db7d2c20881448afc411221d /asciifarm/client/gameclient.py | |
| parent | c0eb8ed32d53030de5b75b49a8e0f64e7c4a05ff (diff) | |
improved input handling
renamed InputHandler to CommandHandler.
made InputHandler for input code that used to be in gameclient
also started my own getstr() replacement.
Diffstat (limited to 'asciifarm/client/gameclient.py')
| -rw-r--r-- | asciifarm/client/gameclient.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py index ec90cc6..0a9b243 100644 --- a/asciifarm/client/gameclient.py +++ b/asciifarm/client/gameclient.py @@ -15,7 +15,6 @@ from .display.screen import Screen from .display.display import Display from .inputhandler import InputHandler -from .keynames import nameFromKey class Client: @@ -28,8 +27,7 @@ class Client: self.logFile = logFile self.closeMessage = None - self.inputHandler = InputHandler(self, self.display, self.connection) - self.keybindings = keybindings["actions"] + self.inputHandler = InputHandler(self, keybindings["actions"]) self.controlsString = keybindings.get("help", "") @@ -128,12 +126,6 @@ class Client: with(open(self.logFile, 'a')) as f: f.write(text+'\n') - def onInput(self, key): - keyName = nameFromKey(key) - if keyName in self.keybindings: - self.inputHandler.execute(self.keybindings[keyName]) - - def command_loop(self): while self.keepalive: @@ -141,7 +133,7 @@ class Client: if action[0] == "message": self.update(action[1]) elif action[0] == "input": - self.onInput(action[1]) + self.inputHandler.onInput(action[1]) elif action[0] == "error": raise action[1] else: |
