From: Christian Heller Date: Fri, 18 Dec 2020 22:12:11 +0000 (+0100) Subject: Allow toggling of map control preset drawing. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7Broute%7D?a=commitdiff_plain;h=52a97e1d01fd8541ec8993f1d680aeb56243df9d;p=plomrogue2 Allow toggling of map control preset drawing. --- diff --git a/plomrogue/commands.py b/plomrogue/commands.py index c86aebe..921d6e0 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -410,3 +410,7 @@ def cmd_THING_CRATE_ITEM(game, crate_id, item_id): raise GameError('thing of ID %s is a crate' % item_id) crate.accept(item) cmd_THING_CRATE_ITEM.argtypes = 'int:pos int:pos' + +def cmd_MAP_CONTROL_PRESETS(game, draw_control_presets): + game.draw_control_presets = draw_control_presets +cmd_MAP_CONTROL_PRESETS.argtypes = 'bool' diff --git a/plomrogue/game.py b/plomrogue/game.py index ff035bb..4b5c337 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -146,6 +146,7 @@ class Game(GameBase): '=': Terrain('=', 'glass', blocks_sound=True, blocks_movement=True), 'T': Terrain('T', 'table', blocks_movement=True), } + self.draw_control_presets = True if os.path.exists(self.io.save_file): if not os.path.isfile(self.io.save_file): raise GameError('save file path refers to non-file') @@ -498,6 +499,9 @@ class Game(GameBase): with open(self.io.save_file, 'w') as f: write(f, 'TURN %s' % self.turn) map_geometry_shape = self.get_map_geometry_shape() + # must come before MAP, otherwise first get_map uses the default + # TODO: refactor into MAP + write(f, 'MAP_CONTROL_PRESETS %s' % int(self.draw_control_presets)) write(f, 'MAP %s %s' % (map_geometry_shape, self.map_geometry.size,)) for terrain in self.terrains.values(): write(f, 'TERRAIN %s %s %s %s %s' % (quote(terrain.character), @@ -576,7 +580,7 @@ class Game(GameBase): maps = self.map_controls if big_yx not in maps: maps[big_yx] = SaveableMap(self.map_geometry) - if type_ == 'control': + if self.draw_control_presets and type_ == 'control': maps[big_yx].draw_presets(big_yx.y % 2) return maps[big_yx] diff --git a/rogue_chat.py b/rogue_chat.py index b22decb..2461289 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -16,7 +16,7 @@ from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN cmd_GOD_PLAYER_FACE, cmd_GOD_PLAYER_HAT, cmd_GOD_PLAYERS_HAT_CHARS, cmd_PLAYER_HAT, cmd_TERRAIN_TAG, cmd_THING_DOOR_KEY, - cmd_THING_CRATE_ITEM) + cmd_THING_CRATE_ITEM, cmd_MAP_CONTROL_PRESETS) from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP, Task_DROP, Task_FLATTEN_SURROUNDINGS, Task_DOOR, Task_INTOXICATE, Task_COMMAND, Task_INSTALL, @@ -75,6 +75,7 @@ game.register_command(cmd_PLAYER_HAT) game.register_command(cmd_THING_HAT_DESIGN) game.register_command(cmd_THING_DOOR_KEY) game.register_command(cmd_THING_CRATE_ITEM) +game.register_command(cmd_MAP_CONTROL_PRESETS) game.register_task(Task_WAIT) game.register_task(Task_MOVE) game.register_task(Task_WRITE)