X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/calendar?a=blobdiff_plain;f=rogue_chat_nocanvas_monochrome.html;h=085c8a298646b4c9fbfc4cdee330b6c170896c86;hb=46108644f062458df5b0540f806abffab650683f;hp=81c1e13ab713b92575e503cea011d661d4992933;hpb=cdb1d2aa196d26c7d54b2c4ade9a1272cab02aae;p=plomrogue2
diff --git a/rogue_chat_nocanvas_monochrome.html b/rogue_chat_nocanvas_monochrome.html
index 81c1e13..085c8a2 100644
--- a/rogue_chat_nocanvas_monochrome.html
+++ b/rogue_chat_nocanvas_monochrome.html
@@ -21,6 +21,7 @@ move right (hex grid):
move down-left (hex grid):
move left (hex grid):
+help:
flatten surroundings:
switch to chat mode:
switch to play mode:
@@ -220,7 +221,6 @@ let server = {
explorer.empty_info_db();
if (tui.mode == mode_post_login_wait) {
tui.switch_mode(mode_play);
- tui.log_help();
} else if (tui.mode == mode_study) {
explorer.query_info();
}
@@ -286,24 +286,25 @@ let unparser = {
}
class Mode {
- constructor(name, has_input_prompt=false, shows_info=false, is_intro=false) {
+ constructor(name, help_intro, has_input_prompt=false, shows_info=false, is_intro=false) {
this.name = name;
this.has_input_prompt = has_input_prompt;
this.shows_info= shows_info;
this.is_intro = is_intro;
+ this.help_intro = help_intro;
}
}
-let mode_waiting_for_server = new Mode('waiting_for_server', false, false, true);
-let mode_login = new Mode('login', true, false, true);
-let mode_post_login_wait = new Mode('waiting for game world', false, false, true);
-let mode_chat = new Mode('chat / write messages to players', true, false);
-let mode_annotate = new Mode('add message to map tile', true, true);
-let mode_play = new Mode('play / move around', false, false);
-let mode_study = new Mode('check map tiles for messages', false, true);
-let mode_edit = new Mode('write ASCII char to map tile', false, false);
-let mode_teleport = new Mode('teleport away?', true);
-let mode_portal = new Mode('add portal to map tile', true, true);
-let mode_password = new Mode('enter terrain password', true, false, false);
+let mode_waiting_for_server = new Mode('waiting_for_server', 'Waiting for a server response.', false, false, true);
+let mode_login = new Mode('login', 'Pick your player name.', true, false, true);
+let mode_post_login_wait = new Mode('waiting for game world', 'Waiting for a server response.', false, false, true);
+let mode_chat = new Mode('chat', 'This mode allows you to engage in chit-chat with other users. Any line you enter into the input prompt that does not start with a "/" will be sent to all users. Lines that start with a "/" are used for commands like:', true, false);
+ let mode_annotate = new Mode('annotate', 'This mode allows you to add/edit a comment on the tile you are currently standing on (provided your map editing password authorizes you so). Hit Return to leave.', true, true);
+let mode_play = new Mode('play', 'This mode allows you to interact with the map.', false, false);
+let mode_study = new Mode('study', 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it.', false, true);
+let mode_edit = new Mode('edit', 'This mode allows you to change the map tile you currently stand on (if your map editing password authorizes you so). Just enter any printable ASCII character to imprint it on the ground below you.', false, false);
+let mode_teleport = new Mode('teleport', 'Follow the instructions to re-connect and log-in to another server, or enter anything else to abort.', true);
+let mode_portal = new Mode('portal', 'This mode allows you to imprint/edit/remove a teleportation target on the ground you are currently standing on (provided your map editing password authorizes you so). Enter or edit a URL to imprint a teleportation target; enter emptiness to remove a pre-existing teleportation target. Hit Return to leave.', true, true);
+let mode_password = new Mode('password', 'This mode allows you to change the password that you send to authorize yourself for editing password-protected map tiles. Hit return to confirm and leave.', true, false, false);
let tui = {
mode: mode_waiting_for_server,
@@ -315,6 +316,7 @@ let tui = {
height_mode_line: 1,
height_input: 1,
password: 'foo',
+ show_help: false,
init: function() {
this.inputEl = document.getElementById("input");
this.inputEl.focus();
@@ -328,14 +330,13 @@ let tui = {
for (let key_selector of key_selectors) {
this.keys[key_selector.id.slice(4)] = key_selector.value;
}
- if (game.map_geometry == 'Square') {
- this.movement_keys = {
- [this.keys.square_move_up]: 'UP',
- [this.keys.square_move_left]: 'LEFT',
- [this.keys.square_move_down]: 'DOWN',
- [this.keys.square_move_right]: 'RIGHT'
- };
- } else if (game.map_geometry == 'Hex') {
+ this.movement_keys = {
+ [this.keys.square_move_up]: 'UP',
+ [this.keys.square_move_left]: 'LEFT',
+ [this.keys.square_move_down]: 'DOWN',
+ [this.keys.square_move_right]: 'RIGHT'
+ };
+ if (game.map_geometry == 'Hex') {
this.movement_keys = {
[this.keys.hex_move_upleft]: 'UPLEFT',
[this.keys.hex_move_upright]: 'UPRIGHT',
@@ -347,38 +348,44 @@ let tui = {
};
},
switch_mode: function(mode, keep_pos=false) {
+ this.show_help = false;
this.map_mode = 'terrain';
if (mode == mode_study && !keep_pos && game.player_id in game.things) {
explorer.position = game.things[game.player_id].position;
}
this.mode = mode;
this.empty_input();
- if (mode == mode_annotate && explorer.position in explorer.info_db) {
- let info = explorer.info_db[explorer.position];
- if (info != "(none)") {
- this.inputEl.value = info;
- this.recalc_input_lines();
- }
- }
+ this.restore_input_values();
if (mode == mode_login) {
if (this.login_name) {
server.send(['LOGIN', this.login_name]);
} else {
this.log_msg("? need login name");
}
- } else if (mode == mode_portal && explorer.position in game.portals) {
- let portal = game.portals[explorer.position]
- this.inputEl.value = portal;
- this.recalc_input_lines();
- } else if (mode == mode_password) {
- this.inputEl.value = this.password;
- this.recalc_input_lines();
+ } else if (mode == mode_edit) {
+ this.show_help = true;
} else if (mode == mode_teleport) {
tui.log_msg("@ May teleport to: " + tui.teleport_target);
tui.log_msg("@ Enter 'YES!' to entusiastically affirm.");
}
this.full_refresh();
},
+ restore_input_values: function() {
+ if (this.mode == mode_annotate && explorer.position in explorer.info_db) {
+ let info = explorer.info_db[explorer.position];
+ if (info != "(none)") {
+ this.inputEl.value = info;
+ this.recalc_input_lines();
+ }
+ } else if (this.mode == mode_portal && explorer.position in game.portals) {
+ let portal = game.portals[explorer.position]
+ this.inputEl.value = portal;
+ this.recalc_input_lines();
+ } else if (this.mode == mode_password) {
+ this.inputEl.value = this.password;
+ this.recalc_input_lines();
+ }
+ },
empty_input: function(str) {
this.inputEl.value = "";
if (this.mode.has_input_prompt) {
@@ -414,37 +421,6 @@ let tui = {
};
this.full_refresh();
},
- log_help: function() {
- let movement_keys_desc = Object.keys(this.movement_keys).join(',');
- this.log_msg("HELP:");
- this.log_msg("chat mode commands:");
- this.log_msg(" /nick NAME - re-name yourself to NAME");
- this.log_msg(" /msg USER TEXT - send TEXT to USER");
- this.log_msg(" /help - show this help");
- this.log_msg(" /" + this.keys.switch_to_play + " or /play - switch to play mode");
- this.log_msg(" /" + this.keys.switch_to_study + " or /study - switch to study mode");
- this.log_msg("commands common to study and play mode:");
- if (game.tasks.includes('MOVE')) {
- this.log_msg(" " + movement_keys_desc + " - move");
- }
- this.log_msg(" " + this.keys.switch_to_chat + " - switch to chat mode");
- this.log_msg("commands specific to play mode:");
- this.log_msg(" " + this.keys.switch_to_password + " - enter terrain password");
- if (game.tasks.includes('WRITE')) {
- this.log_msg(" " + this.keys.switch_to_edit + " - write following ASCII character");
- }
- if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
- this.log_msg(" " + this.keys.flatten + " - flatten surroundings");
- }
- this.log_msg(" " + this.keys.switch_to_study + " - switch to study mode");
- this.log_msg("commands specific to study mode:");
- this.log_msg(" " + this.keys.switch_to_play + " - switch to play mode");
- if (!game.tasks.includes('MOVE')) {
- this.log_msg(" " + movement_keys_desc + " - move");
- }
- this.log_msg(" " + this.keys.switch_to_annotate + " - annotate terrain");
- this.log_msg(" " + this.keys.toggle_map_mode + " - toggle terrain/control view");
- },
draw_map: function() {
let map_lines_split = [];
let line = [];
@@ -508,7 +484,11 @@ let tui = {
}
},
draw_mode_line: function() {
- terminal.write(0, this.window_width, 'MODE: ' + this.mode.name);
+ let help = 'hit [' + this.keys.help + '] for help';
+ if (this.mode.has_input_prompt) {
+ help = 'enter /help for help';
+ }
+ terminal.write(0, this.window_width, 'MODE: ' + this.mode.name + ' â ' + help);
},
draw_turn_line: function(n) {
terminal.write(1, this.window_width, 'TURN: ' + game.turn);
@@ -538,6 +518,47 @@ let tui = {
}
}
},
+ draw_help: function() {
+ let movement_keys_desc = Object.keys(this.movement_keys).join(',');
+ let content = this.mode.name + " mode help (hit any key to disappear)\n\n" + this.mode.help_intro + "\n\n";
+ if (this.mode == mode_play) {
+ content += "Available actions:\n";
+ if (game.tasks.includes('MOVE')) {
+ content += "[" + movement_keys_desc + "] â move player\n";
+ }
+ if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
+ content += "[" + tui.keys.flatten + "] â flatten player's surroundings\n";
+ }
+ content += '\nOther modes available from here:\n';
+ content += '[' + this.keys.switch_to_edit + '] â terrain edit mode\n';
+ content += '[' + this.keys.switch_to_password + '] â terrain password edit mode\n';
+ content += '[' + this.keys.switch_to_chat + '] â chat mode\n';
+ content += '[' + this.keys.switch_to_study + '] â study mode\n';
+ } else if (this.mode == mode_study) {
+ content += "Available actions:\n";
+ content += '[' + movement_keys_desc + '] â move question mark\n';
+ content += '[' + this.keys.toggle_map_mode + '] â toggle view between terrain, and password protection areas\n';
+ content += '\nOther modes available from here:\n';
+ content += '[' + this.keys.switch_to_chat + '] â chat mode\n';
+ content += '[' + this.keys.switch_to_play + '] â play mode\n';
+ content += '[' + this.keys.switch_to_portal + '] â portal mode\n';
+ content += '[' + this.keys.switch_to_annotate + '] â annotation mode\n';
+ } else if (this.mode == mode_chat) {
+ content += '/nick NAME â re-name yourself to NAME\n';
+ content += '/msg USER TEXT â send TEXT to USER\n';
+ content += '/' + this.keys.switch_to_play + ' or /play â switch to play mode\n';
+ content += '/' + this.keys.switch_to_study + ' or /study â switch to study mode\n';
+ }
+ let start_x = 0;
+ if (!this.mode.has_input_prompt) {
+ start_x = this.window_width
+ }
+ terminal.drawBox(0, start_x, terminal.rows, this.window_width);
+ let lines = this.msg_into_lines_of_width(content, this.window_width);
+ for (let y = 0, i = 0; y < terminal.rows && i < lines.length; y++, i++) {
+ terminal.write(y, start_x, lines[i]);
+ }
+ },
full_refresh: function() {
terminal.drawBox(0, 0, terminal.rows, terminal.cols);
if (this.mode.is_intro) {
@@ -556,6 +577,9 @@ let tui = {
}
this.draw_input();
}
+ if (this.show_help) {
+ this.draw_help();
+ }
terminal.refresh();
}
}
@@ -685,13 +709,13 @@ let explorer = {
if (msg.length == 0) {
msg = " "; // triggers annotation deletion
}
- server.send(["ANNOTATE", unparser.to_yx(explorer.position), msg]);
+ server.send(["ANNOTATE", unparser.to_yx(explorer.position), msg, tui.password]);
},
set_portal: function(msg) {
if (msg.length == 0) {
msg = " "; // triggers portal deletion
}
- server.send(["PORTAL", unparser.to_yx(explorer.position), msg]);
+ server.send(["PORTAL", unparser.to_yx(explorer.position), msg, tui.password]);
}
}
@@ -716,10 +740,19 @@ tui.inputEl.addEventListener('input', (event) => {
}
}, false);
tui.inputEl.addEventListener('keydown', (event) => {
+ tui.show_help = false;
if (event.key == 'Enter') {
event.preventDefault();
}
- if (tui.mode == mode_login && event.key == 'Enter') {
+ if (tui.mode.has_input_prompt && event.key == 'Enter' && tui.inputEl.value == '/help') {
+ tui.show_help = true;
+ tui.empty_input();
+ tui.restore_input_values();
+ tui.full_refresh();
+ } else if (!tui.mode.has_input_prompt && event.key == tui.keys.help) {
+ tui.show_help = true;
+ tui.full_refresh();
+ } else if (tui.mode == mode_login && event.key == 'Enter') {
tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
tui.empty_input();
@@ -750,8 +783,6 @@ tui.inputEl.addEventListener('keydown', (event) => {
tui.switch_mode(mode_play);
} else if (tokens[0].slice(1) == 'study' || tokens[0][1] == tui.keys.switch_to_study) {
tui.switch_mode(mode_study);
- } else if (tokens[0].slice(1) == 'help') {
- tui.log_help();
} else if (tokens[0].slice(1) == 'nick') {
if (tokens.length > 1) {
server.send(['NICK', tokens[1]]);