From 123edfd17cd9aa38d6d5e511a8c686d5d71ab140 Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 1 Jan 2018 16:55:58 +0100 Subject: made keybindings readable from an actual file --- asciifarm/client/gameclient.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'asciifarm/client/gameclient.py') diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py index 914d90c..0ab5fb5 100644 --- a/asciifarm/client/gameclient.py +++ b/asciifarm/client/gameclient.py @@ -13,12 +13,15 @@ import string from .display.display import Display import hy -from . import keybindings as defaultkeybindings -import importlib + +hywrapper = """\ +(do + (require [asciifarm.client.keymacros [*]]) + {{ {} }})""" class Client: - def __init__(self, stdscr, display, name, connection, keybindings=None, logFile=None): + def __init__(self, stdscr, display, name, connection, keybindings, logFile=None): self.stdscr = stdscr self.display = display self.name = name @@ -26,11 +29,8 @@ class Client: self.connection = connection self.logFile = logFile - keymodule = defaultkeybindings - if keybindings: - keymodule = importlib.import_module(keybindings) - self.commands = keymodule.commands - self.controlsString = keymodule.docs + self.commands = hy.eval(hy.read_str(hywrapper.format(keybindings))) + self.controlsString = self.commands.get("help", "") self.display.showInfo(self.controlsString) -- cgit