Merge remote-tracking branch 'origin/master' into HEAD
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
#include "command_func.h"
|
||||
#include "network/network_func.h"
|
||||
#include "framerate_type.h"
|
||||
#include "build_confirmation_func.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -1799,7 +1800,7 @@ void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_heigh
|
||||
*
|
||||
* @ingroup dirty
|
||||
*/
|
||||
static void SetSelectionTilesDirty()
|
||||
void SetSelectionTilesDirty()
|
||||
{
|
||||
int x_size = _thd.size.x;
|
||||
int y_size = _thd.size.y;
|
||||
@@ -2015,6 +2016,8 @@ static void PlaceObject()
|
||||
Point pt;
|
||||
Window *w;
|
||||
|
||||
if (BuildConfirmationWindowProcessViewportClick()) return;
|
||||
|
||||
pt = GetTileBelowCursor();
|
||||
if (pt.x == -1) return;
|
||||
|
||||
@@ -2033,6 +2036,22 @@ static void PlaceObject()
|
||||
|
||||
bool HandleViewportClicked(const ViewPort *vp, int x, int y)
|
||||
{
|
||||
if (_move_pressed) return false;
|
||||
|
||||
// Allow scrolling viewport with mouse even in selection mode,
|
||||
// unless we select line or area, or perform drag&drop
|
||||
if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE && !(_thd.place_mode & HT_SCROLL_VIEWPORT)) {
|
||||
PlaceObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HandleViewportMouseUp(const ViewPort *vp, int x, int y)
|
||||
{
|
||||
if (_move_pressed) return false;
|
||||
|
||||
const Vehicle *v = CheckClickOnVehicle(vp, x, y);
|
||||
|
||||
if (_thd.place_mode & HT_VEHICLE) {
|
||||
@@ -2285,8 +2304,10 @@ void UpdateTileSelection()
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
_thd.selstart.x = x1 & ~TILE_UNIT_MASK;
|
||||
_thd.selstart.y = y1 & ~TILE_UNIT_MASK;
|
||||
if (!ConfirmationWindowShown()) {
|
||||
_thd.selstart.x = x1 & ~TILE_UNIT_MASK;
|
||||
_thd.selstart.y = y1 & ~TILE_UNIT_MASK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NOT_REACHED();
|
||||
@@ -2296,6 +2317,8 @@ void UpdateTileSelection()
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfirmationWindowShown()) return;
|
||||
|
||||
/* redraw selection */
|
||||
if (_thd.drawstyle != new_drawstyle ||
|
||||
_thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y ||
|
||||
@@ -2357,7 +2380,9 @@ void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDrag
|
||||
}
|
||||
|
||||
HighLightStyle others = _thd.place_mode & ~(HT_DRAG_MASK | HT_DIR_MASK);
|
||||
if ((_thd.place_mode & HT_DRAG_MASK) == HT_RECT) {
|
||||
if (method == VPM_SINGLE_TILE) {
|
||||
/* Nothing to do. */
|
||||
} else if ((_thd.place_mode & HT_DRAG_MASK) == HT_RECT) {
|
||||
_thd.place_mode = HT_SPECIAL | others;
|
||||
_thd.next_drawstyle = HT_RECT | others;
|
||||
} else if (_thd.place_mode & (HT_RAIL | HT_LINE)) {
|
||||
@@ -2398,7 +2423,7 @@ void VpSetPresizeRange(TileIndex from, TileIndex to)
|
||||
}
|
||||
}
|
||||
|
||||
static void VpStartPreSizing()
|
||||
void VpStartPreSizing()
|
||||
{
|
||||
_thd.selend.x = -1;
|
||||
_special_mouse_mode = WSM_PRESIZE;
|
||||
@@ -2840,6 +2865,11 @@ void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
|
||||
int limit = 0;
|
||||
|
||||
switch (method) {
|
||||
case VPM_SINGLE_TILE:
|
||||
_thd.selstart.x = x;
|
||||
_thd.selstart.y = y;
|
||||
break;
|
||||
|
||||
case VPM_X_OR_Y: // drag in X or Y direction
|
||||
if (abs(sy - y) < abs(sx - x)) {
|
||||
y = sy;
|
||||
@@ -2990,15 +3020,20 @@ EventState VpHandlePlaceSizingDrag()
|
||||
|
||||
/* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */
|
||||
if (_left_button_down) {
|
||||
HideBuildConfirmationWindow();
|
||||
w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor());
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
ShowBuildConfirmationWindow(); // This will also remember tile selection, so it's okay for the code below to change selection
|
||||
|
||||
/* mouse button released..
|
||||
* keep the selected tool, but reset it to the original mode. */
|
||||
_special_mouse_mode = WSM_NONE;
|
||||
HighLightStyle others = _thd.place_mode & ~(HT_DRAG_MASK | HT_DIR_MASK);
|
||||
if ((_thd.next_drawstyle & HT_DRAG_MASK) == HT_RECT) {
|
||||
if (_thd.select_method == VPM_SINGLE_TILE) {
|
||||
goto place_mouseup;
|
||||
} else if ((_thd.next_drawstyle & HT_DRAG_MASK) == HT_RECT) {
|
||||
_thd.place_mode = HT_RECT | others;
|
||||
} else if (_thd.select_method & VPM_SIGNALDIRS) {
|
||||
_thd.place_mode = HT_RECT | others;
|
||||
@@ -3009,9 +3044,7 @@ EventState VpHandlePlaceSizingDrag()
|
||||
}
|
||||
SetTileSelectSize(1, 1);
|
||||
|
||||
HideMeasurementTooltips();
|
||||
w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y));
|
||||
|
||||
place_mouseup:
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
@@ -3029,6 +3062,24 @@ void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Wind
|
||||
|
||||
#include "table/animcursors.h"
|
||||
|
||||
static WindowClass _last_selected_window_class;
|
||||
static WindowNumber _last_selected_window_number;
|
||||
|
||||
/** Place object from the build confirmation dialog */
|
||||
void ConfirmPlacingObject()
|
||||
{
|
||||
Window *w = _thd.GetCallbackWnd();
|
||||
if (w == NULL) {
|
||||
ResetObjectToPlace();
|
||||
return;
|
||||
}
|
||||
|
||||
_last_selected_window_class = _thd.window_class;
|
||||
_last_selected_window_number = _thd.window_number;
|
||||
HideMeasurementTooltips();
|
||||
w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc.
|
||||
* @param icon New shape of the mouse cursor.
|
||||
@@ -3087,7 +3138,20 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
|
||||
/** Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows). */
|
||||
void ResetObjectToPlace()
|
||||
{
|
||||
if (_thd.window_class != WC_INVALID) {
|
||||
_last_selected_window_class = _thd.window_class;
|
||||
_last_selected_window_number = _thd.window_number;
|
||||
}
|
||||
SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
|
||||
HideBuildConfirmationWindow();
|
||||
MoveAllHiddenWindowsBackToScreen();
|
||||
}
|
||||
|
||||
void ToolbarSelectLastTool()
|
||||
{
|
||||
Window *w = FindWindowById(_last_selected_window_class, _last_selected_window_number);
|
||||
if (w != NULL) w->SelectLastTool();
|
||||
_last_selected_window_class = WC_INVALID;
|
||||
}
|
||||
|
||||
Point GetViewportStationMiddle(const ViewPort *vp, const Station *st)
|
||||
|
||||
Reference in New Issue
Block a user