(svn r12987) -Codechange: split viewport and tile selection.
authorrubidium
Wed, 07 May 2008 13:10:15 +0000
changeset 9127 14f21c5954ee
parent 9126 5648d696456b
child 9128 f4b41e7c282e
(svn r12987) -Codechange: split viewport and tile selection.
src/airport_gui.cpp
src/depot_gui.cpp
src/dock_gui.cpp
src/genworld.cpp
src/group_gui.cpp
src/industry_gui.cpp
src/main_gui.cpp
src/misc.cpp
src/misc_gui.cpp
src/order_gui.cpp
src/player_gui.cpp
src/rail_gui.cpp
src/road_gui.cpp
src/station_base.h
src/terraform_gui.cpp
src/tilehighlight_func.h
src/tilehighlight_type.h
src/toolbar_gui.cpp
src/town.h
src/town_gui.cpp
src/viewport.cpp
src/viewport_func.h
src/viewport_type.h
src/window.cpp
src/window_gui.h
--- a/src/airport_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/airport_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/depot_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/depot_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/dock_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/dock_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/genworld.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/genworld.cpp	Wed May 07 13:10:15 2008 +0000
@@ -25,6 +25,7 @@
 #include "settings_type.h"
 #include "newgrf_storage.h"
 #include "water.h"
+#include "tilehighlight_func.h"
 
 #include "table/sprites.h"
 
--- a/src/group_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/group_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/industry_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/industry_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/main_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/main_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/misc.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/misc.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/misc_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/misc_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/order_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/order_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/player_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/player_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/rail_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/rail_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/road_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/road_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/station_base.h	Wed May 07 09:07:19 2008 +0000
+++ b/src/station_base.h	Wed May 07 13:10:15 2008 +0000
@@ -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)
--- a/src/terraform_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/terraform_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tilehighlight_func.h	Wed May 07 13:10:15 2008 +0000
@@ -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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tilehighlight_type.h	Wed May 07 13:10:15 2008 +0000
@@ -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 */
--- a/src/toolbar_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/toolbar_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/town.h	Wed May 07 09:07:19 2008 +0000
+++ b/src/town.h	Wed May 07 13:10:15 2008 +0000
@@ -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,
--- a/src/town_gui.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/town_gui.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/viewport.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/viewport.cpp	Wed May 07 13:10:15 2008 +0000
@@ -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"
--- a/src/viewport_func.h	Wed May 07 09:07:19 2008 +0000
+++ b/src/viewport_func.h	Wed May 07 13:10:15 2008 +0000
@@ -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 @@
 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 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 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 */
--- a/src/viewport_type.h	Wed May 07 09:07:19 2008 +0000
+++ b/src/viewport_type.h	Wed May 07 13:10:15 2008 +0000
@@ -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 @@
 	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 */
--- a/src/window.cpp	Wed May 07 09:07:19 2008 +0000
+++ b/src/window.cpp	Wed May 07 13:10:15 2008 +0000
@@ -21,6 +21,7 @@
 #include "settings_type.h"
 #include "cheat_func.h"
 #include "window_func.h"
+#include "tilehighlight_func.h"
 
 #include "table/sprites.h"
 
--- a/src/window_gui.h	Wed May 07 09:07:19 2008 +0000
+++ b/src/window_gui.h	Wed May 07 13:10:15 2008 +0000
@@ -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.