summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-02-08 23:46:35 +0000
committerterkhen <terkhen@openttd.org>2010-02-08 23:46:35 +0000
commit52312ea17f348ffc9409465845ef50db05800435 (patch)
treeb3ecbee005061d990a643e54fade7d108ae3293d /src
parent3c627747d330a699a099f4330796654c549886a7 (diff)
downloadopenttd-52312ea17f348ffc9409465845ef50db05800435.tar.xz
(svn r19064) -Feature: Allow to select different land colours for the smallmap (reworked by Alberth).
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/settings.cpp13
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/smallmap_gui.cpp103
-rw-r--r--src/smallmap_gui.h3
-rw-r--r--src/table/settings.h2
7 files changed, 110 insertions, 17 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index cc22eadd9..db77d66f6 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1165,6 +1165,10 @@ STR_CONFIG_SETTING_EDGES_NOT_WATER :{WHITE}One or m
STR_CONFIG_SETTING_STATION_SPREAD :{LTBLUE}Max station spread: {ORANGE}{STRING1} {RED}Warning: High setting slows game
STR_CONFIG_SETTING_SERVICEATHELIPAD :{LTBLUE}Service helicopters at helipads automatically: {ORANGE}{STRING1}
STR_CONFIG_SETTING_LINK_TERRAFORM_TOOLBAR :{LTBLUE}Link landscape toolbar to rail/road/water/airport toolbars: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR :{LTBLUE}Land colour used at the smallmap: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_GREEN :Green
+STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_DARK_GREEN :Dark green
+STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_VIOLET :Violet
STR_CONFIG_SETTING_REVERSE_SCROLLING :{LTBLUE}Reverse scroll direction: {ORANGE}{STRING1}
STR_CONFIG_SETTING_SMOOTH_SCROLLING :{LTBLUE}Smooth viewport scrolling: {ORANGE}{STRING1}
STR_CONFIG_SETTING_MEASURE_TOOLTIP :{LTBLUE}Show a measurement tooltip when using various build-tools: {ORANGE}{STRING1}
diff --git a/src/settings.cpp b/src/settings.cpp
index 9af46b4be..767bfbb1a 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -63,6 +63,7 @@
#include "ship.h"
#include "company_base.h"
#include "engine_base.h"
+#include "smallmap_gui.h"
#include "void_map.h"
#include "station_base.h"
@@ -658,6 +659,18 @@ static bool RedrawScreen(int32 p1)
return true;
}
+/**
+ * Redraw the smallmap after a colour scheme change.
+ * @param p1 Callback parameter.
+ * @return Always true.
+ */
+static bool RedrawSmallmap(int32 p1)
+{
+ BuildLandLegend();
+ SetWindowClassesDirty(WC_SMALLMAP);
+ return true;
+}
+
static bool InvalidateDetailsWindow(int32 p1)
{
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index ac8846f34..b652ea5d2 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1256,6 +1256,7 @@ static SettingEntry _settings_ui_display[] = {
SettingEntry("gui.liveries"),
SettingEntry("gui.show_track_reservation"),
SettingEntry("gui.expenses_layout"),
+ SettingEntry("gui.smallmap_land_colour"),
};
/** Display options sub-page */
static SettingsPage _settings_ui_display_page = {_settings_ui_display, lengthof(_settings_ui_display)};
diff --git a/src/settings_type.h b/src/settings_type.h
index 71b5116f6..b875844f7 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -54,6 +54,7 @@ struct GUISettings {
bool autoscroll; ///< scroll when moving mouse to the edge
byte errmsg_duration; ///< duration of error message
bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
+ uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap
bool reverse_scroll; ///< right-Click-Scrolling scrolls in the opposite direction
bool smooth_scroll; ///< smooth scroll viewports
bool measure_tooltip; ///< show a permanent tooltip when dragging tools
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 5763387b3..4ac191c3b 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -56,6 +56,8 @@ static int _smallmap_industry_count; ///< Number of used industries
/** Macro for ordinary entry of LegendAndColour */
#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, true, false, false}
+/** Macro for an entry with configurable colour. */
+#define MC(b) MK(0, b)
/** Macro for end of list marker in arrays of LegendAndColour */
#define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, true, true, false}
/** Macro for break marker in arrays of LegendAndColour.
@@ -73,12 +75,13 @@ struct LegendAndColour {
};
/** Legend text giving the colours to look for on the minimap */
-static const LegendAndColour _legend_land_contours[] = {
- MK(0x5A, STR_SMALLMAP_LEGENDA_100M),
- MK(0x5C, STR_SMALLMAP_LEGENDA_200M),
- MK(0x5E, STR_SMALLMAP_LEGENDA_300M),
- MK(0x1F, STR_SMALLMAP_LEGENDA_400M),
- MK(0x27, STR_SMALLMAP_LEGENDA_500M),
+static LegendAndColour _legend_land_contours[] = {
+ /* The colours for the following values are set at BuildLandLegend() based on each colour scheme. */
+ MC(STR_SMALLMAP_LEGENDA_100M),
+ MC(STR_SMALLMAP_LEGENDA_200M),
+ MC(STR_SMALLMAP_LEGENDA_300M),
+ MC(STR_SMALLMAP_LEGENDA_400M),
+ MC(STR_SMALLMAP_LEGENDA_500M),
MS(0xD7, STR_SMALLMAP_LEGENDA_ROADS),
MK(0x0A, STR_SMALLMAP_LEGENDA_RAILROADS),
@@ -136,6 +139,7 @@ static const LegendAndColour _legend_land_owners[] = {
MKEND()
};
#undef MK
+#undef MC
#undef MS
#undef MKEND
@@ -188,10 +192,8 @@ static const LegendAndColour * const _legend_table[] = {
#define MKCOLOUR(x) TO_LE32X(x)
-/**
- * Height encodings; MAX_TILE_HEIGHT + 1 levels, from 0 to MAX_TILE_HEIGHT
- */
-static const uint32 _map_height_bits[] = {
+/** Height map colours for the green colour scheme, ordered by height. */
+static const uint32 _green_map_heights[] = {
MKCOLOUR(0x5A5A5A5A),
MKCOLOUR(0x5A5B5A5B),
MKCOLOUR(0x5B5B5B5B),
@@ -209,7 +211,71 @@ static const uint32 _map_height_bits[] = {
MKCOLOUR(0x27272727),
MKCOLOUR(0x27272727),
};
-assert_compile(lengthof(_map_height_bits) == MAX_TILE_HEIGHT + 1);
+assert_compile(lengthof(_green_map_heights) == MAX_TILE_HEIGHT + 1);
+
+/** Height map colours for the dark green colour scheme, ordered by height. */
+static const uint32 _dark_green_map_heights[] = {
+ MKCOLOUR(0x60606060),
+ MKCOLOUR(0x60616061),
+ MKCOLOUR(0x61616161),
+ MKCOLOUR(0x61626162),
+ MKCOLOUR(0x62626262),
+ MKCOLOUR(0x62636263),
+ MKCOLOUR(0x63636363),
+ MKCOLOUR(0x63646364),
+ MKCOLOUR(0x64646464),
+ MKCOLOUR(0x64656465),
+ MKCOLOUR(0x65656565),
+ MKCOLOUR(0x65666566),
+ MKCOLOUR(0x66666666),
+ MKCOLOUR(0x66676667),
+ MKCOLOUR(0x67676767),
+ MKCOLOUR(0x67676767),
+};
+assert_compile(lengthof(_dark_green_map_heights) == MAX_TILE_HEIGHT + 1);
+
+/** Height map colours for the violet colour scheme, ordered by height. */
+static const uint32 _violet_map_heights[] = {
+ MKCOLOUR(0x80808080),
+ MKCOLOUR(0x80818081),
+ MKCOLOUR(0x81818181),
+ MKCOLOUR(0x81828182),
+ MKCOLOUR(0x82828282),
+ MKCOLOUR(0x82838283),
+ MKCOLOUR(0x83838383),
+ MKCOLOUR(0x83848384),
+ MKCOLOUR(0x84848484),
+ MKCOLOUR(0x84858485),
+ MKCOLOUR(0x85858585),
+ MKCOLOUR(0x85868586),
+ MKCOLOUR(0x86868686),
+ MKCOLOUR(0x86878687),
+ MKCOLOUR(0x87878787),
+ MKCOLOUR(0x87878787),
+};
+assert_compile(lengthof(_violet_map_heights) == MAX_TILE_HEIGHT + 1);
+
+/** Colour scheme of the smallmap. */
+struct SmallMapColourScheme {
+ const uint32 *height_colours; ///< Colour of each level in a heightmap.
+ uint32 default_colour; ///< Default colour of the land.
+};
+
+/** Available colour schemes for height maps. */
+static const SmallMapColourScheme _heightmap_schemes[] = {
+ {_green_map_heights, MKCOLOUR(0x54545454)}, ///< Green colour scheme.
+ {_dark_green_map_heights, MKCOLOUR(0x62626262)}, ///< Dark green colour scheme.
+ {_violet_map_heights, MKCOLOUR(0x82828282)}, ///< Violet colour scheme.
+};
+
+void BuildLandLegend()
+{
+ _legend_land_contours[0].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[0];
+ _legend_land_contours[1].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[4];
+ _legend_land_contours[2].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[8];
+ _legend_land_contours[3].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[12];
+ _legend_land_contours[4].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[14];
+}
struct AndOr {
uint32 mor;
@@ -295,7 +361,8 @@ static inline TileType GetEffectiveTileType(TileIndex tile)
*/
static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
{
- return ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]);
+ const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
+ return ApplyMask(cs->height_colours[TileHeight(tile)], &_smallmap_contours_andor[t]);
}
/**
@@ -307,7 +374,8 @@ static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
*/
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
{
- return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
+ const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
+ return ApplyMask(cs->default_colour, &_smallmap_vehicles_andor[t]);
}
/**
@@ -329,7 +397,8 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
}
}
- return ApplyMask(_smallmap_industry_show_heightmap ? _map_height_bits[TileHeight(tile)] : MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
+ const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
+ return ApplyMask(_smallmap_industry_show_heightmap ? cs->height_colours[TileHeight(tile)] : cs->default_colour, &_smallmap_vehicles_andor[t]);
}
/**
@@ -353,7 +422,8 @@ static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
}
/* Ground colour */
- return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_contours_andor[t]);
+ const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
+ return ApplyMask(cs->default_colour, &_smallmap_contours_andor[t]);
}
@@ -794,7 +864,7 @@ class SmallMapWindow : public Window {
/* Fill with some special colours */
_owner_colours[OWNER_TOWN] = MKCOLOUR(0xB4B4B4B4);
- _owner_colours[OWNER_NONE] = MKCOLOUR(0x54545454);
+ _owner_colours[OWNER_NONE] = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].default_colour;
_owner_colours[OWNER_WATER] = MKCOLOUR(0xCACACACA);
_owner_colours[OWNER_END] = MKCOLOUR(0x20202020); // Industry
@@ -858,6 +928,7 @@ public:
this->LowerWidget(this->map_type + SM_WIDGET_CONTOUR);
_smallmap_industry_show_heightmap = false;
+ BuildLandLegend();
this->SetWidgetLoweredState(SM_WIDGET_SHOW_HEIGHT, _smallmap_industry_show_heightmap);
this->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, this->show_towns);
diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h
index 62ace3280..1a2bc54dd 100644
--- a/src/smallmap_gui.h
+++ b/src/smallmap_gui.h
@@ -7,12 +7,13 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file smallmap_gui.h Smallmap GUI functions, used at newgrf.cpp and toolbar_gui.cpp. */
+/** @file smallmap_gui.h Smallmap GUI functions. */
#ifndef SMALLMAP_GUI_H
#define SMALLMAP_GUI_H
void BuildIndustriesLegend();
void ShowSmallMap();
+void BuildLandLegend();
#endif /* SMALLMAP_GUI_H */
diff --git a/src/table/settings.h b/src/table/settings.h
index 5fabeae25..cf14ede3c 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -13,6 +13,7 @@
static bool v_PositionMainToolbar(int32 p1);
static bool PopulationInLabelActive(int32 p1);
static bool RedrawScreen(int32 p1);
+static bool RedrawSmallmap(int32 p1);
static bool InvalidateDetailsWindow(int32 p1);
static bool InvalidateStationBuildWindow(int32 p1);
static bool InvalidateBuildIndustryWindow(int32 p1);
@@ -555,6 +556,7 @@ const SettingDesc _settings[] = {
SDTC_VAR(gui.window_soft_limit, SLE_UINT8, S, D0, 20, 5, 255, 1, STR_CONFIG_SETTING_SOFT_LIMIT, NULL),
SDTC_BOOL(gui.population_in_label, S, 0, true, STR_CONFIG_SETTING_POPULATION_IN_LABEL, PopulationInLabelActive),
SDTC_BOOL(gui.link_terraform_toolbar, S, 0, false, STR_CONFIG_SETTING_LINK_TERRAFORM_TOOLBAR, NULL),
+ SDTC_VAR(gui.smallmap_land_colour, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR, RedrawSmallmap),
SDTC_VAR(gui.liveries, SLE_UINT8, S, MS, 2, 0, 2, 0, STR_CONFIG_SETTING_LIVERIES, RedrawScreen),
SDTC_BOOL(gui.prefer_teamchat, S, 0, false, STR_CONFIG_SETTING_PREFER_TEAMCHAT, NULL),
SDTC_VAR(gui.scrollwheel_scrolling, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING, NULL),