[Freeciv-Dev] (PR#12158) draw city outlines
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12158 >
The ability to draw city outlines without the full grid has been an
oft-requested feature in freeciv. This patch does that. GUI support is
needed for the menu items (I added support for gui-gtk-2.0 but even this
needs improvement).
The only real problem is this uses the code drawing of tile boundaries
which I'd like to phase out in favor of sprites.
-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 20:24:10 -0000
@@ -1104,6 +1104,19 @@
}
/**************************************************************************
+ Toggle display of city outlines on the map
+**************************************************************************/
+void request_toggle_city_outlines(void)
+{
+ if (!can_client_change_view()) {
+ return;
+ }
+
+ draw_city_outlines = !draw_city_outlines;
+ update_map_canvas_visible();
+}
+
+/**************************************************************************
Toggle display of grid lines on the map
**************************************************************************/
void request_toggle_map_grid(void)
@@ -2112,6 +2125,14 @@
}
/**************************************************************************
+ Toggle drawing of city outlines.
+**************************************************************************/
+void key_city_outlines_toggle(void)
+{
+ request_toggle_city_outlines();
+}
+
+/**************************************************************************
...
**************************************************************************/
void key_map_grid_toggle(void)
Index: client/control.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.h,v
retrieving revision 1.47
diff -u -r1.47 control.h
--- client/control.h 5 Feb 2005 07:41:53 -0000 1.47
+++ client/control.h 7 Feb 2005 20:24:10 -0000
@@ -83,6 +83,7 @@
void request_unit_wakeup(struct unit *punit);
void request_diplomat_action(enum diplomat_actions action, int dipl_id,
int target_id, int value);
+void request_toggle_city_outlines(void);
void request_toggle_map_grid(void);
void request_toggle_map_borders(void);
void request_toggle_city_names(void);
@@ -135,6 +136,7 @@
void key_focus_unit_toggle(void);
void key_fog_of_war_toggle(void);
void key_end_turn(void);
+void key_city_outlines_toggle(void);
void key_map_grid_toggle(void);
void key_map_borders_toggle(void);
void key_quickselect(enum quickselect_type qtype);
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 20:24:11 -0000
@@ -1344,20 +1344,34 @@
{
enum direction8 dir;
- if (!draw_map_grid) {
- return;
- }
-
- for (dir = 0; dir < 8; dir++) {
- int start_x, start_y, end_x, end_y;
-
- if (get_tile_boundaries(dir, 0, 1,
- &start_x, &start_y, &end_x, &end_y)) {
- canvas_put_line(pcanvas,
- get_grid_color(ptile, dir),
- LINE_NORMAL,
- canvas_x + start_x, canvas_y + start_y,
- end_x - start_x, end_y - start_y);
+ if (draw_map_grid) {
+ for (dir = 0; dir < 8; dir++) {
+ int start_x, start_y, end_x, end_y;
+
+ if (get_tile_boundaries(dir, 0, 1,
+ &start_x, &start_y, &end_x, &end_y)) {
+ canvas_put_line(pcanvas,
+ get_grid_color(ptile, dir),
+ LINE_NORMAL,
+ canvas_x + start_x, canvas_y + start_y,
+ end_x - start_x, end_y - start_y);
+ }
+ }
+ } else if (draw_city_outlines) {
+ for (dir = 0; dir < 8; dir++) {
+ int start_x, start_y, end_x, end_y;
+ struct tile *tile2 = mapstep(ptile, dir);
+
+ if (XOR(player_in_city_radius(game.player_ptr, ptile),
+ player_in_city_radius(game.player_ptr, tile2))
+ && get_tile_boundaries(dir, 0, 1,
+ &start_x, &start_y, &end_x, &end_y)) {
+ canvas_put_line(pcanvas,
+ COLOR_STD_WHITE,
+ LINE_NORMAL,
+ canvas_x + start_x, canvas_y + start_y,
+ end_x - start_x, end_y - start_y);
+ }
}
}
}
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.119
diff -u -r1.119 options.c
--- client/options.c 7 Feb 2005 08:09:10 -0000 1.119
+++ client/options.c 7 Feb 2005 20:24:11 -0000
@@ -210,6 +210,7 @@
/** View Options: **/
+bool draw_city_outlines = TRUE;
bool draw_map_grid = FALSE;
bool draw_city_names = TRUE;
bool draw_city_growth = TRUE;
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.47
diff -u -r1.47 options.h
--- client/options.h 5 Feb 2005 19:46:32 -0000 1.47
+++ client/options.h 7 Feb 2005 20:24:11 -0000
@@ -119,6 +119,7 @@
/** View Options: **/
+extern bool draw_city_outlines;
extern bool draw_map_grid;
extern bool draw_city_names;
extern bool draw_city_growth;
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.60
diff -u -r1.60 menu.c
--- client/gui-gtk-2.0/menu.c 5 Feb 2005 19:46:32 -0000 1.60
+++ client/gui-gtk-2.0/menu.c 7 Feb 2005 20:24:11 -0000
@@ -90,6 +90,7 @@
MENU_GOVERNMENT_WORKLISTS,
MENU_GOVERNMENT_REVOLUTION,
+ MENU_VIEW_SHOW_CITY_OUTLINES,
MENU_VIEW_SHOW_MAP_GRID,
MENU_VIEW_SHOW_NATIONAL_BORDERS,
MENU_VIEW_SHOW_CITY_NAMES,
@@ -284,6 +285,11 @@
GtkWidget *widget)
{
switch(callback_action) {
+ case MENU_VIEW_SHOW_CITY_OUTLINES:
+ if (draw_city_outlines ^ GTK_CHECK_MENU_ITEM(widget)->active) {
+ key_city_outlines_toggle();
+ }
+ break;
case MENU_VIEW_SHOW_MAP_GRID:
if (draw_map_grid ^ GTK_CHECK_MENU_ITEM(widget)->active)
key_map_grid_toggle();
- [Freeciv-Dev] (PR#12158) draw city outlines,
Jason Short <=
|
|