Mercurial > hg > openttd
changeset 16888:f7551be72401 draft
(svn r21623) -Codechange: Remove _terraform_button_proc and _editor_terraform_button_proc arrays.
author | alberth <alberth@openttd.org> |
---|---|
date | Fri, 24 Dec 2010 15:03:19 +0000 |
parents | 69b56a3d9341 |
children | 19b4a53fa020 |
files | src/terraform_gui.cpp |
diffstat | 1 files changed, 89 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -216,17 +216,6 @@ if (HandlePlacePushButton(w, TTW_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT, PlaceProc_Object)) ShowBuildObjectPicker(w); } -static OnButtonClick * const _terraform_button_proc[] = { - TerraformClick_Lower, - TerraformClick_Raise, - TerraformClick_Level, - TerraformClick_Dynamite, - TerraformClick_BuyLand, - TerraformClick_Trees, - TerraformClick_PlaceSign, - TerraformClick_PlaceObject, -}; - struct TerraformToolbarWindow : Window { TerraformToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window() { @@ -248,7 +237,43 @@ virtual void OnClick(Point pt, int widget, int click_count) { - if (widget >= TTW_BUTTONS_START) _terraform_button_proc[widget - TTW_BUTTONS_START](this); + if (widget < TTW_BUTTONS_START) return; + + switch (widget) { + case TTW_LOWER_LAND: // Lower land button + TerraformClick_Lower(this); + break; + + case TTW_RAISE_LAND: // Raise land button + TerraformClick_Raise(this); + break; + + case TTW_LEVEL_LAND: // Level land button + TerraformClick_Level(this); + break; + + case TTW_DEMOLISH: // Demolish aka dynamite button + TerraformClick_Dynamite(this); + break; + + case TTW_BUY_LAND: // Buy land button + TerraformClick_BuyLand(this); + break; + + case TTW_PLANT_TREES: // Plant trees button + TerraformClick_Trees(this); + break; + + case TTW_PLACE_SIGN: // Place sign button + TerraformClick_PlaceSign(this); + break; + + case TTW_PLACE_OBJECT: // Place object button + TerraformClick_PlaceObject(this); + break; + + default: NOT_REACHED(); + } } virtual void OnTimeout() @@ -579,17 +604,6 @@ if (HandlePlacePushButton(w, ETTW_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT, PlaceProc_Object)) ShowBuildObjectPicker(w); } -static OnButtonClick * const _editor_terraform_button_proc[] = { - EditorTerraformClick_Dynamite, - EditorTerraformClick_LowerBigLand, - EditorTerraformClick_RaiseBigLand, - EditorTerraformClick_LevelLand, - EditorTerraformClick_RockyArea, - EditorTerraformClick_Desert, - EditorTerraformClick_PlaceObject -}; - - /** * Callback function for the scenario editor 'reset landscape' confirmation window * @param w Window unused @@ -668,35 +682,61 @@ virtual void OnClick(Point pt, int widget, int click_count) { - if (IsInsideMM(widget, ETTW_BUTTONS_START, ETTW_BUTTONS_END)) { - _editor_terraform_button_proc[widget - ETTW_BUTTONS_START](this); - } else { - switch (widget) { - case ETTW_INCREASE_SIZE: - case ETTW_DECREASE_SIZE: { // Increase/Decrease terraform size - int size = (widget == ETTW_INCREASE_SIZE) ? 1 : -1; - this->HandleButtonClick(widget); - size += _terraform_size; + if (widget < ETTW_BUTTONS_START) return; + + switch (widget) { + case ETTW_DEMOLISH: // Demolish aka dynamite button + EditorTerraformClick_Dynamite(this); + break; + + case ETTW_LOWER_LAND: // Lower land button + EditorTerraformClick_LowerBigLand(this); + break; - if (!IsInsideMM(size, 1, 8 + 1)) return; - _terraform_size = size; + case ETTW_RAISE_LAND: // Raise land button + EditorTerraformClick_RaiseBigLand(this); + break; + + case ETTW_LEVEL_LAND: // Level land button + EditorTerraformClick_LevelLand(this); + break; + + case ETTW_PLACE_ROCKS: // Place rocks button + EditorTerraformClick_RockyArea(this); + break; + + case ETTW_PLACE_DESERT: // Place desert button (in tropical climate) + EditorTerraformClick_Desert(this); + break; - SndPlayFx(SND_15_BEEP); - this->SetDirty(); - break; - } - case ETTW_NEW_SCENARIO: // gen random land - this->HandleButtonClick(widget); - ShowCreateScenario(); - break; - case ETTW_RESET_LANDSCAPE: // Reset landscape - ShowQuery( - STR_QUERY_RESET_LANDSCAPE_CAPTION, - STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, - NULL, - ResetLandscapeConfirmationCallback); - break; + case ETTW_PLACE_OBJECT: // Place transmitter button + EditorTerraformClick_PlaceObject(this); + break; + + case ETTW_INCREASE_SIZE: + case ETTW_DECREASE_SIZE: { // Increase/Decrease terraform size + int size = (widget == ETTW_INCREASE_SIZE) ? 1 : -1; + this->HandleButtonClick(widget); + size += _terraform_size; + + if (!IsInsideMM(size, 1, 8 + 1)) return; + _terraform_size = size; + + SndPlayFx(SND_15_BEEP); + this->SetDirty(); + break; } + + case ETTW_NEW_SCENARIO: // gen random land + this->HandleButtonClick(widget); + ShowCreateScenario(); + break; + + case ETTW_RESET_LANDSCAPE: // Reset landscape + ShowQuery(STR_QUERY_RESET_LANDSCAPE_CAPTION, STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, NULL, ResetLandscapeConfirmationCallback); + break; + + default: NOT_REACHED(); } }