Skip to content
Snippets Groups Projects
Commit d62b8f3a authored by rswindell's avatar rswindell
Browse files

Use Synchronet mouse hotspots to mouse-enable all the menu keys. Uses the new...

Use Synchronet mouse hotspots to mouse-enable all the menu keys. Uses the new CON_MOUSE_PASSTHRU console status.
Also fixed a place or two where the mouse could be left disabled after a command or a text input a prompt.
Use the cached ansiterm_lib.js.
parent 6864af89
No related branches found
No related tags found
No related merge requests found
...@@ -84,13 +84,15 @@ var best = null; ...@@ -84,13 +84,15 @@ var best = null;
log(LOG_DEBUG, title + " options: " + JSON.stringify(options)); log(LOG_DEBUG, title + " options: " + JSON.stringify(options));
var ansi = load({}, 'ansiterm_lib.js'); var ansiterm = bbs.mods.ansiterm_lib;
if(!ansiterm)
ansiterm = bbs.mods.ansiterm_lib = load({}, "ansiterm_lib.js");
function mouse_enable(enable) function mouse_enable(enable)
{ {
if(console.term_supports(USER_ANSI)) { if(console.term_supports(USER_ANSI)) {
ansi.send('mouse', enable ? 'set' : 'clear', 'x10_compatible'); ansiterm.send('mouse', enable ? 'set' : 'clear', 'x10_compatible');
ansi.send('mouse', enable ? 'set' : 'clear', 'extended_coord'); ansiterm.send('mouse', enable ? 'set' : 'clear', 'extended_coord');
} }
} }
...@@ -641,28 +643,29 @@ function draw_board(full) ...@@ -641,28 +643,29 @@ function draw_board(full)
var cmds = ""; var cmds = "";
if(gameover) { if(gameover) {
if(!gamewon) if(!gamewon)
cmds += "\x01n\x01hD\x01nisplay "; cmds += "\x01n\x01h\x01~D\x01nisplay ";
} else { } else {
if(!board[selected.y][selected.x].covered) { if(!board[selected.y][selected.x].covered) {
if(can_chord(selected.x, selected.y)) if(can_chord(selected.x, selected.y))
cmds += "\x01h\x01kDig \x01n\x01hC\x01nhord "; cmds += "\x01h\x01k\x01~Dig \x01n\x01h\x01~C\x01nhord ";
else else
cmds += "\x01h\x01kDig Flag "; cmds += "\x01h\x01k\x01~Dig Flag ";
} }
else else
cmds += "\x01hD\x01nig \x01hF\x01nlag "; cmds += "\x01h\x01~D\x01nig \x01h\x01~F\x01nlag ";
} }
cmds += "\x01n\x01hN\x01new \x01hQ\x01nuit"; cmds += "\x01n\x01h\x01~N\x01new \x01h\x01~Q\x01nuit";
if(full || cmds !== cmds_shown) { if(full || cmds !== cmds_shown) {
console.clear_hotspots();
draw_border(); draw_border();
console.attributes = LIGHTGRAY; console.attributes = LIGHTGRAY;
console_center(cmds); console_center(cmds);
cmds_shown = cmds; cmds_shown = cmds;
draw_border(); draw_border();
cmds = "\x01hW\x01ninners \x01hL\x01nog "; cmds = "\x01h\x01~W\x01ninners \x01h\x01~L\x01nog ";
if(best) if(best)
cmds += "\x01hB\x01nest "; cmds += "\x01h\x01~B\x01nest ";
cmds += "\x01hH\x01nelp" cmds += "\x01h\x01~H\x01nelp"
console_center(cmds); console_center(cmds);
} else if(!console.term_supports(USER_ANSI)) { } else if(!console.term_supports(USER_ANSI)) {
console.creturn(); console.creturn();
...@@ -800,9 +803,13 @@ function get_difficulty(all) ...@@ -800,9 +803,13 @@ function get_difficulty(all)
console.cleartoeol(); console.cleartoeol();
draw_border(); draw_border();
console.attributes = WHITE; console.attributes = WHITE;
console.clear_hotspots();
var lvls = "";
for(var i = 1; i <= max_difficulty; i++)
lvls += "\x01~" + i;
if(all) { if(all) {
console.right((console.screen_columns - 20) / 2); console.right((console.screen_columns - 20) / 2);
console.print(format("Level (1-%u) [All]: ", max_difficulty)); console.print(format("Level (%s) [\x01~All]: ", lvls));
var key = console.getkeys("QA", max_difficulty); var key = console.getkeys("QA", max_difficulty);
if(key == 'A') if(key == 'A')
return 0; return 0;
...@@ -811,7 +818,7 @@ function get_difficulty(all) ...@@ -811,7 +818,7 @@ function get_difficulty(all)
return key; return key;
} }
console.right((console.screen_columns - 24) / 2); console.right((console.screen_columns - 24) / 2);
console.print(format("Difficulty Level (1-%u): ", max_difficulty)); console.print(format("Difficulty Level (%s): ", lvls));
return console.getnum(max_difficulty); return console.getnum(max_difficulty);
} }
...@@ -1079,26 +1086,29 @@ function play() ...@@ -1079,26 +1086,29 @@ function play()
break; break;
case 'N': case 'N':
{ {
mouse_enable(false);
console.home(); console.home();
console.down(top + 1); console.down(top + 1);
full_redraw = true;
if(game.start && !gameover) { if(game.start && !gameover) {
console.cleartoeol(); console.cleartoeol();
draw_border(); draw_border();
console.attributes = LIGHTRED; console.attributes = LIGHTRED;
console.right((console.screen_columns - 15) / 2); console.right((console.screen_columns - 15) / 2);
console.print("New Game (Y/N) ?"); mouse_enable(false);
if(console.getkey(K_UPPER) != 'Y') console.clear_hotspots();
console.print("New Game (\x01~Y/\x01~N) ?");
var key = console.getkey(K_UPPER);
mouse_enable(true);
if(key != 'Y')
break; break;
} }
var new_difficulty = get_difficulty(); var new_difficulty = get_difficulty();
if(new_difficulty > 0) if(new_difficulty > 0)
difficulty = init_game(new_difficulty); difficulty = init_game(new_difficulty);
full_redraw = true;
mouse_enable(true);
break; break;
} }
case 'W': case 'W':
full_redraw = true;
mouse_enable(false); mouse_enable(false);
console.home(); console.home();
console.down(top + 1); console.down(top + 1);
...@@ -1109,7 +1119,6 @@ function play() ...@@ -1109,7 +1119,6 @@ function play()
console.pause(); console.pause();
console.clear(); console.clear();
console.aborted = false; console.aborted = false;
full_redraw = true;
} }
mouse_enable(true); mouse_enable(true);
break break
...@@ -1133,10 +1142,10 @@ function play() ...@@ -1133,10 +1142,10 @@ function play()
mouse_enable(true); mouse_enable(true);
break break
case 'B': case 'B':
mouse_enable(false);
if(!best) if(!best)
break; break;
console.line_counter = 0; console.line_counter = 0;
mouse_enable(false);
show_best(); show_best();
console.pause(); console.pause();
console.clear(); console.clear();
...@@ -1150,6 +1159,7 @@ function play() ...@@ -1150,6 +1159,7 @@ function play()
console.line_counter = 0; console.line_counter = 0;
console.clear(); console.clear();
console.printfile(help_file); console.printfile(help_file);
console.pause();
console.clear(); console.clear();
console.aborted = false; console.aborted = false;
full_redraw = true; full_redraw = true;
...@@ -1166,19 +1176,21 @@ function play() ...@@ -1166,19 +1176,21 @@ function play()
selector++; selector++;
break; break;
case 'Q': case 'Q':
mouse_enable(false);
if(game.start && !gameover) { if(game.start && !gameover) {
full_redraw = true;
console.home(); console.home();
console.down(top + 1); console.down(top + 1);
console.cleartoeol(); console.cleartoeol();
draw_border(); draw_border();
console.attributes = LIGHTRED; console.attributes = LIGHTRED;
console.right((console.screen_columns - 16) / 2); console.right((console.screen_columns - 16) / 2);
console.print("Quit Game (Y/N) ?"); mouse_enable(false);
if(console.getkey(K_UPPER) != 'Y') { console.clear_hotspots();
mouse_enable(true); console.print("Quit Game (\x01~Y/\x01~N) ?");
var key = console.getkey(K_UPPER);
mouse_enable(true);
if(key != 'Y')
break; break;
}
} }
return; return;
} }
...@@ -1211,6 +1223,8 @@ try { ...@@ -1211,6 +1223,8 @@ try {
} }
js.on_exit("console.line_counter = 0"); js.on_exit("console.line_counter = 0");
js.on_exit("console.status = " + console.status);
console.status |= CON_MOUSE_PASSTHRU;
js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru); js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
console.ctrlkey_passthru = "KOPTUZ"; console.ctrlkey_passthru = "KOPTUZ";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment