Changeset - r15410:d32a94848de6
[Not reviewed]
master
0 2 0
yexo - 14 years ago 2010-07-03 18:18:58
yexo@openttd.org
(svn r20063) -Feature: customizable hotkeys for the dock toolbar
2 files changed with 22 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/dock_gui.cpp
Show inline comments
 
@@ -25,12 +25,13 @@
 
#include "gfx_func.h"
 
#include "company_func.h"
 
#include "slope_func.h"
 
#include "tilehighlight_func.h"
 
#include "company_base.h"
 
#include "station_type.h"
 
#include "hotkeys.h"
 

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

	
 
static void ShowBuildDockStationPicker(Window *parent);
 
static void ShowBuildDocksDepotPicker(Window *parent);
 
@@ -186,24 +187,15 @@ struct BuildDocksToolbarWindow : Window 
 
	{
 
		if (widget >= DTW_BUTTONS_BEGIN) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		switch (keycode) {
 
			case '1': BuildDocksClick_Canal(this); break;
 
			case '2': BuildDocksClick_Lock(this); break;
 
			case '3': BuildDocksClick_Demolish(this); break;
 
			case '4': BuildDocksClick_Depot(this); break;
 
			case '5': BuildDocksClick_Dock(this); break;
 
			case '6': BuildDocksClick_Buoy(this); break;
 
			case '7': BuildDocksClick_River(this); break;
 
			case 'B':
 
			case '8': BuildDocksClick_Aqueduct(this); break;
 
			default:  return ES_NOT_HANDLED;
 
		}
 
		int num = CheckHotkeyMatch(dockstoolbar_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);
 
@@ -251,14 +243,30 @@ struct BuildDocksToolbarWindow : Window 
 
	{
 
		DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL));
 
		TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from);
 

	
 
		VpSetPresizeRange(tile_from, tile_to);
 
	}
 

	
 
	static Hotkey<BuildDocksToolbarWindow> dockstoolbar_hotkeys[];
 
};
 

	
 
const uint16 _dockstoolbar_aqueduct_keys[] = {'B', '8', 0};
 

	
 
Hotkey<BuildDocksToolbarWindow> BuildDocksToolbarWindow::dockstoolbar_hotkeys[] = {
 
	Hotkey<BuildDocksToolbarWindow>('1', "canal", DTW_CANAL),
 
	Hotkey<BuildDocksToolbarWindow>('2', "lock", DTW_LOCK),
 
	Hotkey<BuildDocksToolbarWindow>('3', "demolish", DTW_DEMOLISH),
 
	Hotkey<BuildDocksToolbarWindow>('4', "depot", DTW_DEPOT),
 
	Hotkey<BuildDocksToolbarWindow>('5', "dock", DTW_STATION),
 
	Hotkey<BuildDocksToolbarWindow>('6', "buoy", DTW_BUOY),
 
	Hotkey<BuildDocksToolbarWindow>('7', "river", DTW_RIVER),
 
	Hotkey<BuildDocksToolbarWindow>(_dockstoolbar_aqueduct_keys, "aqueduct", DTW_BUILD_AQUEDUCT),
 
	HOTKEY_LIST_END(BuildDocksToolbarWindow)
 
};
 
Hotkey<BuildDocksToolbarWindow> *_dockstoolbar_hotkeys = BuildDocksToolbarWindow::dockstoolbar_hotkeys;
 

	
 
/**
 
 * Nested widget parts of docks toolbar, game version.
 
 * Position of #DTW_RIVER widget has changed.
 
 */
 
static const NWidgetPart _nested_build_docks_toolbar_widgets[] = {
src/hotkeys.cpp
Show inline comments
 
@@ -229,12 +229,13 @@ void SaveLoadHotkeyGroup(IniGroup *group
 

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

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

	
 
@@ -247,12 +248,13 @@ static void SaveLoadHotkeys(bool save)
 

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

	
 

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