2008-03-23 07:35:29 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-03-23 07:35:29 +00:00
|
|
|
/** @file toolbar_gui.cpp Code related to the (main) toolbar. */
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "window_gui.h"
|
|
|
|
#include "window_func.h"
|
|
|
|
#include "viewport_func.h"
|
|
|
|
#include "command_func.h"
|
|
|
|
#include "vehicle_gui.h"
|
|
|
|
#include "rail_gui.h"
|
|
|
|
#include "road_gui.h"
|
|
|
|
#include "date_func.h"
|
|
|
|
#include "vehicle_func.h"
|
|
|
|
#include "sound_func.h"
|
|
|
|
#include "terraform_gui.h"
|
|
|
|
#include "strings_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
|
|
|
#include "company_gui.h"
|
2008-03-23 07:35:29 +00:00
|
|
|
#include "vehicle_base.h"
|
2008-04-17 21:21:01 +00:00
|
|
|
#include "cheat_func.h"
|
2008-04-18 15:11:39 +00:00
|
|
|
#include "transparency_gui.h"
|
|
|
|
#include "screenshot.h"
|
|
|
|
#include "signs_func.h"
|
|
|
|
#include "fios.h"
|
2008-05-24 10:15:06 +00:00
|
|
|
#include "console_gui.h"
|
2008-04-18 15:18:16 +00:00
|
|
|
#include "news_gui.h"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "ai/ai_gui.hpp"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2010-02-08 21:19:41 +00:00
|
|
|
#include "smallmap_gui.h"
|
2010-02-10 15:24:48 +00:00
|
|
|
#include "graph_gui.h"
|
2010-03-13 10:18:57 +00:00
|
|
|
#include "textbuf_gui.h"
|
2013-05-19 14:43:23 +00:00
|
|
|
#include "linkgraph/linkgraph_gui.h"
|
2010-04-25 16:27:30 +00:00
|
|
|
#include "newgrf_debug.h"
|
2010-07-03 19:35:54 +00:00
|
|
|
#include "hotkeys.h"
|
2011-01-16 10:25:47 +00:00
|
|
|
#include "engine_base.h"
|
2012-12-05 19:37:15 +00:00
|
|
|
#include "highscore.h"
|
2013-05-29 18:49:58 +00:00
|
|
|
#include "game/game.hpp"
|
2013-09-13 12:45:25 +00:00
|
|
|
#include "goal_base.h"
|
|
|
|
#include "story_base.h"
|
2015-02-13 21:13:45 +00:00
|
|
|
#include "toolbar_gui.h"
|
2018-07-19 19:17:07 +00:00
|
|
|
#include "framerate_type.h"
|
2018-05-20 08:58:36 +00:00
|
|
|
#include "guitimer_func.h"
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/toolbar_widget.h"
|
|
|
|
|
2008-03-23 07:35:29 +00:00
|
|
|
#include "network/network.h"
|
2008-04-18 15:11:39 +00:00
|
|
|
#include "network/network_gui.h"
|
2009-01-23 22:18:06 +00:00
|
|
|
#include "network/network_func.h"
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2015-02-13 21:13:45 +00:00
|
|
|
/** Width of the toolbar, shared by statusbar. */
|
|
|
|
uint _toolbar_width = 0;
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
RailType _last_built_railtype;
|
2010-07-04 10:57:31 +00:00
|
|
|
RoadType _last_built_roadtype;
|
2008-04-18 15:11:39 +00:00
|
|
|
|
2012-12-09 16:53:21 +00:00
|
|
|
static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the current query is about to confirm.
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/** Toobar modes */
|
2008-05-29 23:33:37 +00:00
|
|
|
enum ToolbarMode {
|
|
|
|
TB_NORMAL,
|
|
|
|
TB_UPPER,
|
|
|
|
TB_LOWER
|
|
|
|
};
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
/** Callback functions. */
|
|
|
|
enum CallBackFunction {
|
|
|
|
CBF_NONE,
|
2010-12-21 22:00:08 +00:00
|
|
|
CBF_PLACE_SIGN,
|
|
|
|
CBF_PLACE_LANDINFO,
|
2010-12-21 21:48:31 +00:00
|
|
|
};
|
|
|
|
|
2016-08-15 18:32:25 +00:00
|
|
|
static CallBackFunction _last_started_action = CBF_NONE; ///< Last started user action.
|
|
|
|
|
|
|
|
|
2008-08-25 20:42:54 +00:00
|
|
|
/**
|
|
|
|
* Drop down list entry for showing a checked/unchecked toggle item.
|
|
|
|
*/
|
|
|
|
class DropDownListCheckedItem : public DropDownListStringItem {
|
2009-11-27 16:20:56 +00:00
|
|
|
uint checkmark_width;
|
2008-08-25 20:42:54 +00:00
|
|
|
public:
|
|
|
|
bool checked;
|
|
|
|
|
2009-11-27 16:20:56 +00:00
|
|
|
DropDownListCheckedItem(StringID string, int result, bool masked, bool checked) : DropDownListStringItem(string, result, masked), checked(checked)
|
|
|
|
{
|
|
|
|
this->checkmark_width = GetStringBoundingBox(STR_JUST_CHECKMARK).width + 3;
|
|
|
|
}
|
2008-08-25 20:42:54 +00:00
|
|
|
|
|
|
|
virtual ~DropDownListCheckedItem() {}
|
|
|
|
|
2009-11-27 16:20:56 +00:00
|
|
|
uint Width() const
|
|
|
|
{
|
2009-11-27 16:35:34 +00:00
|
|
|
return DropDownListStringItem::Width() + this->checkmark_width;
|
2009-11-27 16:20:56 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 19:31:47 +00:00
|
|
|
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
2008-08-25 20:42:54 +00:00
|
|
|
{
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-11-27 16:35:34 +00:00
|
|
|
if (this->checked) {
|
2009-11-27 16:18:03 +00:00
|
|
|
DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
2009-11-27 16:35:34 +00:00
|
|
|
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : this->checkmark_width), right - WD_FRAMERECT_RIGHT - (rtl ? this->checkmark_width : 0), top, this->String(), sel ? TC_WHITE : TC_BLACK);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
2008-06-18 03:19:31 +00:00
|
|
|
};
|
|
|
|
|
2008-08-25 20:42:54 +00:00
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Drop down list entry for showing a company entry, with companies 'blob'.
|
2008-08-25 20:42:54 +00:00
|
|
|
*/
|
|
|
|
class DropDownListCompanyItem : public DropDownListItem {
|
2011-10-11 13:18:52 +00:00
|
|
|
Dimension icon_size;
|
2019-01-22 12:42:52 +00:00
|
|
|
Dimension lock_size;
|
2008-08-25 20:42:54 +00:00
|
|
|
public:
|
|
|
|
bool greyed;
|
2008-05-29 23:33:37 +00:00
|
|
|
|
2009-11-27 16:46:17 +00:00
|
|
|
DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed)
|
|
|
|
{
|
2011-10-11 13:18:52 +00:00
|
|
|
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
2019-01-22 12:42:52 +00:00
|
|
|
this->lock_size = GetSpriteSize(SPR_LOCK);
|
2009-11-27 16:46:17 +00:00
|
|
|
}
|
2008-08-25 20:42:54 +00:00
|
|
|
|
|
|
|
virtual ~DropDownListCompanyItem() {}
|
|
|
|
|
|
|
|
bool Selectable() const
|
|
|
|
{
|
|
|
|
return true;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2008-08-25 20:42:54 +00:00
|
|
|
uint Width() const
|
|
|
|
{
|
2009-11-27 16:35:34 +00:00
|
|
|
CompanyID company = (CompanyID)this->result;
|
2008-09-30 20:39:50 +00:00
|
|
|
SetDParam(0, company);
|
|
|
|
SetDParam(1, company);
|
2019-01-22 12:42:52 +00:00
|
|
|
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
|
2011-10-11 13:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint Height(uint width) const
|
|
|
|
{
|
2019-01-22 12:42:52 +00:00
|
|
|
return max(max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-03-21 19:31:47 +00:00
|
|
|
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
2008-08-25 20:42:54 +00:00
|
|
|
{
|
2009-11-27 16:35:34 +00:00
|
|
|
CompanyID company = (CompanyID)this->result;
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-05-26 11:57:52 +00:00
|
|
|
|
|
|
|
/* It's possible the company is deleted while the dropdown is open */
|
|
|
|
if (!Company::IsValidID(company)) return;
|
|
|
|
|
2011-10-11 13:18:52 +00:00
|
|
|
int icon_offset = (bottom - top - icon_size.height) / 2;
|
|
|
|
int text_offset = (bottom - top - FONT_HEIGHT_NORMAL) / 2;
|
2019-01-22 12:42:52 +00:00
|
|
|
int lock_offset = (bottom - top - lock_size.height) / 2;
|
2011-10-11 13:18:52 +00:00
|
|
|
|
|
|
|
DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
|
2019-01-22 12:42:52 +00:00
|
|
|
if (NetworkCompanyIsPassworded(company)) {
|
|
|
|
DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
|
|
|
|
}
|
2008-08-25 20:42:54 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
SetDParam(0, company);
|
|
|
|
SetDParam(1, company);
|
2009-02-09 02:09:47 +00:00
|
|
|
TextColour col;
|
2008-08-25 20:42:54 +00:00
|
|
|
if (this->greyed) {
|
2012-01-28 20:10:49 +00:00
|
|
|
col = (sel ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
|
2008-08-25 20:42:54 +00:00
|
|
|
} else {
|
|
|
|
col = sel ? TC_WHITE : TC_BLACK;
|
|
|
|
}
|
2019-01-22 12:42:52 +00:00
|
|
|
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 3 + this->lock_size.width : 3 + this->icon_size.width), right - WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 3 + this->lock_size.width), top + text_offset, STR_COMPANY_NAME_COMPANY_NUM, col);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pop up a generic text only menu.
|
2013-06-08 16:54:19 +00:00
|
|
|
* @param w Toolbar
|
|
|
|
* @param widget Toolbar button
|
|
|
|
* @param list List of items
|
|
|
|
* @param def Default item
|
|
|
|
*/
|
|
|
|
static void PopupMainToolbMenu(Window *w, int widget, DropDownList *list, int def)
|
|
|
|
{
|
|
|
|
ShowDropDownList(w, list, def, widget, 0, true, true);
|
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pop up a generic text only menu.
|
|
|
|
* @param w Toolbar
|
|
|
|
* @param widget Toolbar button
|
|
|
|
* @param string String for the first item in the menu
|
|
|
|
* @param count Number of items in the menu
|
2008-08-25 20:42:54 +00:00
|
|
|
*/
|
2013-06-09 15:36:31 +00:00
|
|
|
static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
|
2008-08-25 20:42:54 +00:00
|
|
|
{
|
|
|
|
DropDownList *list = new DropDownList();
|
2013-06-09 15:36:31 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(string + i, i, false);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
2013-06-09 15:36:31 +00:00
|
|
|
PopupMainToolbMenu(w, widget, list, 0);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 22:18:06 +00:00
|
|
|
/** Enum for the Company Toolbar's network related buttons */
|
2010-05-13 10:14:29 +00:00
|
|
|
static const int CTMN_CLIENT_LIST = -1; ///< Show the client list
|
|
|
|
static const int CTMN_NEW_COMPANY = -2; ///< Create a new company
|
|
|
|
static const int CTMN_SPECTATE = -3; ///< Become spectator
|
2013-09-13 12:45:25 +00:00
|
|
|
static const int CTMN_SPECTATOR = -4; ///< Show a company window as spectator
|
2009-01-23 22:18:06 +00:00
|
|
|
|
2008-05-08 12:59:47 +00:00
|
|
|
/**
|
2008-08-25 20:42:54 +00:00
|
|
|
* Pop up a generic company list menu.
|
2013-09-13 12:45:25 +00:00
|
|
|
* @param w The toolbar window.
|
|
|
|
* @param widget The button widget id.
|
|
|
|
* @param grey A bitbask of which items to mark as disabled.
|
|
|
|
* @param include_spectator If true, a spectator option is included in the list.
|
2008-05-08 12:59:47 +00:00
|
|
|
*/
|
2019-02-16 17:37:00 +00:00
|
|
|
static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
|
2008-05-08 12:59:47 +00:00
|
|
|
{
|
2008-08-25 20:42:54 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
2008-05-09 15:27:00 +00:00
|
|
|
|
2019-02-16 17:37:00 +00:00
|
|
|
switch (widget) {
|
|
|
|
case WID_TN_COMPANIES:
|
2009-01-23 22:18:06 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
2019-02-16 17:37:00 +00:00
|
|
|
if (!_networking) break;
|
|
|
|
|
2013-09-13 12:45:25 +00:00
|
|
|
/* Add the client list button for the companies menu */
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false);
|
2009-01-23 22:18:06 +00:00
|
|
|
|
2019-02-16 17:37:00 +00:00
|
|
|
if (_local_company == COMPANY_SPECTATOR) {
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached());
|
2013-09-13 12:45:25 +00:00
|
|
|
} else {
|
2019-02-16 17:37:00 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached());
|
2013-09-13 12:45:25 +00:00
|
|
|
}
|
2009-01-23 22:18:06 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2019-02-16 17:37:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WID_TN_STORY:
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WID_TN_GOAL:
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false);
|
|
|
|
break;
|
|
|
|
}
|
2008-05-08 12:59:47 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
2009-05-17 01:00:56 +00:00
|
|
|
if (!Company::IsValidID(c)) continue;
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListCompanyItem(c, false, HasBit(grey, c));
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-08 16:54:19 +00:00
|
|
|
PopupMainToolbMenu(w, widget, list, _local_company == COMPANY_SPECTATOR ? CTMN_CLIENT_LIST : (int)_local_company);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ToolbarMode _toolbar_mode;
|
|
|
|
|
2010-12-21 22:00:08 +00:00
|
|
|
static CallBackFunction SelectSignTool()
|
2008-08-25 20:42:54 +00:00
|
|
|
{
|
2016-08-15 18:32:25 +00:00
|
|
|
if (_last_started_action == CBF_PLACE_SIGN) {
|
2008-08-25 20:42:54 +00:00
|
|
|
ResetObjectToPlace();
|
2010-12-21 22:00:08 +00:00
|
|
|
return CBF_NONE;
|
2008-08-25 20:42:54 +00:00
|
|
|
} else {
|
2009-04-19 10:31:30 +00:00
|
|
|
SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
|
2010-12-21 22:00:08 +00:00
|
|
|
return CBF_PLACE_SIGN;
|
2008-05-08 12:59:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Pausing --- */
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarPauseClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2010-12-21 21:48:31 +00:00
|
|
|
if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2012-12-23 21:09:09 +00:00
|
|
|
if (DoCommandP(0, PM_PAUSED_NORMAL, _pause_mode == PM_UNPAUSED, CMD_PAUSE)) {
|
|
|
|
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
|
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Toggle fast forward mode.
|
|
|
|
*
|
|
|
|
* @param w Unused.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarFastForwardClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
_fast_forward ^= true;
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Game Option button menu entries.
|
|
|
|
*/
|
2008-06-17 23:51:17 +00:00
|
|
|
enum OptionMenuEntries {
|
2008-08-25 20:42:54 +00:00
|
|
|
OME_GAMEOPTIONS,
|
2009-02-08 12:25:13 +00:00
|
|
|
OME_SETTINGS,
|
2011-12-19 20:56:06 +00:00
|
|
|
OME_SCRIPT_SETTINGS,
|
2008-06-17 23:51:17 +00:00
|
|
|
OME_NEWGRFSETTINGS,
|
|
|
|
OME_TRANSPARENCIES,
|
2008-08-25 20:42:54 +00:00
|
|
|
OME_SHOW_TOWNNAMES,
|
2008-06-17 23:51:17 +00:00
|
|
|
OME_SHOW_STATIONNAMES,
|
|
|
|
OME_SHOW_WAYPOINTNAMES,
|
2009-07-25 11:02:15 +00:00
|
|
|
OME_SHOW_SIGNS,
|
2011-08-01 18:41:21 +00:00
|
|
|
OME_SHOW_COMPETITOR_SIGNS,
|
2008-06-17 23:51:17 +00:00
|
|
|
OME_FULL_ANIMATION,
|
|
|
|
OME_FULL_DETAILS,
|
|
|
|
OME_TRANSPARENTBUILDINGS,
|
|
|
|
OME_SHOW_STATIONSIGNS,
|
|
|
|
};
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on Options button in toolbar.
|
|
|
|
*
|
|
|
|
* @param w parent window the shown Drop down list is attached to.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarOptionsClick(Window *w)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-08-25 20:42:54 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false);
|
2014-10-09 21:16:29 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false);
|
2011-01-02 12:41:24 +00:00
|
|
|
/* 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. */
|
2013-11-24 14:46:26 +00:00
|
|
|
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));
|
2008-08-25 20:42:54 +00:00
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on one of the entries in the Options button menu.
|
|
|
|
*
|
|
|
|
* @param index Index being clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickSettings(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
2010-12-21 21:48:31 +00:00
|
|
|
case OME_GAMEOPTIONS: ShowGameOptions(); return CBF_NONE;
|
|
|
|
case OME_SETTINGS: ShowGameSettings(); return CBF_NONE;
|
2011-12-19 20:56:06 +00:00
|
|
|
case OME_SCRIPT_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
|
2010-12-21 21:48:31 +00:00
|
|
|
case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return CBF_NONE;
|
2009-07-25 10:54:42 +00:00
|
|
|
case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
|
|
|
|
|
|
|
|
case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
|
|
|
|
case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
|
|
|
|
case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break;
|
2009-07-25 11:02:15 +00:00
|
|
|
case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
|
2011-08-01 18:41:21 +00:00
|
|
|
case OME_SHOW_COMPETITOR_SIGNS:
|
|
|
|
ToggleBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
|
|
|
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
|
|
|
|
break;
|
2014-01-03 08:51:49 +00:00
|
|
|
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
|
2009-07-25 10:54:42 +00:00
|
|
|
case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
|
|
|
|
case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
|
|
|
|
case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
MarkWholeScreenDirty();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* SaveLoad entries in scenario editor mode.
|
|
|
|
*/
|
2008-06-20 01:55:00 +00:00
|
|
|
enum SaveLoadEditorMenuEntries {
|
|
|
|
SLEME_SAVE_SCENARIO = 0,
|
|
|
|
SLEME_LOAD_SCENARIO,
|
2011-05-28 13:56:35 +00:00
|
|
|
SLEME_SAVE_HEIGHTMAP,
|
2008-06-20 01:55:00 +00:00
|
|
|
SLEME_LOAD_HEIGHTMAP,
|
|
|
|
SLEME_EXIT_TOINTRO,
|
2011-05-28 13:56:35 +00:00
|
|
|
SLEME_EXIT_GAME = 6,
|
2008-06-20 01:55:00 +00:00
|
|
|
SLEME_MENUCOUNT,
|
|
|
|
};
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* SaveLoad entries in normal game mode.
|
|
|
|
*/
|
2008-06-20 01:55:00 +00:00
|
|
|
enum SaveLoadNormalMenuEntries {
|
|
|
|
SLNME_SAVE_GAME = 0,
|
|
|
|
SLNME_LOAD_GAME,
|
|
|
|
SLNME_EXIT_TOINTRO,
|
2012-02-25 13:58:06 +00:00
|
|
|
SLNME_EXIT_GAME = 4,
|
2008-06-20 01:55:00 +00:00
|
|
|
SLNME_MENUCOUNT,
|
|
|
|
};
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on Save button in toolbar in normal game mode.
|
|
|
|
*
|
|
|
|
* @param w parent window the shown save dialogue is attached to.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarSaveClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_SAVE, STR_FILE_MENU_SAVE_GAME, SLNME_MENUCOUNT);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on SaveLoad button in toolbar in the scenario editor.
|
|
|
|
*
|
|
|
|
* @param w parent window the shown save dialogue is attached to.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TE_SAVE, STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, SLEME_MENUCOUNT);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on one of the entries in the SaveLoad menu.
|
|
|
|
*
|
|
|
|
* @param index Index being clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickSaveLoad(int index = 0)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
if (_game_mode == GM_EDITOR) {
|
|
|
|
switch (index) {
|
2016-09-04 16:06:50 +00:00
|
|
|
case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
|
|
|
|
case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
|
|
|
|
case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_SAVE); break;
|
|
|
|
case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
|
2008-06-20 01:55:00 +00:00
|
|
|
case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
|
|
|
case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (index) {
|
2016-09-04 16:06:50 +00:00
|
|
|
case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
|
|
|
|
case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
|
2008-06-20 01:55:00 +00:00
|
|
|
case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
|
|
|
case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Map button menu --- */
|
|
|
|
|
2008-06-21 01:40:56 +00:00
|
|
|
enum MapMenuEntries {
|
|
|
|
MME_SHOW_SMALLMAP = 0,
|
|
|
|
MME_SHOW_EXTRAVIEWPORTS,
|
2013-05-19 14:43:23 +00:00
|
|
|
MME_SHOW_LINKGRAPH,
|
2008-06-21 01:40:56 +00:00
|
|
|
MME_SHOW_SIGNLISTS,
|
2013-06-08 16:54:19 +00:00
|
|
|
MME_SHOW_TOWNDIRECTORY,
|
|
|
|
MME_SHOW_INDUSTRYDIRECTORY,
|
2008-06-21 01:40:56 +00:00
|
|
|
};
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarMapClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2013-06-08 16:54:19 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
2013-11-24 14:46:26 +00:00
|
|
|
*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);
|
2013-06-08 16:54:19 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_SMALL_MAP, list, 0);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenMapTownDir(Window *w)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2013-06-08 16:54:19 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
2013-11-24 14:46:26 +00:00
|
|
|
*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);
|
2013-06-08 16:54:19 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TE_SMALL_MAP, list, 0);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on one of the entries in the Map menu.
|
|
|
|
*
|
|
|
|
* @param index Index being clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickMap(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
2008-06-21 01:40:56 +00:00
|
|
|
case MME_SHOW_SMALLMAP: ShowSmallMap(); break;
|
|
|
|
case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewPortWindow(); break;
|
2013-05-19 14:43:23 +00:00
|
|
|
case MME_SHOW_LINKGRAPH: ShowLinkGraphLegend(); break;
|
2008-06-21 01:40:56 +00:00
|
|
|
case MME_SHOW_SIGNLISTS: ShowSignList(); break;
|
2013-06-08 16:54:19 +00:00
|
|
|
case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory(); break;
|
|
|
|
case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Town button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarTownClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_TOWNS, STR_TOWN_MENU_TOWN_DIRECTORY, (_settings_game.economy.found_town == TF_FORBIDDEN) ? 1 : 2);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on one of the entries in the Town menu.
|
|
|
|
*
|
|
|
|
* @param index Index being clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickTown(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2009-11-24 21:18:11 +00:00
|
|
|
switch (index) {
|
|
|
|
case 0: ShowTownDirectory(); break;
|
|
|
|
case 1: // setting could be changed when the dropdown was open
|
|
|
|
if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow();
|
|
|
|
break;
|
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Subidies button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarSubsidiesClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2013-05-29 18:49:58 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_SUBSIDIES, STR_SUBSIDIES_MENU_SUBSIDIES, 1);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Subsidies menu.
|
|
|
|
*
|
|
|
|
* @param index Unused.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickSubsidies(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2011-12-19 21:03:17 +00:00
|
|
|
switch (index) {
|
|
|
|
case 0: ShowSubsidiesList(); break;
|
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Stations button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarStationsClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_STATIONS);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Stations menu
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show station list for
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickStations(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowCompanyStations((CompanyID)index);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Finances button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarFinancesClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_FINANCES);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the finances overview menu.
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show finances for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickFinances(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowCompanyFinances((CompanyID)index);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Company's button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarCompaniesClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2019-02-16 17:37:00 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_COMPANIES, 0);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Company menu.
|
|
|
|
*
|
|
|
|
* @param index Menu entry to handle.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickCompany(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2009-01-23 22:18:06 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
if (_networking) {
|
|
|
|
switch (index) {
|
|
|
|
case CTMN_CLIENT_LIST:
|
|
|
|
ShowClientList();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2009-01-23 22:18:06 +00:00
|
|
|
|
|
|
|
case CTMN_NEW_COMPANY:
|
|
|
|
if (_network_server) {
|
2019-02-04 17:06:19 +00:00
|
|
|
DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL);
|
2009-01-23 22:18:06 +00:00
|
|
|
} else {
|
2019-02-04 17:06:19 +00:00
|
|
|
NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
|
2009-01-23 22:18:06 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2009-01-23 22:18:06 +00:00
|
|
|
|
|
|
|
case CTMN_SPECTATE:
|
|
|
|
if (_network_server) {
|
|
|
|
NetworkServerDoMove(CLIENT_ID_SERVER, COMPANY_SPECTATOR);
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
} else {
|
|
|
|
NetworkClientRequestMove(COMPANY_SPECTATOR);
|
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2009-01-23 22:18:06 +00:00
|
|
|
}
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2009-01-23 22:18:06 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
ShowCompany((CompanyID)index);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-09 13:37:04 +00:00
|
|
|
/* --- Story button menu --- */
|
|
|
|
|
|
|
|
static CallBackFunction ToolbarStoryClick(Window *w)
|
|
|
|
{
|
2019-02-16 17:37:00 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_STORY, 0);
|
2013-06-09 13:37:04 +00:00
|
|
|
return CBF_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Story menu
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show story book for
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
|
|
|
static CallBackFunction MenuClickStory(int index)
|
|
|
|
{
|
2013-09-13 12:45:25 +00:00
|
|
|
ShowStoryBook(index == CTMN_SPECTATOR ? INVALID_COMPANY : (CompanyID)index);
|
2013-06-09 13:37:04 +00:00
|
|
|
return CBF_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Goal button menu --- */
|
|
|
|
|
|
|
|
static CallBackFunction ToolbarGoalClick(Window *w)
|
|
|
|
{
|
2019-02-16 17:37:00 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_GOAL, 0);
|
2013-06-09 13:37:04 +00:00
|
|
|
return CBF_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Goal menu
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show story book for
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
|
|
|
static CallBackFunction MenuClickGoal(int index)
|
|
|
|
{
|
2013-09-13 12:45:25 +00:00
|
|
|
ShowGoalsList(index == CTMN_SPECTATOR ? INVALID_COMPANY : (CompanyID)index);
|
2013-06-09 13:37:04 +00:00
|
|
|
return CBF_NONE;
|
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Graphs button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarGraphsClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_GRAPHS, STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Graphs menu.
|
|
|
|
*
|
|
|
|
* @param index Graph to show.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickGraphs(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
|
|
|
case 0: ShowOperatingProfitGraph(); break;
|
|
|
|
case 1: ShowIncomeGraph(); break;
|
|
|
|
case 2: ShowDeliveredCargoGraph(); break;
|
|
|
|
case 3: ShowPerformanceHistoryGraph(); break;
|
|
|
|
case 4: ShowCompanyValueGraph(); break;
|
|
|
|
case 5: ShowCargoPaymentRates(); break;
|
2008-05-29 23:33:37 +00:00
|
|
|
/* functions for combined graphs/league button */
|
|
|
|
case 6: ShowCompanyLeagueTable(); break;
|
|
|
|
case 7: ShowPerformanceRatingDetail(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- League button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarLeagueClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2013-06-09 15:36:31 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_LEAGUE, STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, _networking ? 2 : 3);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the CompanyLeague menu.
|
|
|
|
*
|
|
|
|
* @param index Menu entry number.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickLeague(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
2013-06-09 15:36:31 +00:00
|
|
|
case 0: ShowCompanyLeagueTable(); break;
|
|
|
|
case 1: ShowPerformanceRatingDetail(); break;
|
|
|
|
case 2: ShowHighscoreTable(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Industries button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarIndustryClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
/* Disable build-industry menu if we are a spectator */
|
2012-11-25 15:24:02 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, (_local_company == COMPANY_SPECTATOR) ? 2 : 3);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Industry menu.
|
|
|
|
*
|
|
|
|
* @param index Menu entry number.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickIndustry(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
2012-11-25 15:24:02 +00:00
|
|
|
case 0: ShowIndustryDirectory(); break;
|
|
|
|
case 1: ShowIndustryCargoesWindow(); break;
|
|
|
|
case 2: ShowBuildIndustryWindow(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Trains button menu + 1 helper function for all vehicles. --- */
|
|
|
|
|
|
|
|
static void ToolbarVehicleClick(Window *w, VehicleType veh)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
const Vehicle *v;
|
2008-04-18 15:11:39 +00:00
|
|
|
int dis = ~0;
|
2008-03-23 07:35:29 +00:00
|
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
2008-04-25 06:15:58 +00:00
|
|
|
if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarTrainClick(Window *w)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
ToolbarVehicleClick(w, VEH_TRAIN);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Train menu.
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show train list for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickShowTrains(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Road vehicle button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarRoadClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-18 15:11:39 +00:00
|
|
|
ToolbarVehicleClick(w, VEH_ROAD);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Road Vehicles menu.
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show road vehicles list for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickShowRoad(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Ship button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarShipClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-18 15:11:39 +00:00
|
|
|
ToolbarVehicleClick(w, VEH_SHIP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Ships menu.
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show ship list for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickShowShips(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Aircraft button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarAirClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-18 15:11:39 +00:00
|
|
|
ToolbarVehicleClick(w, VEH_AIRCRAFT);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Aircraft menu.
|
|
|
|
*
|
|
|
|
* @param index CompanyID to show aircraft list for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickShowAir(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Zoom in button --- */
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarZoomInClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Zoom out button --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarZoomOutClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-18 04:37:06 +00:00
|
|
|
if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Rail button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarBuildRailClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true, true);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Build Rail menu.
|
|
|
|
*
|
|
|
|
* @param index RailType to show the build toolbar for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickBuildRail(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
_last_built_railtype = (RailType)index;
|
2010-07-03 20:40:18 +00:00
|
|
|
ShowBuildRailToolbar(_last_built_railtype);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Road button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarBuildRoadClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2009-05-16 23:34:14 +00:00
|
|
|
const Company *c = Company::Get(_local_company);
|
2008-08-25 20:42:54 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
2011-01-16 10:25:47 +00:00
|
|
|
|
|
|
|
/* Road is always visible and available. */
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false);
|
2011-01-16 10:25:47 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2013-11-24 14:46:26 +00:00
|
|
|
*list->Append() = new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
|
2011-01-16 10:25:47 +00:00
|
|
|
break;
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
2011-12-16 18:23:35 +00:00
|
|
|
ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Build Road menu.
|
|
|
|
*
|
|
|
|
* @param index RoadType to show the build toolbar for.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickBuildRoad(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
_last_built_roadtype = (RoadType)index;
|
|
|
|
ShowBuildRoadToolbar(_last_built_roadtype);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Water button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarBuildWaterClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_WATER, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 1);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Build Waterways menu.
|
|
|
|
*
|
|
|
|
* @param index Unused.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickBuildWater(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
ShowBuildDocksToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Airport button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarBuildAirClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_AIR, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 1);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Build Air menu.
|
|
|
|
*
|
|
|
|
* @param index Unused.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickBuildAir(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
ShowBuildAirToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Forest button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarForestClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 3);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the landscaping menu.
|
|
|
|
*
|
|
|
|
* @param index Menu entry clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickForest(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
|
|
|
case 0: ShowTerraformToolbar(); break;
|
|
|
|
case 1: ShowBuildTreesToolbar(); break;
|
2010-12-21 22:00:08 +00:00
|
|
|
case 2: return SelectSignTool();
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Music button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarMusicClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Music menu.
|
|
|
|
*
|
|
|
|
* @param index Unused.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickMusicWindow(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
ShowMusicWindow();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Newspaper button menu --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarNewspaperClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2019-02-16 23:15:58 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 3);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 15:51:48 +00:00
|
|
|
/**
|
|
|
|
* Handle click on the entry in the Newspaper menu.
|
|
|
|
*
|
|
|
|
* @param index Menu entry clicked.
|
|
|
|
* @return #CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickNewspaper(int index)
|
2008-04-18 15:11:39 +00:00
|
|
|
{
|
|
|
|
switch (index) {
|
|
|
|
case 0: ShowLastNewsMessage(); break;
|
2012-12-23 21:06:37 +00:00
|
|
|
case 1: ShowMessageHistory(); break;
|
2019-02-16 23:15:58 +00:00
|
|
|
case 2: DeleteAllMessages(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- Help button menu --- */
|
|
|
|
|
2010-12-21 22:00:08 +00:00
|
|
|
static CallBackFunction PlaceLandBlockInfo()
|
2010-12-21 21:46:19 +00:00
|
|
|
{
|
2016-08-15 18:32:25 +00:00
|
|
|
if (_last_started_action == CBF_PLACE_LANDINFO) {
|
2010-12-21 21:46:19 +00:00
|
|
|
ResetObjectToPlace();
|
2010-12-21 22:00:08 +00:00
|
|
|
return CBF_NONE;
|
2010-12-21 21:46:19 +00:00
|
|
|
} else {
|
|
|
|
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
|
2010-12-21 22:00:08 +00:00
|
|
|
return CBF_PLACE_LANDINFO;
|
2010-12-21 21:46:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarHelpClick(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2018-07-19 19:17:07 +00:00
|
|
|
PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 13 : 10);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
static void MenuClickSmallScreenshot()
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2009-12-19 19:21:37 +00:00
|
|
|
MakeScreenshot(SC_VIEWPORT, NULL);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 16:53:21 +00:00
|
|
|
/**
|
|
|
|
* Callback on the confirmation window for huge screenshots.
|
|
|
|
* @param w Window with viewport
|
|
|
|
* @param confirmed true on confirmation
|
|
|
|
*/
|
|
|
|
static void ScreenshotConfirmCallback(Window *w, bool confirmed)
|
2011-12-31 14:56:39 +00:00
|
|
|
{
|
2012-12-09 16:53:21 +00:00
|
|
|
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, NULL);
|
2011-12-31 14:56:39 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 16:53:21 +00:00
|
|
|
/**
|
|
|
|
* Make a screenshot of the world.
|
|
|
|
* Ask for confirmation if the screenshot will be huge.
|
|
|
|
* @param t Screenshot type: World or viewport screenshot
|
|
|
|
*/
|
|
|
|
static void MenuClickLargeWorldScreenshot(ScreenshotType t)
|
|
|
|
{
|
|
|
|
ViewPort vp;
|
|
|
|
SetupScreenshotViewport(t, &vp);
|
2014-02-06 22:24:02 +00:00
|
|
|
if ((uint64)vp.width * (uint64)vp.height > 8192 * 8192) {
|
2012-12-09 16:53:21 +00:00
|
|
|
/* Ask for confirmation */
|
|
|
|
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);
|
|
|
|
} else {
|
2014-02-06 22:24:02 +00:00
|
|
|
/* Less than 64M pixels, just do it */
|
2012-12-09 16:53:21 +00:00
|
|
|
MakeScreenshot(t, NULL);
|
|
|
|
}
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-07-20 16:19:48 +00:00
|
|
|
/**
|
2011-07-21 15:51:48 +00:00
|
|
|
* Toggle drawing of sprites' bounding boxes.
|
|
|
|
* @note has only an effect when newgrf_developer_tools are active.
|
2011-07-20 16:19:48 +00:00
|
|
|
*
|
|
|
|
* Function is found here and not in viewport.cpp in order to avoid
|
2011-07-21 15:51:48 +00:00
|
|
|
* importing the settings structs to there.
|
2011-07-20 16:19:48 +00:00
|
|
|
*/
|
|
|
|
void ToggleBoundingBoxes()
|
|
|
|
{
|
|
|
|
extern bool _draw_bounding_boxes;
|
|
|
|
/* Always allow to toggle them off */
|
|
|
|
if (_settings_client.gui.newgrf_developer_tools || _draw_bounding_boxes) {
|
|
|
|
_draw_bounding_boxes = !_draw_bounding_boxes;
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-25 19:06:59 +00:00
|
|
|
/**
|
|
|
|
* Toggle drawing of the dirty blocks.
|
|
|
|
* @note has only an effect when newgrf_developer_tools are active.
|
|
|
|
*
|
|
|
|
* Function is found here and not in viewport.cpp in order to avoid
|
|
|
|
* importing the settings structs to there.
|
|
|
|
*/
|
|
|
|
void ToggleDirtyBlocks()
|
|
|
|
{
|
|
|
|
extern bool _draw_dirty_blocks;
|
|
|
|
/* Always allow to toggle them off */
|
|
|
|
if (_settings_client.gui.newgrf_developer_tools || _draw_dirty_blocks) {
|
|
|
|
_draw_dirty_blocks = !_draw_dirty_blocks;
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-15 17:32:31 +00:00
|
|
|
/**
|
|
|
|
* Set the starting year for a scenario.
|
|
|
|
* @param year New starting year.
|
|
|
|
*/
|
|
|
|
void SetStartingYear(Year year)
|
|
|
|
{
|
|
|
|
_settings_game.game_creation.starting_year = Clamp(year, MIN_YEAR, MAX_YEAR);
|
|
|
|
Date new_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
|
|
|
|
/* If you open a savegame as scenario there may already be link graphs.*/
|
2015-03-07 18:27:01 +00:00
|
|
|
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
2013-10-15 17:32:31 +00:00
|
|
|
SetDate(new_date, 0);
|
|
|
|
}
|
|
|
|
|
2011-07-20 16:19:48 +00:00
|
|
|
/**
|
2011-07-21 15:51:48 +00:00
|
|
|
* Choose the proper callback function for the main toolbar's help menu.
|
|
|
|
* @param index The menu index which was selected.
|
2011-07-20 16:19:48 +00:00
|
|
|
* @return CBF_NONE
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction MenuClickHelp(int index)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-18 15:11:39 +00:00
|
|
|
switch (index) {
|
2011-12-31 14:56:39 +00:00
|
|
|
case 0: return PlaceLandBlockInfo();
|
|
|
|
case 2: IConsoleSwitch(); break;
|
|
|
|
case 3: ShowAIDebugWindow(); break;
|
|
|
|
case 4: MenuClickSmallScreenshot(); break;
|
2012-12-09 16:53:21 +00:00
|
|
|
case 5: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
|
|
|
|
case 6: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
|
|
|
|
case 7: MenuClickLargeWorldScreenshot(SC_WORLD); break;
|
2018-07-19 19:17:07 +00:00
|
|
|
case 8: ShowFramerateWindow(); break;
|
|
|
|
case 9: ShowAboutWindow(); break;
|
|
|
|
case 10: ShowSpriteAlignerWindow(); break;
|
|
|
|
case 11: ToggleBoundingBoxes(); break;
|
|
|
|
case 12: ToggleDirtyBlocks(); break;
|
2008-04-18 15:11:39 +00:00
|
|
|
}
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 23:33:37 +00:00
|
|
|
/* --- Switch toolbar button --- */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarSwitchClick(Window *w)
|
2008-05-29 23:33:37 +00:00
|
|
|
{
|
|
|
|
if (_toolbar_mode != TB_LOWER) {
|
|
|
|
_toolbar_mode = TB_LOWER;
|
|
|
|
} else {
|
|
|
|
_toolbar_mode = TB_UPPER;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:02:14 +00:00
|
|
|
w->ReInit();
|
2011-12-16 18:23:35 +00:00
|
|
|
w->SetWidgetLoweredState(WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-05-29 23:33:37 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Scenario editor specific handlers. */
|
|
|
|
|
2010-03-13 10:18:57 +00:00
|
|
|
/**
|
|
|
|
* Called when clicking at the date panel of the scenario editor toolbar.
|
|
|
|
*/
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenDatePanel(Window *w)
|
2010-03-13 10:18:57 +00:00
|
|
|
{
|
2010-10-28 18:15:42 +00:00
|
|
|
SetDParam(0, _settings_game.game_creation.starting_year);
|
2011-04-17 18:42:17 +00:00
|
|
|
ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
|
2010-03-13 10:18:57 +00:00
|
|
|
_left_button_clicked = false;
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2010-03-13 10:18:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenDateBackward(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
/* don't allow too fast scrolling */
|
2011-12-17 20:52:07 +00:00
|
|
|
if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_DATE_BACKWARD);
|
2008-05-06 22:08:18 +00:00
|
|
|
w->SetDirty();
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2013-10-15 17:32:31 +00:00
|
|
|
SetStartingYear(_settings_game.game_creation.starting_year - 1);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
_left_button_clicked = false;
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenDateForward(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
|
|
|
/* don't allow too fast scrolling */
|
2011-12-17 20:52:07 +00:00
|
|
|
if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_DATE_FORWARD);
|
2008-05-06 22:08:18 +00:00
|
|
|
w->SetDirty();
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2013-10-15 17:32:31 +00:00
|
|
|
SetStartingYear(_settings_game.game_creation.starting_year + 1);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
_left_button_clicked = false;
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenGenLand(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_LAND_GENERATE);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
|
|
|
ShowEditorTerraformToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenGenTown(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_TOWN_GENERATE);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2009-09-21 18:16:00 +00:00
|
|
|
ShowFoundTownWindow();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenGenIndustry(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_INDUSTRY);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-03-23 07:35:29 +00:00
|
|
|
ShowBuildIndustryWindow();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenBuildRoad(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_ROADS);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-03-23 07:35:29 +00:00
|
|
|
ShowBuildRoadScenToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenBuildDocks(Window *w)
|
2008-06-25 17:30:16 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_WATER);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-06-25 17:30:16 +00:00
|
|
|
ShowBuildDocksScenToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-06-25 17:30:16 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenPlantTrees(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_TREES);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-05-12 21:46:08 +00:00
|
|
|
ShowBuildTreesToolbar();
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarScenPlaceSign(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
w->HandleButtonClick(WID_TE_SIGNS);
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-21 22:00:08 +00:00
|
|
|
return SelectSignTool();
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
static CallBackFunction ToolbarBtn_NULL(Window *w)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2010-12-21 21:48:31 +00:00
|
|
|
return CBF_NONE;
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
typedef CallBackFunction MenuClickedProc(int index);
|
2008-08-25 20:42:54 +00:00
|
|
|
|
|
|
|
static MenuClickedProc * const _menu_clicked_procs[] = {
|
2009-03-15 00:32:18 +00:00
|
|
|
NULL, // 0
|
|
|
|
NULL, // 1
|
|
|
|
MenuClickSettings, // 2
|
|
|
|
MenuClickSaveLoad, // 3
|
|
|
|
MenuClickMap, // 4
|
|
|
|
MenuClickTown, // 5
|
|
|
|
MenuClickSubsidies, // 6
|
|
|
|
MenuClickStations, // 7
|
|
|
|
MenuClickFinances, // 8
|
|
|
|
MenuClickCompany, // 9
|
2013-06-09 13:37:04 +00:00
|
|
|
MenuClickStory, // 10
|
|
|
|
MenuClickGoal, // 11
|
|
|
|
MenuClickGraphs, // 12
|
|
|
|
MenuClickLeague, // 13
|
|
|
|
MenuClickIndustry, // 14
|
|
|
|
MenuClickShowTrains, // 15
|
|
|
|
MenuClickShowRoad, // 16
|
|
|
|
MenuClickShowShips, // 17
|
|
|
|
MenuClickShowAir, // 18
|
|
|
|
MenuClickMap, // 19
|
|
|
|
NULL, // 20
|
|
|
|
MenuClickBuildRail, // 21
|
|
|
|
MenuClickBuildRoad, // 22
|
|
|
|
MenuClickBuildWater, // 23
|
|
|
|
MenuClickBuildAir, // 24
|
|
|
|
MenuClickForest, // 25
|
|
|
|
MenuClickMusicWindow, // 26
|
|
|
|
MenuClickNewspaper, // 27
|
|
|
|
MenuClickHelp, // 28
|
2008-08-25 20:42:54 +00:00
|
|
|
};
|
|
|
|
|
2009-11-04 20:02:14 +00:00
|
|
|
/** Full blown container to make it behave exactly as we want :) */
|
|
|
|
class NWidgetToolbarContainer : public NWidgetContainer {
|
2011-12-16 18:23:35 +00:00
|
|
|
bool visible[WID_TN_END]; ///< The visible headers
|
2009-11-06 20:32:15 +00:00
|
|
|
protected:
|
2009-11-04 20:02:14 +00:00
|
|
|
uint spacers; ///< Number of spacer widgets in this toolbar
|
|
|
|
|
|
|
|
public:
|
|
|
|
NWidgetToolbarContainer() : NWidgetContainer(NWID_HORIZONTAL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
/**
|
|
|
|
* Check whether the given widget type is a button for us.
|
2011-07-21 15:51:48 +00:00
|
|
|
* @param type the widget type to check.
|
|
|
|
* @return true if it is a button for us.
|
2009-11-06 20:32:15 +00:00
|
|
|
*/
|
|
|
|
bool IsButton(WidgetType type) const
|
|
|
|
{
|
|
|
|
return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:02:14 +00:00
|
|
|
void SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
{
|
|
|
|
this->smallest_x = 0; // Biggest child
|
|
|
|
this->smallest_y = 0; // Biggest child
|
2009-11-22 18:26:01 +00:00
|
|
|
this->fill_x = 1;
|
|
|
|
this->fill_y = 0;
|
2009-11-04 20:02:14 +00:00
|
|
|
this->resize_x = 1; // We only resize in this direction
|
|
|
|
this->resize_y = 0; // We never resize in this direction
|
|
|
|
this->spacers = 0;
|
|
|
|
|
2010-09-15 21:10:14 +00:00
|
|
|
uint nbuttons = 0;
|
2009-11-04 20:02:14 +00:00
|
|
|
/* First initialise some variables... */
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; 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);
|
2009-11-06 20:32:15 +00:00
|
|
|
if (this->IsButton(child_wid->type)) {
|
2010-09-15 21:10:14 +00:00
|
|
|
nbuttons++;
|
2009-11-06 20:32:15 +00:00
|
|
|
this->smallest_x = max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
|
|
|
|
} else if (child_wid->type == NWID_SPACER) {
|
|
|
|
this->spacers++;
|
|
|
|
}
|
2009-11-04 20:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
|
2009-11-06 20:32:15 +00:00
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; 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;
|
|
|
|
}
|
|
|
|
}
|
2015-02-13 21:13:45 +00:00
|
|
|
_toolbar_width = nbuttons * this->smallest_x;
|
2009-11-04 20:02:14 +00:00
|
|
|
}
|
|
|
|
|
2009-11-20 20:10:06 +00:00
|
|
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
|
2009-11-04 20:02:14 +00:00
|
|
|
{
|
|
|
|
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
|
|
|
|
|
|
|
|
this->pos_x = x;
|
|
|
|
this->pos_y = y;
|
|
|
|
this->current_x = given_width;
|
|
|
|
this->current_y = given_height;
|
|
|
|
|
|
|
|
/* Figure out what are the visible buttons */
|
|
|
|
memset(this->visible, 0, sizeof(this->visible));
|
2009-11-06 20:32:15 +00:00
|
|
|
uint arrangable_count, button_count, spacer_count;
|
|
|
|
const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
|
|
|
|
for (uint i = 0; i < arrangable_count; i++) {
|
2009-11-04 20:02:14 +00:00
|
|
|
this->visible[arrangement[i]] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create us ourselves a quick lookup table */
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidgetBase *widgets[WID_TN_END];
|
2009-11-04 20:02:14 +00:00
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
|
|
|
if (child_wid->type == NWID_SPACER) continue;
|
|
|
|
widgets[((NWidgetCore*)child_wid)->index] = child_wid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now assign the widgets to their rightful place */
|
|
|
|
uint position = 0; // Place to put next child relative to origin of the container.
|
2009-11-06 20:32:15 +00:00
|
|
|
uint spacer_space = max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
|
|
|
|
uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
|
2009-11-04 20:02:14 +00:00
|
|
|
uint spacer_i = 0;
|
2009-11-06 20:32:15 +00:00
|
|
|
uint button_i = 0;
|
2009-11-04 20:02:14 +00:00
|
|
|
|
|
|
|
/* Index into the arrangement indices. The macro lastof cannot be used here! */
|
2009-11-06 20:32:15 +00:00
|
|
|
const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
|
|
|
|
for (uint i = 0; i < arrangable_count; i++) {
|
2009-11-04 20:02:14 +00:00
|
|
|
NWidgetBase *child_wid = widgets[*cur_wid];
|
2009-11-06 20:32:15 +00:00
|
|
|
/* If we have to give space to the spacers, do that */
|
|
|
|
if (spacer_space != 0) {
|
2009-11-04 20:02:14 +00:00
|
|
|
NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev;
|
|
|
|
if (possible_spacer != NULL && possible_spacer->type == NWID_SPACER) {
|
2009-11-06 20:32:15 +00:00
|
|
|
uint add = spacer_space / (spacer_count - spacer_i);
|
2009-11-04 20:02:14 +00:00
|
|
|
position += add;
|
2009-11-06 20:32:15 +00:00
|
|
|
spacer_space -= add;
|
2009-11-04 20:02:14 +00:00
|
|
|
spacer_i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
/* Buttons can be scaled, the others not. */
|
|
|
|
if (this->IsButton(child_wid->type)) {
|
|
|
|
child_wid->current_x = button_space / (button_count - button_i);
|
|
|
|
button_space -= child_wid->current_x;
|
|
|
|
button_i++;
|
|
|
|
}
|
2009-11-20 20:10:06 +00:00
|
|
|
child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
|
2009-11-04 20:02:14 +00:00
|
|
|
position += child_wid->current_x;
|
|
|
|
|
|
|
|
if (rtl) {
|
|
|
|
cur_wid--;
|
|
|
|
} else {
|
|
|
|
cur_wid++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void Draw(const Window *w)
|
|
|
|
{
|
|
|
|
/* Draw brown-red toolbar bg. */
|
2011-05-06 21:13:29 +00:00
|
|
|
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);
|
2009-11-04 20:02:14 +00:00
|
|
|
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-11-25 21:30:45 +00:00
|
|
|
for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != NULL; child_wid = rtl ? child_wid->prev : child_wid->next) {
|
2009-11-04 20:02:14 +00:00
|
|
|
if (child_wid->type == NWID_SPACER) continue;
|
|
|
|
if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
|
|
|
|
|
|
|
|
child_wid->Draw(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y)
|
|
|
|
{
|
|
|
|
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
|
|
|
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; 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;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the arrangement of the buttons for the toolbar.
|
2011-07-21 15:51:48 +00:00
|
|
|
* @param width the new width of the toolbar.
|
|
|
|
* @param arrangable_count output of the number of visible items.
|
|
|
|
* @param button_count output of the number of visible buttons.
|
|
|
|
* @param spacer_count output of the number of spacers.
|
|
|
|
* @return the button configuration.
|
2009-11-04 20:02:14 +00:00
|
|
|
*/
|
2009-11-06 20:32:15 +00:00
|
|
|
virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 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
|
2009-11-04 20:02:14 +00:00
|
|
|
{
|
|
|
|
static const uint SMALLEST_ARRANGEMENT = 14;
|
2013-09-14 12:58:58 +00:00
|
|
|
static const uint BIGGEST_ARRANGEMENT = 20;
|
2016-10-30 17:36:57 +00:00
|
|
|
|
|
|
|
/* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
|
|
|
|
* The total number of buttons should be equal to arrangable_count * 2.
|
|
|
|
* No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
|
|
|
|
* pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
|
|
|
|
* enough space.
|
|
|
|
*/
|
2009-11-04 20:02:14 +00:00
|
|
|
static const byte arrange14[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
static const byte arrange15[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
static const byte arrange16[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
static const byte arrange17[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
static const byte arrange18[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
static const byte arrange19[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
2013-09-14 12:58:58 +00:00
|
|
|
static const byte arrange20[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_GOAL,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_STORY,
|
|
|
|
WID_TN_HELP,
|
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_SWITCH_BAR,
|
2013-09-14 12:58:58 +00:00
|
|
|
};
|
2009-11-04 20:02:14 +00:00
|
|
|
static const byte arrange_all[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_PAUSE,
|
|
|
|
WID_TN_FAST_FORWARD,
|
|
|
|
WID_TN_SETTINGS,
|
|
|
|
WID_TN_SAVE,
|
|
|
|
WID_TN_SMALL_MAP,
|
|
|
|
WID_TN_TOWNS,
|
|
|
|
WID_TN_SUBSIDIES,
|
|
|
|
WID_TN_STATIONS,
|
|
|
|
WID_TN_FINANCES,
|
|
|
|
WID_TN_COMPANIES,
|
|
|
|
WID_TN_STORY,
|
|
|
|
WID_TN_GOAL,
|
|
|
|
WID_TN_GRAPHS,
|
|
|
|
WID_TN_LEAGUE,
|
|
|
|
WID_TN_INDUSTRIES,
|
|
|
|
WID_TN_TRAINS,
|
|
|
|
WID_TN_ROADVEHS,
|
|
|
|
WID_TN_SHIPS,
|
2018-04-30 16:52:32 +00:00
|
|
|
WID_TN_AIRCRAFT,
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TN_ZOOM_IN,
|
|
|
|
WID_TN_ZOOM_OUT,
|
|
|
|
WID_TN_RAILS,
|
|
|
|
WID_TN_ROADS,
|
|
|
|
WID_TN_WATER,
|
|
|
|
WID_TN_AIR,
|
|
|
|
WID_TN_LANDSCAPE,
|
|
|
|
WID_TN_MUSIC_SOUND,
|
|
|
|
WID_TN_MESSAGES,
|
|
|
|
WID_TN_HELP
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
/* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
|
2010-04-18 14:56:05 +00:00
|
|
|
uint full_buttons = max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
|
2009-11-04 20:02:14 +00:00
|
|
|
if (full_buttons > BIGGEST_ARRANGEMENT) {
|
2009-11-06 20:32:15 +00:00
|
|
|
button_count = arrangable_count = lengthof(arrange_all);
|
|
|
|
spacer_count = this->spacers;
|
2009-11-04 20:02:14 +00:00
|
|
|
return arrange_all;
|
|
|
|
}
|
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
/* Introduce the split toolbar */
|
2013-09-14 12:58:58 +00:00
|
|
|
static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
|
2009-11-04 20:02:14 +00:00
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
button_count = arrangable_count = full_buttons;
|
|
|
|
spacer_count = this->spacers;
|
2009-11-04 20:02:14 +00:00
|
|
|
return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-11-06 20:34:43 +00:00
|
|
|
/** Container for the scenario editor's toolbar */
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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) {
|
|
|
|
if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
|
|
|
|
|
|
|
|
assert(i < lengthof(this->panel_widths));
|
|
|
|
this->panel_widths[i++] = child_wid->current_x;
|
2015-02-13 21:13:45 +00:00
|
|
|
_toolbar_width += child_wid->current_x;
|
2009-11-06 20:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
|
|
|
|
{
|
|
|
|
static const byte arrange_all[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TE_PAUSE,
|
|
|
|
WID_TE_FAST_FORWARD,
|
|
|
|
WID_TE_SETTINGS,
|
|
|
|
WID_TE_SAVE,
|
|
|
|
WID_TE_SPACER,
|
|
|
|
WID_TE_DATE_PANEL,
|
|
|
|
WID_TE_SMALL_MAP,
|
|
|
|
WID_TE_ZOOM_IN,
|
|
|
|
WID_TE_ZOOM_OUT,
|
|
|
|
WID_TE_LAND_GENERATE,
|
|
|
|
WID_TE_TOWN_GENERATE,
|
|
|
|
WID_TE_INDUSTRY,
|
|
|
|
WID_TE_ROADS,
|
|
|
|
WID_TE_WATER,
|
|
|
|
WID_TE_TREES,
|
|
|
|
WID_TE_SIGNS,
|
|
|
|
WID_TE_MUSIC_SOUND,
|
|
|
|
WID_TE_HELP,
|
2009-11-06 20:34:43 +00:00
|
|
|
};
|
|
|
|
static const byte arrange_nopanel[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TE_PAUSE,
|
|
|
|
WID_TE_FAST_FORWARD,
|
|
|
|
WID_TE_SETTINGS,
|
|
|
|
WID_TE_SAVE,
|
|
|
|
WID_TE_DATE_PANEL,
|
|
|
|
WID_TE_SMALL_MAP,
|
|
|
|
WID_TE_ZOOM_IN,
|
|
|
|
WID_TE_ZOOM_OUT,
|
|
|
|
WID_TE_LAND_GENERATE,
|
|
|
|
WID_TE_TOWN_GENERATE,
|
|
|
|
WID_TE_INDUSTRY,
|
|
|
|
WID_TE_ROADS,
|
|
|
|
WID_TE_WATER,
|
|
|
|
WID_TE_TREES,
|
|
|
|
WID_TE_SIGNS,
|
|
|
|
WID_TE_MUSIC_SOUND,
|
|
|
|
WID_TE_HELP,
|
2009-11-06 20:34:43 +00:00
|
|
|
};
|
|
|
|
static const byte arrange_switch[] = {
|
2016-10-30 17:36:57 +00:00
|
|
|
WID_TE_DATE_PANEL,
|
|
|
|
WID_TE_SMALL_MAP,
|
|
|
|
WID_TE_LAND_GENERATE,
|
|
|
|
WID_TE_TOWN_GENERATE,
|
|
|
|
WID_TE_INDUSTRY,
|
|
|
|
WID_TE_ROADS,
|
|
|
|
WID_TE_WATER,
|
|
|
|
WID_TE_TREES,
|
|
|
|
WID_TE_SIGNS,
|
|
|
|
WID_TE_SWITCH_BAR,
|
|
|
|
// lower toolbar
|
|
|
|
WID_TE_PAUSE,
|
|
|
|
WID_TE_FAST_FORWARD,
|
|
|
|
WID_TE_SETTINGS,
|
|
|
|
WID_TE_SAVE,
|
|
|
|
WID_TE_DATE_PANEL,
|
|
|
|
WID_TE_ZOOM_IN,
|
|
|
|
WID_TE_ZOOM_OUT,
|
|
|
|
WID_TE_MUSIC_SOUND,
|
|
|
|
WID_TE_HELP, WID_TE_SWITCH_BAR,
|
2009-11-06 20:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* If we can place all buttons *and* the panels, show them. */
|
|
|
|
uint min_full_width = (lengthof(arrange_all) - lengthof(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
|
|
|
|
if (width >= min_full_width) {
|
|
|
|
width -= this->panel_widths[0] + this->panel_widths[1];
|
|
|
|
arrangable_count = lengthof(arrange_all);
|
|
|
|
button_count = arrangable_count - 2;
|
|
|
|
spacer_count = this->spacers;
|
|
|
|
return arrange_all;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise don't show the date panel and if we can't fit half the buttons and the panels anymore, split the toolbar in two */
|
|
|
|
uint min_small_width = (lengthof(arrange_switch) - lengthof(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
|
|
|
|
if (width > min_small_width) {
|
|
|
|
width -= this->panel_widths[1];
|
|
|
|
arrangable_count = lengthof(arrange_nopanel);
|
|
|
|
button_count = arrangable_count - 1;
|
|
|
|
spacer_count = this->spacers - 1;
|
|
|
|
return arrange_nopanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Split toolbar */
|
|
|
|
width -= this->panel_widths[1];
|
|
|
|
arrangable_count = lengthof(arrange_switch) / 2;
|
|
|
|
button_count = arrangable_count - 1;
|
|
|
|
spacer_count = 0;
|
|
|
|
return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Toolbar handling for the 'normal' case */
|
|
|
|
|
2010-12-21 21:48:31 +00:00
|
|
|
typedef CallBackFunction ToolbarButtonProc(Window *w);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
|
|
|
static ToolbarButtonProc * const _toolbar_button_procs[] = {
|
|
|
|
ToolbarPauseClick,
|
|
|
|
ToolbarFastForwardClick,
|
|
|
|
ToolbarOptionsClick,
|
|
|
|
ToolbarSaveClick,
|
|
|
|
ToolbarMapClick,
|
|
|
|
ToolbarTownClick,
|
|
|
|
ToolbarSubsidiesClick,
|
|
|
|
ToolbarStationsClick,
|
2008-04-18 15:11:39 +00:00
|
|
|
ToolbarFinancesClick,
|
2008-09-30 20:39:50 +00:00
|
|
|
ToolbarCompaniesClick,
|
2013-06-09 13:37:04 +00:00
|
|
|
ToolbarStoryClick,
|
|
|
|
ToolbarGoalClick,
|
2008-03-23 07:35:29 +00:00
|
|
|
ToolbarGraphsClick,
|
|
|
|
ToolbarLeagueClick,
|
|
|
|
ToolbarIndustryClick,
|
|
|
|
ToolbarTrainClick,
|
|
|
|
ToolbarRoadClick,
|
|
|
|
ToolbarShipClick,
|
|
|
|
ToolbarAirClick,
|
|
|
|
ToolbarZoomInClick,
|
|
|
|
ToolbarZoomOutClick,
|
|
|
|
ToolbarBuildRailClick,
|
|
|
|
ToolbarBuildRoadClick,
|
|
|
|
ToolbarBuildWaterClick,
|
|
|
|
ToolbarBuildAirClick,
|
|
|
|
ToolbarForestClick,
|
|
|
|
ToolbarMusicClick,
|
|
|
|
ToolbarNewspaperClick,
|
|
|
|
ToolbarHelpClick,
|
2008-05-29 23:33:37 +00:00
|
|
|
ToolbarSwitchClick,
|
2008-03-23 07:35:29 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 19:35:54 +00:00
|
|
|
enum MainToolbarHotkeys {
|
|
|
|
MTHK_PAUSE,
|
|
|
|
MTHK_FASTFORWARD,
|
|
|
|
MTHK_SETTINGS,
|
|
|
|
MTHK_SAVEGAME,
|
2010-07-21 14:28:06 +00:00
|
|
|
MTHK_LOADGAME,
|
2010-07-03 19:35:54 +00:00
|
|
|
MTHK_SMALLMAP,
|
|
|
|
MTHK_TOWNDIRECTORY,
|
|
|
|
MTHK_SUBSIDIES,
|
|
|
|
MTHK_STATIONS,
|
|
|
|
MTHK_FINANCES,
|
|
|
|
MTHK_COMPANIES,
|
2013-06-09 13:37:04 +00:00
|
|
|
MTHK_STORY,
|
|
|
|
MTHK_GOAL,
|
2010-07-03 19:35:54 +00:00
|
|
|
MTHK_GRAPHS,
|
|
|
|
MTHK_LEAGUE,
|
|
|
|
MTHK_INDUSTRIES,
|
|
|
|
MTHK_TRAIN_LIST,
|
|
|
|
MTHK_ROADVEH_LIST,
|
|
|
|
MTHK_SHIP_LIST,
|
|
|
|
MTHK_AIRCRAFT_LIST,
|
|
|
|
MTHK_ZOOM_IN,
|
|
|
|
MTHK_ZOOM_OUT,
|
|
|
|
MTHK_BUILD_RAIL,
|
|
|
|
MTHK_BUILD_ROAD,
|
|
|
|
MTHK_BUILD_DOCKS,
|
|
|
|
MTHK_BUILD_AIRPORT,
|
|
|
|
MTHK_BUILD_TREES,
|
|
|
|
MTHK_MUSIC,
|
2010-11-30 00:15:38 +00:00
|
|
|
MTHK_AI_DEBUG,
|
2010-07-03 19:35:54 +00:00
|
|
|
MTHK_SMALL_SCREENSHOT,
|
2010-08-15 23:32:36 +00:00
|
|
|
MTHK_ZOOMEDIN_SCREENSHOT,
|
2011-12-31 14:56:39 +00:00
|
|
|
MTHK_DEFAULTZOOM_SCREENSHOT,
|
2010-07-03 19:35:54 +00:00
|
|
|
MTHK_GIANT_SCREENSHOT,
|
|
|
|
MTHK_CHEATS,
|
|
|
|
MTHK_TERRAFORM,
|
|
|
|
MTHK_EXTRA_VIEWPORT,
|
2010-07-21 14:28:06 +00:00
|
|
|
MTHK_CLIENT_LIST,
|
|
|
|
MTHK_SIGN_LIST,
|
2010-07-03 19:35:54 +00:00
|
|
|
};
|
|
|
|
|
2010-12-21 22:00:08 +00:00
|
|
|
/** Main toolbar. */
|
2008-05-18 22:11:46 +00:00
|
|
|
struct MainToolbarWindow : Window {
|
2018-05-20 08:58:36 +00:00
|
|
|
GUITimer timer;
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
MainToolbarWindow(WindowDesc *desc) : Window(desc)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->InitNested(0);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2016-08-15 18:32:25 +00:00
|
|
|
_last_started_action = CBF_NONE;
|
2011-12-15 19:54:23 +00:00
|
|
|
CLRBITS(this->flags, WF_WHITE_BORDER);
|
2011-12-16 18:23:35 +00:00
|
|
|
this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
|
|
|
|
this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
|
2008-05-18 22:11:46 +00:00
|
|
|
PositionMainToolbar(this);
|
|
|
|
DoZoomInOutWindow(ZOOM_NONE, this);
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2018-05-20 08:58:36 +00:00
|
|
|
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 21:13:45 +00:00
|
|
|
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
|
|
|
|
{
|
|
|
|
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
|
|
|
}
|
|
|
|
|
2008-05-18 22:11:46 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
/* If spectator, disable all construction buttons
|
2009-03-14 18:16:29 +00:00
|
|
|
* ie : Build road, rail, ships, airports and landscaping
|
|
|
|
* Since enabled state is the default, just disable when needed */
|
2011-12-16 18:23:35 +00:00
|
|
|
this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, WID_TN_RAILS, WID_TN_ROADS, WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE, WIDGET_LIST_END);
|
2008-05-18 22:11:46 +00:00
|
|
|
/* disable company list drop downs, if there are no companies */
|
2018-04-30 16:52:32 +00:00
|
|
|
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);
|
2013-09-13 12:45:25 +00:00
|
|
|
|
|
|
|
this->SetWidgetDisabledState(WID_TN_GOAL, Goal::GetNumItems() == 0);
|
|
|
|
this->SetWidgetDisabledState(WID_TN_STORY, StoryPage::GetNumItems() == 0);
|
2008-05-18 22:11:46 +00:00
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
this->SetWidgetDisabledState(WID_TN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
|
|
|
|
this->SetWidgetDisabledState(WID_TN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
|
2008-05-18 22:11:46 +00:00
|
|
|
|
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
|
|
|
if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
|
|
|
|
}
|
|
|
|
|
2008-08-25 20:42:54 +00:00
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
|
{
|
2010-12-21 22:00:08 +00:00
|
|
|
CallBackFunction cbf = _menu_clicked_procs[widget](index);
|
2016-08-15 18:32:25 +00:00
|
|
|
if (cbf != CBF_NONE) _last_started_action = cbf;
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-15 15:30:44 +00:00
|
|
|
virtual EventState OnHotkey(int hotkey)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2013-06-15 15:30:44 +00:00
|
|
|
switch (hotkey) {
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_PAUSE: ToolbarPauseClick(this); break;
|
|
|
|
case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
|
|
|
case MTHK_SETTINGS: ShowGameOptions(); break;
|
|
|
|
case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
|
2016-09-04 16:06:50 +00:00
|
|
|
case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_SMALLMAP: ShowSmallMap(); break;
|
|
|
|
case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
|
|
|
|
case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
|
|
|
|
case MTHK_STATIONS: ShowCompanyStations(_local_company); break;
|
|
|
|
case MTHK_FINANCES: ShowCompanyFinances(_local_company); break;
|
|
|
|
case MTHK_COMPANIES: ShowCompany(_local_company); break;
|
2013-06-09 13:37:04 +00:00
|
|
|
case MTHK_STORY: ShowStoryBook(_local_company); break;
|
|
|
|
case MTHK_GOAL: ShowGoalsList(_local_company); break;
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_GRAPHS: ShowOperatingProfitGraph(); break;
|
|
|
|
case MTHK_LEAGUE: ShowCompanyLeagueTable(); break;
|
|
|
|
case MTHK_INDUSTRIES: ShowBuildIndustryWindow(); break;
|
|
|
|
case MTHK_TRAIN_LIST: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
|
|
|
|
case MTHK_ROADVEH_LIST: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
|
|
|
|
case MTHK_SHIP_LIST: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
|
|
|
|
case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
|
|
|
|
case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
|
|
|
|
case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
|
2010-07-03 20:40:18 +00:00
|
|
|
case MTHK_BUILD_RAIL: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype); break;
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
|
|
|
|
case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
|
|
|
|
case MTHK_BUILD_AIRPORT: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
|
|
|
|
case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
|
|
|
|
case MTHK_MUSIC: ShowMusicWindow(); break;
|
2010-11-30 00:15:38 +00:00
|
|
|
case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot(); break;
|
2012-12-09 16:53:21 +00:00
|
|
|
case MTHK_ZOOMEDIN_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
|
|
|
|
case MTHK_DEFAULTZOOM_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
|
|
|
|
case MTHK_GIANT_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_WORLD); break;
|
2010-07-03 19:35:54 +00:00
|
|
|
case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
|
|
|
|
case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
|
2010-10-17 13:54:05 +00:00
|
|
|
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
2010-07-21 14:28:06 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
|
|
|
|
#endif
|
|
|
|
case MTHK_SIGN_LIST: ShowSignList(); break;
|
2008-05-18 22:11:46 +00:00
|
|
|
default: return ES_NOT_HANDLED;
|
|
|
|
}
|
|
|
|
return ES_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
2016-08-15 18:32:25 +00:00
|
|
|
switch (_last_started_action) {
|
2010-12-21 22:00:08 +00:00
|
|
|
case CBF_PLACE_SIGN:
|
|
|
|
PlaceProc_Sign(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CBF_PLACE_LANDINFO:
|
|
|
|
ShowLandInfo(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2016-08-15 18:32:25 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
|
|
|
_last_started_action = CBF_NONE;
|
|
|
|
}
|
|
|
|
|
2018-05-04 20:29:22 +00:00
|
|
|
virtual void OnRealtimeTick(uint delta_ms)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2018-05-20 08:58:36 +00:00
|
|
|
if (!this->timer.Elapsed(delta_ms)) return;
|
|
|
|
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
|
|
|
|
this->ToggleWidgetLoweredState(WID_TN_PAUSE);
|
|
|
|
this->SetWidgetDirty(WID_TN_PAUSE);
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
if (this->IsWidgetLowered(WID_TN_FAST_FORWARD) != !!_fast_forward) {
|
|
|
|
this->ToggleWidgetLoweredState(WID_TN_FAST_FORWARD);
|
|
|
|
this->SetWidgetDirty(WID_TN_FAST_FORWARD);
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
2009-11-04 15:50:14 +00:00
|
|
|
/* We do not want to automatically raise the pause, fast forward and
|
|
|
|
* switchbar buttons; they have to stay down when pressed etc. */
|
2011-12-16 18:23:35 +00:00
|
|
|
for (uint i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) {
|
2008-05-18 22:11:46 +00:00
|
|
|
if (this->IsWidgetLowered(i)) {
|
|
|
|
this->RaiseWidget(i);
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(i);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @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)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2011-12-16 18:23:35 +00:00
|
|
|
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TN_ZOOM_IN, WID_TN_ZOOM_OUT);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2010-07-03 19:35:54 +00:00
|
|
|
|
2013-06-15 15:28:09 +00:00
|
|
|
static HotkeyList hotkeys;
|
2010-07-03 19:35:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
|
|
|
|
const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
|
|
|
|
const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
|
|
|
|
const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4, 'M', 0};
|
|
|
|
|
2013-06-15 15:28:09 +00:00
|
|
|
static Hotkey maintoolbar_hotkeys[] = {
|
2013-06-15 15:27:33 +00:00
|
|
|
Hotkey(_maintoolbar_pause_keys, "pause", MTHK_PAUSE),
|
|
|
|
Hotkey((uint16)0, "fastforward", MTHK_FASTFORWARD),
|
|
|
|
Hotkey(WKC_F2, "settings", MTHK_SETTINGS),
|
|
|
|
Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME),
|
|
|
|
Hotkey((uint16)0, "load_game", MTHK_LOADGAME),
|
|
|
|
Hotkey(_maintoolbar_smallmap_keys, "smallmap", MTHK_SMALLMAP),
|
|
|
|
Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY),
|
|
|
|
Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES),
|
|
|
|
Hotkey(WKC_F7, "station_list", MTHK_STATIONS),
|
|
|
|
Hotkey(WKC_F8, "finances", MTHK_FINANCES),
|
|
|
|
Hotkey(WKC_F9, "companies", MTHK_COMPANIES),
|
|
|
|
Hotkey((uint16)0, "story_book", MTHK_STORY),
|
|
|
|
Hotkey((uint16)0, "goal_list", MTHK_GOAL),
|
|
|
|
Hotkey(WKC_F10, "graphs", MTHK_GRAPHS),
|
|
|
|
Hotkey(WKC_F11, "league", MTHK_LEAGUE),
|
|
|
|
Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES),
|
|
|
|
Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST),
|
|
|
|
Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST),
|
|
|
|
Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST),
|
|
|
|
Hotkey(WKC_SHIFT | WKC_F4, "aircraft_list", MTHK_AIRCRAFT_LIST),
|
|
|
|
Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTHK_ZOOM_IN),
|
|
|
|
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(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),
|
|
|
|
Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC),
|
|
|
|
Hotkey((uint16)0, "ai_debug", MTHK_AI_DEBUG),
|
|
|
|
Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT),
|
|
|
|
Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
|
|
|
|
Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
|
|
|
|
Hotkey((uint16)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
|
|
|
|
Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
|
|
|
|
Hotkey('L', "terraform", MTHK_TERRAFORM),
|
|
|
|
Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
|
2010-07-21 14:28:06 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
2013-06-15 15:27:33 +00:00
|
|
|
Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
|
2010-07-21 14:28:06 +00:00
|
|
|
#endif
|
2013-06-15 15:27:33 +00:00
|
|
|
Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
|
|
|
|
HOTKEY_LIST_END
|
2008-05-18 22:11:46 +00:00
|
|
|
};
|
2013-06-15 15:28:09 +00:00
|
|
|
HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-11-04 20:02:14 +00:00
|
|
|
static NWidgetBase *MakeMainToolbar(int *biggest_index)
|
|
|
|
{
|
|
|
|
/** Sprites to use for the different toolbar buttons */
|
|
|
|
static const SpriteID toolbar_button_sprites[] = {
|
2011-12-16 18:23:35 +00:00
|
|
|
SPR_IMG_PAUSE, // WID_TN_PAUSE
|
|
|
|
SPR_IMG_FASTFORWARD, // WID_TN_FAST_FORWARD
|
|
|
|
SPR_IMG_SETTINGS, // WID_TN_SETTINGS
|
|
|
|
SPR_IMG_SAVE, // WID_TN_SAVE
|
|
|
|
SPR_IMG_SMALLMAP, // WID_TN_SMALL_MAP
|
|
|
|
SPR_IMG_TOWN, // WID_TN_TOWNS
|
|
|
|
SPR_IMG_SUBSIDIES, // WID_TN_SUBSIDIES
|
|
|
|
SPR_IMG_COMPANY_LIST, // WID_TN_STATIONS
|
|
|
|
SPR_IMG_COMPANY_FINANCE, // WID_TN_FINANCES
|
|
|
|
SPR_IMG_COMPANY_GENERAL, // WID_TN_COMPANIES
|
2013-06-09 13:37:04 +00:00
|
|
|
SPR_IMG_STORY_BOOK, // WID_TN_STORY
|
|
|
|
SPR_IMG_GOAL, // WID_TN_GOAL
|
2011-12-16 18:23:35 +00:00
|
|
|
SPR_IMG_GRAPHS, // WID_TN_GRAPHS
|
|
|
|
SPR_IMG_COMPANY_LEAGUE, // WID_TN_LEAGUE
|
|
|
|
SPR_IMG_INDUSTRY, // WID_TN_INDUSTRIES
|
|
|
|
SPR_IMG_TRAINLIST, // WID_TN_TRAINS
|
|
|
|
SPR_IMG_TRUCKLIST, // WID_TN_ROADVEHS
|
|
|
|
SPR_IMG_SHIPLIST, // WID_TN_SHIPS
|
|
|
|
SPR_IMG_AIRPLANESLIST, // WID_TN_AIRCRAFT
|
|
|
|
SPR_IMG_ZOOMIN, // WID_TN_ZOOMIN
|
|
|
|
SPR_IMG_ZOOMOUT, // WID_TN_ZOOMOUT
|
|
|
|
SPR_IMG_BUILDRAIL, // WID_TN_RAILS
|
|
|
|
SPR_IMG_BUILDROAD, // WID_TN_ROADS
|
|
|
|
SPR_IMG_BUILDWATER, // WID_TN_WATER
|
|
|
|
SPR_IMG_BUILDAIR, // WID_TN_AIR
|
|
|
|
SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE
|
|
|
|
SPR_IMG_MUSIC, // WID_TN_MUSIC_SOUND
|
|
|
|
SPR_IMG_MESSAGES, // WID_TN_MESSAGES
|
|
|
|
SPR_IMG_QUERY, // WID_TN_HELP
|
|
|
|
SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR
|
2009-11-04 20:02:14 +00:00
|
|
|
};
|
|
|
|
|
2009-11-06 20:32:15 +00:00
|
|
|
NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer();
|
2011-12-16 18:23:35 +00:00
|
|
|
for (uint i = 0; i < WID_TN_END; i++) {
|
2009-11-04 20:02:14 +00:00
|
|
|
switch (i) {
|
2016-10-30 17:36:57 +00:00
|
|
|
case WID_TN_SMALL_MAP:
|
|
|
|
case WID_TN_FINANCES:
|
|
|
|
case WID_TN_VEHICLE_START:
|
|
|
|
case WID_TN_ZOOM_IN:
|
|
|
|
case WID_TN_BUILDING_TOOLS_START:
|
|
|
|
case WID_TN_MUSIC_SOUND:
|
|
|
|
hor->Add(new NWidgetSpacer(0, 0));
|
|
|
|
break;
|
2009-11-04 20:02:14 +00:00
|
|
|
}
|
2011-12-16 18:23:35 +00:00
|
|
|
hor->Add(new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i));
|
2009-11-04 20:02:14 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
*biggest_index = max<int>(*biggest_index, WID_TN_SWITCH_BAR);
|
2009-11-04 20:02:14 +00:00
|
|
|
return hor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const NWidgetPart _nested_toolbar_normal_widgets[] = {
|
|
|
|
NWidgetFunction(MakeMainToolbar),
|
2008-03-23 07:35:29 +00:00
|
|
|
};
|
|
|
|
|
2010-09-15 21:10:14 +00:00
|
|
|
static WindowDesc _toolb_normal_desc(
|
2015-02-13 21:13:45 +00:00
|
|
|
WDP_MANUAL, NULL, 0, 0,
|
2008-03-23 07:35:29 +00:00
|
|
|
WC_MAIN_TOOLBAR, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_NO_FOCUS,
|
2013-06-15 15:30:44 +00:00
|
|
|
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
|
|
|
|
&MainToolbarWindow::hotkeys
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
|
|
|
|
2008-04-18 15:11:39 +00:00
|
|
|
/* --- Toolbar handling for the scenario editor */
|
|
|
|
|
2008-03-23 07:35:29 +00:00
|
|
|
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
|
|
|
|
ToolbarPauseClick,
|
|
|
|
ToolbarFastForwardClick,
|
|
|
|
ToolbarOptionsClick,
|
|
|
|
ToolbarScenSaveOrLoad,
|
|
|
|
ToolbarBtn_NULL,
|
2010-03-13 10:18:57 +00:00
|
|
|
ToolbarScenDatePanel,
|
2008-03-23 07:35:29 +00:00
|
|
|
ToolbarScenDateBackward,
|
|
|
|
ToolbarScenDateForward,
|
|
|
|
ToolbarScenMapTownDir,
|
2008-07-01 00:04:09 +00:00
|
|
|
ToolbarZoomInClick,
|
|
|
|
ToolbarZoomOutClick,
|
2008-03-23 07:35:29 +00:00
|
|
|
ToolbarScenGenLand,
|
|
|
|
ToolbarScenGenTown,
|
|
|
|
ToolbarScenGenIndustry,
|
|
|
|
ToolbarScenBuildRoad,
|
2008-06-25 17:30:16 +00:00
|
|
|
ToolbarScenBuildDocks,
|
2008-03-23 07:35:29 +00:00
|
|
|
ToolbarScenPlantTrees,
|
|
|
|
ToolbarScenPlaceSign,
|
2009-11-15 20:16:51 +00:00
|
|
|
ToolbarBtn_NULL,
|
2008-03-23 07:35:29 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2013-06-09 13:37:04 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-03-23 07:35:29 +00:00
|
|
|
ToolbarMusicClick,
|
|
|
|
NULL,
|
|
|
|
ToolbarHelpClick,
|
2009-11-06 20:34:43 +00:00
|
|
|
ToolbarSwitchClick,
|
2008-03-23 07:35:29 +00:00
|
|
|
};
|
|
|
|
|
2010-07-04 11:48:04 +00:00
|
|
|
enum MainToolbarEditorHotkeys {
|
|
|
|
MTEHK_PAUSE,
|
|
|
|
MTEHK_FASTFORWARD,
|
|
|
|
MTEHK_SETTINGS,
|
|
|
|
MTEHK_SAVEGAME,
|
|
|
|
MTEHK_GENLAND,
|
|
|
|
MTEHK_GENTOWN,
|
|
|
|
MTEHK_GENINDUSTRY,
|
|
|
|
MTEHK_BUILD_ROAD,
|
|
|
|
MTEHK_BUILD_DOCKS,
|
|
|
|
MTEHK_BUILD_TREES,
|
|
|
|
MTEHK_SIGN,
|
|
|
|
MTEHK_MUSIC,
|
|
|
|
MTEHK_LANDINFO,
|
|
|
|
MTEHK_SMALL_SCREENSHOT,
|
2010-08-15 23:32:36 +00:00
|
|
|
MTEHK_ZOOMEDIN_SCREENSHOT,
|
2011-12-31 14:56:39 +00:00
|
|
|
MTEHK_DEFAULTZOOM_SCREENSHOT,
|
2010-07-04 11:48:04 +00:00
|
|
|
MTEHK_GIANT_SCREENSHOT,
|
|
|
|
MTEHK_ZOOM_IN,
|
|
|
|
MTEHK_ZOOM_OUT,
|
|
|
|
MTEHK_TERRAFORM,
|
|
|
|
MTEHK_SMALLMAP,
|
|
|
|
MTEHK_EXTRA_VIEWPORT,
|
|
|
|
};
|
|
|
|
|
2008-05-18 22:11:46 +00:00
|
|
|
struct ScenarioEditorToolbarWindow : Window {
|
2018-05-20 08:58:36 +00:00
|
|
|
GUITimer timer;
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->InitNested(0);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2016-08-15 18:32:25 +00:00
|
|
|
_last_started_action = CBF_NONE;
|
2011-12-15 19:54:23 +00:00
|
|
|
CLRBITS(this->flags, WF_WHITE_BORDER);
|
2008-05-18 22:11:46 +00:00
|
|
|
PositionMainToolbar(this);
|
|
|
|
DoZoomInOutWindow(ZOOM_NONE, this);
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2018-05-20 08:58:36 +00:00
|
|
|
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2015-02-14 21:22:47 +00:00
|
|
|
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
|
|
|
|
{
|
|
|
|
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
|
|
|
}
|
|
|
|
|
2008-05-18 22:11:46 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
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);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2008-05-18 22:11:46 +00:00
|
|
|
this->DrawWidgets();
|
2009-11-06 20:34:43 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-11-06 20:34:43 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:23:35 +00:00
|
|
|
case WID_TE_DATE:
|
2009-11-06 20:34:43 +00:00
|
|
|
SetDParam(0, ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
2010-07-02 13:53:05 +00:00
|
|
|
DrawString(r.left, r.right, (this->height - FONT_HEIGHT_NORMAL) / 2, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER);
|
2009-11-06 20:34:43 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
case WID_TE_SPACER: {
|
2009-11-06 20:34:43 +00:00
|
|
|
int height = r.bottom - r.top;
|
|
|
|
if (height > 2 * FONT_HEIGHT_NORMAL) {
|
2010-07-02 13:53:05 +00:00
|
|
|
DrawString(r.left, r.right, (height + 1) / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
|
|
|
|
DrawString(r.left, r.right, (height + 1) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
|
2009-11-06 20:34:43 +00:00
|
|
|
} else {
|
2010-07-02 13:53:05 +00:00
|
|
|
DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
|
2009-11-06 20:34:43 +00:00
|
|
|
}
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-11-06 20:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-11-06 20:34:43 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:23:35 +00:00
|
|
|
case WID_TE_SPACER:
|
2009-11-06 20:34:43 +00:00
|
|
|
size->width = max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
case WID_TE_DATE:
|
2009-11-06 20:34:43 +00:00
|
|
|
SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
|
|
|
|
*size = GetStringBoundingBox(STR_WHITE_DATE_LONG);
|
2009-11-09 17:20:48 +00:00
|
|
|
size->height = max(size->height, GetSpriteSize(SPR_IMG_SAVE).height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
|
2009-11-06 20:34:43 +00:00
|
|
|
break;
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
|
|
|
if (_game_mode == GM_MENU) return;
|
2010-12-21 22:00:08 +00:00
|
|
|
CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
|
2016-08-15 18:32:25 +00:00
|
|
|
if (cbf != CBF_NONE) _last_started_action = cbf;
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
|
|
|
|
2008-08-25 20:42:54 +00:00
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
|
{
|
|
|
|
/* The map button is in a different location on the scenario
|
|
|
|
* editor toolbar, so we need to adjust for it. */
|
2011-12-16 18:23:35 +00:00
|
|
|
if (widget == WID_TE_SMALL_MAP) widget = WID_TN_SMALL_MAP;
|
2010-12-21 22:00:08 +00:00
|
|
|
CallBackFunction cbf = _menu_clicked_procs[widget](index);
|
2016-08-15 18:32:25 +00:00
|
|
|
if (cbf != CBF_NONE) _last_started_action = cbf;
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-08-25 20:42:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-15 15:30:44 +00:00
|
|
|
virtual EventState OnHotkey(int hotkey)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2010-12-21 22:00:08 +00:00
|
|
|
CallBackFunction cbf = CBF_NONE;
|
2013-06-15 15:30:44 +00:00
|
|
|
switch (hotkey) {
|
2011-12-31 14:56:39 +00:00
|
|
|
case MTEHK_PAUSE: ToolbarPauseClick(this); break;
|
|
|
|
case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
|
|
|
case MTEHK_SETTINGS: ShowGameOptions(); break;
|
|
|
|
case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
|
|
|
|
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_DOCKS: ToolbarScenBuildDocks(this); break;
|
|
|
|
case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
|
|
|
|
case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
|
|
|
|
case MTEHK_MUSIC: ShowMusicWindow(); break;
|
|
|
|
case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
|
|
|
|
case MTEHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot(); break;
|
2012-12-09 16:53:21 +00:00
|
|
|
case MTEHK_ZOOMEDIN_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
|
|
|
|
case MTEHK_DEFAULTZOOM_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
|
|
|
|
case MTEHK_GIANT_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_WORLD); break;
|
2011-12-31 14:56:39 +00:00
|
|
|
case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
|
|
|
|
case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
|
|
|
|
case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
|
|
|
|
case MTEHK_SMALLMAP: ShowSmallMap(); break;
|
|
|
|
case MTEHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
2008-05-18 22:11:46 +00:00
|
|
|
default: return ES_NOT_HANDLED;
|
|
|
|
}
|
2016-08-15 18:32:25 +00:00
|
|
|
if (cbf != CBF_NONE) _last_started_action = cbf;
|
2008-05-18 22:11:46 +00:00
|
|
|
return ES_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
2016-08-15 18:32:25 +00:00
|
|
|
switch (_last_started_action) {
|
2010-12-21 22:00:08 +00:00
|
|
|
case CBF_PLACE_SIGN:
|
|
|
|
PlaceProc_Sign(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CBF_PLACE_LANDINFO:
|
|
|
|
ShowLandInfo(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 22:11:46 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2016-08-15 18:32:25 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
|
|
|
_last_started_action = CBF_NONE;
|
|
|
|
}
|
|
|
|
|
2009-08-15 20:33:38 +00:00
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
2011-12-16 18:23:35 +00:00
|
|
|
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);
|
2009-08-15 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
2018-05-04 20:29:22 +00:00
|
|
|
virtual void OnRealtimeTick(uint delta_ms)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2018-05-20 08:58:36 +00:00
|
|
|
if (!this->timer.Elapsed(delta_ms)) return;
|
|
|
|
this->timer.SetInterval(MILLISECONDS_PER_TICK);
|
2018-05-04 20:29:22 +00:00
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
if (this->IsWidgetLowered(WID_TE_PAUSE) != !!_pause_mode) {
|
|
|
|
this->ToggleWidgetLoweredState(WID_TE_PAUSE);
|
2008-05-18 22:11:46 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
|
2011-12-16 18:23:35 +00:00
|
|
|
if (this->IsWidgetLowered(WID_TE_FAST_FORWARD) != !!_fast_forward) {
|
|
|
|
this->ToggleWidgetLoweredState(WID_TE_FAST_FORWARD);
|
2008-05-18 22:11:46 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @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)
|
2008-05-18 22:11:46 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2011-12-16 18:23:35 +00:00
|
|
|
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2010-03-13 10:18:57 +00:00
|
|
|
|
|
|
|
virtual void OnQueryTextFinished(char *str)
|
|
|
|
{
|
|
|
|
/* Was 'cancel' pressed? */
|
|
|
|
if (str == NULL) return;
|
|
|
|
|
|
|
|
int32 value;
|
|
|
|
if (!StrEmpty(str)) {
|
|
|
|
value = atoi(str);
|
|
|
|
} else {
|
|
|
|
/* An empty string means revert to the default */
|
|
|
|
value = DEF_START_YEAR;
|
|
|
|
}
|
2013-10-15 17:32:31 +00:00
|
|
|
SetStartingYear(value);
|
2010-03-13 10:18:57 +00:00
|
|
|
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
2010-07-04 11:48:04 +00:00
|
|
|
|
2013-06-15 15:28:09 +00:00
|
|
|
static HotkeyList hotkeys;
|
2010-07-04 11:48:04 +00:00
|
|
|
};
|
|
|
|
|
2013-06-15 15:28:09 +00:00
|
|
|
static Hotkey scenedit_maintoolbar_hotkeys[] = {
|
2013-06-15 15:27:33 +00:00
|
|
|
Hotkey(_maintoolbar_pause_keys, "pause", MTEHK_PAUSE),
|
|
|
|
Hotkey((uint16)0, "fastforward", MTEHK_FASTFORWARD),
|
|
|
|
Hotkey(WKC_F2, "settings", MTEHK_SETTINGS),
|
|
|
|
Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME),
|
|
|
|
Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND),
|
|
|
|
Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
|
|
|
|
Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
|
|
|
|
Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
|
|
|
|
Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
|
|
|
|
Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
|
|
|
|
Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
|
|
|
|
Hotkey(WKC_F11, "music", MTEHK_MUSIC),
|
|
|
|
Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO),
|
|
|
|
Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT),
|
|
|
|
Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
|
|
|
|
Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
|
|
|
|
Hotkey((uint16)0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT),
|
|
|
|
Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTEHK_ZOOM_IN),
|
|
|
|
Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTEHK_ZOOM_OUT),
|
|
|
|
Hotkey('L', "terraform", MTEHK_TERRAFORM),
|
|
|
|
Hotkey('M', "smallmap", MTEHK_SMALLMAP),
|
|
|
|
Hotkey('V', "extra_viewport", MTEHK_EXTRA_VIEWPORT),
|
|
|
|
HOTKEY_LIST_END
|
2008-05-18 22:11:46 +00:00
|
|
|
};
|
2013-06-15 15:28:09 +00:00
|
|
|
HotkeyList ScenarioEditorToolbarWindow::hotkeys("scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-11-06 20:34:43 +00:00
|
|
|
static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetDataTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetDataTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetDataTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS),
|
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_GREY, WID_TE_SAVE), SetDataTip(SPR_IMG_SAVE, STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(3, 2, 3),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD),
|
|
|
|
NWidget(WWT_EMPTY, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_NULL, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD),
|
2009-11-06 20:34:43 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SMALL_MAP), SetDataTip(SPR_IMG_SMALLMAP, STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_IN), SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
|
|
|
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_OUT), SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
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_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),
|
2009-11-06 20:34:43 +00:00
|
|
|
NWidget(NWID_SPACER),
|
2011-12-16 18:23:35 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_MUSIC_SOUND), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_HELP), SetDataTip(SPR_IMG_QUERY, STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
|
2009-11-06 20:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static NWidgetBase *MakeScenarioToolbar(int *biggest_index)
|
|
|
|
{
|
|
|
|
return MakeNWidgets(_nested_toolb_scen_inner_widgets, lengthof(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer());
|
|
|
|
}
|
|
|
|
|
|
|
|
static const NWidgetPart _nested_toolb_scen_widgets[] = {
|
|
|
|
NWidgetFunction(MakeScenarioToolbar),
|
2008-03-23 07:35:29 +00:00
|
|
|
};
|
|
|
|
|
2010-09-15 21:10:14 +00:00
|
|
|
static WindowDesc _toolb_scen_desc(
|
2015-02-13 21:13:45 +00:00
|
|
|
WDP_MANUAL, NULL, 0, 0,
|
2008-03-23 07:35:29 +00:00
|
|
|
WC_MAIN_TOOLBAR, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_NO_FOCUS,
|
2013-06-15 15:30:44 +00:00
|
|
|
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
|
|
|
|
&ScenarioEditorToolbarWindow::hotkeys
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/** Allocate the toolbar. */
|
2008-05-15 19:00:20 +00:00
|
|
|
void AllocateToolbar()
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2008-04-21 07:57:51 +00:00
|
|
|
/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
|
2008-04-18 15:11:39 +00:00
|
|
|
_last_built_roadtype = ROADTYPE_ROAD;
|
|
|
|
|
2008-05-18 22:11:46 +00:00
|
|
|
if (_game_mode == GM_EDITOR) {
|
2010-02-14 16:31:35 +00:00
|
|
|
new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
|
2008-05-18 22:11:46 +00:00
|
|
|
} else {
|
|
|
|
new MainToolbarWindow(&_toolb_normal_desc);
|
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|