diff options
| author | troido <troido@protonmail.com> | 2018-05-22 16:45:09 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2018-05-22 16:45:09 +0200 |
| commit | 0df7f7850c0f36067c2fec5d7e0c508b36330b20 (patch) | |
| tree | ab1859a42e6bfa5ea90893006c0f3851df0e0c12 | |
| parent | cffcb10b6ae859032afdf58822ea1e66e960caf9 (diff) | |
created support for writable objects
| -rw-r--r-- | asciifarm/charmaps/default.json | 3 | ||||
| -rw-r--r-- | asciifarm/charmaps/fullwidth.json | 3 | ||||
| -rw-r--r-- | asciifarm/client/display/display.py | 8 |
3 files changed, 14 insertions, 0 deletions
diff --git a/asciifarm/charmaps/default.json b/asciifarm/charmaps/default.json index 43a770d..27c4578 100644 --- a/asciifarm/charmaps/default.json +++ b/asciifarm/charmaps/default.json @@ -38,6 +38,9 @@ "opendoor": ["\"",3 ], " ": [" ", 7] }, + "writable": { + "engravedwall": [15, 8] + }, "default": ["?", 7], "charwidth": 1, "healthfull": ["#", 7, 2], diff --git a/asciifarm/charmaps/fullwidth.json b/asciifarm/charmaps/fullwidth.json index 6e32cbd..afff747 100644 --- a/asciifarm/charmaps/fullwidth.json +++ b/asciifarm/charmaps/fullwidth.json @@ -38,6 +38,9 @@ "opendoor": [""",3], " ": [" ", 7] }, + "writable": { + "engravedwall": [15, 8] + }, "default": ["?", 7], "charwidth": 2, "healthfull": ["#", 7, 2], diff --git a/asciifarm/client/display/display.py b/asciifarm/client/display/display.py index ede443e..4ca5816 100644 --- a/asciifarm/client/display/display.py +++ b/asciifarm/client/display/display.py @@ -15,6 +15,7 @@ from asciifarm.common.utils import get SIDEWIDTH = 20 +ALPHABET = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" class Display: @@ -37,6 +38,13 @@ class Display: vals = parseSprite(sprite) if vals: self.characters[name] = vals + + for name, colours in charMap.get("writable", {}).items(): + fg = get(colours, 0) + bg = get(colours, 1) + for i in range(min(len(ALPHABET), len(charMap.get("alphabet", [])))): + self.characters[name + '-' + ALPHABET[i]] = (charMap["alphabet"][i], fg, bg) + self.defaultChar = parseSprite(charMap.get("default", "?")) self.screen = Screen(self, stdscr, self.colours) |
