diff --git a/src/lang/english.txt b/src/lang/english.txt index 86b352af9c..cdaa67b455 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -6299,3 +6299,6 @@ CM_STR_BUILD_INFO_OVERLAY_ERROR :{RED}{STRING} CM_STR_BUILD_INFO_OVERLAY_ERROR_UNKNOWN :{RED}Unknown Error! CM_STR_VEHICLE_INFO_BUILT_VALUE_WITH_ID :{LTBLUE}{ENGINE} {BLACK}Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY_LONG}{BLACK} ID: {LTBLUE}{NUM} + +CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE :Toolbar dropdowns activate on release: {STRING2} +CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE_HELPTEXT :Control whether the main toolbar dropdowns activate their default function when the mouse button is released. If not enabled then the dropdown menu will stay open so a selection can be made. diff --git a/src/lang/russian.txt b/src/lang/russian.txt index 6947f65d11..3e5993b216 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -6522,3 +6522,6 @@ CM_STR_BUILD_INFO_OVERLAY_ERROR :{RED}{STRING} CM_STR_BUILD_INFO_OVERLAY_ERROR_UNKNOWN :{RED}Неизвестная Ошибка! CM_STR_VEHICLE_INFO_BUILT_VALUE_WITH_ID :{LTBLUE}{ENGINE} {BLACK}Построен в {LTBLUE}{NUM} г.{BLACK} Стоимость: {LTBLUE}{CURRENCY_LONG}{BLACK} ID: {LTBLUE}{NUM} + +CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE :Активировать выпадающие меню при отпускании клавиши: {STRING2} +CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE_HELPTEXT :Контролирует, активируют ли выпадающие меню основной панели инструментов свою стандартную функцию при отпускании кнопки мыши. Если выключено, то выпадающее меню останется открытым, чтобы можно было сделать выбор. diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a930951447..b86f1ef8b0 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2009,6 +2009,7 @@ static SettingsContainer &GetSettingsTree() general->Add(new SettingEntry("gui.cm_remove_mod")); general->Add(new SettingEntry("gui.cm_estimate_mod")); general->Add(new SettingEntry("gui.cm_show_apm")); + general->Add(new SettingEntry("gui.cm_toolbar_dropdown_close")); } SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS)); diff --git a/src/settings_type.h b/src/settings_type.h index 2c533509b3..c19dc1af2a 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -259,6 +259,7 @@ struct GUISettings { bool cm_show_client_overlay; bool cm_enable_polyrail_terraform; bool cm_invert_fn_for_signal_drag; + bool cm_toolbar_dropdown_close; /* CityMania code end */ /** diff --git a/src/table/settings/cmclient_settings.ini b/src/table/settings/cmclient_settings.ini index c18b108bbd..7d450bfbf2 100644 --- a/src/table/settings/cmclient_settings.ini +++ b/src/table/settings/cmclient_settings.ini @@ -289,3 +289,10 @@ def = false str = CM_STR_CONFIG_SETTING_INVERT_FN_FOR_SIGNAL_DRAG strhelp = CM_STR_CONFIG_SETTING_INVERT_FN_FOR_SIGNAL_DRAG_HELPTEXT cat = SC_BASIC + +[SDTC_BOOL] +var = gui.cm_toolbar_dropdown_close +def = true +str = CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE +strhelp = CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE_HELPTEXT +cat = SC_BASIC diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index d49845ff12..e5757b70e3 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -124,7 +124,7 @@ public: */ static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def) { - ShowDropDownList(w, std::move(list), def, widget, 0, true); + ShowDropDownList(w, std::move(list), def, widget, 0, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } @@ -305,7 +305,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w) list.push_back(std::make_unique(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false)); list.push_back(std::make_unique(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -722,7 +722,7 @@ static CallBackFunction ToolbarGraphsClick(Window *w) if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list); - ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true); + ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -735,7 +735,7 @@ static CallBackFunction ToolbarLeagueClick(Window *w) AddDropDownLeagueTableOptions(list); int selected = list[0]->result; - ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true); + ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -917,7 +917,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) static CallBackFunction ToolbarBuildRailClick(Window *w) { - ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true); + ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -939,7 +939,7 @@ static CallBackFunction MenuClickBuildRail(int index) static CallBackFunction ToolbarBuildRoadClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true); + ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -961,7 +961,7 @@ static CallBackFunction MenuClickBuildRoad(int index) static CallBackFunction ToolbarBuildTramClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true); + ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -985,7 +985,7 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w) { DropDownList list; list.push_back(std::make_unique(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1007,7 +1007,7 @@ static CallBackFunction ToolbarBuildAirClick(Window *w) { DropDownList list; list.push_back(std::make_unique(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1031,7 +1031,7 @@ static CallBackFunction ToolbarForestClick(Window *w) list.push_back(std::make_unique(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false)); list.push_back(std::make_unique(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false)); list.push_back(std::make_unique(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1300,7 +1300,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w) static CallBackFunction ToolbarScenBuildRoadClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true); + ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1320,7 +1320,7 @@ static CallBackFunction ToolbarScenBuildRoad(int index) static CallBackFunction ToolbarScenBuildTramClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true); + ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, _settings_client.gui.cm_toolbar_dropdown_close); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -2066,6 +2066,10 @@ struct MainToolbarWindow : Window { void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { + bool lowered = this->IsWidgetLowered(widget); + this->CloseChildWindows(WC_DROPDOWN_MENU); + if (lowered != this->IsWidgetLowered(widget)) return; + if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); }