Changeset - r15409:7239f4bba8bf
[Not reviewed]
master
0 2 0
yexo - 14 years ago 2010-07-03 18:10:18
yexo@openttd.org
(svn r20062) -Feature: customizable hotkeys for the airport toolbar
2 files changed with 15 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -23,12 +23,13 @@
 
#include "tilehighlight_func.h"
 
#include "company_base.h"
 
#include "station_type.h"
 
#include "newgrf_airport.h"
 
#include "widgets/dropdown_type.h"
 
#include "core/geometry_func.hpp"
 
#include "hotkeys.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
static AirportClassID _selected_airport_class; ///< the currently visible airport class
 
static int _selected_airport_index;            ///< the index of the selected airport in the current class or -1
 
@@ -103,17 +104,15 @@ struct BuildAirToolbarWindow : Window {
 
		_build_air_button_proc[widget - ATW_AIRPORT](this);
 
	}
 

	
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		switch (keycode) {
 
			case '1': BuildAirClick_Airport(this); break;
 
			case '2': BuildAirClick_Demolish(this); break;
 
			default: return ES_NOT_HANDLED;
 
		}
 
		int num = CheckHotkeyMatch(airtoolbar_hotkeys, keycode, this);
 
		if (num == -1) return ES_NOT_HANDLED;
 
		this->OnClick(Point(), num, 1);
 
		return ES_HANDLED;
 
	}
 

	
 
	virtual void OnPlaceObject(Point pt, TileIndex tile)
 
	{
 
		_place_proc(tile);
 
@@ -135,14 +134,23 @@ struct BuildAirToolbarWindow : Window {
 
	{
 
		this->RaiseButtons();
 

	
 
		DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
 
		DeleteWindowById(WC_SELECT_STATION, 0);
 
	}
 

	
 
	static Hotkey<BuildAirToolbarWindow> airtoolbar_hotkeys[];
 
};
 

	
 
Hotkey<BuildAirToolbarWindow> BuildAirToolbarWindow::airtoolbar_hotkeys[] = {
 
	Hotkey<BuildAirToolbarWindow>('1', "airport", ATW_AIRPORT),
 
	Hotkey<BuildAirToolbarWindow>('2', "demolish", ATW_DEMOLISH),
 
	HOTKEY_LIST_END(BuildAirToolbarWindow)
 
};
 
Hotkey<BuildAirToolbarWindow> *_airtoolbar_hotkeys = BuildAirToolbarWindow::airtoolbar_hotkeys;
 

	
 
static const NWidgetPart _nested_air_toolbar_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
 
		NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
 
	EndContainer(),
src/hotkeys.cpp
Show inline comments
 
@@ -228,12 +228,13 @@ void SaveLoadHotkeyGroup(IniGroup *group
 
}
 

	
 
struct MainWindow;
 
struct TerraformToolbarWindow;
 
struct ScenarioEditorLandscapeGenerationWindow;
 
struct OrdersWindow;
 
struct BuildAirToolbarWindow;
 

	
 
static void SaveLoadHotkeys(bool save)
 
{
 
	IniFile *ini = new IniFile();
 
	ini->LoadFromDisk(_hotkeys_file);
 

	
 
@@ -245,12 +246,13 @@ static void SaveLoadHotkeys(bool save)
 
	SaveLoadHotkeyGroup(group, _##name##_hotkeys, save);
 

	
 
	SL_HOTKEYS(global, MainWindow);
 
	SL_HOTKEYS(terraform, TerraformToolbarWindow);
 
	SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow);
 
	SL_HOTKEYS(order, OrdersWindow);
 
	SL_HOTKEYS(airtoolbar, BuildAirToolbarWindow);
 

	
 

	
 
#undef SL_HOTKEYS
 
	if (save) ini->SaveToDisk(_hotkeys_file);
 
	delete ini;
 
}
0 comments (0 inline, 0 general)