summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-07 13:10:15 +0000
committerrubidium <rubidium@openttd.org>2008-05-07 13:10:15 +0000
commit3d5567ccf767160de35b67bd165abe3badf487fe (patch)
treebcef44c109a8918a321975b6aaaff9a98017d596
parent7ccda80b0bae730f17d6863df84e78ea455ff1db (diff)
downloadopenttd-3d5567ccf767160de35b67bd165abe3badf487fe.tar.xz
(svn r12987) -Codechange: split viewport and tile selection.
-rw-r--r--src/airport_gui.cpp1
-rw-r--r--src/depot_gui.cpp1
-rw-r--r--src/dock_gui.cpp1
-rw-r--r--src/genworld.cpp1
-rw-r--r--src/group_gui.cpp1
-rw-r--r--src/industry_gui.cpp1
-rw-r--r--src/main_gui.cpp1
-rw-r--r--src/misc.cpp1
-rw-r--r--src/misc_gui.cpp1
-rw-r--r--src/order_gui.cpp1
-rw-r--r--src/player_gui.cpp1
-rw-r--r--src/rail_gui.cpp1
-rw-r--r--src/road_gui.cpp1
-rw-r--r--src/station_base.h1
-rw-r--r--src/terraform_gui.cpp1
-rw-r--r--src/tilehighlight_func.h26
-rw-r--r--src/tilehighlight_type.h77
-rw-r--r--src/toolbar_gui.cpp1
-rw-r--r--src/town.h1
-rw-r--r--src/town_gui.cpp1
-rw-r--r--src/viewport.cpp1
-rw-r--r--src/viewport_func.h17
-rw-r--r--src/viewport_type.h67
-rw-r--r--src/window.cpp1
-rw-r--r--src/window_gui.h3
25 files changed, 129 insertions, 81 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index fe2d46181..fb6b39df2 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -18,6 +18,7 @@
#include "player_func.h"
#include "order_func.h"
#include "station_type.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 8021aa303..571bcb210 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -24,6 +24,7 @@
#include "player_func.h"
#include "order_func.h"
#include "depot_base.h"
+#include "tilehighlight_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 408a5edf7..70530dcb5 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -20,6 +20,7 @@
#include "gfx_func.h"
#include "player_func.h"
#include "slope_func.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 25c1f8fac..ff58de86a 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -25,6 +25,7 @@
#include "settings_type.h"
#include "newgrf_storage.h"
#include "water.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 066dbe617..4f7a551a4 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -23,6 +23,7 @@
#include "player_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
+#include "tilehighlight_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index d84f766ae..2f1f10f79 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -24,6 +24,7 @@
#include "map_func.h"
#include "player_func.h"
#include "settings_type.h"
+#include "tilehighlight_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 33a42f01b..c9927d8ff 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -30,6 +30,7 @@
#include "settings_type.h"
#include "toolbar_gui.h"
#include "variables.h"
+#include "tilehighlight_func.h"
#include "network/network.h"
#include "network/network_data.h"
diff --git a/src/misc.cpp b/src/misc.cpp
index 047737eca..1342e20d7 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -26,6 +26,7 @@
#include "gfx_func.h"
#include "core/alloc_type.hpp"
#include "animated_tile_func.h"
+#include "tilehighlight_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 8330b5266..296c3ab6e 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -43,6 +43,7 @@
#include "settings_type.h"
#include "newgrf_cargo.h"
#include "rail_gui.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 0df7079c0..125118fcb 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -30,6 +30,7 @@
#include "textbuf_gui.h"
#include "string_func.h"
#include "depot_base.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 8af5c2bb4..a8f05d593 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -30,6 +30,7 @@
#include "settings_type.h"
#include "widgets/dropdown_func.h"
#include "widgets/dropdown_type.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 5696f8bc1..5c6f9fe76 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -30,6 +30,7 @@
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "tunnelbridge.h"
+#include "tilehighlight_func.h"
#include "bridge_map.h"
#include "rail_map.h"
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index e5e080478..c20a6e03e 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -23,6 +23,7 @@
#include "player_func.h"
#include "settings_type.h"
#include "tunnelbridge.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/station_base.h b/src/station_base.h
index ca311d0f1..94f88d85f 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -16,6 +16,7 @@
#include "vehicle_type.h"
#include "player_type.h"
#include "core/geometry_type.hpp"
+#include "viewport_type.h"
#include <list>
DECLARE_OLD_POOL(Station, Station, 6, 1000)
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 969e21e1a..81c46959b 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -24,6 +24,7 @@
#include "settings_type.h"
#include "tree_map.h"
#include "landscape_type.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h
new file mode 100644
index 000000000..13278aa5f
--- /dev/null
+++ b/src/tilehighlight_func.h
@@ -0,0 +1,26 @@
+/* $Id$ */
+
+/** @file tilehighlight_func.h Functions related to tile highlights. */
+
+#ifndef TILEHIGHLIGHT_FUNC_H
+#define TILEHIGHLIGHT_FUNC_H
+
+#include "gfx_type.h"
+#include "window_type.h"
+#include "viewport_type.h"
+#include "tilehighlight_type.h"
+
+typedef void PlaceProc(TileIndex tile);
+void PlaceProc_DemolishArea(TileIndex tile);
+void PlaceProc_LevelLand(TileIndex tile);
+void PlaceProc_BuyLand(TileIndex tile);
+bool GUIPlaceProcDragXY(const WindowEvent *e);
+
+bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
+void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
+void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
+
+extern PlaceProc *_place_proc;
+extern TileHighlightData _thd;
+
+#endif /* TILEHIGHLIGHT_FUNC_H */
diff --git a/src/tilehighlight_type.h b/src/tilehighlight_type.h
new file mode 100644
index 000000000..0637d374e
--- /dev/null
+++ b/src/tilehighlight_type.h
@@ -0,0 +1,77 @@
+/* $Id$ */
+
+/** @file tilehighlight_type.h Types related to highlighting tiles. */
+
+#ifndef TILEHIGHLIGHT_TYPE_H
+#define TILEHIGHLIGHT_TYPE_H
+
+#include "core/geometry_type.hpp"
+#include "zoom_type.h"
+#include "window_type.h"
+#include "tile_type.h"
+
+/** Viewport highlight mode (for highlighting tiles below cursor) */
+enum ViewportHighlightMode {
+ VHM_NONE = 0, ///< default
+ VHM_RECT = 1, ///< rectangle (stations, depots, ...)
+ VHM_POINT = 2, ///< point (lower land, raise land, level land, ...)
+ VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
+ VHM_DRAG = 4, ///< dragging items in the depot windows
+ VHM_RAIL = 5, ///< rail pieces
+};
+
+/** Highlighting draw styles */
+enum HighLightStyle {
+ HT_NONE = 0x00,
+ HT_RECT = 0x80,
+ HT_POINT = 0x40,
+ HT_LINE = 0x20, ///< used for autorail highlighting (longer streches)
+ ///< (uses lower bits to indicate direction)
+ HT_RAIL = 0x10, ///< autorail (one piece)
+ ///< (uses lower bits to indicate direction)
+ HT_DRAG_MASK = 0xF0, ///< masks the drag-type
+
+ /* lower bits (used with HT_LINE and HT_RAIL):
+ * (see ASCII art in autorail.h for a visual interpretation) */
+ HT_DIR_X = 0, ///< X direction
+ HT_DIR_Y = 1, ///< Y direction
+ HT_DIR_HU = 2, ///< horizontal upper
+ HT_DIR_HL = 3, ///< horizontal lower
+ HT_DIR_VL = 4, ///< vertical left
+ HT_DIR_VR = 5, ///< vertical right
+ HT_DIR_MASK = 0x7 ///< masks the drag-direction
+};
+DECLARE_ENUM_AS_BIT_SET(HighLightStyle);
+
+
+struct TileHighlightData {
+ Point size;
+ Point outersize;
+ Point pos;
+ Point offs;
+
+ Point new_pos;
+ Point new_size;
+ Point new_outersize;
+
+ Point selend, selstart;
+
+ byte dirty;
+ byte sizelimit;
+
+ byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information
+ byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new
+ byte next_drawstyle; // queued, but not yet drawn style
+
+ ViewportHighlightMode place_mode;
+ bool make_square_red;
+ WindowClass window_class;
+ WindowNumber window_number;
+
+ ViewportPlaceMethod select_method;
+ byte select_proc;
+
+ TileIndex redsq;
+};
+
+#endif /* TILEHIGHLIGHT_TYPE_H */
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 734de007c..8d0c3d2d6 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -37,6 +37,7 @@
#include "functions.h"
#include "console.h"
#include "news_gui.h"
+#include "tilehighlight_func.h"
#include "network/network.h"
#include "network/network_gui.h"
diff --git a/src/town.h b/src/town.h
index 0b0952256..03d0cc112 100644
--- a/src/town.h
+++ b/src/town.h
@@ -15,6 +15,7 @@
#include "player_type.h"
#include "settings_type.h"
#include "strings_type.h"
+#include "viewport_type.h"
enum {
HOUSE_NO_CLASS = 0,
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 3190554d0..d67d42469 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -22,6 +22,7 @@
#include "economy_func.h"
#include "core/alloc_func.hpp"
#include "settings_type.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/viewport.cpp b/src/viewport.cpp
index d70a0ed5d..3de54e987 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -46,6 +46,7 @@
#include "core/alloc_type.hpp"
#include "misc/smallvec.h"
#include "window_func.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/viewport_func.h b/src/viewport_func.h
index de088b6c1..7be3e733e 100644
--- a/src/viewport_func.h
+++ b/src/viewport_func.h
@@ -9,6 +9,8 @@
#include "viewport_type.h"
#include "vehicle_type.h"
#include "strings_type.h"
+#include "window_type.h"
+#include "tile_type.h"
void SetSelectionRed(bool);
@@ -17,6 +19,7 @@ void InitializeWindowViewport(Window *w, int x, int y, int width, int height, ui
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
Point GetTileBelowCursor();
void UpdateViewportPosition(Window *w);
+void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str);
bool DoZoomInOutWindow(int how, Window *w);
void ZoomInOrOutToCursorWindow(bool in, Window * w);
@@ -53,20 +56,8 @@ void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process
void VpSetPresizeRange(TileIndex from, TileIndex to);
void VpSetPlaceSizingLimit(int limit);
-typedef void PlaceProc(TileIndex tile);
-void PlaceProc_DemolishArea(TileIndex tile);
-void PlaceProc_LevelLand(TileIndex tile);
-void PlaceProc_BuyLand(TileIndex tile);
-bool GUIPlaceProcDragXY(const WindowEvent *e);
-
-/* common button handler */
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
-
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
-void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
-void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
-
void ResetObjectToPlace();
bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
@@ -74,8 +65,6 @@ bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
bool ScrollMainWindowTo(int x, int y, bool instant = false);
-extern PlaceProc *_place_proc;
extern Point _tile_fract_coords;
-extern TileHighlightData _thd;
#endif /* VIEWPORT_FUNC_H */
diff --git a/src/viewport_type.h b/src/viewport_type.h
index f43566fbb..e14862e65 100644
--- a/src/viewport_type.h
+++ b/src/viewport_type.h
@@ -5,10 +5,7 @@
#ifndef VIEWPORT_TYPE_H
#define VIEWPORT_TYPE_H
-#include "core/geometry_type.hpp"
#include "zoom_type.h"
-#include "window_type.h"
-#include "tile_type.h"
/**
* Data structure for viewport, display of a part of the world
@@ -55,68 +52,4 @@ enum ViewportPlaceMethod {
VPM_SIGNALDIRS = 6, ///< similiar to VMP_RAILDIRS, but with different cursor
};
-/** Viewport highlight mode (for highlighting tiles below cursor) */
-enum ViewportHighlightMode {
- VHM_NONE = 0, ///< default
- VHM_RECT = 1, ///< rectangle (stations, depots, ...)
- VHM_POINT = 2, ///< point (lower land, raise land, level land, ...)
- VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
- VHM_DRAG = 4, ///< dragging items in the depot windows
- VHM_RAIL = 5, ///< rail pieces
-};
-
-/** Highlighting draw styles */
-enum HighLightStyle {
- HT_NONE = 0x00,
- HT_RECT = 0x80,
- HT_POINT = 0x40,
- HT_LINE = 0x20, ///< used for autorail highlighting (longer streches)
- ///< (uses lower bits to indicate direction)
- HT_RAIL = 0x10, ///< autorail (one piece)
- ///< (uses lower bits to indicate direction)
- HT_DRAG_MASK = 0xF0, ///< masks the drag-type
-
- /* lower bits (used with HT_LINE and HT_RAIL):
- * (see ASCII art in autorail.h for a visual interpretation) */
- HT_DIR_X = 0, ///< X direction
- HT_DIR_Y = 1, ///< Y direction
- HT_DIR_HU = 2, ///< horizontal upper
- HT_DIR_HL = 3, ///< horizontal lower
- HT_DIR_VL = 4, ///< vertical left
- HT_DIR_VR = 5, ///< vertical right
- HT_DIR_MASK = 0x7 ///< masks the drag-direction
-};
-DECLARE_ENUM_AS_BIT_SET(HighLightStyle);
-
-
-struct TileHighlightData {
- Point size;
- Point outersize;
- Point pos;
- Point offs;
-
- Point new_pos;
- Point new_size;
- Point new_outersize;
-
- Point selend, selstart;
-
- byte dirty;
- byte sizelimit;
-
- byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information
- byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new
- byte next_drawstyle; // queued, but not yet drawn style
-
- ViewportHighlightMode place_mode;
- bool make_square_red;
- WindowClass window_class;
- WindowNumber window_number;
-
- ViewportPlaceMethod select_method;
- byte select_proc;
-
- TileIndex redsq;
-};
-
#endif /* VIEWPORT_TYPE_H */
diff --git a/src/window.cpp b/src/window.cpp
index 4e5df5f82..023b47fb4 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -21,6 +21,7 @@
#include "settings_type.h"
#include "cheat_func.h"
#include "window_func.h"
+#include "tilehighlight_func.h"
#include "table/sprites.h"
diff --git a/src/window_gui.h b/src/window_gui.h
index a608957ee..081ec736b 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -6,11 +6,14 @@
#define WINDOW_GUI_H
#include "core/bitmath_func.hpp"
+#include "core/geometry_type.hpp"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "player_type.h"
#include "strings_type.h"
#include "core/alloc_type.hpp"
+#include "window_type.h"
+#include "tile_type.h"
/**
* The maximum number of windows that can be opened.