home · contact · privacy
In ASCII art drawing mode, pad short lines with whitespace to tolerate them.
[plomrogue2] / rogue_chat_curses.py
index a58b842e70a46154341ea003f904d333f10b5972..f7ac8cf0bf33c492eac88482d18f7c0b1a9c7c9b 100755 (executable)
@@ -518,7 +518,7 @@ class TUI:
         self.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
                                            "control_tile_type", "chat",
                                            "study", "play", "edit"]
-        self.mode_admin.available_actions = ["move"]
+        self.mode_admin.available_actions = ["move", "toggle_map_mode"]
         self.mode_control_tile_draw.available_modes = ["admin_enter"]
         self.mode_control_tile_draw.available_actions = ["move_explorer",
                                                          "toggle_tile_draw"]
@@ -703,7 +703,7 @@ class TUI:
             not self.game.player.carrying.commandable):
             return fail('not carrying anything commandable')
         if mode_name == 'name_thing' and not self.game.player.carrying:
-            return fail('not carrying anything to re-name')
+            return fail('not carrying anything to re-name', 'edit')
         if mode_name == 'admin_thing_protect' and not self.game.player.carrying:
             return fail('not carrying anything to protect')
         if mode_name == 'take_thing' and self.game.player.carrying:
@@ -1117,9 +1117,11 @@ class TUI:
             self.switch_mode('play')
 
         def enter_ascii_art(command):
-            if len(self.input_) != 6:
-                self.log_msg('? wrong input length, must be 6; try again')
+            if len(self.input_) > 6:
+                self.log_msg('? wrong input length, must be max 6; try again')
                 return
+            if len(self.input_) < 6:
+                self.input_ += ' ' * (6 - len(self.input_))
             self.log_msg('  ' + self.input_)
             self.full_ascii_draw += self.input_
             self.ascii_draw_stage += 1
@@ -1170,6 +1172,7 @@ class TUI:
         reset_screen_size()
         self.explorer = YX(0, 0)
         self.input_ = ''
+        store_widechar = False
         input_prompt = '> '
         interval = datetime.timedelta(seconds=5)
         last_ping = datetime.datetime.now() - interval
@@ -1204,6 +1207,13 @@ class TUI:
             keycode = None
             if len(key) == 1:
                 keycode = ord(key)
+                # workaround for <https://stackoverflow.com/a/56390915>
+                if store_widechar:
+                    store_widechar = False
+                    key = bytes([195, keycode]).decode()
+                if keycode == 195:
+                    store_widechar = True
+                    continue
             self.show_help = False
             self.draw_face = False
             if key == 'KEY_RESIZE':
@@ -1356,6 +1366,8 @@ class TUI:
             elif self.mode.name == 'admin':
                 if self.mode.mode_switch_on_key(self, key):
                     continue
+                elif key == self.keys['toggle_map_mode']:
+                    self.toggle_map_mode()
                 elif key in self.movement_keys and task_action_on('move'):
                     self.send('TASK:MOVE ' + self.movement_keys[key])
             elif self.mode.name == 'edit':