[Freeciv-Dev] (PR#12160) better behavior of 't'
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12160 >
In the 't' (city overlay) behavior...
It's hard to remove colors since you have to cycle through all of them.
There should be more colors but this would make the problem even worse.
This patch fixes both problems. Each press of 't' toggles whether the
city is colored at all. And each time a city is colored the 'global'
color index is increased. This means it's easier to get cities to be
different colors, and also easier to get the colors to go away.
I also added COLOR_STD_CYAN and moved WHITE to the end.
I also think maybe the colors should be removed at the end of each turn.
But for now this will do.
-jason
? fog
? fog.c
? fog.png
? foo
? data/isotrident/grid.png
? data/isotrident/grid.xcf
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.153
diff -u -r1.153 control.c
--- client/control.c 5 Feb 2005 07:41:53 -0000 1.153
+++ client/control.c 7 Feb 2005 21:10:16 -0000
@@ -1396,7 +1396,7 @@
/* We have to refresh the tile before moving. This will draw
* the tile without the unit (because it was unlinked above). */
if (unit_type_flag(punit->type, F_CITIES)
- && punit->client.color != 0) {
+ && punit->client.colored) {
/* For settlers with an overlay, redraw the entire area of the
* overlay. */
int width = get_citydlg_canvas_width();
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.177
diff -u -r1.177 mapview_common.c
--- client/mapview_common.c 6 Feb 2005 23:36:20 -0000 1.177
+++ client/mapview_common.c 7 Feb 2005 21:10:17 -0000
@@ -1013,21 +1013,21 @@
}
/*
- * pcity->client.color is an index into the city_colors array. The default
- * color index is DEFAULT_CITY_COLOR in city.h. When toggle_city_color is
- * called the index moves forward one position. Each color in the array
- * tells what color the citymap will be drawn on the mapview; COLOR_STD_LAST
- * is a marker meaning nothing will be drawn (which of course is the
- * default).
+ * pcity->client.color_index is an index into the city_colors array.
+ * When toggle_city_color is called the city's coloration is toggled. When
+ * a city is newly colored its color is taken from color_index and
+ * color_index is moved forward one position. Each color in the array
+ * tells what color the citymap will be drawn on the mapview.
*
* This array can be added to without breaking anything elsewhere.
*/
static enum color_std city_colors[] = {
- COLOR_STD_LAST, /* Default color (see DEFAULT_CITY_COLOR in city.h). */
COLOR_STD_RED,
- COLOR_STD_WHITE,
COLOR_STD_YELLOW,
+ COLOR_STD_CYAN,
+ COLOR_STD_WHITE
};
+static int color_index = 0;
#define NUM_CITY_COLORS ARRAY_SIZE(city_colors)
@@ -1042,7 +1042,13 @@
int width = get_citydlg_canvas_width();
int height = get_citydlg_canvas_height();
- pcity->client.color = (pcity->client.color + 1) % NUM_CITY_COLORS;
+ if (pcity->client.colored) {
+ pcity->client.colored = FALSE;
+ } else {
+ pcity->client.colored = TRUE;
+ pcity->client.color_index = color_index;
+ color_index = (color_index + 1) % NUM_CITY_COLORS;
+ }
tile_to_canvas_pos(&canvas_x, &canvas_y, pcity->tile);
update_map_canvas(canvas_x - (width - NORMAL_TILE_WIDTH) / 2,
@@ -1061,7 +1067,13 @@
int width = get_citydlg_canvas_width();
int height = get_citydlg_canvas_height();
- punit->client.color = (punit->client.color + 1) % NUM_CITY_COLORS;
+ if (punit->client.colored) {
+ punit->client.colored = FALSE;
+ } else {
+ punit->client.colored = TRUE;
+ punit->client.color_index = color_index;
+ color_index = (color_index + 1) % NUM_CITY_COLORS;
+ }
tile_to_canvas_pos(&canvas_x, &canvas_y, punit->tile);
update_map_canvas(canvas_x - (width - NORMAL_TILE_WIDTH) / 2,
@@ -1562,22 +1574,21 @@
pcity = find_city_or_settler_near_tile(ptile, &punit);
if (pcity
- && city_colors[pcity->client.color] != COLOR_STD_LAST
+ && pcity->client.colored
&& map_to_city_map(&city_x, &city_y, pcity, ptile)) {
enum city_tile_type worker = get_worker_city(pcity, city_x, city_y);
put_city_worker(mapview_canvas.store,
- city_colors[pcity->client.color], worker,
+ city_colors[pcity->client.color_index], worker,
canvas_x2, canvas_y2);
if (worker == C_TILE_WORKER) {
put_city_tile_output(pcity, city_x, city_y,
mapview_canvas.store, canvas_x2, canvas_y2);
}
- } else if (punit
- && city_colors[punit->client.color] != COLOR_STD_LAST) {
+ } else if (punit && punit->client.colored) {
/* Draw citymap overlay for settlers. */
put_city_worker(mapview_canvas.store,
- city_colors[punit->client.color], C_TILE_EMPTY,
+ city_colors[punit->client.color_index], C_TILE_EMPTY,
canvas_x2, canvas_y2);
}
}
@@ -2013,7 +2024,7 @@
if (!closest_settler) {
closest_settler = psettler;
}
- if (!best_settler && psettler->client.color != 0) {
+ if (!best_settler && psettler->client.colored) {
best_settler = psettler;
}
}
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.312
diff -u -r1.312 city.c
--- common/city.c 5 Feb 2005 05:36:00 -0000 1.312
+++ common/city.c 7 Feb 2005 21:10:18 -0000
@@ -2567,7 +2567,7 @@
pcity->client.occupied = FALSE;
pcity->client.happy = pcity->client.unhappy = FALSE;
- pcity->client.color = DEFAULT_CITY_COLOR;
+ pcity->client.colored = FALSE;
pcity->debug = FALSE;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.199
diff -u -r1.199 city.h
--- common/city.h 3 Feb 2005 08:38:55 -0000 1.199
+++ common/city.h 7 Feb 2005 21:10:18 -0000
@@ -267,8 +267,8 @@
bool happy, unhappy;
/* The color is an index into the city_colors array in mapview_common */
-#define DEFAULT_CITY_COLOR 0
- int color;
+ bool colored;
+ int color_index;
} client;
int steal; /* diplomats steal once; for spies, gets harder */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.226
diff -u -r1.226 unit.c
--- common/unit.c 22 Jan 2005 19:45:43 -0000 1.226
+++ common/unit.c 7 Feb 2005 21:10:18 -0000
@@ -1784,7 +1784,7 @@
punit->ord_city = 0;
set_unit_activity(punit, ACTIVITY_IDLE);
punit->occupy = 0;
- punit->client.color = DEFAULT_CITY_COLOR;
+ punit->client.colored = FALSE;
punit->has_orders = FALSE;
return punit;
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.135
diff -u -r1.135 unit.h
--- common/unit.h 5 Feb 2005 07:41:54 -0000 1.135
+++ common/unit.h 7 Feb 2005 21:10:18 -0000
@@ -164,7 +164,8 @@
int occupy; /* number of units that occupy transporter */
struct {
/* Equivalent to pcity->client.color. Only for F_CITIES units. */
- int color;
+ bool colored;
+ int color_index;
} client;
bool has_orders;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12160) better behavior of 't',
Jason Short <=
|
|