mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
This commit is contained in:
parent
9f148789c8
commit
ca5c578d0f
@ -39,7 +39,7 @@ static void PlaceAirport(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceAir_DemolishArea(TileIndex tile)
|
static void PlaceAir_DemolishArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, 4);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_DRAG:
|
case WE_PLACE_DRAG:
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
|
@ -53,12 +53,12 @@ static void PlaceDocks_Buoy(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceDocks_DemolishArea(TileIndex tile)
|
static void PlaceDocks_DemolishArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DemolishArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceDocks_BuildCanal(TileIndex tile)
|
static void PlaceDocks_BuildCanal(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceDocks_BuildLock(TileIndex tile)
|
static void PlaceDocks_BuildLock(TileIndex tile)
|
||||||
@ -147,16 +147,20 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_DRAG: {
|
case WE_PLACE_DRAG: {
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->we.place.pt.x != -1) {
|
if (e->we.place.pt.x != -1) {
|
||||||
if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
switch (e->we.place.select_method) {
|
||||||
GUIPlaceProcDragXY(e);
|
case VPM_X_AND_Y:
|
||||||
} else if (e->we.place.userdata == VPM_X_OR_Y) {
|
GUIPlaceProcDragXY(e);
|
||||||
DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
break;
|
||||||
|
case VPM_X_OR_Y:
|
||||||
|
DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
17
src/gui.h
17
src/gui.h
@ -68,14 +68,15 @@ void PlaceProc_DemolishArea(TileIndex tile);
|
|||||||
void PlaceProc_LevelLand(TileIndex tile);
|
void PlaceProc_LevelLand(TileIndex tile);
|
||||||
bool GUIPlaceProcDragXY(const WindowEvent *e);
|
bool GUIPlaceProcDragXY(const WindowEvent *e);
|
||||||
|
|
||||||
enum { // max 32 - 4 = 28 types
|
enum {
|
||||||
GUI_PlaceProc_DemolishArea = 0 << 4,
|
GUI_PlaceProc_None,
|
||||||
GUI_PlaceProc_LevelArea = 1 << 4,
|
GUI_PlaceProc_DemolishArea,
|
||||||
GUI_PlaceProc_DesertArea = 2 << 4,
|
GUI_PlaceProc_LevelArea,
|
||||||
GUI_PlaceProc_WaterArea = 3 << 4,
|
GUI_PlaceProc_DesertArea,
|
||||||
GUI_PlaceProc_ConvertRailArea = 4 << 4,
|
GUI_PlaceProc_WaterArea,
|
||||||
GUI_PlaceProc_RockyArea = 5 << 4,
|
GUI_PlaceProc_ConvertRailArea,
|
||||||
GUI_PlaceProc_RemoveFromStation = 6 << 4,
|
GUI_PlaceProc_RockyArea,
|
||||||
|
GUI_PlaceProc_RemoveFromStation,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* misc_gui.cpp */
|
/* misc_gui.cpp */
|
||||||
|
@ -1131,7 +1131,7 @@ static void PlaceProc_LowerBigLand(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceProc_RockyArea(TileIndex tile)
|
static void PlaceProc_RockyArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RockyArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_RockyArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceProc_LightHouse(TileIndex tile)
|
static void PlaceProc_LightHouse(TileIndex tile)
|
||||||
@ -1158,12 +1158,12 @@ static void PlaceProc_Transmitter(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceProc_DesertArea(TileIndex tile)
|
static void PlaceProc_DesertArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DesertArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DesertArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceProc_WaterArea(TileIndex tile)
|
static void PlaceProc_WaterArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_WaterArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_WaterArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Widget _scen_edit_land_gen_widgets[] = {
|
static const Widget _scen_edit_land_gen_widgets[] = {
|
||||||
@ -1377,12 +1377,12 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
|
|||||||
_place_proc(e->we.place.tile);
|
_place_proc(e->we.place.tile);
|
||||||
break;
|
break;
|
||||||
case WE_PLACE_DRAG:
|
case WE_PLACE_DRAG:
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->we.place.pt.x != -1) {
|
if (e->we.place.pt.x != -1) {
|
||||||
if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions
|
if (e->we.place.select_method == VPM_X_AND_Y) // dragged actions
|
||||||
GUIPlaceProcDragXY(e);
|
GUIPlaceProcDragXY(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -382,12 +382,12 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WE_PLACE_OBJ:
|
case WE_PLACE_OBJ:
|
||||||
VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED);
|
VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED, GUI_PlaceProc_None);
|
||||||
VpSetPlaceSizingLimit(20);
|
VpSetPlaceSizingLimit(20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_DRAG:
|
case WE_PLACE_DRAG:
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
|
@ -72,7 +72,7 @@ static void PlaceRail_N(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceRail_NE(TileIndex tile)
|
static void PlaceRail_NE(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_FIX_Y);
|
VpStartPlaceSizing(tile, VPM_FIX_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRail_E(TileIndex tile)
|
static void PlaceRail_E(TileIndex tile)
|
||||||
@ -83,12 +83,12 @@ static void PlaceRail_E(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceRail_NW(TileIndex tile)
|
static void PlaceRail_NW(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_FIX_X);
|
VpStartPlaceSizing(tile, VPM_FIX_X, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRail_AutoRail(TileIndex tile)
|
static void PlaceRail_AutoRail(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_RAILDIRS);
|
VpStartPlaceSizing(tile, VPM_RAILDIRS, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
|
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
|
||||||
@ -151,9 +151,9 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||||||
static void PlaceRail_Station(TileIndex tile)
|
static void PlaceRail_Station(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (_remove_button_clicked) {
|
if (_remove_button_clicked) {
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RemoveFromStation);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_RemoveFromStation);
|
||||||
} else if (_railstation.dragdrop) {
|
} else if (_railstation.dragdrop) {
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, GUI_PlaceProc_None);
|
||||||
VpSetPlaceSizingLimit(_patches.station_spread);
|
VpSetPlaceSizingLimit(_patches.station_spread);
|
||||||
} else {
|
} else {
|
||||||
DoCommandP(tile,
|
DoCommandP(tile,
|
||||||
@ -197,7 +197,7 @@ static void GenericPlaceSignals(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceRail_Bridge(TileIndex tile)
|
static void PlaceRail_Bridge(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
@ -223,12 +223,12 @@ void PlaceProc_BuyLand(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceRail_ConvertRail(TileIndex tile)
|
static void PlaceRail_ConvertRail(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_ConvertRailArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRail_AutoSignals(TileIndex tile)
|
static void PlaceRail_AutoSignals(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
|
VpStartPlaceSizing(tile, VPM_SIGNALDIRS, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case WE_PLACE_DRAG: {
|
case WE_PLACE_DRAG: {
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,30 +501,45 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
TileIndex start_tile = e->we.place.starttile;
|
TileIndex start_tile = e->we.place.starttile;
|
||||||
TileIndex end_tile = e->we.place.tile;
|
TileIndex end_tile = e->we.place.tile;
|
||||||
|
|
||||||
if (e->we.place.userdata == VPM_X_OR_Y) {
|
switch (e->we.place.select_method) {
|
||||||
ResetObjectToPlace();
|
case VPM_X_OR_Y:
|
||||||
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
|
ResetObjectToPlace();
|
||||||
} else if (e->we.place.userdata == VPM_RAILDIRS) {
|
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
|
||||||
bool old = _remove_button_clicked;
|
break;
|
||||||
if (_ctrl_pressed) _remove_button_clicked = true;
|
|
||||||
HandleAutodirPlacement();
|
|
||||||
_remove_button_clicked = old;
|
|
||||||
} else if (e->we.place.userdata == VPM_SIGNALDIRS) {
|
|
||||||
HandleAutoSignalPlacement();
|
|
||||||
} else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) {
|
|
||||||
if (GUIPlaceProcDragXY(e)) break;
|
|
||||||
|
|
||||||
if ((e->we.place.userdata >> 4) == GUI_PlaceProc_RemoveFromStation >> 4) {
|
case VPM_RAILDIRS: {
|
||||||
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
|
bool old = _remove_button_clicked;
|
||||||
|
if (_ctrl_pressed) _remove_button_clicked = true;
|
||||||
|
HandleAutodirPlacement();
|
||||||
|
_remove_button_clicked = old;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) {
|
case VPM_SIGNALDIRS:
|
||||||
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
|
HandleAutoSignalPlacement();
|
||||||
}
|
break;
|
||||||
} else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) {
|
|
||||||
HandleStationPlacement(start_tile, end_tile);
|
case VPM_X_AND_Y:
|
||||||
} else {
|
if (GUIPlaceProcDragXY(e)) break;
|
||||||
DoRailroadTrack(e->we.place.userdata & 1);
|
|
||||||
|
switch (e->we.place.select_proc) {
|
||||||
|
case GUI_PlaceProc_RemoveFromStation:
|
||||||
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PlaceProc_ConvertRailArea:
|
||||||
|
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VPM_X_AND_Y_LIMITED:
|
||||||
|
HandleStationPlacement(start_tile, end_tile);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DoRailroadTrack(e->we.place.select_method == VPM_FIX_Y ? TRACK_X : TRACK_Y);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -45,18 +45,18 @@ void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||||||
static void PlaceRoad_NE(TileIndex tile)
|
static void PlaceRoad_NE(TileIndex tile)
|
||||||
{
|
{
|
||||||
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
|
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
|
||||||
VpStartPlaceSizing(tile, VPM_FIX_X);
|
VpStartPlaceSizing(tile, VPM_FIX_X, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRoad_NW(TileIndex tile)
|
static void PlaceRoad_NW(TileIndex tile)
|
||||||
{
|
{
|
||||||
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
|
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
|
||||||
VpStartPlaceSizing(tile, VPM_FIX_Y);
|
VpStartPlaceSizing(tile, VPM_FIX_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRoad_Bridge(TileIndex tile)
|
static void PlaceRoad_Bridge(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ static void PlaceRoad_TruckStation(TileIndex tile)
|
|||||||
|
|
||||||
static void PlaceRoad_DemolishArea(TileIndex tile)
|
static void PlaceRoad_DemolishArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, 4);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -270,47 +270,41 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
if (w != NULL) WP(w, def_d).close = true;
|
if (w != NULL) WP(w, def_d).close = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_DRAG: {
|
case WE_PLACE_DRAG:
|
||||||
int sel_method;
|
switch (e->we.place.select_method) {
|
||||||
switch (e->we.place.userdata) {
|
case VPM_FIX_X:
|
||||||
case 1:
|
|
||||||
sel_method = VPM_FIX_X;
|
|
||||||
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2);
|
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case VPM_FIX_Y:
|
||||||
sel_method = VPM_FIX_Y;
|
|
||||||
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2);
|
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
|
||||||
sel_method = VPM_X_AND_Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sel_method = VPM_X_OR_Y;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, sel_method);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->we.place.pt.x != -1) {
|
if (e->we.place.pt.x != -1) {
|
||||||
TileIndex start_tile = e->we.place.starttile;
|
TileIndex start_tile = e->we.place.starttile;
|
||||||
TileIndex end_tile = e->we.place.tile;
|
TileIndex end_tile = e->we.place.tile;
|
||||||
|
|
||||||
if (e->we.place.userdata == 0) {
|
switch (e->we.place.select_method) {
|
||||||
ResetObjectToPlace();
|
case VPM_X_OR_Y:
|
||||||
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
|
ResetObjectToPlace();
|
||||||
} else if (e->we.place.userdata != 4) {
|
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
|
||||||
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
|
break;
|
||||||
_remove_button_clicked ?
|
|
||||||
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
|
case VPM_X_AND_Y:
|
||||||
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
||||||
} else {
|
break;
|
||||||
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
|
||||||
|
default:
|
||||||
|
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
|
||||||
|
_remove_button_clicked ?
|
||||||
|
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
|
||||||
|
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -104,23 +104,24 @@ bool GUIPlaceProcDragXY(const WindowEvent *e)
|
|||||||
TileIndex start_tile = e->we.place.starttile;
|
TileIndex start_tile = e->we.place.starttile;
|
||||||
TileIndex end_tile = e->we.place.tile;
|
TileIndex end_tile = e->we.place.tile;
|
||||||
|
|
||||||
switch (e->we.place.userdata >> 4) {
|
switch (e->we.place.select_proc) {
|
||||||
case GUI_PlaceProc_DemolishArea >> 4:
|
case GUI_PlaceProc_DemolishArea:
|
||||||
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
||||||
break;
|
break;
|
||||||
case GUI_PlaceProc_LevelArea >> 4:
|
case GUI_PlaceProc_LevelArea:
|
||||||
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
|
||||||
break;
|
break;
|
||||||
case GUI_PlaceProc_RockyArea >> 4:
|
case GUI_PlaceProc_RockyArea:
|
||||||
GenerateRockyArea(end_tile, start_tile);
|
GenerateRockyArea(end_tile, start_tile);
|
||||||
break;
|
break;
|
||||||
case GUI_PlaceProc_DesertArea >> 4:
|
case GUI_PlaceProc_DesertArea:
|
||||||
GenerateDesertArea(end_tile, start_tile);
|
GenerateDesertArea(end_tile, start_tile);
|
||||||
break;
|
break;
|
||||||
case GUI_PlaceProc_WaterArea >> 4:
|
case GUI_PlaceProc_WaterArea:
|
||||||
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
||||||
break;
|
break;
|
||||||
default: return false;
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -140,7 +141,7 @@ static const uint16 _terraform_keycodes[] = {
|
|||||||
|
|
||||||
void PlaceProc_DemolishArea(TileIndex tile)
|
void PlaceProc_DemolishArea(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DemolishArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceProc_RaiseLand(TileIndex tile)
|
static void PlaceProc_RaiseLand(TileIndex tile)
|
||||||
@ -161,7 +162,7 @@ static void PlaceProc_LowerLand(TileIndex tile)
|
|||||||
|
|
||||||
void PlaceProc_LevelLand(TileIndex tile)
|
void PlaceProc_LevelLand(TileIndex tile)
|
||||||
{
|
{
|
||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_LevelArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TerraformClick_Lower(Window *w)
|
static void TerraformClick_Lower(Window *w)
|
||||||
@ -239,12 +240,11 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case WE_PLACE_DRAG:
|
case WE_PLACE_DRAG:
|
||||||
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->we.place.pt.x != -1 &&
|
if (e->we.place.pt.x != -1 && e->we.place.select_method == VPM_X_AND_Y) {
|
||||||
(e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
|
||||||
GUIPlaceProcDragXY(e);
|
GUIPlaceProcDragXY(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1985,9 +1985,10 @@ void UpdateTileSelection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** highlighting tiles while only going over them with the mouse */
|
/** highlighting tiles while only going over them with the mouse */
|
||||||
void VpStartPlaceSizing(TileIndex tile, int user)
|
void VpStartPlaceSizing(TileIndex tile, byte method, byte process)
|
||||||
{
|
{
|
||||||
_thd.userdata = user;
|
_thd.select_method = method;
|
||||||
|
_thd.select_proc = process;
|
||||||
_thd.selend.x = TileX(tile) * TILE_SIZE;
|
_thd.selend.x = TileX(tile) * TILE_SIZE;
|
||||||
_thd.selstart.x = TileX(tile) * TILE_SIZE;
|
_thd.selstart.x = TileX(tile) * TILE_SIZE;
|
||||||
_thd.selend.y = TileY(tile) * TILE_SIZE;
|
_thd.selend.y = TileY(tile) * TILE_SIZE;
|
||||||
@ -2445,7 +2446,8 @@ bool VpHandlePlaceSizingDrag()
|
|||||||
|
|
||||||
if (_special_mouse_mode != WSM_SIZING) return true;
|
if (_special_mouse_mode != WSM_SIZING) return true;
|
||||||
|
|
||||||
e.we.place.userdata = _thd.userdata;
|
e.we.place.select_method = _thd.select_method;
|
||||||
|
e.we.place.select_proc = _thd.select_proc;
|
||||||
|
|
||||||
/* stop drag mode if the window has been closed */
|
/* stop drag mode if the window has been closed */
|
||||||
w = FindWindowById(_thd.window_class, _thd.window_number);
|
w = FindWindowById(_thd.window_class, _thd.window_number);
|
||||||
@ -2467,7 +2469,7 @@ bool VpHandlePlaceSizingDrag()
|
|||||||
_special_mouse_mode = WSM_NONE;
|
_special_mouse_mode = WSM_NONE;
|
||||||
if (_thd.next_drawstyle == HT_RECT) {
|
if (_thd.next_drawstyle == HT_RECT) {
|
||||||
_thd.place_mode = VHM_RECT;
|
_thd.place_mode = VHM_RECT;
|
||||||
} else if ((e.we.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
|
} else if (e.we.place.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
|
||||||
_thd.place_mode = VHM_RECT;
|
_thd.place_mode = VHM_RECT;
|
||||||
} else if (_thd.next_drawstyle & HT_LINE) {
|
} else if (_thd.next_drawstyle & HT_LINE) {
|
||||||
_thd.place_mode = VHM_RAIL;
|
_thd.place_mode = VHM_RAIL;
|
||||||
|
@ -62,7 +62,7 @@ void SetRedErrorSquare(TileIndex tile);
|
|||||||
void SetTileSelectSize(int w, int h);
|
void SetTileSelectSize(int w, int h);
|
||||||
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
|
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
|
||||||
|
|
||||||
void VpStartPlaceSizing(TileIndex tile, int user);
|
void VpStartPlaceSizing(TileIndex tile, byte method, byte process);
|
||||||
void VpSetPresizeRange(uint from, uint to);
|
void VpSetPresizeRange(uint from, uint to);
|
||||||
void VpSetPlaceSizingLimit(int limit);
|
void VpSetPlaceSizingLimit(int limit);
|
||||||
|
|
||||||
@ -137,7 +137,9 @@ struct TileHighlightData {
|
|||||||
WindowClass window_class;
|
WindowClass window_class;
|
||||||
WindowNumber window_number;
|
WindowNumber window_number;
|
||||||
|
|
||||||
int userdata;
|
byte select_method;
|
||||||
|
byte select_proc;
|
||||||
|
|
||||||
TileIndex redsq;
|
TileIndex redsq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,8 @@ struct WindowEvent {
|
|||||||
Point pt;
|
Point pt;
|
||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
TileIndex starttile;
|
TileIndex starttile;
|
||||||
int userdata;
|
byte select_method;
|
||||||
|
byte select_proc;
|
||||||
} place;
|
} place;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user