(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.

pull/155/head
rubidium 17 years ago
parent c5a9fd4559
commit ecdb16de42

@ -51,12 +51,12 @@ enum {
static void BuildAirClick_Airport(Window *w) static void BuildAirClick_Airport(Window *w)
{ {
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker(); if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker();
} }
static void BuildAirClick_Demolish(Window *w) static void BuildAirClick_Demolish(Window *w)
{ {
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea); HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceAir_DemolishArea);
} }

@ -436,7 +436,7 @@ static void DepotClick(Window *w, int x, int y)
WP(w, depot_d).sel = v->index; WP(w, depot_d).sel = v->index;
SetWindowDirty(w); SetWindowDirty(w);
SetObjectToPlaceWnd(image, GetVehiclePalette(v), 4, w); SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, w);
} }
} }
break; break;

@ -79,35 +79,35 @@ enum {
static void BuildDocksClick_Canal(Window *w) static void BuildDocksClick_Canal(Window *w)
{ {
HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal); HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal);
} }
static void BuildDocksClick_Lock(Window *w) static void BuildDocksClick_Lock(Window *w)
{ {
HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock); HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock);
} }
static void BuildDocksClick_Demolish(Window *w) static void BuildDocksClick_Demolish(Window *w)
{ {
HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea); HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceDocks_DemolishArea);
} }
static void BuildDocksClick_Depot(Window *w) static void BuildDocksClick_Depot(Window *w)
{ {
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(); if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
} }
static void BuildDocksClick_Dock(Window *w) static void BuildDocksClick_Dock(Window *w)
{ {
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker(); if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker();
} }
static void BuildDocksClick_Buoy(Window *w) static void BuildDocksClick_Buoy(Window *w)
{ {
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy); HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy);
} }

@ -6,6 +6,7 @@
#define FUNCTIONS_H #define FUNCTIONS_H
#include "gfx.h" #include "gfx.h"
#include "viewport.h"
void UpdateTownMaxPass(Town *t); void UpdateTownMaxPass(Town *t);
@ -123,8 +124,8 @@ void InvalidateWindowClassesData(WindowClass cls);
void DeleteWindowById(WindowClass cls, WindowNumber number); void DeleteWindowById(WindowClass cls, WindowNumber number);
void DeleteWindowByClass(WindowClass cls); void DeleteWindowByClass(WindowClass cls);
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w); void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num); void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
void ResetObjectToPlace(); void ResetObjectToPlace();

@ -20,6 +20,7 @@
#include "settings.h" #include "settings.h"
#include "heightmap.h" #include "heightmap.h"
#include "date.h" #include "date.h"
#include "viewport.h"
void GenerateClearTile(); void GenerateClearTile();
void GenerateIndustries(); void GenerateIndustries();
@ -85,7 +86,7 @@ static void *_GenerateWorld(void *arg)
if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom(); if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
_random_seeds[0][0] = _random_seeds[0][1] = _patches.generation_seed; _random_seeds[0][0] = _random_seeds[0][1] = _patches.generation_seed;
SetGeneratingWorldProgress(GWP_MAP_INIT, 2); SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0); SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
IncreaseGeneratingWorldProgress(GWP_MAP_INIT); IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
/* Must start economy early because of the costs. */ /* Must start economy early because of the costs. */

@ -554,7 +554,7 @@ static void GroupWndProc(Window *w, WindowEvent *e)
gv->vehicle_sel = v->index; gv->vehicle_sel = v->index;
if (v->IsValid()) { if (v->IsValid()) {
SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), 4, w); SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), VHM_DRAG, w);
} }
SetWindowDirty(w); SetWindowDirty(w);

@ -270,7 +270,7 @@ static void BuildDynamicIndustryWndProc(Window *w, WindowEvent *e)
DoCommandP(0, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); DoCommandP(0, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
HandleButtonClick(w, DYNA_INDU_FUND_WIDGET); HandleButtonClick(w, DYNA_INDU_FUND_WIDGET);
} else { } else {
HandlePlacePushButton(w, DYNA_INDU_FUND_WIDGET, SPR_CURSOR_INDUSTRY, 1, NULL); HandlePlacePushButton(w, DYNA_INDU_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);
} }
} break; } break;
} }

@ -119,7 +119,7 @@ void HandleOnEditText(const char *str)
* @param placeproc Procedure which will be called when someone clicks on the map * @param placeproc Procedure which will be called when someone clicks on the map
* @return true if the button is clicked, false if it's unclicked * @return true if the button is clicked, false if it's unclicked
*/ */
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc) bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
{ {
if (IsWindowWidgetDisabled(w, widget)) return false; if (IsWindowWidgetDisabled(w, widget)) return false;
@ -352,7 +352,7 @@ static void SelectSignTool()
if (_cursor.sprite == SPR_CURSOR_SIGN) { if (_cursor.sprite == SPR_CURSOR_SIGN) {
ResetObjectToPlace(); ResetObjectToPlace();
} else { } else {
SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, 1, WC_MAIN_TOOLBAR, 0); SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
_place_proc = PlaceProc_Sign; _place_proc = PlaceProc_Sign;
} }
} }
@ -1197,42 +1197,42 @@ static const int8 _multi_terraform_coords[][2] = {
*/ */
static void EditorTerraformClick_Dynamite(Window *w) static void EditorTerraformClick_Dynamite(Window *w)
{ {
HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
} }
static void EditorTerraformClick_LowerBigLand(Window *w) static void EditorTerraformClick_LowerBigLand(Window *w)
{ {
HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand); HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
} }
static void EditorTerraformClick_RaiseBigLand(Window *w) static void EditorTerraformClick_RaiseBigLand(Window *w)
{ {
HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand); HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
} }
static void EditorTerraformClick_LevelLand(Window *w) static void EditorTerraformClick_LevelLand(Window *w)
{ {
HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand); HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
} }
static void EditorTerraformClick_WaterArea(Window *w) static void EditorTerraformClick_WaterArea(Window *w)
{ {
HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, 1, PlaceProc_WaterArea); HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
} }
static void EditorTerraformClick_RockyArea(Window *w) static void EditorTerraformClick_RockyArea(Window *w)
{ {
HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, 1, PlaceProc_RockyArea); HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
} }
static void EditorTerraformClick_DesertLightHouse(Window *w) static void EditorTerraformClick_DesertLightHouse(Window *w)
{ {
HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, 1, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse); HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
} }
static void EditorTerraformClick_Transmitter(Window *w) static void EditorTerraformClick_Transmitter(Window *w)
{ {
HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, 1, PlaceProc_Transmitter); HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
} }
static const uint16 _editor_terraform_keycodes[] = { static const uint16 _editor_terraform_keycodes[] = {
@ -1462,7 +1462,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 4: // new town case 4: // new town
HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, 1, PlaceProc_Town); HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
break; break;
case 5: {// random town case 5: {// random town
Town *t; Town *t;

@ -23,6 +23,7 @@
#include "date.h" #include "date.h"
#include "cargotype.h" #include "cargotype.h"
#include "group.h" #include "group.h"
#include "viewport.h"
char _name_array[512][32]; char _name_array[512][32];
@ -105,7 +106,7 @@ void InitializeGame(int mode, uint size_x, uint size_y)
AddTypeToEngines(); // make sure all engines have a type AddTypeToEngines(); // make sure all engines have a type
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0); SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
_pause_game = 0; _pause_game = 0;
_fast_forward = 0; _fast_forward = 0;

@ -199,7 +199,7 @@ void PlaceLandBlockInfo()
ResetObjectToPlace(); ResetObjectToPlace();
} else { } else {
_place_proc = Place_LandInfo; _place_proc = Place_LandInfo;
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, 1, WC_MAIN_TOOLBAR, 0); SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
} }
} }
@ -366,12 +366,12 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
case 11:case 12: case 13: case 14: case 11:case 12: case 13: case 14:
if (wid - 3 >= WP(w,tree_d).count) break; if (wid - 3 >= WP(w,tree_d).count) break;
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL)) if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL))
_tree_to_plant = WP(w,tree_d).base + wid - 3; _tree_to_plant = WP(w,tree_d).base + wid - 3;
break; break;
case 15: // tree of random type. case 15: // tree of random type.
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, 1, NULL)) if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL))
_tree_to_plant = -1; _tree_to_plant = -1;
break; break;
@ -1675,7 +1675,7 @@ void ShowSaveLoadDialog(int mode)
const WindowDesc *sld = &_save_dialog_desc; const WindowDesc *sld = &_save_dialog_desc;
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0); SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
DeleteWindowById(WC_QUERY_STRING, 0); DeleteWindowById(WC_QUERY_STRING, 0);
DeleteWindowById(WC_SAVELOAD, 0); DeleteWindowById(WC_SAVELOAD, 0);

@ -401,7 +401,7 @@ static void OrderClick_Goto(Window *w, const Vehicle *v)
ToggleWidgetLoweredState(w, ORDER_WIDGET_GOTO); ToggleWidgetLoweredState(w, ORDER_WIDGET_GOTO);
if (IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) { if (IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) {
_place_clicked_vehicle = NULL; _place_clicked_vehicle = NULL;
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, 1, w); SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
} else { } else {
ResetObjectToPlace(); ResetObjectToPlace();
} }
@ -591,7 +591,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
if (v->owner == _local_player) { if (v->owner == _local_player) {
/* Activate drag and drop */ /* Activate drag and drop */
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, 4, w); SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w);
} }
} }
} }

@ -1159,7 +1159,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
if (tile == 0) { if (tile == 0) {
if ((byte)w->window_number != _local_player) if ((byte)w->window_number != _local_player)
return; return;
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, 1, w); SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
SetTileSelectSize(2, 2); SetTileSelectSize(2, 2);
LowerWindowWidget(w, PCW_WIDGET_BUILD_VIEW_HQ); LowerWindowWidget(w, PCW_WIDGET_BUILD_VIEW_HQ);
InvalidateWidget(w, PCW_WIDGET_BUILD_VIEW_HQ); InvalidateWidget(w, PCW_WIDGET_BUILD_VIEW_HQ);
@ -1170,7 +1170,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
} }
case PCW_WIDGET_RELOCATE_HQ: case PCW_WIDGET_RELOCATE_HQ:
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, 1, w); SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
SetTileSelectSize(2, 2); SetTileSelectSize(2, 2);
LowerWindowWidget(w, PCW_WIDGET_RELOCATE_HQ); LowerWindowWidget(w, PCW_WIDGET_RELOCATE_HQ);
InvalidateWidget(w, PCW_WIDGET_RELOCATE_HQ); InvalidateWidget(w, PCW_WIDGET_RELOCATE_HQ);

@ -258,22 +258,22 @@ enum RailToolbarWidgets {
static void BuildRailClick_N(Window *w) static void BuildRailClick_N(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N); HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, VHM_RECT, PlaceRail_N);
} }
static void BuildRailClick_NE(Window *w) static void BuildRailClick_NE(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE); HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, VHM_RECT, PlaceRail_NE);
} }
static void BuildRailClick_E(Window *w) static void BuildRailClick_E(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E); HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, VHM_RECT, PlaceRail_E);
} }
static void BuildRailClick_NW(Window *w) static void BuildRailClick_NW(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW); HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, VHM_RECT, PlaceRail_NW);
} }
static void BuildRailClick_AutoRail(Window *w) static void BuildRailClick_AutoRail(Window *w)
@ -283,12 +283,12 @@ static void BuildRailClick_AutoRail(Window *w)
static void BuildRailClick_Demolish(Window *w) static void BuildRailClick_Demolish(Window *w)
{ {
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
} }
static void BuildRailClick_Depot(Window *w) static void BuildRailClick_Depot(Window *w)
{ {
if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) { if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) {
ShowBuildTrainDepotPicker(); ShowBuildTrainDepotPicker();
} }
} }
@ -296,7 +296,7 @@ static void BuildRailClick_Depot(Window *w)
static void BuildRailClick_Waypoint(Window *w) static void BuildRailClick_Waypoint(Window *w)
{ {
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) && if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) &&
_waypoint_count > 1) { _waypoint_count > 1) {
ShowBuildWaypointPicker(); ShowBuildWaypointPicker();
} }
@ -304,7 +304,7 @@ static void BuildRailClick_Waypoint(Window *w)
static void BuildRailClick_Station(Window *w) static void BuildRailClick_Station(Window *w)
{ {
if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder(); if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder();
} }
static void BuildRailClick_AutoSignals(Window *w) static void BuildRailClick_AutoSignals(Window *w)
@ -314,12 +314,12 @@ static void BuildRailClick_AutoSignals(Window *w)
static void BuildRailClick_Bridge(Window *w) static void BuildRailClick_Bridge(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge); HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRail_Bridge);
} }
static void BuildRailClick_Tunnel(Window *w) static void BuildRailClick_Tunnel(Window *w)
{ {
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel); HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, VHM_SPECIAL, PlaceRail_Tunnel);
} }
static void BuildRailClick_Remove(Window *w) static void BuildRailClick_Remove(Window *w)
@ -340,7 +340,7 @@ static void BuildRailClick_Remove(Window *w)
static void BuildRailClick_Convert(Window *w) static void BuildRailClick_Convert(Window *w)
{ {
HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail); HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, VHM_RECT, PlaceRail_ConvertRail);
} }

