Skip to content

Commit

Permalink
Add an optional "(City)" in Viewport labels
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowOnion authored and JGRennison committed Jul 30, 2023
1 parent 4d2db01 commit 924b2ab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/lang/extra/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2167,5 +2167,11 @@ STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_OFF :Off
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_SIMPLE :Simple
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_DETAILED :Detailed

STR_CONFIG_SETTING_CITY_IN_LABEL :Show city in town name label: {STRING2}
STR_CONFIG_SETTING_CITY_IN_LABEL_HELPTEXT :Display if a town is also a city in their label on the map

###length 4
STR_VIEWPORT_TOWN_COLOUR :{1:SET_COLOUR}{0:TOWN}
STR_VIEWPORT_TOWN_COLOUR_POP :{WHITE}{TOWN} {SET_COLOUR}({COMMA})
STR_VIEWPORT_TOWN_COLOUR_CITY :{1:SET_COLOUR}{0:TOWN} (City)
STR_VIEWPORT_TOWN_COLOUR_CITY_POP :{WHITE}{TOWN} {SET_COLOUR}(City, {COMMA})
1 change: 1 addition & 0 deletions src/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@ static SettingsContainer &GetSettingsTree()
viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
#endif
viewports->Add(new SettingEntry("gui.population_in_label"));
viewports->Add(new SettingEntry("gui.city_in_label"));
viewports->Add(new SettingEntry("gui.liveries"));
viewports->Add(new SettingEntry("gui.measure_tooltip"));
viewports->Add(new SettingEntry("gui.loading_indicators"));
Expand Down
1 change: 1 addition & 0 deletions src/settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct GUISettings : public TimeSettings {
byte max_num_lt_autosaves; ///< controls how many long-term autosavegames are made before the game starts to overwrite (names them 0 to max_num_lt_autosaves - 1)
uint8 savegame_overwrite_confirm; ///< Mode for when to warn about overwriting an existing savegame
bool population_in_label; ///< show the population of a town in its label?
bool city_in_label; ///< show cities in label?
uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking?
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
Expand Down
4 changes: 1 addition & 3 deletions src/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,9 +1938,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg

bool tiny = (b == SCC_VIEWPORT_TOWN_LABEL2);
StringID string_id = STR_VIEWPORT_TOWN_COLOUR;
if (!tiny && HasBit(data, 40)) {
string_id = STR_VIEWPORT_TOWN_COLOUR_POP;
}
if (!tiny) string_id += GB(data, 40, 2);
int64 args_array[] = {t, GB(data, 32, 8), GB(data, 0, 32)};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, string_id, &tmp_params, last);
Expand Down
8 changes: 8 additions & 0 deletions src/table/settings/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4762,6 +4762,14 @@ str = STR_CONFIG_SETTING_POPULATION_IN_LABEL
strhelp = STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT
post_cb = [](auto) { UpdateAllTownVirtCoords(); }

[SDTC_BOOL]
var = gui.city_in_label
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
def = false
str = STR_CONFIG_SETTING_CITY_IN_LABEL
strhelp = STR_CONFIG_SETTING_CITY_IN_LABEL_HELPTEXT
post_cb = [](auto) { UpdateAllTownVirtCoords(); }

[SDTC_BOOL]
var = gui.link_terraform_toolbar
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
Expand Down
1 change: 1 addition & 0 deletions src/town_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ uint64 Town::LabelParam2() const
SB(value, 32, 8, TC_WHITE);
}
if (_settings_client.gui.population_in_label) SetBit(value, 40);
if (_settings_client.gui.city_in_label && this->larger_town) SetBit(value, 41);
return value;
}

Expand Down

0 comments on commit 924b2ab

Please sign in to comment.