terraform_gui.cpp File Reference

#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "clear_map.h"
#include "player_func.h"
#include "player_base.h"
#include "gui.h"
#include "window_gui.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
#include "signs.h"
#include "variables.h"
#include "functions.h"
#include "sound_func.h"
#include "station.h"
#include "unmovable_map.h"
#include "textbuf_gui.h"
#include "genworld.h"
#include "settings_type.h"
#include "tree_map.h"
#include "table/sprites.h"
#include "table/strings.h"

Go to the source code of this file.

Typedefs

typedef void OnButtonClick (Window *w)

Functions

void CcTerraform (bool success, TileIndex tile, uint32 p1, uint32 p2)
static void GenerateDesertArea (TileIndex end, TileIndex start)
 Scenario editor command that generates desert areas.
static void GenerateRockyArea (TileIndex end, TileIndex start)
 Scenario editor command that generates rocky areas.
bool GUIPlaceProcDragXY (const WindowEvent *e)
 A central place to handle all X_AND_Y dragged GUI functions.
void PlaceProc_DemolishArea (TileIndex tile)
static void PlaceProc_RaiseLand (TileIndex tile)
static void PlaceProc_LowerLand (TileIndex tile)
void PlaceProc_LevelLand (TileIndex tile)
static void TerraformClick_Lower (Window *w)
static void TerraformClick_Raise (Window *w)
static void TerraformClick_Level (Window *w)
static void TerraformClick_Dynamite (Window *w)
static void TerraformClick_BuyLand (Window *w)
static void TerraformClick_Trees (Window *w)
static void TerraformClick_PlaceSign (Window *w)
static void TerraformToolbWndProc (Window *w, WindowEvent *e)
void ShowTerraformToolbar (Window *link)
static void CommonRaiseLowerBigLand (TileIndex tile, int mode)
 Raise/Lower a bigger chunk of land at the same time in the editor.
static void PlaceProc_RaiseBigLand (TileIndex tile)
static void PlaceProc_LowerBigLand (TileIndex tile)
static void PlaceProc_RockyArea (TileIndex tile)
static void PlaceProc_LightHouse (TileIndex tile)
static void PlaceProc_Transmitter (TileIndex tile)
static void PlaceProc_DesertArea (TileIndex tile)
static void PlaceProc_WaterArea (TileIndex tile)
static void PlaceProc_RiverArea (TileIndex tile)
static void EditorTerraformClick_Dynamite (Window *w)
static void EditorTerraformClick_LowerBigLand (Window *w)
static void EditorTerraformClick_RaiseBigLand (Window *w)
static void EditorTerraformClick_LevelLand (Window *w)
static void EditorTerraformClick_WaterArea (Window *w)
static void EditorTerraformClick_RiverArea (Window *w)
static void EditorTerraformClick_RockyArea (Window *w)
static void EditorTerraformClick_DesertLightHouse (Window *w)
static void EditorTerraformClick_Transmitter (Window *w)
static void ResetLandscapeConfirmationCallback (Window *w, bool confirmed)
 Callback function for the scenario editor 'reset landscape' confirmation window.
static void ScenEditLandGenWndProc (Window *w, WindowEvent *e)
void ShowEditorTerraformToolbar ()

Variables

static const uint16 _terraform_keycodes []
static OnButtonClick *const _terraform_button_proc []
static const Widget _terraform_widgets []
static const WindowDesc _terraform_desc
static byte _terraform_size = 1
static const Widget _scen_edit_land_gen_widgets []
static const int8 _multi_terraform_coords [][2]
static const uint16 _editor_terraform_keycodes []
static OnButtonClick *const _editor_terraform_button_proc []
static const WindowDesc _scen_edit_land_gen_desc


Detailed Description

Definition in file terraform_gui.cpp.


Function Documentation

static void CommonRaiseLowerBigLand ( TileIndex  tile,
int  mode 
) [static]

Raise/Lower a bigger chunk of land at the same time in the editor.

When raising get the lowest point, when lowering the highest point, and set all tiles in the selection to that height.

Todo:
: Incorporate into game itself to allow for ingame raising/lowering of larger chunks at the same time OR remove altogether, as we have 'level land' ?
Parameters:
tile The top-left tile where the terraforming will start
mode 1 for raising, 0 for lowering land

Definition at line 328 of file terraform_gui.cpp.

References BEGIN_TILE_LOOP, CMD_MSG, CMD_TERRAFORM_LAND, DoCommandP(), END_TILE_LOOP, MapSizeX(), MapSizeY(), max(), min(), SLOPE_N, TileHeight(), TileX(), and TileY().

static void EditorTerraformClick_Dynamite ( Window *  w  )  [static]

Todo:
Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater

Definition at line 464 of file terraform_gui.cpp.

