Merge remote-tracking branch 'upstream/master' into 13.0

This commit is contained in:
Pavel Stupnikov
2022-11-26 22:16:25 +04:00
508 changed files with 14617 additions and 9750 deletions

View File

@@ -24,6 +24,9 @@
#include "window_gui.h"
#include "window_func.h"
#include "zoom_func.h"
#include "terraform_cmd.h"
#include "object_cmd.h"
#include "road_cmd.h"
#include "widgets/object_widget.h"
@@ -455,7 +458,7 @@ public:
}
if (_selected_object_index != -1) {
SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT, this, CM_DDSP_PLACE_OBJECT);
SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT | HT_DIAGONAL, this, CM_DDSP_PLACE_OBJECT);
}
this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view);
@@ -540,9 +543,38 @@ public:
void OnPlaceObject(Point pt, TileIndex tile) override
{
ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
DoCommandP(tile, objclass->GetSpec(_selected_object_index)->Index(),
_selected_object_view, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform);
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
if (spec->size == OBJECT_SIZE_1X1) {
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUILD_OBJECT);
} else {
Command<CMD_BUILD_OBJECT>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), _selected_object_view);
}
}
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x == -1) return;
switch (select_proc) {
default: NOT_REACHED();
case DDSP_BUILD_OBJECT:
if (!_settings_game.construction.freeform_edges) {
/* When end_tile is MP_VOID, the error tile will not be visible to the
* user. This happens when terraforming at the southern border. */
if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0);
if (TileY(end_tile) == MapMaxY()) end_tile += TileDiffXY(0, -1);
}
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
break;
}
}
void OnPlaceObjectAbort() override
@@ -656,7 +688,9 @@ static const NWidgetPart _nested_build_object_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 2),