mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
js: Better handling of games without presets and/or solve
Games with neither presets nor configuration (which may only be the Null Game) have been slightly broken since the introduction of hierarchical preset menus, in that the code to remove the "Type..." menu stopped being called then. My switch to using radio buttons in menus then broke them utterly because it's not possible to set the value of an empty radio group, causing a crash at startup. Fix this by detected when there's no preset menu, removing the item from the menu bar, and setting the variable that's meant to indicate this has been done. The solve button problem was more subtle, in that only the <button> was being hidden and not the <li> containing it, which led to the right border of the menu bar being two pixels thick. Switch to fully removing the <li> from the DOM, like we now do with the presets menu, since that also makes my keyboard handler (in another branch) simpler.
This commit is contained in:
17
emcc.c
17
emcc.c
@ -974,14 +974,17 @@ int main(int argc, char **argv)
|
|||||||
if (thegame.can_configure)
|
if (thegame.can_configure)
|
||||||
js_add_preset(0, "Custom", -1);
|
js_add_preset(0, "Custom", -1);
|
||||||
|
|
||||||
have_presets_dropdown = true;
|
have_presets_dropdown = npresets > 0 || thegame.can_configure;
|
||||||
|
|
||||||
/*
|
if (have_presets_dropdown)
|
||||||
* Now ensure the appropriate element of the presets menu
|
/*
|
||||||
* starts off selected, in case it isn't the first one in the
|
* Now ensure the appropriate element of the presets menu
|
||||||
* list (e.g. Slant).
|
* starts off selected, in case it isn't the first one in the
|
||||||
*/
|
* list (e.g. Slant).
|
||||||
select_appropriate_preset();
|
*/
|
||||||
|
select_appropriate_preset();
|
||||||
|
else
|
||||||
|
js_remove_type_dropdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
10
emcclib.js
10
emcclib.js
@ -45,7 +45,9 @@ mergeInto(LibraryManager.library, {
|
|||||||
* provides neither presets nor configurability.
|
* provides neither presets nor configurability.
|
||||||
*/
|
*/
|
||||||
js_remove_type_dropdown: function() {
|
js_remove_type_dropdown: function() {
|
||||||
gametypelist.style.display = "none";
|
var gametypeitem = gametypelist.closest("li");
|
||||||
|
if (gametypeitem === null) return;
|
||||||
|
gametypeitem.parentNode.removeChild(gametypeitem);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -55,7 +57,11 @@ mergeInto(LibraryManager.library, {
|
|||||||
* time if the game doesn't support an in-game solve function.
|
* time if the game doesn't support an in-game solve function.
|
||||||
*/
|
*/
|
||||||
js_remove_solve_button: function() {
|
js_remove_solve_button: function() {
|
||||||
document.getElementById("solve").style.display = "none";
|
var solvebutton = document.getElementById("solve");
|
||||||
|
if (solvebutton === null) return;
|
||||||
|
var solveitem = solvebutton.closest("li");
|
||||||
|
if (solveitem === null) return;
|
||||||
|
solveitem.parentNode.removeChild(solveitem);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user