Merge 1.7.0-RC1

This commit is contained in:
Pavel Stupnikov
2017-04-09 22:34:33 +03:00
262 changed files with 4673 additions and 3860 deletions
+36 -26
View File
@@ -1,4 +1,4 @@
/* $Id: toolbar_gui.cpp 27178 2015-03-07 18:27:01Z frosch $ */
/* $Id: toolbar_gui.cpp 27671 2016-10-30 17:36:57Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -84,6 +84,9 @@ enum CallBackFunction {
CBF_BUILD_HQ,
};
static CallBackFunction _last_started_action = CBF_NONE; ///< Last started user action.
/**
* Drop down list entry for showing a checked/unchecked toggle item.
*/ /*
@@ -266,7 +269,7 @@ static ToolbarMode _toolbar_mode;
static CallBackFunction SelectSignTool()
{
if (_cursor.sprite == SPR_CURSOR_SIGN) {
if (_last_started_action == CBF_PLACE_SIGN) {
ResetObjectToPlace();
return CBF_NONE;
} else {
@@ -277,7 +280,7 @@ static CallBackFunction SelectSignTool()
/* hq hotkey */
static CallBackFunction BuildCompanyHQ(){
if (_cursor.sprite == SPR_CURSOR_HQ) {
if (_last_started_action == CBF_BUILD_HQ) {
ResetObjectToPlace();
return CBF_NONE;
} else {
@@ -458,17 +461,17 @@ static CallBackFunction MenuClickSaveLoad(int index = 0)
{
if (_game_mode == GM_EDITOR) {
switch (index) {
case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(SLD_SAVE_SCENARIO); break;
case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(SLD_SAVE_HEIGHTMAP); break;
case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
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;
case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
}
} else {
switch (index) {
case SLNME_SAVE_GAME: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
case SLNME_LOAD_GAME: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
}
@@ -792,7 +795,7 @@ static CallBackFunction MenuClickLeague(int index)
static CallBackFunction ToolbarIndustryClick(Window *w)
{
/* Disable build-industry menu if we are a spectator */
PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, 3);
PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, (_local_company == COMPANY_SPECTATOR) ? 2 : 3);
return CBF_NONE;
}
@@ -1096,7 +1099,7 @@ static CallBackFunction MenuClickNewspaper(int index)
static CallBackFunction PlaceLandBlockInfo()
{
if (_cursor.sprite == SPR_CURSOR_QUERY) {
if (_last_started_action == CBF_PLACE_LANDINFO) {
ResetObjectToPlace();
return CBF_NONE;
} else {
@@ -2060,13 +2063,11 @@ enum MainToolbarHotkeys {
/** Main toolbar. */
struct MainToolbarWindow : Window {
CallBackFunction last_started_action; ///< Last started user action.
MainToolbarWindow(WindowDesc *desc) : Window(desc)
{
this->InitNested(0);
this->last_started_action = CBF_NONE;
_last_started_action = CBF_NONE;
CLRBITS(this->flags, WF_WHITE_BORDER);
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
@@ -2113,7 +2114,7 @@ struct MainToolbarWindow : Window {
virtual void OnDropdownSelect(int widget, int index)
{
CallBackFunction cbf = _menu_clicked_procs[widget](index);
if (cbf != CBF_NONE) this->last_started_action = cbf;
if (cbf != CBF_NONE) _last_started_action = cbf;
}
virtual EventState OnHotkey(int hotkey)
@@ -2123,7 +2124,7 @@ struct MainToolbarWindow : Window {
case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
case MTHK_SETTINGS: ShowGameOptions(); break;
case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
case MTHK_LOADGAME: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
case MTHK_SMALLMAP: ShowSmallMap(); break;
case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
@@ -2159,7 +2160,7 @@ struct MainToolbarWindow : Window {
case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
case MTHK_COMMANDS_GUI: extern bool _novahost; if (_networking && _novahost){ ShowCommandsToolbar(); } break;
#endif
case MTHK_BUILD_HQ: if(_current_company != COMPANY_SPECTATOR){ this->last_started_action = CBF_BUILD_HQ; BuildCompanyHQ(); } break;
case MTHK_BUILD_HQ: if(_current_company != COMPANY_SPECTATOR){ _last_started_action = CBF_BUILD_HQ; BuildCompanyHQ(); } break;
case MTHK_CARGOTABLE: if(_current_company != COMPANY_SPECTATOR){ ShowCompanyCargos(_current_company); } break;
case MTHK_TREES: if(_current_company != COMPANY_SPECTATOR){ BuildTreesWindow(); } break;
case MTHK_SIGN_LIST: ShowSignList(); break;
@@ -2167,7 +2168,7 @@ struct MainToolbarWindow : Window {
case MTHK_LOGINWINDOW: ShowLoginWindow(); break;
case MTHK_SETTINGS_ADV: ShowGameSettings(); break;
case MTHK_NEWGRF: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); break;
case MTHK_LANDINFO: this->last_started_action = PlaceLandBlockInfo(); break;
case MTHK_LANDINFO: _last_started_action = PlaceLandBlockInfo(); break;
default: return ES_NOT_HANDLED;
}
return ES_HANDLED;
@@ -2193,7 +2194,7 @@ struct MainToolbarWindow : Window {
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
switch (this->last_started_action) {
switch (_last_started_action) {
case CBF_PLACE_SIGN:
PlaceProc_Sign(tile);
break;
@@ -2213,11 +2214,17 @@ struct MainToolbarWindow : Window {
}
}
virtual void OnPlaceObjectAbort()
{
_last_started_action = CBF_NONE;
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
virtual void OnTick()
{
if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
@@ -2447,13 +2454,11 @@ enum MainToolbarEditorHotkeys {
};
struct ScenarioEditorToolbarWindow : Window {
CallBackFunction last_started_action; ///< Last started user action.
ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc)
{
this->InitNested(0);
this->last_started_action = CBF_NONE;
_last_started_action = CBF_NONE;
CLRBITS(this->flags, WF_WHITE_BORDER);
PositionMainToolbar(this);
DoZoomInOutWindow(ZOOM_NONE, this);
@@ -2512,7 +2517,7 @@ struct ScenarioEditorToolbarWindow : Window {
{
if (_game_mode == GM_MENU) return;
CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
if (cbf != CBF_NONE) this->last_started_action = cbf;
if (cbf != CBF_NONE) _last_started_action = cbf;
}
virtual void OnDropdownSelect(int widget, int index)
@@ -2521,7 +2526,7 @@ struct ScenarioEditorToolbarWindow : Window {
* editor toolbar, so we need to adjust for it. */
if (widget == WID_TE_SMALL_MAP) widget = WID_TN_SMALL_MAP;
CallBackFunction cbf = _menu_clicked_procs[widget](index);
if (cbf != CBF_NONE) this->last_started_action = cbf;
if (cbf != CBF_NONE) _last_started_action = cbf;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
}
@@ -2553,13 +2558,13 @@ struct ScenarioEditorToolbarWindow : Window {
case MTEHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
default: return ES_NOT_HANDLED;
}
if (cbf != CBF_NONE) this->last_started_action = cbf;
if (cbf != CBF_NONE) _last_started_action = cbf;
return ES_HANDLED;
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
switch (this->last_started_action) {
switch (_last_started_action) {
case CBF_PLACE_SIGN:
PlaceProc_Sign(tile);
break;
@@ -2572,6 +2577,11 @@ struct ScenarioEditorToolbarWindow : Window {
}
}
virtual void OnPlaceObjectAbort()
{
_last_started_action = CBF_NONE;
}
virtual void OnTimeout()
{
this->SetWidgetsLoweredState(false, WID_TE_DATE_BACKWARD, WID_TE_DATE_FORWARD, WIDGET_LIST_END);