From: Christian Heller Date: Mon, 28 Dec 2020 10:24:55 +0000 (+0100) Subject: Make name shortening more forgiving. X-Git-Url: https://plomlompom.com/repos/do_tasks?a=commitdiff_plain;h=97b606810ee702789497f9e842718441585ad545;p=plomrogue2 Make name shortening more forgiving. --- diff --git a/rogue_chat.html b/rogue_chat.html index 8c3229c..d6a86e0 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -1261,9 +1261,9 @@ let tui = { for (const player of players) { let name = player.name_; const offset_y = y - shrink_offset; - const max_len = Math.max(4, (tui.left_window_width / 2) - (offset_y * 2) - 8); + const max_len = Math.max(5, (tui.left_window_width / 2) - (offset_y * 2) - 8); if (name.length > max_len) { - name = name.slice(0, max_len) + '…'; + name = name.slice(0, max_len - 1) + '…'; } terminal.write(y, 0, '@' + player.thing_char + ':' + name); y += 1; @@ -1293,7 +1293,7 @@ let tui = { } terminal.write(terminal.rows - 2, start_x, '----------'); let name = t.name_; - if (name.length > 6) { + if (name.length > 7) { name = name.slice(0, 6) + '…'; } terminal.write(terminal.rows - 1, start_x, '@' + t.thing_char + ':' + name); diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 9db7b44..d2cc704 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -1084,10 +1084,10 @@ class TUI: y = 0 for t in players: offset_y = y - shrink_offset - max_len = max(4, (self.left_window_width // 2) - (offset_y * 2) - 8) + max_len = max(5, (self.left_window_width // 2) - (offset_y * 2) - 8) name = t.name[:] if len(name) > max_len: - name = name[:max_len] + '…' + name = name[:max_len - 1] + '…' safe_addstr(y, 0, '@%s:%s' % (t.thing_char, name)) y += 1 if y >= self.size.y: @@ -1112,8 +1112,8 @@ class TUI: draw_body_part(t.hat, self.size.y - 6) safe_addstr(self.size.y - 2, start_x, '----------') name = t.name[:] - if len(name) > 6: - name = name[:6] + '…' + if len(name) > 7: + name = name[:6 - 1] + '…' safe_addstr(self.size.y - 1, start_x, '@%s:%s' % (t.thing_char, name))