Add setting for alternative linkgraph overlay colour schemes

pull/182/head
Jonathan G Rennison 4 years ago
parent 1fd9c929ef
commit f26143f063

@ -1374,6 +1374,13 @@ STR_CONFIG_SETTING_SHOW_DEPOT_SELL_GUI_HELPTEXT :Show go to depo
STR_CONFIG_SETTING_OPEN_VEHICLE_GUI_CLONE_SHARE :Open new vehicle window when share-cloning: {STRING2}
STR_CONFIG_SETTING_OPEN_VEHICLE_GUI_CLONE_SHARE_HELPTEXT :When enabled, open the newly cloned vehicle's window when cloning a vehicle with shared orders from the depot window.
STR_CONFIG_SETTING_LINKGRAPH_COLOURS :Cargo flow overlay colours: {STRING2}
STR_CONFIG_SETTING_LINKGRAPH_COLOURS_HELPTEXT :Set the colour the scheme used for the cargo flow overlay.
STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREEN_TO_RED :Green to red (original)
STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREEN_TO_BLUE :Green to blue
STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREY_TO_RED :Grey to red
STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREYSCALE :Greyscale
STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES :Enable signals on bridges/tunnels advanced modes: {STRING2}
STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES_HELPTEXT :Enables use of advanced modes of signal simulation on bridges and tunnels. When disabled, bridges/tunnels which are not already in an advanced mode cannot be changed to an advanced mode, however other players may choose to enable this setting and use an advanced mode.

