diff --git a/cm_changelog.txt b/cm_changelog.txt index d22652a322..edbac4efda 100644 --- a/cm_changelog.txt +++ b/cm_changelog.txt @@ -76,23 +76,23 @@ This is usable for any OpenTTD servers *** next () *** - Fix order hotkeys adding extra no load/unload orders. -- Allow to use TAB as a hotkey -- Add hotkey to toggle minimap -- Make hotkey to close news and errors configurable (still defaults to SPACE) -- Remove custom hotkey keycodes that were added to vanilla +- Allow to use TAB as a hotkey. +- Add hotkey to toggle minimap. +- Make hotkey to close news and errors configurable (still defaults to SPACE). +- Remove custom hotkey keycodes that were added to vanilla. - Make land info tool work with right click tooltip setting and/or disabled extra tooltip settings. - Make station rating tooltips work with right click tooltip setting -- Splilt extra(land) tooltips setting in config into 3 for industries, stations and houses separately. -- Add a setting to pause games after loading. -- Add a "step" console command to advance the game for n ticks (singleplayer only). -- cmexport +- Splilt extra (land) tooltips setting in config into 3 for industries, stations and houses separately. - Make modifier key (ctrl/alt/shift) functions configurable. - Allow to toggle removal mode with modifier key on station and signal building tools if it's different from fn modifier (otherwise fn takes priority). -- Center text and icons in the status bar vertically. -- Shaded trees. +- Add a setting to pause games after loading. +- Add "step" console command to advance the game for n ticks (singleplayer only). +- Add "cmexport" console command to export various in-game data in json format (for developers). +- Add "cmtreemap" console command to plant trees according to a heightmap image (scenario editor only). +- Add option to enable shading trees on slopes for better looks. - Add APM counter to the status bar. -- Added cmtreemap console command to plant trees according to a heightmap image (scenario editor only). - Fix town HR couter. +- Allow spectators to open industry funding window from the menu. *** 1.10.2 (5 Jun 2020) *** - Add new minimap mode showing industries, height and farms at the same time. diff --git a/src/lang/english.txt b/src/lang/english.txt index 040c3aad2e..3a38588b27 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5543,4 +5543,6 @@ STR_CM_CONFIG_SETTING_SHADED_TREES_OFF : Always off STR_CM_CONFIG_SETTING_SHADED_TREES_ON : Always on STR_CM_CONFIG_SETTING_SHADED_TREES_SERVER : As server -STR_CM_STATUSBAR_EPM : {WHITE}APM: {NUM} AVG: {NUM} +STR_CM_CONFIG_SETTING_SHOW_APM : Show APM counter: {STRING2} +STR_CM_CONFIG_SETTING_SHOW_APM_HELPTEXT : Adds APM (actions per minute) counter to the statusbar. +STR_CM_STATUSBAR_APM : {WHITE}APM: {NUM} AVG: {NUM} diff --git a/src/settings.cpp b/src/settings.cpp index 7fb2e72491..9cc36a3526 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2281,3 +2281,10 @@ static bool IsSignedVarMemType(VarType vt) } return false; } + +// CM +#include "statusbar_gui.h" +static bool cm_v_RedrawStatusBar(int32 p1) { + CM_RedrawStatusBar(); + return true; +} diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 34cf7a63ae..f340729e8e 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1547,6 +1547,7 @@ static SettingsContainer &GetSettingsTree() general->Add(new SettingEntry("gui.cm_fn_mod")); general->Add(new SettingEntry("gui.cm_remove_mod")); general->Add(new SettingEntry("gui.cm_estimate_mod")); + general->Add(new SettingEntry("gui.cm_show_apm")); } SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS)); diff --git a/src/settings_type.h b/src/settings_type.h index 85c1a00d50..97d4f8646a 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -200,6 +200,7 @@ struct GUISettings { citymania::ModKey cm_estimate_mod; uint8 cm_shaded_trees; + bool cm_show_apm; /** * Returns true when the user has sufficient privileges to edit newgrfs on a running game diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index be2ab85862..411fe0153b 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -130,10 +130,14 @@ struct StatusBarWindow : Window { break; } - case CM_WID_S_EPM: + case CM_WID_S_APM: + if (!_settings_client.gui.cm_show_apm) { + *size = Dimension(0, 0); + return; + } SetDParam(0, 999); SetDParam(1, 999); - d = GetStringBoundingBox(STR_CM_STATUSBAR_EPM); + d = GetStringBoundingBox(STR_CM_STATUSBAR_APM); break; default: @@ -198,11 +202,13 @@ struct StatusBarWindow : Window { } break; - case CM_WID_S_EPM: - auto epm = citymania::GetEPM(); - SetDParam(0, epm.second); - SetDParam(1, epm.first); - DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_CM_STATUSBAR_EPM, TC_FROMSTRING, SA_HOR_CENTER); + case CM_WID_S_APM: + if (_settings_client.gui.cm_show_apm) { + auto epm = citymania::GetEPM(); + SetDParam(0, epm.second); + SetDParam(1, epm.first); + DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_CM_STATUSBAR_APM, TC_FROMSTRING, SA_HOR_CENTER); + } break; } } @@ -255,7 +261,7 @@ struct StatusBarWindow : Window { } if (this->cm_epm_timer.CountElapsed(delta_ms)) { - this->SetWidgetDirty(CM_WID_S_EPM); + this->SetWidgetDirty(CM_WID_S_APM); } } }; @@ -264,7 +270,7 @@ static const NWidgetPart _nested_main_status_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_GREY, WID_S_LEFT), SetMinimalSize(100, 12), EndContainer(), NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0), - NWidget(WWT_PANEL, COLOUR_GREY, CM_WID_S_EPM), SetMinimalSize(100, 12), EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY, CM_WID_S_APM), SetMinimalSize(100, 12), EndContainer(), NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_RIGHT), SetMinimalSize(100, 12), EndContainer(), }; @@ -292,3 +298,8 @@ void ShowStatusBar() { new StatusBarWindow(&_main_status_desc); } + +void CM_RedrawStatusBar() { + StatusBarWindow *w = dynamic_cast(FindWindowById(WC_STATUS_BAR, 0)); + w->ReInit(); +} diff --git a/src/statusbar_gui.h b/src/statusbar_gui.h index 26503dbff1..2190718a76 100644 --- a/src/statusbar_gui.h +++ b/src/statusbar_gui.h @@ -23,4 +23,6 @@ enum StatusBarInvalidate { bool IsNewsTickerShown(); void ShowStatusBar(); +void CM_RedrawStatusBar(); + #endif /* STATUSBAR_GUI_H */ diff --git a/src/table/settings.ini b/src/table/settings.ini index 2df4fdc28b..4033abe64c 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -47,6 +47,8 @@ static bool UpdateServerPassword(int32 p1); static bool UpdateRconPassword(int32 p1); static bool UpdateClientConfigValues(int32 p1); +static bool cm_v_RedrawStatusBar(int32 p1); + extern int32 _old_ending_year_slv_105; /* End - Callback Functions for the various settings */ @@ -4285,5 +4287,14 @@ strval = STR_CM_CONFIG_SETTING_SHADED_TREES_OFF cat = SC_ADVANCED proc = RedrawScreen +[SDTC_BOOL] +var = gui.cm_show_apm +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = false +str = STR_CM_CONFIG_SETTING_SHOW_APM +strhelp = STR_CM_CONFIG_SETTING_SHOW_APM_HELPTEXT +cat = SC_ADVANCED +proc = cm_v_RedrawStatusBar + [SDT_END] diff --git a/src/widgets/statusbar_widget.h b/src/widgets/statusbar_widget.h index b58ca7ed56..870718ac9c 100644 --- a/src/widgets/statusbar_widget.h +++ b/src/widgets/statusbar_widget.h @@ -15,7 +15,7 @@ enum StatusbarWidgets { WID_S_LEFT, ///< Left part of the statusbar; date is shown there. WID_S_MIDDLE, ///< Middle part; current news or company name or *** SAVING *** or *** PAUSED ***. WID_S_RIGHT, ///< Right part; bank balance. - CM_WID_S_EPM, ///< CityMania EPM counter. + CM_WID_S_APM, ///< CityMania EPM counter. }; #endif /* WIDGETS_STATUSBAR_WIDGET_H */