rlgterm.js: make the options table functional.
Enable launching games from the options table, and replace the old select dialog.
This commit is contained in:
parent
d3abfbcea9
commit
aba0a4b7da
2 changed files with 20 additions and 19 deletions
22
rlgterm.js
22
rlgterm.js
|
|
@ -440,6 +440,9 @@ function getchoices() {
|
|||
var button = document.createElement("span");
|
||||
button.appendChild(document.createTextNode(acttext));
|
||||
button.className = "ibutton";
|
||||
if ("s0".indexOf(reply.stat[gname]) >= 0) {
|
||||
button.onclick = makeStarter(gname);
|
||||
}
|
||||
var actdiv = document.createElement("div");
|
||||
actdiv.appendChild(button);
|
||||
var gamediv = document.createElement("div");
|
||||
|
|
@ -455,13 +458,26 @@ function getchoices() {
|
|||
return;
|
||||
}
|
||||
|
||||
function startgame(ev) {
|
||||
ev.preventDefault();
|
||||
/* This can't be in the loop in getchoices(), or the closure's scope will
|
||||
* get overwritten on the next iteration, and then all the games end up
|
||||
* being Super-Rogue.
|
||||
*/
|
||||
function makeStarter(gname) {
|
||||
if (!(gname in games))
|
||||
return null;
|
||||
var game = games[gname];
|
||||
function starter(ev) {
|
||||
startgame(game);
|
||||
}
|
||||
return starter;
|
||||
}
|
||||
|
||||
function startgame(game) {
|
||||
if (termemu.sessid != null || !lcred)
|
||||
return;
|
||||
var smsg = {};
|
||||
smsg["key"] = lcred;
|
||||
smsg["game"] = document.getElementById("input_game").value;
|
||||
smsg["game"] = game.uname;
|
||||
smsg["h"] = 24;
|
||||
smsg["w"] = 80;
|
||||
var req = new XMLHttpRequest();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue