Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/crashlog.cpp # src/fileio.cpp # src/fileio_func.h # src/fios_gui.cpp # src/ini_load.cpp # src/ini_type.h # src/lang/english.txt # src/lang/german.txt # src/lang/korean.txt # src/network/network_client.cpp # src/order_base.h # src/order_cmd.cpp # src/os/windows/win32.cpp # src/road_cmd.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/settings.cpp # src/station_cmd.cpp # src/stdafx.h # src/table/settings.ini # src/tree_cmd.cpp # src/tree_gui.cpp # src/vehicle_base.h # src/video/cocoa/cocoa_v.mm # src/video/cocoa/event.mm # src/video/cocoa/wnd_quartz.mm # src/viewport.cpp # src/widgets/tree_widget.h
This commit is contained in:
@@ -2175,9 +2175,8 @@ static inline Vehicle *GetVehicleFromWindow(Window *w)
|
||||
|
||||
static inline TileIndex GetLastValidOrderLocation(const Vehicle *veh)
|
||||
{
|
||||
Order *order;
|
||||
TileIndex tmp, result = INVALID_TILE;
|
||||
FOR_VEHICLE_ORDERS(veh, order) {
|
||||
for(const Order *order : veh->Orders()) {
|
||||
switch (order->GetType()) {
|
||||
case OT_GOTO_STATION:
|
||||
case OT_GOTO_WAYPOINT:
|
||||
@@ -2193,7 +2192,7 @@ static inline TileIndex GetLastValidOrderLocation(const Vehicle *veh)
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Order *GetFinalOrder(const Vehicle *veh, Order *order)
|
||||
static inline const Order *GetFinalOrder(const Vehicle *veh, const Order *order)
|
||||
{
|
||||
// Use Floyd's cycle-finding algorithm to prevent endless loop
|
||||
// due to a cycle formed by confitional orders.
|
||||
@@ -2226,9 +2225,8 @@ static bool ViewportMapPrepareVehicleRoute(const Vehicle * const veh)
|
||||
TileIndex from_tile = GetLastValidOrderLocation(veh);
|
||||
if (from_tile == INVALID_TILE) return false;
|
||||
|
||||
Order *order;
|
||||
FOR_VEHICLE_ORDERS(veh, order) {
|
||||
Order *final_order = GetFinalOrder(veh, order);
|
||||
for(const Order *order : veh->Orders()) {
|
||||
const Order *final_order = GetFinalOrder(veh, order);
|
||||
if (final_order == nullptr) continue;
|
||||
const TileIndex to_tile = final_order->GetLocation(veh, veh->type == VEH_AIRCRAFT);
|
||||
if (to_tile == INVALID_TILE) continue;
|
||||
@@ -2363,9 +2361,8 @@ static bool ViewportPrepareVehicleRouteSteps(const Vehicle * const veh)
|
||||
|
||||
if (_vp_route_steps.size() == 0) {
|
||||
/* Prepare data. */
|
||||
Order *order;
|
||||
int order_rank = 0;
|
||||
FOR_VEHICLE_ORDERS(veh, order) {
|
||||
for(const Order *order : veh->Orders()) {
|
||||
const TileIndex tile = order->GetLocation(veh, veh->type == VEH_AIRCRAFT);
|
||||
order_rank++;
|
||||
if (tile == INVALID_TILE) continue;
|
||||
@@ -4658,6 +4655,18 @@ void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDrag
|
||||
_special_mouse_mode = WSM_SIZING;
|
||||
}
|
||||
|
||||
/** Drag over the map while holding the left mouse down. */
|
||||
void VpStartDragging(ViewportDragDropSelectionProcess process)
|
||||
{
|
||||
_thd.select_method = VPM_X_AND_Y;
|
||||
_thd.select_proc = process;
|
||||
_thd.selstart.x = 0;
|
||||
_thd.selstart.y = 0;
|
||||
_thd.next_drawstyle = HT_RECT;
|
||||
|
||||
_special_mouse_mode = WSM_DRAGGING;
|
||||
}
|
||||
|
||||
void VpSetPlaceSizingLimit(int limit)
|
||||
{
|
||||
_thd.sizelimit = limit;
|
||||
@@ -5537,7 +5546,7 @@ calc_heightdiff_single_direction:;
|
||||
*/
|
||||
EventState VpHandlePlaceSizingDrag()
|
||||
{
|
||||
if (_special_mouse_mode != WSM_SIZING) return ES_NOT_HANDLED;
|
||||
if (_special_mouse_mode != WSM_SIZING && _special_mouse_mode != WSM_DRAGGING) return ES_NOT_HANDLED;
|
||||
|
||||
/* stop drag mode if the window has been closed */
|
||||
Window *w = _thd.GetCallbackWnd();
|
||||
@@ -5546,14 +5555,23 @@ EventState VpHandlePlaceSizingDrag()
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
if (_left_button_down && _special_mouse_mode == WSM_DRAGGING) {
|
||||
/* Only register a drag event when the mouse moved. */
|
||||
if (_thd.new_pos.x == _thd.selstart.x && _thd.new_pos.y == _thd.selstart.y) return ES_HANDLED;
|
||||
_thd.selstart.x = _thd.new_pos.x;
|
||||
_thd.selstart.y = _thd.new_pos.y;
|
||||
}
|
||||
|
||||
/* While dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ).
|
||||
* Do it even if the button is no longer pressed to make sure that OnPlaceDrag was called at least once. */
|
||||
w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor());
|
||||
if (_left_button_down) return ES_HANDLED;
|
||||
|
||||
/* mouse button released..
|
||||
* keep the selected tool, but reset it to the original mode. */
|
||||
/* Mouse button released. */
|
||||
_special_mouse_mode = WSM_NONE;
|
||||
if (_special_mouse_mode == WSM_DRAGGING) return ES_HANDLED;
|
||||
|
||||
/* Keep the selected tool, but reset it to the original mode. */
|
||||
HighLightStyle others = _thd.place_mode & ~(HT_DRAG_MASK | HT_DIR_MASK);
|
||||
if ((_thd.next_drawstyle & HT_DRAG_MASK) == HT_RECT) {
|
||||
_thd.place_mode = HT_RECT | others;
|
||||
|
Reference in New Issue
Block a user