@ -31,10 +31,27 @@
* Colours for the various "load" states of links. Ordered from "unused" to
* "overloaded".
*/
const uint8 LinkGraphOverlay::LINK_COLOURS[] = {
const uint8 LinkGraphOverlay::LINK_COLOURS[][12] = {
{
0x0f, 0xd1, 0xd0, 0x57,
0x55, 0x53, 0xbf, 0xbd,
0xba, 0xb9, 0xb7, 0xb5
},
{
0x0f, 0xd1, 0xd0, 0x57,
0x55, 0x53, 0x96, 0x95,
0x94, 0x93, 0x92, 0x91
},
{
0x0f, 0x0b, 0x09, 0x07,
0x05, 0x03, 0xbf, 0xbd,
0xba, 0xb9, 0xb7, 0xb5
},
{
0x0f, 0x0b, 0x0a, 0x09,
0x08, 0x07, 0x06, 0x05,
0x04, 0x03, 0x02, 0x01
}
};
/**
@ -377,7 +394,7 @@ void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const
void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &cargo) const
{
uint usage_or_plan = min(cargo.capacity * 2 + 1, max(cargo.usage, cargo.planned));
int colour = LinkGraphOverlay::LINK_COLOURS[usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS) / (cargo.capacity * 2 + 2)];
int colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS[0]) / (cargo.capacity * 2 + 2)];
int dash = cargo.shared ? this->scale * 4 : 0;
/* Move line a bit 90° against its dominant direction to prevent it from
@ -486,7 +503,7 @@ NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI(int *biggest_index)
NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index)
{
NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE);
for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS); ++i) {
for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS[0]); ++i) {
NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST);
wid->SetMinimalSize(50, FONT_HEIGHT_SMALL);
wid->SetFill(1, 1);
@ -560,7 +577,7 @@ static const NWidgetPart _nested_linkgraph_legend_widgets[] = {
};
assert_compile(WID_LGL_SATURATION_LAST - WID_LGL_SATURATION_FIRST ==
lengthof(LinkGraphOverlay::LINK_COLOURS) - 1);
lengthof(LinkGraphOverlay::LINK_COLOURS[0]) - 1);
static WindowDesc _linkgraph_legend_desc(
WDP_AUTO, "toolbar_linkgraph", 0, 0,
@ -642,7 +659,8 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
DrawCompanyIcon(cid, (r.left + r.right + 1 - sprite_size.width) / 2, (r.top + r.bottom + 1 - sprite_size.height) / 2);
}
if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, LinkGraphOverlay::LINK_COLOURS[widget - WID_LGL_SATURATION_FIRST]);
uint8 colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST];
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, colour);
StringID str = STR_NULL;
if (widget == WID_LGL_SATURATION_FIRST) {
str = STR_LINKGRAPH_LEGEND_UNUSED;
@ -651,7 +669,9 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
} else if (widget == (WID_LGL_SATURATION_LAST + WID_LGL_SATURATION_FIRST) / 2) {
str = STR_LINKGRAPH_LEGEND_SATURATED;
}
if (str != STR_NULL) DrawString(r.left, r.right, (r.top + r.bottom + 1 - FONT_HEIGHT_SMALL) / 2, str, TC_FROMSTRING, SA_HOR_CENTER);
if (str != STR_NULL) {
DrawString(r.left, r.right, (r.top + r.bottom + 1 - FONT_HEIGHT_SMALL) / 2, str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER);
}
}
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) return;

@ -53,7 +53,7 @@ public:
typedef std::vector<StationSupplyInfo> StationSupplyList;
typedef std::vector<LinkInfo> LinkList;
static const uint8 LINK_COLOURS[];
static const uint8 LINK_COLOURS[][12];
/**
* Create a link graph overlay for the specified window.

@ -1296,6 +1296,12 @@ static bool ViewportMapShowTunnelModeChanged(int32 p1)
return RedrawScreen(p1);
}
static bool UpdateLinkgraphColours(int32 p1)
{
BuildLinkStatsLegend();
return RedrawScreen(p1);
}
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
static void ValidateSettings()
{

@ -1579,6 +1579,7 @@ static SettingsContainer &GetSettingsTree()
graphics->Add(new SettingEntry("gui.zoom_min"));
graphics->Add(new SettingEntry("gui.zoom_max"));
graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
graphics->Add(new SettingEntry("gui.linkgraph_colours"));
graphics->Add(new SettingEntry("gui.graph_line_thickness"));
graphics->Add(new SettingEntry("gui.show_vehicle_route_steps"));
graphics->Add(new SettingEntry("gui.show_vehicle_route"));

@ -201,6 +201,7 @@ struct GUISettings : public TimeSettings {
bool adv_sig_bridge_tun_modes; ///< Enable advanced modes for signals on bridges/tunnels.
bool show_depot_sell_gui; ///< Show go to depot and sell in UI
bool open_vehicle_gui_clone_share; ///< Open vehicle GUI when share-cloning vehicle from depot GUI
uint8 linkgraph_colours; ///< linkgraph overlay colours
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.

@ -214,7 +214,7 @@ void BuildLinkStatsLegend()
for (; i < _smallmap_cargo_count + lengthof(_linkstat_colours_in_legenda); ++i) {
_legend_linkstats[i].legend = STR_EMPTY;
_legend_linkstats[i].colour = LinkGraphOverlay::LINK_COLOURS[_linkstat_colours_in_legenda[i - _smallmap_cargo_count]];
_legend_linkstats[i].colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][_linkstat_colours_in_legenda[i - _smallmap_cargo_count]];
_legend_linkstats[i].show_on_map = true;
}

@ -52,6 +52,7 @@ static bool SimulatedWormholeSignalsChanged(int32 p1);
static bool EnableSingleVehSharedOrderGuiChanged(int32 p1);
static bool CheckYapfRailSignalPenalties(int32 p1);
static bool ViewportMapShowTunnelModeChanged(int32 p1);
static bool UpdateLinkgraphColours(int32 p1);
static bool UpdateClientName(int32 p1);
static bool UpdateServerPassword(int32 p1);
@ -4952,6 +4953,20 @@ strhelp = STR_CONFIG_SETTING_SHOW_NEWGRF_NAME_HELPTEXT
proc = RedrawScreen
cat = SC_ADVANCED
[SDTC_VAR]
var = gui.linkgraph_colours
type = SLE_UINT8
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_MULTISTRING
def = 0
min = 0
max = 3
str = STR_CONFIG_SETTING_LINKGRAPH_COLOURS
strhelp = STR_CONFIG_SETTING_LINKGRAPH_COLOURS_HELPTEXT
strval = STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREEN_TO_RED
proc = UpdateLinkgraphColours
cat = SC_BASIC
; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL]
ifdef = DEDICATED

Loading…
Cancel
Save