References ANIMCURSOR_DEMOLISH, HandlePlacePushButton(), and VHM_RECT.

bool GUIPlaceProcDragXY ( const WindowEvent *  e  ) 

A central place to handle all X_AND_Y dragged GUI functions.

Parameters:
e WindowEvent variable holding in its higher bits (excluding the lower 4, since that defined the X_Y drag) the type of action to be performed
Returns:
Returns true if the action was found and handled, and false otherwise. This allows for additional implements that are more local. For example X_Y drag of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp

Definition at line 111 of file terraform_gui.cpp.

References _ctrl_pressed, CMD_BUILD_CANAL, CMD_CLEAR_AREA, CMD_LEVEL_LAND, CMD_MSG, DoCommandP(), GenerateDesertArea(), and GenerateRockyArea().

Referenced by BuildRailToolbWndProc().

static void ResetLandscapeConfirmationCallback ( Window *  w,
bool  confirmed 
) [static]

Callback function for the scenario editor 'reset landscape' confirmation window.

Parameters:
w Window unused
confirmed boolean value, true when yes was clicked, false otherwise

Definition at line 538 of file terraform_gui.cpp.

References PLAYER_SPECTATOR.


Variable Documentation

OnButtonClick* const _editor_terraform_button_proc[] [static]

Initial value:

 {
  EditorTerraformClick_Dynamite,
  EditorTerraformClick_LowerBigLand,
  EditorTerraformClick_RaiseBigLand,
  EditorTerraformClick_LevelLand,
  EditorTerraformClick_WaterArea,
  EditorTerraformClick_RiverArea,
  EditorTerraformClick_RockyArea,
  EditorTerraformClick_DesertLightHouse,
  EditorTerraformClick_Transmitter
}

Definition at line 522 of file terraform_gui.cpp.

const uint16 _editor_terraform_keycodes[] [static]

Initial value:

 {
  'D',
  'Q',
  'W',
  'E',
  'R',
  'T',
  'Y',
  'U',
  'I'
}

Definition at line 509 of file terraform_gui.cpp.

const int8 _multi_terraform_coords[][2] [static]

