mirror of https://github.com/OpenTTD/OpenTTD
(svn r20071) -Codechange: Consistently return the toolbar window for ShowBuildXxxToolbar().
parent
26be68ae98
commit
397d1186d7
|
@ -168,20 +168,27 @@ static const WindowDesc _air_toolbar_desc(
|
||||||
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)
|
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
void ShowBuildAirToolbar()
|
/**
|
||||||
|
* Open the build airport toolbar window
|
||||||
|
*
|
||||||
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
||||||
|
*
|
||||||
|
* @return newly opened airport toolbar, or NULL if the toolbar could not be opened.
|
||||||
|
*/
|
||||||
|
Window *ShowBuildAirToolbar()
|
||||||
{
|
{
|
||||||
if (!Company::IsValidID(_local_company)) return;
|
if (!Company::IsValidID(_local_company)) return NULL;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
{
|
{
|
||||||
int num = CheckHotkeyMatch<BuildAirToolbarWindow>(_airtoolbar_hotkeys, keycode, NULL, true);
|
int num = CheckHotkeyMatch<BuildAirToolbarWindow>(_airtoolbar_hotkeys, keycode, NULL, true);
|
||||||
if (num == -1) return ES_NOT_HANDLED;
|
if (num == -1) return ES_NOT_HANDLED;
|
||||||
ShowBuildAirToolbar();
|
Window *w = ShowBuildAirToolbar();
|
||||||
Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
|
if (w == NULL) return ES_NOT_HANDLED;
|
||||||
return w->OnKeyPress(key, keycode);
|
return w->OnKeyPress(key, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,20 +294,27 @@ static const WindowDesc _build_docks_toolbar_desc(
|
||||||
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets)
|
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
void ShowBuildDocksToolbar()
|
/**
|
||||||
|
* Open the build water toolbar window
|
||||||
|
*
|
||||||
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
||||||
|
*
|
||||||
|
* @return newly opened water toolbar, or NULL if the toolbar could not be opened.
|
||||||
|
*/
|
||||||
|
Window *ShowBuildDocksToolbar()
|
||||||
{
|
{
|
||||||
if (!Company::IsValidID(_local_company)) return;
|
if (!Company::IsValidID(_local_company)) return NULL;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState DockToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
EventState DockToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
{
|
{
|
||||||
int num = CheckHotkeyMatch<BuildDocksToolbarWindow>(_dockstoolbar_hotkeys, keycode, NULL, true);
|
int num = CheckHotkeyMatch<BuildDocksToolbarWindow>(_dockstoolbar_hotkeys, keycode, NULL, true);
|
||||||
if (num == -1) return ES_NOT_HANDLED;
|
if (num == -1) return ES_NOT_HANDLED;
|
||||||
ShowBuildDocksToolbar();
|
Window *w = ShowBuildDocksToolbar();
|
||||||
Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
|
if (w == NULL) return ES_NOT_HANDLED;
|
||||||
return w->OnKeyPress(key, keycode);
|
return w->OnKeyPress(key, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,9 +346,14 @@ static const WindowDesc _build_docks_scen_toolbar_desc(
|
||||||
_nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets)
|
_nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
void ShowBuildDocksScenToolbar()
|
/**
|
||||||
|
* Open the build water toolbar window for the scenario editor.
|
||||||
|
*
|
||||||
|
* @return newly opened water toolbar, or NULL if the toolbar could not be opened.
|
||||||
|
*/
|
||||||
|
Window *ShowBuildDocksScenToolbar()
|
||||||
{
|
{
|
||||||
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
|
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Widget numbers of the build-dock GUI. */
|
/** Widget numbers of the build-dock GUI. */
|
||||||
|
|
10
src/gui.h
10
src/gui.h
|
@ -19,6 +19,8 @@
|
||||||
#include "strings_type.h"
|
#include "strings_type.h"
|
||||||
#include "transport_type.h"
|
#include "transport_type.h"
|
||||||
|
|
||||||
|
struct Window;
|
||||||
|
|
||||||
/* main_gui.cpp */
|
/* main_gui.cpp */
|
||||||
void HandleOnEditText(const char *str);
|
void HandleOnEditText(const char *str);
|
||||||
void InitializeGUI();
|
void InitializeGUI();
|
||||||
|
@ -33,11 +35,11 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
|
||||||
void ShowOrdersWindow(const Vehicle *v);
|
void ShowOrdersWindow(const Vehicle *v);
|
||||||
|
|
||||||
/* dock_gui.cpp */
|
/* dock_gui.cpp */
|
||||||
void ShowBuildDocksToolbar();
|
Window *ShowBuildDocksToolbar();
|
||||||
void ShowBuildDocksScenToolbar();
|
Window *ShowBuildDocksScenToolbar();
|
||||||
|
|
||||||
/* aircraft_gui.cpp */
|
/* airport_gui.cpp */
|
||||||
void ShowBuildAirToolbar();
|
Window *ShowBuildAirToolbar();
|
||||||
|
|
||||||
/* tgp_gui.cpp */
|
/* tgp_gui.cpp */
|
||||||
void ShowGenerateLandscape();
|
void ShowGenerateLandscape();
|
||||||
|
|
|
@ -898,16 +898,17 @@ static const WindowDesc _build_rail_desc(
|
||||||
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
||||||
*
|
*
|
||||||
* @param railtype Rail type to open the window for
|
* @param railtype Rail type to open the window for
|
||||||
|
* @return newly opened rail toolbar, or NULL if the toolbar could not be opened.
|
||||||
*/
|
*/
|
||||||
void ShowBuildRailToolbar(RailType railtype)
|
Window *ShowBuildRailToolbar(RailType railtype)
|
||||||
{
|
{
|
||||||
if (!Company::IsValidID(_local_company)) return;
|
if (!Company::IsValidID(_local_company)) return NULL;
|
||||||
if (!ValParamRailtype(railtype)) return;
|
if (!ValParamRailtype(railtype)) return NULL;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
_cur_railtype = railtype;
|
_cur_railtype = railtype;
|
||||||
BuildRailToolbarWindow *w = new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
|
|
||||||
_remove_button_clicked = false;
|
_remove_button_clicked = false;
|
||||||
|
return new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
|
@ -915,8 +916,8 @@ EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
extern RailType _last_built_railtype;
|
extern RailType _last_built_railtype;
|
||||||
int num = CheckHotkeyMatch<BuildRailToolbarWindow>(_railtoolbar_hotkeys, keycode, NULL, true);
|
int num = CheckHotkeyMatch<BuildRailToolbarWindow>(_railtoolbar_hotkeys, keycode, NULL, true);
|
||||||
if (num == -1) return ES_NOT_HANDLED;
|
if (num == -1) return ES_NOT_HANDLED;
|
||||||
ShowBuildRailToolbar(_last_built_railtype);
|
Window *w = ShowBuildRailToolbar(_last_built_railtype);
|
||||||
Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
|
if (w == NULL) return ES_NOT_HANDLED;
|
||||||
return w->OnKeyPress(key, keycode);
|
return w->OnKeyPress(key, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "rail_type.h"
|
#include "rail_type.h"
|
||||||
|
|
||||||
void ShowBuildRailToolbar(RailType railtype);
|
Window *ShowBuildRailToolbar(RailType railtype);
|
||||||
void ReinitGuiAfterToggleElrail(bool disable);
|
void ReinitGuiAfterToggleElrail(bool disable);
|
||||||
bool ResetSignalVariant(int32 = 0);
|
bool ResetSignalVariant(int32 = 0);
|
||||||
void InitializeRailGUI();
|
void InitializeRailGUI();
|
||||||
|
|
|
@ -360,6 +360,7 @@ EventState TerraformToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
int num = CheckHotkeyMatch<TerraformToolbarWindow>(_terraform_hotkeys, keycode, NULL, true);
|
int num = CheckHotkeyMatch<TerraformToolbarWindow>(_terraform_hotkeys, keycode, NULL, true);
|
||||||
if (num == -1) return ES_NOT_HANDLED;
|
if (num == -1) return ES_NOT_HANDLED;
|
||||||
Window *w = ShowTerraformToolbar(NULL);
|
Window *w = ShowTerraformToolbar(NULL);
|
||||||
|
if (w == NULL) return ES_NOT_HANDLED;
|
||||||
return w->OnKeyPress(key, keycode);
|
return w->OnKeyPress(key, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,5 +770,6 @@ EventState TerraformToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
||||||
int num = CheckHotkeyMatch<ScenarioEditorLandscapeGenerationWindow>(_terraform_editor_hotkeys, keycode, NULL, true);
|
int num = CheckHotkeyMatch<ScenarioEditorLandscapeGenerationWindow>(_terraform_editor_hotkeys, keycode, NULL, true);
|
||||||
if (num == -1) return ES_NOT_HANDLED;
|
if (num == -1) return ES_NOT_HANDLED;
|
||||||
Window *w = ShowEditorTerraformToolbar();
|
Window *w = ShowEditorTerraformToolbar();
|
||||||
|
if (w == NULL) return ES_NOT_HANDLED;
|
||||||
return w->OnKeyPress(key, keycode);
|
return w->OnKeyPress(key, keycode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue