Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
#include "window_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "command_func.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "dropdown_common_type.h"
|
||||
#include "house.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "rail_gui.h"
|
||||
#include "road.h"
|
||||
@@ -107,7 +111,7 @@ static CallBackFunction _last_started_action = CBF_NONE; ///< Last started user
|
||||
*/
|
||||
class DropDownListCompanyItem : public DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>> {
|
||||
public:
|
||||
DropDownListCompanyItem(CompanyID company, bool shaded) : DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>>(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(company), NetworkCompanyIsPassworded(company) ? SPR_LOCK : SPR_EMPTY, PAL_NONE, STR_NULL, company, false, shaded)
|
||||
DropDownListCompanyItem(CompanyID company, bool shaded) : DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>>(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(company), NetworkCanJoinCompany(company) ? SPR_EMPTY : SPR_LOCK, PAL_NONE, STR_NULL, company, false, shaded)
|
||||
{
|
||||
SetDParam(0, company);
|
||||
SetDParam(1, company);
|
||||
@@ -140,9 +144,9 @@ static void PopupMainToolbarMenu(Window *w, WidgetID widget, const std::initiali
|
||||
int i = 0;
|
||||
for (StringID string : strings) {
|
||||
if (string == STR_NULL) {
|
||||
list.push_back(std::make_unique<DropDownListDividerItem>(-1, false));
|
||||
list.push_back(MakeDropDownListDividerItem());
|
||||
} else {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(string, i, false));
|
||||
list.push_back(MakeDropDownListStringItem(string, i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -170,20 +174,20 @@ static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask gr
|
||||
if (!_networking) break;
|
||||
|
||||
/* Add the client list button for the companies menu */
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST));
|
||||
|
||||
if (_local_company == COMPANY_SPECTATOR) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(CM_STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
|
||||
list.push_back(MakeDropDownListStringItem(CM_STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
|
||||
} else {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
|
||||
}
|
||||
break;
|
||||
case WID_TN_STORY:
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR));
|
||||
break;
|
||||
|
||||
case WID_TN_GOAL:
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -279,31 +283,31 @@ enum OptionMenuEntries {
|
||||
static CallBackFunction ToolbarOptionsClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS));
|
||||
/* Changes to the per-AI settings don't get send from the server to the clients. Clients get
|
||||
* the settings once they join but never update it. As such don't show the window at all
|
||||
* to network clients. */
|
||||
if (!_networking || _network_server) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS));
|
||||
}
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS));
|
||||
if (_game_mode != GM_EDITOR && !_networking) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_SANDBOX_OPTIONS, OME_SANDBOX, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_SANDBOX_OPTIONS, OME_SANDBOX));
|
||||
}
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(CM_STR_SETTINGS_MENU_ZONING, CM_OME_ZONING, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false));
|
||||
list.push_back(std::make_unique<DropDownListDividerItem>(-1, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_TOWN_NAMES), STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_STATION_NAMES), STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES), STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS), STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_FULL_ANIMATION), STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_FULL_DETAIL), STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false));
|
||||
list.push_back(std::make_unique<DropDownListCheckedItem>(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false));
|
||||
list.push_back(MakeDropDownListStringItem(CM_STR_SETTINGS_MENU_ZONING, CM_OME_ZONING, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES));
|
||||
list.push_back(MakeDropDownListDividerItem());
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_TOWN_NAMES), STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_STATION_NAMES), STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES), STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS), STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_FULL_ANIMATION), STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION));
|
||||
list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_FULL_DETAIL), STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS));
|
||||
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS));
|
||||
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS));
|
||||
|
||||
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);
|
||||
@@ -436,10 +440,10 @@ enum MapMenuEntries {
|
||||
static CallBackFunction ToolbarMapClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
|
||||
PopupMainToolbarMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -447,11 +451,11 @@ static CallBackFunction ToolbarMapClick(Window *w)
|
||||
static CallBackFunction ToolbarScenMapTownDir(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
|
||||
list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY));
|
||||
list.push_back(MakeDropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY));
|
||||
PopupMainToolbarMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -698,13 +702,13 @@ static void AddDropDownLeagueTableOptions(DropDownList &list)
|
||||
{
|
||||
if (LeagueTable::GetNumItems() > 0) {
|
||||
for (LeagueTable *lt : LeagueTable::Iterate()) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false));
|
||||
list.push_back(MakeDropDownListStringItem(lt->title, lt->index));
|
||||
}
|
||||
} else {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, LTMN_PERFORMANCE_LEAGUE, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING, LTMN_PERFORMANCE_RATING, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, LTMN_PERFORMANCE_LEAGUE));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING, LTMN_PERFORMANCE_RATING));
|
||||
if (!_networking) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_HIGHSCORE, LTMN_HIGHSCORE, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_HIGHSCORE, LTMN_HIGHSCORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -713,12 +717,12 @@ static CallBackFunction ToolbarGraphsClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, GRMN_OPERATING_PROFIT_GRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_INCOME_GRAPH, GRMN_INCOME_GRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH, GRMN_DELIVERED_CARGO_GRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_PERFORMANCE_HISTORY_GRAPH, GRMN_PERFORMANCE_HISTORY_GRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH, GRMN_COMPANY_VALUE_GRAPH, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_CARGO_PAYMENT_RATES, GRMN_CARGO_PAYMENT_RATES, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, GRMN_OPERATING_PROFIT_GRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_INCOME_GRAPH, GRMN_INCOME_GRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH, GRMN_DELIVERED_CARGO_GRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_PERFORMANCE_HISTORY_GRAPH, GRMN_PERFORMANCE_HISTORY_GRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH, GRMN_COMPANY_VALUE_GRAPH));
|
||||
list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_CARGO_PAYMENT_RATES, GRMN_CARGO_PAYMENT_RATES));
|
||||
|
||||
if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
|
||||
|
||||
@@ -984,7 +988,7 @@ static CallBackFunction MenuClickBuildTram(int index)
|
||||
static CallBackFunction ToolbarBuildWaterClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0));
|
||||
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;
|
||||
@@ -1006,7 +1010,7 @@ static CallBackFunction MenuClickBuildWater(int)
|
||||
static CallBackFunction ToolbarBuildAirClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0));
|
||||
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;
|
||||
@@ -1028,9 +1032,9 @@ static CallBackFunction MenuClickBuildAir(int)
|
||||
static CallBackFunction ToolbarForestClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false));
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false));
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2));
|
||||
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;
|
||||
@@ -1281,12 +1285,18 @@ static CallBackFunction ToolbarScenGenLand(Window *w)
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
|
||||
static CallBackFunction ToolbarScenGenTown(Window *w)
|
||||
static CallBackFunction ToolbarScenGenTownClick(Window *w)
|
||||
{
|
||||
w->HandleButtonClick(WID_TE_TOWN_GENERATE);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
ShowFoundTownWindow();
|
||||
PopupMainToolbarMenu(w, WID_TE_TOWN_GENERATE, {STR_SCENEDIT_TOWN_MENU_BUILD_TOWN, STR_SCENEDIT_TOWN_MENU_PACE_HOUSE});
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
static CallBackFunction ToolbarScenGenTown(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0: ShowFoundTownWindow(); break;
|
||||
case 1: ShowBuildHousePicker(nullptr); break;
|
||||
}
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1485,7 +1495,7 @@ public:
|
||||
uint spacer_i = 0;
|
||||
uint button_i = 0;
|
||||
|
||||
/* Index into the arrangement indices. The macro lastof cannot be used here! */
|
||||
/* Index into the arrangement indices. */
|
||||
const WidgetID *slotp = rtl ? &arrangement[arrangable_count - 1] : arrangement;
|
||||
for (uint i = 0; i < arrangable_count; i++) {
|
||||
uint slot = lookup[*slotp];
|
||||
@@ -2024,7 +2034,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = {
|
||||
|
||||
/** Main toolbar. */
|
||||
struct MainToolbarWindow : Window {
|
||||
MainToolbarWindow(WindowDesc *desc) : Window(desc)
|
||||
MainToolbarWindow(WindowDesc &desc) : Window(desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
|
||||
@@ -2320,11 +2330,11 @@ static constexpr NWidgetPart _nested_toolbar_normal_widgets[] = {
|
||||
NWidgetFunction(MakeMainToolbar),
|
||||
};
|
||||
|
||||
static WindowDesc _toolb_normal_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _toolb_normal_desc(
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS | WDF_NO_CLOSE,
|
||||
std::begin(_nested_toolbar_normal_widgets), std::end(_nested_toolbar_normal_widgets),
|
||||
_nested_toolbar_normal_widgets,
|
||||
&MainToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
@@ -2344,7 +2354,7 @@ static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
|
||||
nullptr, // 9
|
||||
nullptr, // 10
|
||||
nullptr, // 11
|
||||
nullptr, // 12
|
||||
ToolbarScenGenTown, // 12
|
||||
nullptr, // 13
|
||||
ToolbarScenBuildRoad, // 14
|
||||
ToolbarScenBuildTram, // 15
|
||||
@@ -2370,7 +2380,7 @@ static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
|
||||
ToolbarZoomInClick,
|
||||
ToolbarZoomOutClick,
|
||||
ToolbarScenGenLand,
|
||||
ToolbarScenGenTown,
|
||||
ToolbarScenGenTownClick,
|
||||
ToolbarScenGenIndustry,
|
||||
ToolbarScenBuildRoadClick,
|
||||
ToolbarScenBuildTramClick,
|
||||
@@ -2411,7 +2421,7 @@ enum MainToolbarEditorHotkeys {
|
||||
};
|
||||
|
||||
struct ScenarioEditorToolbarWindow : Window {
|
||||
ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc)
|
||||
ScenarioEditorToolbarWindow(WindowDesc &desc) : Window(desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
|
||||
@@ -2461,16 +2471,16 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_TE_SPACER:
|
||||
size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
|
||||
size.width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
|
||||
break;
|
||||
|
||||
case WID_TE_DATE:
|
||||
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
|
||||
*size = GetStringBoundingBox(STR_JUST_DATE_LONG);
|
||||
size = GetStringBoundingBox(STR_JUST_DATE_LONG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2498,7 +2508,7 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
case MTEHK_SETTINGS: ShowGameOptions(); break;
|
||||
case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
|
||||
case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
|
||||
case MTEHK_GENTOWN: ToolbarScenGenTown(this); break;
|
||||
case MTEHK_GENTOWN: ToolbarScenGenTownClick(this); break;
|
||||
case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
|
||||
case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
|
||||
case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
|
||||
@@ -2574,14 +2584,14 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
HandleZoomMessage(this, GetMainWindow()->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT);
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
/* Was 'cancel' pressed? */
|
||||
if (str == nullptr) return;
|
||||
if (!str.has_value()) return;
|
||||
|
||||
TimerGameCalendar::Year value;
|
||||
if (!StrEmpty(str)) {
|
||||
value = atoi(str);
|
||||
if (!str->empty()) {
|
||||
value = atoi(str->c_str());
|
||||
} else {
|
||||
/* An empty string means revert to the default */
|
||||
value = CalendarTime::DEF_START_YEAR.base();
|
||||
@@ -2656,18 +2666,18 @@ static constexpr NWidgetPart _nested_toolb_scen_inner_widgets[] = {
|
||||
|
||||
static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
|
||||
{
|
||||
return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique<NWidgetScenarioToolbarContainer>());
|
||||
return MakeNWidgets(_nested_toolb_scen_inner_widgets, std::make_unique<NWidgetScenarioToolbarContainer>());
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_toolb_scen_widgets[] = {
|
||||
NWidgetFunction(MakeScenarioToolbar),
|
||||
};
|
||||
|
||||
static WindowDesc _toolb_scen_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _toolb_scen_desc(
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS | WDF_NO_CLOSE,
|
||||
std::begin(_nested_toolb_scen_widgets), std::end(_nested_toolb_scen_widgets),
|
||||
_nested_toolb_scen_widgets,
|
||||
&ScenarioEditorToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
@@ -2679,8 +2689,8 @@ void AllocateToolbar()
|
||||
_last_built_tramtype = ROADTYPE_TRAM;
|
||||
|
||||
if (_game_mode == GM_EDITOR) {
|
||||
new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
|
||||
new ScenarioEditorToolbarWindow(_toolb_scen_desc);
|
||||
} else {
|
||||
new MainToolbarWindow(&_toolb_normal_desc);
|
||||
new MainToolbarWindow(_toolb_normal_desc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user