Changeset - r7888:a45fbbd1aeee
[Not reviewed]
master
0 3 0
rubidium - 17 years ago 2007-11-15 18:21:59
rubidium@openttd.org
(svn r11439) -Codechange: replace some magic numbers by a ViewportPlaceMethod enumified constant. Patch by SmatZ.
3 files changed with 18 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/viewport.cpp
Show inline comments
 
@@ -2291,13 +2291,13 @@ void UpdateTileSelection()
 
		/* draw the new selection? */
 
		if (_thd.new_drawstyle) SetSelectionTilesDirty();
 
	}
 
}
 

	
 
/** highlighting tiles while only going over them with the mouse */
 
void VpStartPlaceSizing(TileIndex tile, byte method, byte process)
 
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process)
 
{
 
	_thd.select_method = method;
 
	_thd.select_proc   = process;
 
	_thd.selend.x = TileX(tile) * TILE_SIZE;
 
	_thd.selstart.x = TileX(tile) * TILE_SIZE;
 
	_thd.selend.y = TileY(tile) * TILE_SIZE;
 
@@ -2628,13 +2628,13 @@ static void CalcRaildirsDrawstyle(TileHi
 
/**
 
 * Selects tiles while dragging
 
 * @param x X coordinate of end of selection
 
 * @param y Y coordinate of end of selection
 
 * @param method modifies the way tiles are selected. Possible
 
 * methods are VPM_* in viewport.h */
 
void VpSelectTilesWithMethod(int x, int y, int method)
 
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
 
{
 
	int sx, sy;
 
	HighLightStyle style;
 

	
 
	if (x == -1) {
 
		_thd.selend.x = -1;
src/viewport.h
Show inline comments
 
@@ -70,39 +70,39 @@ void EndSpriteCombine();
 
void HandleViewportClicked(const ViewPort *vp, int x, int y);
 
void PlaceObject();
 
void SetRedErrorSquare(TileIndex tile);
 
void SetTileSelectSize(int w, int h);
 
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
 

	
 
void VpStartPlaceSizing(TileIndex tile, byte method, byte process);
 
void VpSetPresizeRange(uint from, uint to);
 
void VpSetPlaceSizingLimit(int limit);
 

	
 
Vehicle *CheckMouseOverVehicle();
 

	
 
enum {
 
	VPM_X_OR_Y          = 0,
 
	VPM_FIX_X           = 1,
 
	VPM_FIX_Y           = 2,
 
	VPM_RAILDIRS        = 3,
 
	VPM_X_AND_Y         = 4,
 
	VPM_X_AND_Y_LIMITED = 5,
 
	VPM_SIGNALDIRS      = 6
 
/** Viewport place method (type of highlighted area and placed objects) */
 
enum ViewportPlaceMethod {
 
	VPM_X_OR_Y          = 0, ///< drag in X or Y direction
 
	VPM_FIX_X           = 1, ///< drag only in X axis
 
	VPM_FIX_Y           = 2, ///< drag only in Y axis
 
	VPM_RAILDIRS        = 3, ///< all rail directions
 
	VPM_X_AND_Y         = 4, ///< area of land in X and Y directions
 
	VPM_X_AND_Y_LIMITED = 5, ///< area of land of limited size
 
	VPM_SIGNALDIRS      = 6, ///< similiar to VMP_RAILDIRS, but with different cursor
 
};
 

	
 
/* viewport highlight mode (for highlighting tiles below cursor) */
 
enum {
 
	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
 
};
 

	
 
void VpSelectTilesWithMethod(int x, int y, int method);
 
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
 
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process);
 
void VpSetPresizeRange(uint from, uint to);
 
void VpSetPlaceSizingLimit(int limit);
 

	
 
/* highlighting draw styles */
 
typedef byte HighLightStyle;
 
enum HighLightStyles {
 
	HT_NONE   = 0x00,
 
	HT_RECT   = 0x80,
 
@@ -145,13 +145,13 @@ struct TileHighlightData {
 

	
 
	byte place_mode;
 
	bool make_square_red;
 
	WindowClass window_class;
 
	WindowNumber window_number;
 

	
 
	byte select_method;
 
	ViewportPlaceMethod select_method;
 
	byte select_proc;
 

	
 
	TileIndex redsq;
 
};
 

	
 

	
src/window.h
Show inline comments
 
@@ -9,12 +9,13 @@
 
#include "string.h"
 
#include "order.h"
 
#include "rail.h"
 
#include "road.h"
 
#include "airport.h"
 
#include "vehicle.h"
 
#include "viewport.h"
 

	
 
struct WindowEvent;
 

	
 
typedef void WindowProc(Window *w, WindowEvent *e);
 

	
 
/* How the resize system works:
 
@@ -137,13 +138,13 @@ struct WindowEvent {
 
		} click;
 

	
 
		struct {
 
			Point pt;
 
			TileIndex tile;
 
			TileIndex starttile;
 
			byte select_method;
 
			ViewportPlaceMethod select_method;
 
			byte select_proc;
 
		} place;
 

	
 
		struct {
 
			Point pt;
 
			int widget;
0 comments (0 inline, 0 general)