diff options
| author | Simon Tatham <anakin@pobox.com> | 2013-04-05 15:49:29 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2013-04-05 15:49:29 +0000 |
| commit | 36f35f5db81d95c3fc038f27ac791a2f4f748c10 (patch) | |
| tree | e15c262299b537d08308b3e39ac2c2e251acb310 /emcc.c | |
| parent | 2360b77812e184902e44c7f4ea2f6fc79729e370 (diff) | |
| download | puzzles-36f35f5db81d95c3fc038f27ac791a2f4f748c10.zip puzzles-36f35f5db81d95c3fc038f27ac791a2f4f748c10.tar.gz puzzles-36f35f5db81d95c3fc038f27ac791a2f4f748c10.tar.bz2 puzzles-36f35f5db81d95c3fc038f27ac791a2f4f748c10.tar.xz | |
Regretfully remove my trickery with a hidden <option> element inside
the game-type <select>, since IE turns out to ignore display:none on
options. Oh well.
Instead I now do a more transparent thing: when custom game params are
in use, there's a "Custom" option selected in the dropdown, and a
separate 'Re-customise' option which brings the config box back up.
When an ordinary preset is selected, the Custom option is missing, and
there's just a 'Customise'.
In the process I've tinkered a bit to arrange that the custom 'preset'
is always represented by a negative number rather than one past the
last real preset; that seems more consistent overall.
[originally from svn r9811]
Diffstat (limited to 'emcc.c')
| -rw-r--r-- | emcc.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -53,6 +53,7 @@ * that using whatever they normally use to print PDFs!) */ +#include <assert.h> #include <string.h> #include "puzzles.h" @@ -528,14 +529,14 @@ const struct drawing_api js_drawing = { * Presets and game-configuration dialog support. */ static game_params **presets; -static int custom_preset; +static int npresets; int have_presets_dropdown; void select_appropriate_preset(void) { if (have_presets_dropdown) { int preset = midend_which_preset(me); - js_select_preset(preset < 0 ? custom_preset : preset); + js_select_preset(preset < 0 ? -1 : preset); } } @@ -656,7 +657,7 @@ void command(int n) case 2: /* game parameter dropdown changed */ { int i = js_get_selected_preset(); - if (i == custom_preset) { + if (i < 0) { /* * The user selected 'Custom', so launch the config * box. @@ -668,12 +669,14 @@ void command(int n) * The user selected a preset, so just switch straight * to that. */ + assert(i < npresets); midend_set_params(me, presets[i]); midend_new_game(me); resize(); midend_redraw(me); update_undo_redo(); js_focus_canvas(); + select_appropriate_preset(); /* sort out Custom/Customise */ } } break; @@ -762,12 +765,10 @@ int main(int argc, char **argv) /* * Set up the game-type dropdown with presets and/or the Custom - * option. We remember the index of the Custom option (as - * custom_preset) so that we can easily treat it specially when - * it's selected. + * option. */ - custom_preset = midend_num_presets(me); - if (custom_preset == 0) { + npresets = midend_num_presets(me); + if (npresets == 0) { /* * This puzzle doesn't have selectable game types at all. * Completely remove the drop-down list from the page. @@ -777,8 +778,8 @@ int main(int argc, char **argv) } else { int preset; - presets = snewn(custom_preset, game_params *); - for (i = 0; i < custom_preset; i++) { + presets = snewn(npresets, game_params *); + for (i = 0; i < npresets; i++) { char *name; midend_fetch_preset(me, i, &name, &presets[i]); js_add_preset(name); |