Update to 1.10.0-beta1
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "command_func.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "rail_gui.h"
|
||||
#include "road.h"
|
||||
#include "road_gui.h"
|
||||
#include "date_func.h"
|
||||
#include "vehicle_func.h"
|
||||
@@ -64,6 +65,7 @@ uint _toolbar_width = 0;
|
||||
|
||||
RailType _last_built_railtype;
|
||||
RoadType _last_built_roadtype;
|
||||
RoadType _last_built_tramtype;
|
||||
|
||||
static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the current query is about to confirm.
|
||||
|
||||
@@ -97,14 +99,12 @@ public:
|
||||
this->checkmark_width = GetStringBoundingBox(STR_JUST_CHECKMARK).width + 3;
|
||||
}
|
||||
|
||||
virtual ~DropDownListCheckedItem() {}
|
||||
|
||||
uint Width() const
|
||||
{
|
||||
return DropDownListStringItem::Width() + this->checkmark_width;
|
||||
}
|
||||
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
|
||||
{
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
if (this->checked) {
|
||||
@@ -129,14 +129,12 @@ public:
|
||||
this->lock_size = GetSpriteSize(SPR_LOCK);
|
||||
}
|
||||
|
||||
virtual ~DropDownListCompanyItem() {}
|
||||
|
||||
bool Selectable() const
|
||||
bool Selectable() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
uint Width() const
|
||||
uint Width() const override
|
||||
{
|
||||
CompanyID company = (CompanyID)this->result;
|
||||
SetDParam(0, company);
|
||||
@@ -144,12 +142,12 @@ public:
|
||||
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
|
||||
}
|
||||
|
||||
uint Height(uint width) const
|
||||
uint Height(uint width) const override
|
||||
{
|
||||
return max(max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override
|
||||
{
|
||||
CompanyID company = (CompanyID)this->result;
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
@@ -162,11 +160,9 @@ public:
|
||||
int lock_offset = (bottom - top - lock_size.height) / 2;
|
||||
|
||||
DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (NetworkCompanyIsPassworded(company)) {
|
||||
DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
SetDParam(0, company);
|
||||
SetDParam(1, company);
|
||||
@@ -187,9 +183,9 @@ public:
|
||||
* @param list List of items
|
||||
* @param def Default item
|
||||
*/
|
||||
static void PopupMainToolbMenu(Window *w, int widget, DropDownList *list, int def)
|
||||
static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
|
||||
{
|
||||
ShowDropDownList(w, list, def, widget, 0, true, true);
|
||||
ShowDropDownList(w, std::move(list), def, widget, 0, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
}
|
||||
|
||||
@@ -202,11 +198,11 @@ static void PopupMainToolbMenu(Window *w, int widget, DropDownList *list, int de
|
||||
*/
|
||||
static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
DropDownList list;
|
||||
for (int i = 0; i < count; i++) {
|
||||
*list->Append() = new DropDownListStringItem(string + i, i, false);
|
||||
list.emplace_back(new DropDownListStringItem(string + i, i, false));
|
||||
}
|
||||
PopupMainToolbMenu(w, widget, list, 0);
|
||||
PopupMainToolbMenu(w, widget, std::move(list), 0);
|
||||
}
|
||||
|
||||
/** Enum for the Company Toolbar's network related buttons */
|
||||
@@ -223,39 +219,37 @@ static const int CTMN_SPECTATOR = -4; ///< Show a company window as spectator
|
||||
*/
|
||||
static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
DropDownList list;
|
||||
|
||||
switch (widget) {
|
||||
case WID_TN_COMPANIES:
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) break;
|
||||
|
||||
/* Add the client list button for the companies menu */
|
||||
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false);
|
||||
list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
|
||||
|
||||
if (_local_company == COMPANY_SPECTATOR) {
|
||||
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached());
|
||||
list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
|
||||
} else {
|
||||
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached());
|
||||
list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached()));
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
break;
|
||||
|
||||
case WID_TN_STORY:
|
||||
*list->Append() = new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false);
|
||||
list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
|
||||
break;
|
||||
|
||||
case WID_TN_GOAL:
|
||||
*list->Append() = new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false);
|
||||
list.emplace_back(new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
|
||||
break;
|
||||
}
|
||||
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
if (!Company::IsValidID(c)) continue;
|
||||
*list->Append() = new DropDownListCompanyItem(c, false, HasBit(grey, c));
|
||||
list.emplace_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
|
||||
}
|
||||
|
||||
PopupMainToolbMenu(w, widget, list, _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company);
|
||||
PopupMainToolbMenu(w, widget, std::move(list), _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company);
|
||||
}
|
||||
|
||||
|
||||
@@ -325,27 +319,27 @@ enum OptionMenuEntries {
|
||||
*/
|
||||
static CallBackFunction ToolbarOptionsClick(Window *w)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false));
|
||||
/* 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->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false);
|
||||
*list->Append() = new DropDownListItem(-1, false);
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES));
|
||||
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS));
|
||||
if (!_networking || _network_server) list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false));
|
||||
list.emplace_back(new DropDownListItem(-1, false));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)));
|
||||
|
||||
ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true);
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -471,24 +465,24 @@ enum MapMenuEntries {
|
||||
|
||||
static CallBackFunction ToolbarMapClick(Window *w)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false);
|
||||
PopupMainToolbMenu(w, WID_TN_SMALL_MAP, list, 0);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
|
||||
PopupMainToolbMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
static CallBackFunction ToolbarScenMapTownDir(Window *w)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false);
|
||||
PopupMainToolbMenu(w, WID_TE_SMALL_MAP, list, 0);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
|
||||
PopupMainToolbMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -614,7 +608,6 @@ static CallBackFunction ToolbarCompaniesClick(Window *w)
|
||||
*/
|
||||
static CallBackFunction MenuClickCompany(int index)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_networking) {
|
||||
switch (index) {
|
||||
case CTMN_CLIENT_LIST:
|
||||
@@ -625,7 +618,7 @@ static CallBackFunction MenuClickCompany(int index)
|
||||
if (_network_server) {
|
||||
DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL);
|
||||
} else {
|
||||
NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
|
||||
NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, nullptr, _local_company);
|
||||
}
|
||||
return CBF_NONE;
|
||||
|
||||
@@ -639,7 +632,6 @@ static CallBackFunction MenuClickCompany(int index)
|
||||
return CBF_NONE;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
ShowCompany((CompanyID)index);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -903,22 +895,7 @@ static CallBackFunction MenuClickBuildRail(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildRoadClick(Window *w)
|
||||
{
|
||||
const Company *c = Company::Get(_local_company);
|
||||
DropDownList *list = new DropDownList();
|
||||
|
||||
/* Road is always visible and available. */
|
||||
*list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false);
|
||||
|
||||
/* Tram is only visible when there will be a tram, and available when that has been introduced. */
|
||||
Engine *e;
|
||||
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
|
||||
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
|
||||
if (!HasBit(e->info.misc_flags, EF_ROAD_TRAM)) continue;
|
||||
|
||||
*list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
|
||||
break;
|
||||
}
|
||||
ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true);
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -936,11 +913,35 @@ static CallBackFunction MenuClickBuildRoad(int index)
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
/* --- Tram button menu --- */
|
||||
|
||||
static CallBackFunction ToolbarBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle click on the entry in the Build Tram menu.
|
||||
*
|
||||
* @param index RoadType to show the build toolbar for.
|
||||
* @return #CBF_NONE
|
||||
*/
|
||||
static CallBackFunction MenuClickBuildTram(int index)
|
||||
{
|
||||
_last_built_tramtype = (RoadType)index;
|
||||
ShowBuildRoadToolbar(_last_built_tramtype);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
/* --- Water button menu --- */
|
||||
|
||||
static CallBackFunction ToolbarBuildWaterClick(Window *w)
|
||||
{
|
||||
PopupMainToolbMenu(w, WID_TN_WATER, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 1);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true, true);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -960,7 +961,9 @@ static CallBackFunction MenuClickBuildWater(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildAirClick(Window *w)
|
||||
{
|
||||
PopupMainToolbMenu(w, WID_TN_AIR, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 1);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true, true);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -980,7 +983,11 @@ static CallBackFunction MenuClickBuildAir(int index)
|
||||
|
||||
static CallBackFunction ToolbarForestClick(Window *w)
|
||||
{
|
||||
PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 3);
|
||||
DropDownList list;
|
||||
list.emplace_back(new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false));
|
||||
list.emplace_back(new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false));
|
||||
list.emplace_back(new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true, true);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1004,7 +1011,7 @@ static CallBackFunction MenuClickForest(int index)
|
||||
|
||||
static CallBackFunction ToolbarMusicClick(Window *w)
|
||||
{
|
||||
PopupMainToolbMenu(w, WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
|
||||
PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1059,13 +1066,13 @@ static CallBackFunction PlaceLandBlockInfo()
|
||||
|
||||
static CallBackFunction ToolbarHelpClick(Window *w)
|
||||
{
|
||||
PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 13 : 10);
|
||||
PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_HELP : (int)WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 13 : 10);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
static void MenuClickSmallScreenshot()
|
||||
{
|
||||
MakeScreenshot(SC_VIEWPORT, NULL);
|
||||
MakeScreenshot(SC_VIEWPORT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1075,7 +1082,7 @@ static void MenuClickSmallScreenshot()
|
||||
*/
|
||||
static void ScreenshotConfirmCallback(Window *w, bool confirmed)
|
||||
{
|
||||
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, NULL);
|
||||
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1092,10 +1099,10 @@ static void MenuClickLargeWorldScreenshot(ScreenshotType t)
|
||||
SetDParam(0, vp.width);
|
||||
SetDParam(1, vp.height);
|
||||
_confirmed_screenshot_type = t;
|
||||
ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, NULL, ScreenshotConfirmCallback);
|
||||
ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, nullptr, ScreenshotConfirmCallback);
|
||||
} else {
|
||||
/* Less than 64M pixels, just do it */
|
||||
MakeScreenshot(t, NULL);
|
||||
MakeScreenshot(t, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,7 +1188,7 @@ static CallBackFunction ToolbarSwitchClick(Window *w)
|
||||
}
|
||||
|
||||
w->ReInit();
|
||||
w->SetWidgetLoweredState(WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
|
||||
w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (uint)WID_TE_SWITCH_BAR : (uint)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -1251,11 +1258,43 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w)
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
static CallBackFunction ToolbarScenBuildRoad(Window *w)
|
||||
static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
|
||||
{
|
||||
w->HandleButtonClick(WID_TE_ROADS);
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
ShowBuildRoadScenToolbar();
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle click on the entry in the Build Road menu.
|
||||
*
|
||||
* @param index RoadType to show the build toolbar for.
|
||||
* @return #CBF_NONE
|
||||
*/
|
||||
static CallBackFunction ToolbarScenBuildRoad(int index)
|
||||
{
|
||||
_last_built_roadtype = (RoadType)index;
|
||||
ShowBuildRoadScenToolbar(_last_built_roadtype);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
static CallBackFunction ToolbarScenBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true, true);
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle click on the entry in the Build Tram menu.
|
||||
*
|
||||
* @param index RoadType to show the build toolbar for.
|
||||
* @return #CBF_NONE
|
||||
*/
|
||||
static CallBackFunction ToolbarScenBuildTram(int index)
|
||||
{
|
||||
_last_built_tramtype = (RoadType)index;
|
||||
ShowBuildRoadScenToolbar(_last_built_tramtype);
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1290,8 +1329,8 @@ static CallBackFunction ToolbarBtn_NULL(Window *w)
|
||||
typedef CallBackFunction MenuClickedProc(int index);
|
||||
|
||||
static MenuClickedProc * const _menu_clicked_procs[] = {
|
||||
NULL, // 0
|
||||
NULL, // 1
|
||||
nullptr, // 0
|
||||
nullptr, // 1
|
||||
MenuClickSettings, // 2
|
||||
MenuClickSaveLoad, // 3
|
||||
MenuClickMap, // 4
|
||||
@@ -1310,15 +1349,16 @@ static MenuClickedProc * const _menu_clicked_procs[] = {
|
||||
MenuClickShowShips, // 17
|
||||
MenuClickShowAir, // 18
|
||||
MenuClickMap, // 19
|
||||
NULL, // 20
|
||||
nullptr, // 20
|
||||
MenuClickBuildRail, // 21
|
||||
MenuClickBuildRoad, // 22
|
||||
MenuClickBuildWater, // 23
|
||||
MenuClickBuildAir, // 24
|
||||
MenuClickForest, // 25
|
||||
MenuClickMusicWindow, // 26
|
||||
MenuClickNewspaper, // 27
|
||||
MenuClickHelp, // 28
|
||||
MenuClickBuildTram, // 23
|
||||
MenuClickBuildWater, // 24
|
||||
MenuClickBuildAir, // 25
|
||||
MenuClickForest, // 26
|
||||
MenuClickMusicWindow, // 27
|
||||
MenuClickNewspaper, // 28
|
||||
MenuClickHelp, // 29
|
||||
};
|
||||
|
||||
/** Full blown container to make it behave exactly as we want :) */
|
||||
@@ -1342,7 +1382,7 @@ public:
|
||||
return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
|
||||
}
|
||||
|
||||
void SetupSmallestSize(Window *w, bool init_array)
|
||||
void SetupSmallestSize(Window *w, bool init_array) override
|
||||
{
|
||||
this->smallest_x = 0; // Biggest child
|
||||
this->smallest_y = 0; // Biggest child
|
||||
@@ -1354,7 +1394,7 @@ public:
|
||||
|
||||
uint nbuttons = 0;
|
||||
/* First initialise some variables... */
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
child_wid->SetupSmallestSize(w, init_array);
|
||||
this->smallest_y = max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
|
||||
if (this->IsButton(child_wid->type)) {
|
||||
@@ -1366,7 +1406,7 @@ public:
|
||||
}
|
||||
|
||||
/* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
child_wid->current_y = this->smallest_y;
|
||||
if (!this->IsButton(child_wid->type)) {
|
||||
child_wid->current_x = child_wid->smallest_x;
|
||||
@@ -1375,7 +1415,7 @@ public:
|
||||
_toolbar_width = nbuttons * this->smallest_x;
|
||||
}
|
||||
|
||||
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
|
||||
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
|
||||
{
|
||||
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
|
||||
|
||||
@@ -1394,7 +1434,7 @@ public:
|
||||
|
||||
/* Create us ourselves a quick lookup table */
|
||||
NWidgetBase *widgets[WID_TN_END];
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
if (child_wid->type == NWID_SPACER) continue;
|
||||
widgets[((NWidgetCore*)child_wid)->index] = child_wid;
|
||||
}
|
||||
@@ -1413,7 +1453,7 @@ public:
|
||||
/* If we have to give space to the spacers, do that */
|
||||
if (spacer_space != 0) {
|
||||
NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev;
|
||||
if (possible_spacer != NULL && possible_spacer->type == NWID_SPACER) {
|
||||
if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) {
|
||||
uint add = spacer_space / (spacer_count - spacer_i);
|
||||
position += add;
|
||||
spacer_space -= add;
|
||||
@@ -1438,14 +1478,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void Draw(const Window *w)
|
||||
void Draw(const Window *w) override
|
||||
{
|
||||
/* Draw brown-red toolbar bg. */
|
||||
GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED);
|
||||
GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_DARK_RED, FILLRECT_CHECKER);
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != NULL; child_wid = rtl ? child_wid->prev : child_wid->next) {
|
||||
for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) {
|
||||
if (child_wid->type == NWID_SPACER) continue;
|
||||
if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
|
||||
|
||||
@@ -1453,18 +1493,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y)
|
||||
NWidgetCore *GetWidgetFromPos(int x, int y) override
|
||||
{
|
||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
|
||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
|
||||
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
if (child_wid->type == NWID_SPACER) continue;
|
||||
if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
|
||||
|
||||
NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
|
||||
if (nwid != NULL) return nwid;
|
||||
if (nwid != nullptr) return nwid;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1480,7 +1520,7 @@ public:
|
||||
|
||||
/** Container for the 'normal' main toolbar */
|
||||
class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||
/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
|
||||
const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
|
||||
{
|
||||
static const uint SMALLEST_ARRANGEMENT = 14;
|
||||
static const uint BIGGEST_ARRANGEMENT = 20;
|
||||
@@ -1774,6 +1814,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||
WID_TN_ZOOM_OUT,
|
||||
WID_TN_RAILS,
|
||||
WID_TN_ROADS,
|
||||
WID_TN_TRAMS,
|
||||
WID_TN_WATER,
|
||||
WID_TN_AIR,
|
||||
WID_TN_LANDSCAPE,
|
||||
@@ -1803,13 +1844,13 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||
class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
uint panel_widths[2]; ///< The width of the two panels (the text panel and date panel)
|
||||
|
||||
void SetupSmallestSize(Window *w, bool init_array)
|
||||
void SetupSmallestSize(Window *w, bool init_array) override
|
||||
{
|
||||
this->NWidgetToolbarContainer::SetupSmallestSize(w, init_array);
|
||||
|
||||
/* Find the size of panel_widths */
|
||||
uint i = 0;
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
|
||||
|
||||
assert(i < lengthof(this->panel_widths));
|
||||
@@ -1818,7 +1859,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
|
||||
const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
|
||||
{
|
||||
static const byte arrange_all[] = {
|
||||
WID_TE_PAUSE,
|
||||
@@ -1834,6 +1875,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
WID_TE_TOWN_GENERATE,
|
||||
WID_TE_INDUSTRY,
|
||||
WID_TE_ROADS,
|
||||
WID_TE_TRAMS,
|
||||
WID_TE_WATER,
|
||||
WID_TE_TREES,
|
||||
WID_TE_SIGNS,
|
||||
@@ -1853,6 +1895,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
WID_TE_TOWN_GENERATE,
|
||||
WID_TE_INDUSTRY,
|
||||
WID_TE_ROADS,
|
||||
WID_TE_TRAMS,
|
||||
WID_TE_WATER,
|
||||
WID_TE_TREES,
|
||||
WID_TE_SIGNS,
|
||||
@@ -1866,6 +1909,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
WID_TE_TOWN_GENERATE,
|
||||
WID_TE_INDUSTRY,
|
||||
WID_TE_ROADS,
|
||||
WID_TE_TRAMS,
|
||||
WID_TE_WATER,
|
||||
WID_TE_TREES,
|
||||
WID_TE_SIGNS,
|
||||
@@ -1876,10 +1920,12 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||
WID_TE_SETTINGS,
|
||||
WID_TE_SAVE,
|
||||
WID_TE_DATE_PANEL,
|
||||
WID_TE_SMALL_MAP,
|
||||
WID_TE_ZOOM_IN,
|
||||
WID_TE_ZOOM_OUT,
|
||||
WID_TE_MUSIC_SOUND,
|
||||
WID_TE_HELP, WID_TE_SWITCH_BAR,
|
||||
WID_TE_HELP,
|
||||
WID_TE_SWITCH_BAR,
|
||||
};
|
||||
|
||||
/* If we can place all buttons *and* the panels, show them. */
|
||||
@@ -1939,6 +1985,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = {
|
||||
ToolbarZoomOutClick,
|
||||
ToolbarBuildRailClick,
|
||||
ToolbarBuildRoadClick,
|
||||
ToolbarBuildTramClick,
|
||||
ToolbarBuildWaterClick,
|
||||
ToolbarBuildAirClick,
|
||||
ToolbarForestClick,
|
||||
@@ -1973,6 +2020,7 @@ enum MainToolbarHotkeys {
|
||||
MTHK_ZOOM_OUT,
|
||||
MTHK_BUILD_RAIL,
|
||||
MTHK_BUILD_ROAD,
|
||||
MTHK_BUILD_TRAM,
|
||||
MTHK_BUILD_DOCKS,
|
||||
MTHK_BUILD_AIRPORT,
|
||||
MTHK_BUILD_TREES,
|
||||
@@ -2007,17 +2055,17 @@ struct MainToolbarWindow : Window {
|
||||
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||
}
|
||||
|
||||
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
|
||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||
{
|
||||
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
/* If spectator, disable all construction buttons
|
||||
* ie : Build road, rail, ships, airports and landscaping
|
||||
* Since enabled state is the default, just disable when needed */
|
||||
this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, WID_TN_RAILS, WID_TN_ROADS, WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, WID_TN_RAILS, WID_TN_ROADS, WID_TN_TRAMS, WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE, WIDGET_LIST_END);
|
||||
/* disable company list drop downs, if there are no companies */
|
||||
this->SetWidgetsDisabledState(Company::GetNumItems() == 0, WID_TN_STATIONS, WID_TN_FINANCES, WID_TN_TRAINS, WID_TN_ROADVEHS, WID_TN_SHIPS, WID_TN_AIRCRAFT, WIDGET_LIST_END);
|
||||
|
||||
@@ -2025,23 +2073,25 @@ struct MainToolbarWindow : Window {
|
||||
this->SetWidgetDisabledState(WID_TN_STORY, StoryPage::GetNumItems() == 0);
|
||||
|
||||
this->SetWidgetDisabledState(WID_TN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
|
||||
this->SetWidgetDisabledState(WID_TN_ROADS, !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_ROAD));
|
||||
this->SetWidgetDisabledState(WID_TN_TRAMS, !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM));
|
||||
this->SetWidgetDisabledState(WID_TN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
|
||||
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
CallBackFunction cbf = _menu_clicked_procs[widget](index);
|
||||
if (cbf != CBF_NONE) _last_started_action = cbf;
|
||||
}
|
||||
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
EventState OnHotkey(int hotkey) override
|
||||
{
|
||||
switch (hotkey) {
|
||||
case MTHK_PAUSE: ToolbarPauseClick(this); break;
|
||||
@@ -2068,6 +2118,7 @@ struct MainToolbarWindow : Window {
|
||||
case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
|
||||
case MTHK_BUILD_RAIL: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype); break;
|
||||
case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
|
||||
case MTHK_BUILD_TRAM: if (CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM)) ShowBuildRoadToolbar(_last_built_tramtype); break;
|
||||
case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
|
||||
case MTHK_BUILD_AIRPORT: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
|
||||
case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
|
||||
@@ -2080,16 +2131,14 @@ struct MainToolbarWindow : Window {
|
||||
case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
|
||||
case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
|
||||
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
||||
#ifdef ENABLE_NETWORK
|
||||
case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
|
||||
#endif
|
||||
case MTHK_SIGN_LIST: ShowSignList(); break;
|
||||
default: return ES_NOT_HANDLED;
|
||||
}
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
void OnPlaceObject(Point pt, TileIndex tile) override
|
||||
{
|
||||
switch (_last_started_action) {
|
||||
case CBF_PLACE_SIGN:
|
||||
@@ -2104,12 +2153,12 @@ struct MainToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPlaceObjectAbort()
|
||||
void OnPlaceObjectAbort() override
|
||||
{
|
||||
_last_started_action = CBF_NONE;
|
||||
}
|
||||
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
if (!this->timer.Elapsed(delta_ms)) return;
|
||||
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||
@@ -2125,7 +2174,7 @@ struct MainToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnTimeout()
|
||||
void OnTimeout() override
|
||||
{
|
||||
/* We do not want to automatically raise the pause, fast forward and
|
||||
* switchbar buttons; they have to stay down when pressed etc. */
|
||||
@@ -2142,10 +2191,10 @@ struct MainToolbarWindow : Window {
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TN_ZOOM_IN, WID_TN_ZOOM_OUT);
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != nullptr) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TN_ZOOM_IN, WID_TN_ZOOM_OUT);
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
@@ -2181,6 +2230,7 @@ static Hotkey maintoolbar_hotkeys[] = {
|
||||
Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTHK_ZOOM_OUT),
|
||||
Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL),
|
||||
Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD),
|
||||
Hotkey((uint16)0, "build_tram", MTHK_BUILD_TRAM),
|
||||
Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS),
|
||||
Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT),
|
||||
Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES),
|
||||
@@ -2193,9 +2243,7 @@ static Hotkey maintoolbar_hotkeys[] = {
|
||||
Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
|
||||
Hotkey('L', "terraform", MTHK_TERRAFORM),
|
||||
Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
|
||||
#ifdef ENABLE_NETWORK
|
||||
Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
|
||||
#endif
|
||||
Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
@@ -2228,6 +2276,7 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index)
|
||||
SPR_IMG_ZOOMOUT, // WID_TN_ZOOMOUT
|
||||
SPR_IMG_BUILDRAIL, // WID_TN_RAILS
|
||||
SPR_IMG_BUILDROAD, // WID_TN_ROADS
|
||||
SPR_IMG_BUILDTRAMS, // WID_TN_TRAMS
|
||||
SPR_IMG_BUILDWATER, // WID_TN_WATER
|
||||
SPR_IMG_BUILDAIR, // WID_TN_AIR
|
||||
SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE
|
||||
@@ -2261,7 +2310,7 @@ static const NWidgetPart _nested_toolbar_normal_widgets[] = {
|
||||
};
|
||||
|
||||
static WindowDesc _toolb_normal_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS,
|
||||
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
|
||||
@@ -2271,6 +2320,32 @@ static WindowDesc _toolb_normal_desc(
|
||||
|
||||
/* --- Toolbar handling for the scenario editor */
|
||||
|
||||
static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
|
||||
nullptr, // 0
|
||||
nullptr, // 1
|
||||
MenuClickSettings, // 2
|
||||
MenuClickSaveLoad, // 3
|
||||
nullptr, // 4
|
||||
nullptr, // 5
|
||||
nullptr, // 6
|
||||
nullptr, // 7
|
||||
MenuClickMap, // 8
|
||||
nullptr, // 9
|
||||
nullptr, // 10
|
||||
nullptr, // 11
|
||||
nullptr, // 12
|
||||
nullptr, // 13
|
||||
ToolbarScenBuildRoad, // 14
|
||||
ToolbarScenBuildTram, // 15
|
||||
nullptr, // 16
|
||||
nullptr, // 17
|
||||
nullptr, // 18
|
||||
nullptr, // 19
|
||||
MenuClickMusicWindow, // 20
|
||||
MenuClickHelp, // 21
|
||||
nullptr, // 22
|
||||
};
|
||||
|
||||
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
|
||||
ToolbarPauseClick,
|
||||
ToolbarFastForwardClick,
|
||||
@@ -2286,20 +2361,13 @@ static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
|
||||
ToolbarScenGenLand,
|
||||
ToolbarScenGenTown,
|
||||
ToolbarScenGenIndustry,
|
||||
ToolbarScenBuildRoad,
|
||||
ToolbarScenBuildRoadClick,
|
||||
ToolbarScenBuildTramClick,
|
||||
ToolbarScenBuildDocks,
|
||||
ToolbarScenPlantTrees,
|
||||
ToolbarScenPlaceSign,
|
||||
ToolbarBtn_NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ToolbarMusicClick,
|
||||
NULL,
|
||||
ToolbarHelpClick,
|
||||
ToolbarSwitchClick,
|
||||
};
|
||||
@@ -2313,6 +2381,7 @@ enum MainToolbarEditorHotkeys {
|
||||
MTEHK_GENTOWN,
|
||||
MTEHK_GENINDUSTRY,
|
||||
MTEHK_BUILD_ROAD,
|
||||
MTEHK_BUILD_TRAM,
|
||||
MTEHK_BUILD_DOCKS,
|
||||
MTEHK_BUILD_TREES,
|
||||
MTEHK_SIGN,
|
||||
@@ -2344,20 +2413,22 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||
}
|
||||
|
||||
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
|
||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||
{
|
||||
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= MIN_YEAR);
|
||||
this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= MAX_YEAR);
|
||||
this->SetWidgetDisabledState(WID_TE_ROADS, (GetRoadTypes(true) & ~_roadtypes_type) == ROADTYPES_NONE);
|
||||
this->SetWidgetDisabledState(WID_TE_TRAMS, (GetRoadTypes(true) & _roadtypes_type) == ROADTYPES_NONE);
|
||||
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_TE_DATE:
|
||||
@@ -2378,7 +2449,7 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_TE_SPACER:
|
||||
@@ -2393,24 +2464,21 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
if (_game_mode == GM_MENU) return;
|
||||
CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
|
||||
if (cbf != CBF_NONE) _last_started_action = cbf;
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
/* The map button is in a different location on the scenario
|
||||
* editor toolbar, so we need to adjust for it. */
|
||||
if (widget == WID_TE_SMALL_MAP) widget = WID_TN_SMALL_MAP;
|
||||
CallBackFunction cbf = _menu_clicked_procs[widget](index);
|
||||
CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
|
||||
if (cbf != CBF_NONE) _last_started_action = cbf;
|
||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
}
|
||||
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
EventState OnHotkey(int hotkey) override
|
||||
{
|
||||
CallBackFunction cbf = CBF_NONE;
|
||||
switch (hotkey) {
|
||||
@@ -2421,7 +2489,8 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
|
||||
case MTEHK_GENTOWN: ToolbarScenGenTown(this); break;
|
||||
case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
|
||||
case MTEHK_BUILD_ROAD: ToolbarScenBuildRoad(this); break;
|
||||
case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
|
||||
case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
|
||||
case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(this); break;
|
||||
case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
|
||||
case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
|
||||
@@ -2442,7 +2511,7 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
void OnPlaceObject(Point pt, TileIndex tile) override
|
||||
{
|
||||
switch (_last_started_action) {
|
||||
case CBF_PLACE_SIGN:
|
||||
@@ -2457,19 +2526,19 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPlaceObjectAbort()
|
||||
void OnPlaceObjectAbort() override
|
||||
{
|
||||
_last_started_action = CBF_NONE;
|
||||
}
|
||||
|
||||
virtual void OnTimeout()
|
||||
void OnTimeout() override
|
||||
{
|
||||
this->SetWidgetsLoweredState(false, WID_TE_DATE_BACKWARD, WID_TE_DATE_FORWARD, WIDGET_LIST_END);
|
||||
this->SetWidgetDirty(WID_TE_DATE_BACKWARD);
|
||||
this->SetWidgetDirty(WID_TE_DATE_FORWARD);
|
||||
}
|
||||
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
if (!this->timer.Elapsed(delta_ms)) return;
|
||||
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||
@@ -2490,16 +2559,16 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT);
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != nullptr) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT);
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
/* Was 'cancel' pressed? */
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
int32 value;
|
||||
if (!StrEmpty(str)) {
|
||||
@@ -2525,6 +2594,7 @@ static Hotkey scenedit_maintoolbar_hotkeys[] = {
|
||||
Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
|
||||
Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
|
||||
Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
|
||||
Hotkey((uint16)0, "build_tram", MTEHK_BUILD_TRAM),
|
||||
Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
|
||||
Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
|
||||
Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
|
||||
@@ -2567,7 +2637,8 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_LAND_GENERATE), SetDataTip(SPR_IMG_LANDSCAPING, STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TOWN_GENERATE), SetDataTip(SPR_IMG_TOWN, STR_SCENEDIT_TOOLBAR_TOWN_GENERATION),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_INDUSTRY), SetDataTip(SPR_IMG_INDUSTRY, STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ROADS), SetDataTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION),
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_ROADS), SetDataTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION),
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TRAMS), SetDataTip(SPR_IMG_BUILDTRAMS, STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_WATER), SetDataTip(SPR_IMG_BUILDWATER, STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TREES), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_SIGNS), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
|
||||
@@ -2587,7 +2658,7 @@ static const NWidgetPart _nested_toolb_scen_widgets[] = {
|
||||
};
|
||||
|
||||
static WindowDesc _toolb_scen_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS,
|
||||
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
|
||||
@@ -2599,6 +2670,7 @@ void AllocateToolbar()
|
||||
{
|
||||
/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
|
||||
_last_built_roadtype = ROADTYPE_ROAD;
|
||||
_last_built_tramtype = ROADTYPE_TRAM;
|
||||
|
||||
if (_game_mode == GM_EDITOR) {
|
||||
new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
|
||||
|
||||
Reference in New Issue
Block a user