ref: cb8dcc34f7c656b8603a510617e35492a0d16b8c
parent: 96d65e852cea8a95001fa70e3ec2996d4ea5e2b4
author: Simon Tatham <[email protected]>
date: Sat Nov 18 08:56:42 EST 2023
Untangle: turn #define VERTEX_NUMBERS into a preference. This compile-time definition switches the game into showing a distinct non-negative integer for each vertex, instead of indistinguishable blobs. Its main use to me in the past has been when I'm trying to planarise 'real' graphs, that is, graphs I got from outside the game and wanted a planar embedding of. Having made one in Untangle's UI I could then read off which vertex was which. That's an unusual use of the game, but _might_ be useful to someone else. Perhaps a more interesting use of this feature would be to direct someone else's play verbally - it would be much easier to tell them which vertex to click on that way!
--- a/untangle.c
+++ b/untangle.c
@@ -1054,6 +1054,12 @@
* crossing.
*/
bool show_crossed_edges;
+
+ /*
+ * User preference option to show vertices as numbers instead of
+ * circular blobs, so you can easily tell them apart.
+ */
+ bool vertex_numbers;
};
static game_ui *new_ui(const game_state *state)
@@ -1063,6 +1069,7 @@
ui->just_moved = ui->just_dragged = false;
ui->snap_to_grid = false;
ui->show_crossed_edges = false;
+ ui->vertex_numbers = false;
return ui;
}
@@ -1070,7 +1077,7 @@
{
config_item *cfg;
- cfg = snewn(3, config_item);
+ cfg = snewn(4, config_item);
cfg[0].name = "Snap points to a grid";
cfg[0].kw = "snap-to-grid";
@@ -1082,9 +1089,16 @@
cfg[1].type = C_BOOLEAN;
cfg[1].u.boolean.bval = ui->show_crossed_edges;
- cfg[2].name = NULL;
- cfg[2].type = C_END;
+ cfg[2].name = "Display style for vertices";
+ cfg[2].kw = "vertex-style";
+ cfg[2].type = C_CHOICES;
+ cfg[2].u.choices.choicenames = ":Circles:Numbers";
+ cfg[2].u.choices.choicekws = ":circle:number";
+ cfg[2].u.choices.selected = ui->vertex_numbers;
+ cfg[3].name = NULL;
+ cfg[3].type = C_END;
+
return cfg;
}
@@ -1092,6 +1106,7 @@
{
ui->snap_to_grid = cfg[0].u.boolean.bval;
ui->show_crossed_edges = cfg[1].u.boolean.bval;
+ ui->vertex_numbers = cfg[2].u.choices.selected;
}
static void free_ui(game_ui *ui)
@@ -1472,19 +1487,17 @@
}
if (c == thisc) {
-#ifdef VERTEX_NUMBERS
- draw_circle(dr, ds->x[i], ds->y[i], DRAG_THRESHOLD, bg, bg);
- {
- char buf[80];
- sprintf(buf, "%d", i);
- draw_text(dr, ds->x[i], ds->y[i], FONT_VARIABLE,
+ if (ui->vertex_numbers) {
+ char buf[80];
+ draw_circle(dr, ds->x[i], ds->y[i], DRAG_THRESHOLD, bg, bg);
+ sprintf(buf, "%d", i);
+ draw_text(dr, ds->x[i], ds->y[i], FONT_VARIABLE,
DRAG_THRESHOLD*3/2,
- ALIGN_VCENTRE|ALIGN_HCENTRE, c, buf);
- }
-#else
- draw_circle(dr, ds->x[i], ds->y[i], CIRCLE_RADIUS,
- c, COL_OUTLINE);
-#endif
+ ALIGN_VCENTRE|ALIGN_HCENTRE, c, buf);
+ } else {
+ draw_circle(dr, ds->x[i], ds->y[i], CIRCLE_RADIUS,
+ c, COL_OUTLINE);
+ }
}
}
}