@ -167,27 +167,27 @@ void PlaceProc_LevelLand(TileIndex tile)
static void TerraformClick_Lower(Window *w) static void TerraformClick_Lower(Window *w)
{ {
HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand); HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerLand);
} }
static void TerraformClick_Raise(Window *w) static void TerraformClick_Raise(Window *w)
{ {
HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand); HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseLand);
} }
static void TerraformClick_Level(Window *w) static void TerraformClick_Level(Window *w)
{ {
HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand); HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
} }
static void TerraformClick_Dynamite(Window *w) static void TerraformClick_Dynamite(Window *w)
{ {
HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea); HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , VHM_RECT, PlaceProc_DemolishArea);
} }
static void TerraformClick_BuyLand(Window *w) static void TerraformClick_BuyLand(Window *w)
{ {
HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand); HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, VHM_RECT, PlaceProc_BuyLand);
} }
static void TerraformClick_Trees(Window *w) static void TerraformClick_Trees(Window *w)
@ -198,7 +198,7 @@ static void TerraformClick_Trees(Window *w)
static void TerraformClick_PlaceSign(Window *w) static void TerraformClick_PlaceSign(Window *w)
{ {
HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign); HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, VHM_RECT, PlaceProc_Sign);
} }
static OnButtonClick * const _terraform_button_proc[] = { static OnButtonClick * const _terraform_button_proc[] = {

@ -2799,14 +2799,14 @@ bool VpHandlePlaceSizingDrag()
return false; return false;
} }
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w) void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w)
{ {
SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number); SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number);
} }
#include "table/animcursors.h" #include "table/animcursors.h"
void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num) void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num)
{ {
Window *w; Window *w;
@ -2821,8 +2821,8 @@ void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window
_thd.make_square_red = false; _thd.make_square_red = false;
if (mode == VHM_DRAG) { // mode 4 is for dragdropping trains in the depot window if (mode == VHM_DRAG) { // VHM_DRAG is for dragdropping trains in the depot window
mode = 0; mode = VHM_NONE;
_special_mouse_mode = WSM_DRAGDROP; _special_mouse_mode = WSM_DRAGDROP;
} else { } else {
_special_mouse_mode = WSM_NONE; _special_mouse_mode = WSM_NONE;

@ -87,7 +87,7 @@ enum ViewportPlaceMethod {
}; };
/* viewport highlight mode (for highlighting tiles below cursor) */ /* viewport highlight mode (for highlighting tiles below cursor) */
enum { enum ViewportHighlightMode {
VHM_NONE = 0, ///< default VHM_NONE = 0, ///< default
VHM_RECT = 1, ///< rectangle (stations, depots, ...) VHM_RECT = 1, ///< rectangle (stations, depots, ...)
VHM_POINT = 2, ///< point (lower land, raise land, level land, ...) VHM_POINT = 2, ///< point (lower land, raise land, level land, ...)
@ -156,7 +156,7 @@ struct TileHighlightData {
/* common button handler */ /* common button handler */
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc); bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
VARDEF Point _tile_fract_coords; VARDEF Point _tile_fract_coords;

Loading…
Cancel
Save