Initial value:

 {
  {  0, -2},
  {  4,  0}, { -4,  0}, {  0,  2},
  { -8,  2}, { -4,  4}, {  0,  6}, {  4,  4}, {  8,  2},
  {-12,  0}, { -8, -2}, { -4, -4}, {  0, -6}, {  4, -4}, {  8, -2}, { 12,  0},
  {-16,  2}, {-12,  4}, { -8,  6}, { -4,  8}, {  0, 10}, {  4,  8}, {  8,  6}, { 12,  4}, { 16,  2},
  {-20,  0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, {  0,-10}, {  4, -8}, {  8, -6}, { 12, -4}, { 16, -2}, { 20,  0},
  {-24,  2}, {-20,  4}, {-16,  6}, {-12,  8}, { -8, 10}, { -4, 12}, {  0, 14}, {  4, 12}, {  8, 10}, { 12,  8}, { 16,  6}, { 20,  4}, { 24,  2},
  {-28,  0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, {  0,-14}, {  4,-12}, {  8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28,  0},
}

Definition at line 449 of file terraform_gui.cpp.

const WindowDesc _scen_edit_land_gen_desc [static]

Initial value:

 {
  WDP_AUTO, WDP_AUTO, 204, 103, 204, 103,
  WC_SCEN_LAND_GEN, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
  _scen_edit_land_gen_widgets,
  ScenEditLandGenWndProc,
}

Definition at line 670 of file terraform_gui.cpp.

const Widget _scen_edit_land_gen_widgets[] [static]

Initial value:

 {
{  WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW},
{   WWT_CAPTION,   RESIZE_NONE,     7,    11,   191,     0,    13, STR_0223_LAND_GENERATION,  STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX,   RESIZE_NONE,     7,   192,   203,     0,    13, STR_NULL,                  STR_STICKY_BUTTON},
{     WWT_PANEL,   RESIZE_NONE,     7,     0,   203,    14,   102, 0x0,                       STR_NULL},
{    WWT_IMGBTN,   RESIZE_NONE,    14,     2,    23,    16,    37, SPR_IMG_DYNAMITE,          STR_018D_DEMOLISH_BUILDINGS_ETC},
{    WWT_IMGBTN,   RESIZE_NONE,    14,    24,    45,    16,    37, SPR_IMG_TERRAFORM_DOWN,    STR_018E_LOWER_A_CORNER_OF_LAND},
{    WWT_IMGBTN,   RESIZE_NONE,    14,    46,    67,    16,    37, SPR_IMG_TERRAFORM_UP,      STR_018F_RAISE_A_CORNER_OF_LAND},
{    WWT_IMGBTN,   RESIZE_NONE,    14,    68,    89,    16,    37, SPR_IMG_LEVEL_LAND,        STR_LEVEL_LAND_TOOLTIP},
{    WWT_IMGBTN,   RESIZE_NONE,    14,    90,   111,    16,    37, SPR_IMG_BUILD_CANAL,       STR_CREATE_LAKE},
{    WWT_IMGBTN,   RESIZE_NONE,    14,   112,   133,    16,    37, SPR_IMG_BUILD_RIVER,       STR_CREATE_RIVER},
{    WWT_IMGBTN,   RESIZE_NONE,    14,   134,   156,    16,    37, SPR_IMG_ROCKS,             STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE},
{    WWT_IMGBTN,   RESIZE_NONE,    14,   157,   179,    16,    37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, 
{    WWT_IMGBTN,   RESIZE_NONE,    14,   180,   201,    16,    37, SPR_IMG_TRANSMITTER,       STR_028E_PLACE_TRANSMITTER},
{    WWT_IMGBTN,   RESIZE_NONE,    14,   150,   161,    45,    56, SPR_ARROW_UP,              STR_0228_INCREASE_SIZE_OF_LAND_AREA},
{    WWT_IMGBTN,   RESIZE_NONE,    14,   150,   161,    58,    69, SPR_ARROW_DOWN,            STR_0229_DECREASE_SIZE_OF_LAND_AREA},
{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   179,    76,    87, STR_SE_NEW_WORLD,          STR_022A_GENERATE_RANDOM_LAND},
{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   179,    89,   100, STR_022B_RESET_LANDSCAPE,  STR_RESET_LANDSCAPE_TOOLTIP},
{   WIDGETS_END},
}

Definition at line 428 of file terraform_gui.cpp.

OnButtonClick* const _terraform_button_proc[] [static]

Initial value:

 {
  TerraformClick_Lower,
  TerraformClick_Raise,
  TerraformClick_Level,
  TerraformClick_Dynamite,
  TerraformClick_BuyLand,
  TerraformClick_Trees,
  TerraformClick_PlaceSign,
}

Definition at line 216 of file terraform_gui.cpp.

const WindowDesc _terraform_desc [static]

Initial value:

 {
  WDP_ALIGN_TBR, 22 + 36, 158, 36, 158, 36,
  WC_SCEN_LAND_GEN, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
  _terraform_widgets,
  TerraformToolbWndProc
}

Definition at line 294 of file terraform_gui.cpp.

const uint16 _terraform_keycodes[] [static]

Initial value:

 {
  'Q',
  'W',
  'E',
  'D',
  'U',
  'I',
  'O',
}

Definition at line 150 of file terraform_gui.cpp.

const Widget _terraform_widgets[] [static]

Initial value:

 {
{ WWT_CLOSEBOX,   RESIZE_NONE,     7,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
{  WWT_CAPTION,   RESIZE_NONE,     7,  11, 145,   0,  13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
{WWT_STICKYBOX,   RESIZE_NONE,     7, 146, 157,   0,  13, STR_NULL,                STR_STICKY_BUTTON},

{    WWT_PANEL,   RESIZE_NONE,     7,  66,  69,  14,  35, 0x0,                    STR_NULL},
{   WWT_IMGBTN,   RESIZE_NONE,     7,   0,  21,  14,  35, SPR_IMG_TERRAFORM_DOWN,  STR_018E_LOWER_A_CORNER_OF_LAND},
{   WWT_IMGBTN,   RESIZE_NONE,     7,  22,  43,  14,  35, SPR_IMG_TERRAFORM_UP,    STR_018F_RAISE_A_CORNER_OF_LAND},
{   WWT_IMGBTN,   RESIZE_NONE,     7,  44,  65,  14,  35, SPR_IMG_LEVEL_LAND,      STR_LEVEL_LAND_TOOLTIP},
{   WWT_IMGBTN,   RESIZE_NONE,     7,  70,  91,  14,  35, SPR_IMG_DYNAMITE,        STR_018D_DEMOLISH_BUILDINGS_ETC},
{   WWT_IMGBTN,   RESIZE_NONE,     7,  92, 113,  14,  35, SPR_IMG_BUY_LAND,        STR_0329_PURCHASE_LAND_FOR_FUTURE},
{   WWT_IMGBTN,   RESIZE_NONE,     7, 114, 135,  14,  35, SPR_IMG_PLANTTREES,      STR_0185_PLANT_TREES_PLACE_SIGNS},
{   WWT_IMGBTN,   RESIZE_NONE,     7, 136, 157,  14,  35, SPR_IMG_SIGN,            STR_0289_PLACE_SIGN},

{   WIDGETS_END},
}

Definition at line 277 of file terraform_gui.cpp.


Generated on Wed Oct 1 17:03:32 2008 for openttd by  doxygen 1.5.6