From: Christian Heller Date: Wed, 4 Nov 2020 04:36:29 +0000 (+0100) Subject: Minor client improvements. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/condition?a=commitdiff_plain;h=2d26a570e3e4f26a45a476fde6c5b9902607e4b6;p=plomrogue2-experiments Minor client improvements. --- diff --git a/new2/rogue_chat_curses.py b/new2/rogue_chat_curses.py index 6f27256..e272fb2 100755 --- a/new2/rogue_chat_curses.py +++ b/new2/rogue_chat_curses.py @@ -330,15 +330,32 @@ class TUI: self.input_ = self.input_[:max_length] elif self.mode == self.mode_login and key == '\n': self.socket.send('LOGIN ' + quote(self.input_)) + self.input_ = "" elif self.mode == self.mode_chat and key == '\n': # TODO: query, nick, help, reconnect, unknown command - if self.input_ == ':p': - self.switch_mode('play') - elif self.input_ == ':?': - self.switch_mode('study') + if self.input_[0] == ':': + if self.input_ in {':p', ':play'}: + self.switch_mode('play') + elif self.input_ in {':?', ':study'}: + self.switch_mode('study') + elif self.input_.startswith(':nick'): + tokens = self.input_.split(maxsplit=1) + if len(tokens) == 2: + self.socket.send('LOGIN ' + quote(tokens[1])) + else: + self.log_msg('? need login name') + elif self.input_.startswith(':msg'): + tokens = self.input_.split(maxsplit=2) + if len(tokens) == 3: + self.socket.send('QUERY %s %s' % (quote(tokens[1]), + quote(tokens[2]))) + else: + self.log_msg('? need message target and message') + else: + self.log_msg('? unknown command') else: self.socket.send('ALL ' + quote(self.input_)) - self.input_ = "" + self.input_ = "" elif self.mode == self.mode_annotate and key == '\n': if (self.input_ == ''): self.input_ = ' ' diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index bb1ecda..f513ad9 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -201,6 +201,7 @@ let server = { } else if (tokens[0] === 'LOGIN_OK') { this.send(['GET_GAMESTATE']); tui.log_help(); + // TODO wait for game state for this switch, use intermediary mode? tui.switch_mode(mode_play); } else if (tokens[0] === 'PORTAL') { let position = parser.parse_yx(tokens[1]); @@ -591,7 +592,7 @@ tui.inputEl.addEventListener('input', (event) => { }, false); tui.inputEl.addEventListener('keydown', (event) => { if (event.key == 'Enter') { - event.preventDefault(); + event.preventDefault(); } if (tui.mode == mode_login && event.key == 'Enter') { server.send(['LOGIN', tui.inputEl.value]);