Changeset - r15418:e7ab6dbdd591
[Not reviewed]
master
0 6 0
frosch - 14 years ago 2010-07-04 09:27:15
frosch@openttd.org
(svn r20071) -Codechange: Consistently return the toolbar window for ShowBuildXxxToolbar().
6 files changed with 47 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -168,20 +168,27 @@ static const WindowDesc _air_toolbar_des
 
	_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);
 
	AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
 
	return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
 
}
 

	
 
EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
 
{
 
	int num = CheckHotkeyMatch<BuildAirToolbarWindow>(_airtoolbar_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	ShowBuildAirToolbar();
 
	Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
 
	Window *w = ShowBuildAirToolbar();
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -294,20 +294,27 @@ static const WindowDesc _build_docks_too
 
	_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);
 
	AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
 
	return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
 
}
 

	
 
EventState DockToolbarGlobalHotkeys(uint16 key, uint16 keycode)
 
{
 
	int num = CheckHotkeyMatch<BuildDocksToolbarWindow>(_dockstoolbar_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	ShowBuildDocksToolbar();
 
	Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
 
	Window *w = ShowBuildDocksToolbar();
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
 

	
 
@@ -339,9 +346,14 @@ static const WindowDesc _build_docks_sce
 
	_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. */
src/gui.h
Show inline comments
 
@@ -19,6 +19,8 @@
 
#include "strings_type.h"
 
#include "transport_type.h"
 

	
 
struct Window;
 

	
 
/* main_gui.cpp */
 
void HandleOnEditText(const char *str);
 
void InitializeGUI();
 
@@ -33,11 +35,11 @@ void DrawArrowButtons(int x, int y, Colo
 
void ShowOrdersWindow(const Vehicle *v);
 

	
 
/* dock_gui.cpp */
 
void ShowBuildDocksToolbar();
 
void ShowBuildDocksScenToolbar();
 
Window *ShowBuildDocksToolbar();
 
Window *ShowBuildDocksScenToolbar();
 

	
 
/* aircraft_gui.cpp */
 
void ShowBuildAirToolbar();
 
/* airport_gui.cpp */
 
Window *ShowBuildAirToolbar();
 

	
 
/* tgp_gui.cpp */
 
void ShowGenerateLandscape();
src/rail_gui.cpp
Show inline comments
 
@@ -898,16 +898,17 @@ static const WindowDesc _build_rail_desc
 
 * If the terraform toolbar is linked to the toolbar, that window is also opened.
 
 *
 
 * @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 (!ValParamRailtype(railtype)) return;
 
	if (!Company::IsValidID(_local_company)) return NULL;
 
	if (!ValParamRailtype(railtype)) return NULL;
 

	
 
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 
	_cur_railtype = railtype;
 
	BuildRailToolbarWindow *w = new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
 
	_remove_button_clicked = false;
 
	return new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
 
}
 

	
 
EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
 
@@ -915,8 +916,8 @@ EventState RailToolbarGlobalHotkeys(uint
 
	extern RailType _last_built_railtype;
 
	int num = CheckHotkeyMatch<BuildRailToolbarWindow>(_railtoolbar_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	ShowBuildRailToolbar(_last_built_railtype);
 
	Window *w = FindWindowByClass(WC_BUILD_TOOLBAR);
 
	Window *w = ShowBuildRailToolbar(_last_built_railtype);
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
 

	
src/rail_gui.h
Show inline comments
 
@@ -14,7 +14,7 @@
 

	
 
#include "rail_type.h"
 

	
 
void ShowBuildRailToolbar(RailType railtype);
 
Window *ShowBuildRailToolbar(RailType railtype);
 
void ReinitGuiAfterToggleElrail(bool disable);
 
bool ResetSignalVariant(int32 = 0);
 
void InitializeRailGUI();
src/terraform_gui.cpp
Show inline comments
 
@@ -360,6 +360,7 @@ EventState TerraformToolbarGlobalHotkeys
 
	int num = CheckHotkeyMatch<TerraformToolbarWindow>(_terraform_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	Window *w = ShowTerraformToolbar(NULL);
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
 

	
 
@@ -769,5 +770,6 @@ EventState TerraformToolbarEditorGlobalH
 
	int num = CheckHotkeyMatch<ScenarioEditorLandscapeGenerationWindow>(_terraform_editor_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	Window *w = ShowEditorTerraformToolbar();
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
0 comments (0 inline, 0 general)