Changeset - r9127:933c13888121
[Not reviewed]
master
0 23 2
rubidium - 17 years ago 2008-05-07 13:10:15
rubidium@openttd.org
(svn r12987) -Codechange: split viewport and tile selection.
25 files changed with 129 insertions and 81 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -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"
src/depot_gui.cpp
Show inline comments
 
@@ -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"
src/dock_gui.cpp
Show inline comments
 
@@ -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"
src/genworld.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "settings_type.h"
 
#include "newgrf_storage.h"
 
#include "water.h"
 
#include "tilehighlight_func.h"
 

	
 
#include "table/sprites.h"
 

	
src/group_gui.cpp
Show inline comments
 
@@ -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"
src/industry_gui.cpp
Show inline comments
 
@@ -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"
src/main_gui.cpp
Show inline comments
 
@@ -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"
src/misc.cpp
Show inline comments
 
@@ -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"
src/misc_gui.cpp
Show inline comments
 
@@ -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"
src/order_gui.cpp
Show inline comments
 
@@ -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"
src/player_gui.cpp
Show inline comments
 
@@ -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"
src/rail_gui.cpp
Show inline comments
 
@@ -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"
src/road_gui.cpp
Show inline comments
 
@@ -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"
src/station_base.h
Show inline comments
 
@@ -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)
src/terraform_gui.cpp
Show inline comments
 
@@ -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"
src/tilehighlight_func.h
Show inline comments
 
new file 100644
 
/* $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 */
src/tilehighlight_type.h
Show inline comments
 
new file 100644
 
/* $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 */
src/toolbar_gui.cpp
Show inline comments
 
@@ -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"
src/town.h
Show inline comments
 
@@ -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,
src/town_gui.cpp
Show inline comments
 
@@ -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"
src/viewport.cpp
Show inline comments
 
@@ -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"
src/viewport_func.h
Show inline comments
 
@@ -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,
 
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, 
 
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
 
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 */
src/viewport_type.h
Show inline comments
 
@@ -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 */
src/window.cpp
Show inline comments
 
@@ -21,6 +21,7 @@
 
#include "settings_type.h"
 
#include "cheat_func.h"
 
#include "window_func.h"
 
#include "tilehighlight_func.h"
 

	
 
#include "table/sprites.h"
 

	
src/window_gui.h
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)