mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Add preferences for existing UI style controls
Some puzzles have keys that make changes to the display style in ways that would probably have been user preferences if they had existed. I've added a user preference for each of these. The keys still work, and unlike the preferences can be changed without saving any state. The affected settings are: * Labelling colours with numbers in Guess ("L" key) * Labelling regions with numbers in Map ("L" key) * Whether monsters are shown as letters or pictures in Undead ("A" key)
This commit is contained in:
29
guess.c
29
guess.c
@ -411,19 +411,44 @@ static game_ui *new_ui(const game_state *state)
|
|||||||
{
|
{
|
||||||
game_ui *ui = snew(game_ui);
|
game_ui *ui = snew(game_ui);
|
||||||
memset(ui, 0, sizeof(game_ui));
|
memset(ui, 0, sizeof(game_ui));
|
||||||
|
if (state != NULL) {
|
||||||
ui->params = state->params; /* structure copy */
|
ui->params = state->params; /* structure copy */
|
||||||
ui->curr_pegs = new_pegrow(state->params.npegs);
|
ui->curr_pegs = new_pegrow(state->params.npegs);
|
||||||
ui->holds = snewn(state->params.npegs, bool);
|
ui->holds = snewn(state->params.npegs, bool);
|
||||||
ui->display_cur = getenv_bool("PUZZLES_SHOW_CURSOR", false);
|
|
||||||
memset(ui->holds, 0, sizeof(bool)*state->params.npegs);
|
memset(ui->holds, 0, sizeof(bool)*state->params.npegs);
|
||||||
|
}
|
||||||
|
ui->display_cur = getenv_bool("PUZZLES_SHOW_CURSOR", false);
|
||||||
ui->drag_opeg = -1;
|
ui->drag_opeg = -1;
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static config_item *get_prefs(game_ui *ui)
|
||||||
|
{
|
||||||
|
config_item *ret;
|
||||||
|
|
||||||
|
ret = snewn(2, config_item);
|
||||||
|
|
||||||
|
ret[0].name = "Label colours with numbers";
|
||||||
|
ret[0].kw = "show-labels";
|
||||||
|
ret[0].type = C_BOOLEAN;
|
||||||
|
ret[0].u.boolean.bval = ui->show_labels;
|
||||||
|
|
||||||
|
ret[1].name = NULL;
|
||||||
|
ret[1].type = C_END;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_prefs(game_ui *ui, const config_item *cfg)
|
||||||
|
{
|
||||||
|
ui->show_labels = cfg[0].u.boolean.bval;
|
||||||
|
}
|
||||||
|
|
||||||
static void free_ui(game_ui *ui)
|
static void free_ui(game_ui *ui)
|
||||||
{
|
{
|
||||||
if (ui->hint)
|
if (ui->hint)
|
||||||
free_pegrow(ui->hint);
|
free_pegrow(ui->hint);
|
||||||
|
if (ui->curr_pegs)
|
||||||
free_pegrow(ui->curr_pegs);
|
free_pegrow(ui->curr_pegs);
|
||||||
sfree(ui->holds);
|
sfree(ui->holds);
|
||||||
sfree(ui);
|
sfree(ui);
|
||||||
@ -1518,7 +1543,7 @@ const struct game thegame = {
|
|||||||
free_game,
|
free_game,
|
||||||
true, solve_game,
|
true, solve_game,
|
||||||
false, NULL, NULL, /* can_format_as_text_now, text_format */
|
false, NULL, NULL, /* can_format_as_text_now, text_format */
|
||||||
NULL, NULL, /* get_prefs, set_prefs */
|
get_prefs, set_prefs,
|
||||||
new_ui,
|
new_ui,
|
||||||
free_ui,
|
free_ui,
|
||||||
encode_ui,
|
encode_ui,
|
||||||
|
12
map.c
12
map.c
@ -2337,7 +2337,7 @@ static config_item *get_prefs(game_ui *ui)
|
|||||||
{
|
{
|
||||||
config_item *ret;
|
config_item *ret;
|
||||||
|
|
||||||
ret = snewn(2, config_item);
|
ret = snewn(3, config_item);
|
||||||
|
|
||||||
ret[0].name = "Victory flash effect";
|
ret[0].name = "Victory flash effect";
|
||||||
ret[0].kw = "flash-type";
|
ret[0].kw = "flash-type";
|
||||||
@ -2346,8 +2346,13 @@ static config_item *get_prefs(game_ui *ui)
|
|||||||
ret[0].u.choices.choicekws = ":cyclic:each-white:all-white";
|
ret[0].u.choices.choicekws = ":cyclic:each-white:all-white";
|
||||||
ret[0].u.choices.selected = ui->flash_type;
|
ret[0].u.choices.selected = ui->flash_type;
|
||||||
|
|
||||||
ret[1].name = NULL;
|
ret[1].name = "Number regions";
|
||||||
ret[1].type = C_END;
|
ret[1].kw = "show-numbers";
|
||||||
|
ret[1].type = C_BOOLEAN;
|
||||||
|
ret[1].u.boolean.bval = ui->show_numbers;
|
||||||
|
|
||||||
|
ret[2].name = NULL;
|
||||||
|
ret[2].type = C_END;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2355,6 +2360,7 @@ static config_item *get_prefs(game_ui *ui)
|
|||||||
static void set_prefs(game_ui *ui, const config_item *cfg)
|
static void set_prefs(game_ui *ui, const config_item *cfg)
|
||||||
{
|
{
|
||||||
ui->flash_type = cfg[0].u.choices.selected;
|
ui->flash_type = cfg[0].u.choices.selected;
|
||||||
|
ui->show_numbers = cfg[1].u.boolean.bval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_ui(game_ui *ui)
|
static void free_ui(game_ui *ui)
|
||||||
|
16
puzzles.but
16
puzzles.but
@ -1443,6 +1443,13 @@ that, use one extra colour.
|
|||||||
this increases the search space (making things harder), and is turned on by
|
this increases the search space (making things harder), and is turned on by
|
||||||
default.
|
default.
|
||||||
|
|
||||||
|
\H{guess-prefs} \I{preferences, for Guess}Guess user preferences
|
||||||
|
|
||||||
|
On platforms that support user preferences, the \q{Preferences} option
|
||||||
|
on the \q{Game} menu will let you configure whether pegs are labelled
|
||||||
|
with their numbers. Unlike the \q{L} key, this will persist between
|
||||||
|
games.
|
||||||
|
|
||||||
|
|
||||||
\C{pegs} \i{Pegs}
|
\C{pegs} \i{Pegs}
|
||||||
|
|
||||||
@ -2004,7 +2011,7 @@ Unreasonable puzzles may require guessing and backtracking.
|
|||||||
|
|
||||||
On platforms that support user preferences, the \q{Preferences} option
|
On platforms that support user preferences, the \q{Preferences} option
|
||||||
on the \q{Game} menu will let you configure the style of the victory
|
on the \q{Game} menu will let you configure the style of the victory
|
||||||
flash.
|
flash and also whether the regions start out labelled with numbers.
|
||||||
|
|
||||||
|
|
||||||
\C{loopy} \i{Loopy}
|
\C{loopy} \i{Loopy}
|
||||||
@ -3288,6 +3295,13 @@ These parameters are available from the \q{Custom...} option on the
|
|||||||
|
|
||||||
\dd Controls the difficulty of the generated puzzle.
|
\dd Controls the difficulty of the generated puzzle.
|
||||||
|
|
||||||
|
\H{undead-prefs} \I{preferences, for Undead}Undead user preferences
|
||||||
|
|
||||||
|
On platforms that support user preferences, the \q{Preferences} option
|
||||||
|
on the \q{Game} menu will let you configure whether Undead uses letters
|
||||||
|
or pictures to represent monsters.
|
||||||
|
|
||||||
|
|
||||||
\C{unruly} \i{Unruly}
|
\C{unruly} \i{Unruly}
|
||||||
|
|
||||||
\cfg{winhelp-topic}{games.unruly}
|
\cfg{winhelp-topic}{games.unruly}
|
||||||
|
26
undead.c
26
undead.c
@ -1656,6 +1656,30 @@ static game_ui *new_ui(const game_state *state)
|
|||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static config_item *get_prefs(game_ui *ui)
|
||||||
|
{
|
||||||
|
config_item *ret;
|
||||||
|
|
||||||
|
ret = snewn(2, config_item);
|
||||||
|
|
||||||
|
ret[0].name = "Monster representation";
|
||||||
|
ret[0].kw = "monsters";
|
||||||
|
ret[0].type = C_CHOICES;
|
||||||
|
ret[0].u.choices.choicenames = ":Pictures:Letters";
|
||||||
|
ret[0].u.choices.choicekws = ":pictures:letters";
|
||||||
|
ret[0].u.choices.selected = ui->ascii;
|
||||||
|
|
||||||
|
ret[1].name = NULL;
|
||||||
|
ret[1].type = C_END;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_prefs(game_ui *ui, const config_item *cfg)
|
||||||
|
{
|
||||||
|
ui->ascii = cfg[0].u.choices.selected;
|
||||||
|
}
|
||||||
|
|
||||||
static void free_ui(game_ui *ui) {
|
static void free_ui(game_ui *ui) {
|
||||||
sfree(ui);
|
sfree(ui);
|
||||||
return;
|
return;
|
||||||
@ -2784,7 +2808,7 @@ const struct game thegame = {
|
|||||||
free_game,
|
free_game,
|
||||||
true, solve_game,
|
true, solve_game,
|
||||||
true, game_can_format_as_text_now, game_text_format,
|
true, game_can_format_as_text_now, game_text_format,
|
||||||
NULL, NULL, /* get_prefs, set_prefs */
|
get_prefs, set_prefs,
|
||||||
new_ui,
|
new_ui,
|
||||||
free_ui,
|
free_ui,
|
||||||
NULL, /* encode_ui */
|
NULL, /* encode_ui */
|
||||||
|
Reference in New Issue
Block a user