Changeset - r15404:58ea9b70001e
[Not reviewed]
master
0 2 0
yexo - 14 years ago 2010-07-03 13:29:01
yexo@openttd.org
(svn r20057) -Feature: customizable hotkeys for the terraform toolbar in scenario editor
2 files changed with 22 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/hotkeys.cpp
Show inline comments
 
@@ -228,6 +228,7 @@ void SaveLoadHotkeyGroup(IniGroup *group
 
}
 

	
 
struct TerraformToolbarWindow;
 
struct ScenarioEditorLandscapeGenerationWindow;
 

	
 
static void SaveLoadHotkeys(bool save)
 
{
 
@@ -242,6 +243,7 @@ static void SaveLoadHotkeys(bool save)
 
	SaveLoadHotkeyGroup(group, _##name##_hotkeys, save);
 

	
 
	SL_HOTKEYS(terraform, TerraformToolbarWindow);
 
	SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow);
 

	
 

	
 
#undef SL_HOTKEYS
src/terraform_gui.cpp
Show inline comments
 
@@ -578,17 +578,6 @@ static void EditorTerraformClick_Transmi
 
	HandlePlacePushButton(w, ETTW_PLACE_TRANSMITTER, SPR_CURSOR_TRANSMITTER, HT_RECT, PlaceProc_Transmitter);
 
}
 

	
 
static const uint16 _editor_terraform_keycodes[] = {
 
	'D',
 
	'Q',
 
	'W',
 
	'E',
 
	'R',
 
	'T',
 
	'Y'
 
};
 

	
 
typedef void OnButtonClick(Window *w);
 
static OnButtonClick * const _editor_terraform_button_proc[] = {
 
	EditorTerraformClick_Dynamite,
 
	EditorTerraformClick_LowerBigLand,
 
@@ -666,13 +655,10 @@ struct ScenarioEditorLandscapeGeneration
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		for (uint i = 0; i != lengthof(_editor_terraform_keycodes); i++) {
 
			if (keycode == _editor_terraform_keycodes[i]) {
 
				_editor_terraform_button_proc[i](this);
 
				return ES_HANDLED;
 
			}
 
		}
 
		return ES_NOT_HANDLED;
 
		int num = CheckHotkeyMatch(terraform_editor_hotkeys, keycode, this);
 
		if (num == -1) return ES_NOT_HANDLED;
 
		this->OnClick(Point(), num, 1);
 
		return ES_HANDLED;
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
@@ -751,8 +737,24 @@ struct ScenarioEditorLandscapeGeneration
 
		this->RaiseButtons();
 
		this->SetDirty();
 
	}
 

	
 
	static Hotkey<ScenarioEditorLandscapeGenerationWindow> terraform_editor_hotkeys[];
 
};
 

	
 
Hotkey<ScenarioEditorLandscapeGenerationWindow> ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys[] = {
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('D', "dynamite", ETTW_DEMOLISH),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('Q', "lower", ETTW_LOWER_LAND),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('W', "raise", ETTW_RAISE_LAND),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('E', "level", ETTW_LEVEL_LAND),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('R', "rocky", ETTW_PLACE_ROCKS),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('T', "desertlighthouse", ETTW_PLACE_DESERT_LIGHTHOUSE),
 
	Hotkey<ScenarioEditorLandscapeGenerationWindow>('Y', "transmitter", ETTW_PLACE_TRANSMITTER),
 
	HOTKEY_LIST_END(ScenarioEditorLandscapeGenerationWindow)
 
};
 

	
 
Hotkey<ScenarioEditorLandscapeGenerationWindow> *_terraform_editor_hotkeys = ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys;
 

	
 

	
 
static const WindowDesc _scen_edit_land_gen_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_SCEN_LAND_GEN, WC_NONE,
0 comments (0 inline, 0 general)