[Freeciv-Dev] (PR#13560) layers for the overview
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13560 >
This patch adds configurable layers to the overview.
There are four layers; background (land/ocean/fog), borders (player tile
ownership), units, and cities. The background layer should be split
further - we should split out fog-of-war into a separate layer but this
will take more work. The borders layer is disabled by default (so
default behavior isn't changed) but it was so easy to add I went ahead
and put it in. The units and cities layers give the same behavior as
now but are configurable - these too could be split further into "my"
versus "other" units/cities.
The options are added into the local-options dialog, in a new section
"overview". Eventually these will need to be more accessible - players
will want to turn layers on and off quickly to cycle through different
views to see what they need to know. For instance turning on the
pollution layer for a few seconds lets you see what areas need attention.
We have many ideas for future layers. These will require tileset
support (any layer needs to have its color combinations put into the
tileset). We shouldn't go overboard with adding layers, but since
toggling them is so easy we can have a good number. The only
restriction is the layers should be sufficiently few that players don't
get overwhelmed.
This is a change from the previous idea of overview "modes". Vasco and
I had discussed what the different modes might be. But Egor (evyscr)
pointed out that layers are more better because they allow more
combinations with the same number of options. This is basically his design.
And a screenshot (with borders enabled):
http://freeciv.org/~jdorje/overview.png .
-jason
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.134
diff -p -u -r1.134 options.c
--- client/options.c 28 Jul 2005 17:59:06 -0000 1.134
+++ client/options.c 28 Jul 2005 20:45:54 -0000
@@ -35,6 +35,7 @@
#include "clinet.h"
#include "cma_fec.h"
#include "mapview_common.h"
+#include "overview_common.h"
#include "plrdlg_common.h"
#include "tilespec.h"
@@ -81,6 +82,7 @@ bool update_city_text_in_refresh_tile =
const char *client_option_class_names[COC_MAX] = {
N_("Graphics"),
+ N_("Overview"),
N_("Sound"),
N_("Interface"),
N_("Network")
@@ -216,6 +218,23 @@ static client_option common_options[] =
N_("If this option is set then a newly-founded city will "
"havce its city dialog popped up automatically."),
COC_INTERFACE),
+
+ GEN_BOOL_OPTION(overview.layers[OLAYER_BACKGROUND],
+ N_("Background layer"),
+ N_("The background layer of the overview shows ocean, "
+ "land, and fog."), COC_OVERVIEW),
+ GEN_BOOL_OPTION(overview.layers[OLAYER_BORDERS],
+ N_("Borders layer"),
+ N_("The borders layer of the overview shows which tiles "
+ "are owned by each player."), COC_OVERVIEW),
+ GEN_BOOL_OPTION(overview.layers[OLAYER_UNITS],
+ N_("Units layer"),
+ N_("If enabled then units will be drawn on the overview."),
+ COC_OVERVIEW),
+ GEN_BOOL_OPTION(overview.layers[OLAYER_BACKGROUND],
+ N_("Cities layer"),
+ N_("If enabled then cities will be drawn on the overview."),
+ COC_OVERVIEW)
};
#undef GEN_INT_OPTION
#undef GEN_BOOL_OPTION
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.54
diff -p -u -r1.54 options.h
--- client/options.h 13 Jul 2005 15:41:32 -0000 1.54
+++ client/options.h 28 Jul 2005 20:45:54 -0000
@@ -59,6 +59,7 @@ enum client_option_type {
enum client_option_class {
COC_GRAPHICS,
+ COC_OVERVIEW,
COC_SOUND,
COC_INTERFACE,
COC_NETWORK,
Index: client/overview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/overview_common.c,v
retrieving revision 1.13
diff -p -u -r1.13 overview_common.c
--- client/overview_common.c 4 Jul 2005 17:48:36 -0000 1.13
+++ client/overview_common.c 28 Jul 2005 20:45:54 -0000
@@ -26,7 +26,11 @@
#include "mapview_g.h"
int OVERVIEW_TILE_SIZE = 2;
-struct overview overview;
+struct overview overview = {
+ .layers = {[OLAYER_BACKGROUND] = TRUE,
+ [OLAYER_UNITS] = TRUE,
+ [OLAYER_CITIES] = TRUE}
+};
/*
* Set to TRUE if the backing store is more recent than the version
@@ -102,42 +106,60 @@ static void gui_to_overview_pos(const st
****************************************************************************/
static struct color *overview_tile_color(struct tile *ptile)
{
- struct unit *punit;
- struct city *pcity;
+ if (overview.layers[OLAYER_CITIES]) {
+ struct city *pcity = tile_get_city(ptile);
- if (client_tile_get_known(ptile) == TILE_UNKNOWN) {
- return get_color(tileset, COLOR_OVERVIEW_UNKNOWN);
- } else if ((pcity = tile_get_city(ptile))) {
- if (pcity->owner == game.player_ptr) {
- return get_color(tileset, COLOR_OVERVIEW_MY_CITY);
- } else if (pplayers_allied(city_owner(pcity), game.player_ptr)) {
- /* Includes teams. */
- return get_color(tileset, COLOR_OVERVIEW_ALLIED_CITY);
- } else {
- return get_color(tileset, COLOR_OVERVIEW_ENEMY_CITY);
+ if (pcity) {
+ if (pcity->owner == game.player_ptr) {
+ return get_color(tileset, COLOR_OVERVIEW_MY_CITY);
+ } else if (pplayers_allied(city_owner(pcity), game.player_ptr)) {
+ /* Includes teams. */
+ return get_color(tileset, COLOR_OVERVIEW_ALLIED_CITY);
+ } else {
+ return get_color(tileset, COLOR_OVERVIEW_ENEMY_CITY);
+ }
}
- } else if ((punit = find_visible_unit(ptile))) {
- if (punit->owner == game.player_ptr) {
- return get_color(tileset, COLOR_OVERVIEW_MY_UNIT);
- } else if (pplayers_allied(unit_owner(punit), game.player_ptr)) {
- /* Includes teams. */
- return get_color(tileset, COLOR_OVERVIEW_ALLIED_UNIT);
- } else {
- return get_color(tileset, COLOR_OVERVIEW_ENEMY_UNIT);
+ }
+ if (overview.layers[OLAYER_UNITS]) {
+ struct unit *punit = find_visible_unit(ptile);
+
+ if (punit) {
+ if (punit->owner == game.player_ptr) {
+ return get_color(tileset, COLOR_OVERVIEW_MY_UNIT);
+ } else if (pplayers_allied(unit_owner(punit), game.player_ptr)) {
+ /* Includes teams. */
+ return get_color(tileset, COLOR_OVERVIEW_ALLIED_UNIT);
+ } else {
+ return get_color(tileset, COLOR_OVERVIEW_ENEMY_UNIT);
+ }
}
- } else if (is_ocean(ptile->terrain)) {
- if (client_tile_get_known(ptile) == TILE_KNOWN_FOGGED && draw_fog_of_war) {
- return get_color(tileset, COLOR_OVERVIEW_FOGGED_OCEAN);
- } else {
- return get_color(tileset, COLOR_OVERVIEW_OCEAN);
+ }
+ if (overview.layers[OLAYER_BORDERS]) {
+ struct player *owner = ptile->owner;
+
+ if (owner) {
+ return get_player_color(tileset, owner);
}
- } else {
- if (client_tile_get_known(ptile) == TILE_KNOWN_FOGGED && draw_fog_of_war) {
- return get_color(tileset, COLOR_OVERVIEW_FOGGED_LAND);
+ }
+ if (overview.layers[OLAYER_BACKGROUND] && ptile->terrain != T_UNKNOWN) {
+ if (is_ocean(ptile->terrain)) {
+ if (client_tile_get_known(ptile) == TILE_KNOWN_FOGGED
+ && draw_fog_of_war) {
+ return get_color(tileset, COLOR_OVERVIEW_FOGGED_OCEAN);
+ } else {
+ return get_color(tileset, COLOR_OVERVIEW_OCEAN);
+ }
} else {
- return get_color(tileset, COLOR_OVERVIEW_LAND);
+ if (client_tile_get_known(ptile) == TILE_KNOWN_FOGGED
+ && draw_fog_of_war) {
+ return get_color(tileset, COLOR_OVERVIEW_FOGGED_LAND);
+ } else {
+ return get_color(tileset, COLOR_OVERVIEW_LAND);
+ }
}
}
+
+ return get_color(tileset, COLOR_OVERVIEW_UNKNOWN);
}
/**************************************************************************
Index: client/overview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/overview_common.h,v
retrieving revision 1.4
diff -p -u -r1.4 overview_common.h
--- client/overview_common.h 24 Apr 2005 23:10:32 -0000 1.4
+++ client/overview_common.h 28 Jul 2005 20:45:54 -0000
@@ -18,6 +18,14 @@
#include "canvas_g.h"
+enum overview_layers {
+ OLAYER_BACKGROUND,
+ OLAYER_BORDERS,
+ OLAYER_UNITS,
+ OLAYER_CITIES,
+ OLAYER_COUNT
+};
+
/* Holds all information about the overview aka minimap. */
struct overview {
/* The following fields are controlled by mapview_common.c. */
@@ -29,6 +37,8 @@ struct overview {
/* A backing store for the window itself, wrapped. */
struct canvas *window;
+
+ bool layers[OLAYER_COUNT];
};
extern struct overview overview;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13560) layers for the overview,
Jason Short <=
|
|