From 633b8f067137207624fa54d72c01569b86ee77e6 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Wed, 31 Dec 2014 02:44:08 +0000 Subject: [PATCH 04/14] Change CoasterBuildModes --- src/coaster_build.h | 16 +++++----------- src/coaster_gui.cpp | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/coaster_build.h b/src/coaster_build.h index 0c44308..251ce6f 100644 --- a/src/coaster_build.h +++ b/src/coaster_build.h @@ -64,9 +64,7 @@ public: TileEdge direction; ///< Orientation of the build cursor. uint8 mouse_state; ///< Stored state of the mouse buttons. Point16 mouse_pos; ///< Stored mouse position. - uint16 track_xpos; ///< Entry X position of the selected track piece. - uint16 track_ypos; ///< Entry Y position of the selected track piece. - uint8 track_zpos; ///< Entry Z position of the selected track piece. + XYZPoint16 track_pos; ///< Entry position of the selected track piece. bool suppress_display; ///< Suppress display of a track piece. bool use_mousepos; ///< Use mouse position to derive the position of the track piece. @@ -110,18 +108,14 @@ public: /** * Denote to the mouse mode handler to display a track piece at the given position. - * @param piece Selected track piece to attach. - * @param x X position of the piece. - * @param y Y position of the piece. - * @param z Z position of the piece. + * @aram piece Selected track piece to attach. + * @param vox Position of the piece. * @param direction Direction of building (to use with a cursor). */ - void SetFixedPiece(ConstTrackPiecePtr piece, int x, int y, int z, TileEdge direction) + void SetFixedPiece(ConstTrackPiecePtr piece, const XYZPoint16 &vox, TileEdge direction) { this->cur_piece = piece; - this->track_xpos = x; - this->track_ypos = y; - this->track_zpos = z; + this->track_pos = vox; this->direction = direction; this->use_mousepos = false; } diff --git a/src/coaster_gui.cpp b/src/coaster_gui.cpp index e092e69..9c9f4f0 100644 --- a/src/coaster_gui.cpp +++ b/src/coaster_gui.cpp @@ -586,8 +586,7 @@ void CoasterBuildWindow::SetupSelection() int CoasterBuildWindow::BuildTrackPiece() { if (this->sel_piece == nullptr) return -1; - PositionedTrackPiece ptp(XYZPoint16(_coaster_builder.track_xpos, _coaster_builder.track_ypos, _coaster_builder.track_zpos), - this->sel_piece); + PositionedTrackPiece ptp(_coaster_builder.track_pos, this->sel_piece); if (!ptp.CanBePlaced()) return -1; /* Add the piece to the coaster instance. */ @@ -862,7 +861,7 @@ public: void DisplayPiece(uint16 instance, ConstTrackPiecePtr piece, const XYZPoint16 &vox, TileEdge direction) const override { if (this->mode->instance != instance) return; - this->mode->SetFixedPiece(piece, vox.x, vox.y, vox.z, direction); + this->mode->SetFixedPiece(piece, vox, direction); } }; @@ -939,7 +938,7 @@ public: void DisplayPiece(uint16 instance, ConstTrackPiecePtr piece, const XYZPoint16 &vox, TileEdge direction) const override { if (this->mode->instance != instance) return; - this->mode->SetFixedPiece(piece, vox.x, vox.y, vox.z, direction); + this->mode->SetFixedPiece(piece, vox, direction); this->mode->UpdateDisplay(false); this->mode->SetState(BS_FIXED); } @@ -988,7 +987,7 @@ public: void OnMouseButtonEvent(Viewport *vp, uint8 state) const override { - PositionedTrackPiece ptp(XYZPoint16(this->mode->track_xpos, this->mode->track_ypos, this->mode->track_zpos), this->mode->cur_piece); + PositionedTrackPiece ptp(this->mode->track_pos, this->mode->cur_piece); if (ptp.CanBePlaced()) { this->mode->SetNoPiece(); this->mode->UpdateDisplay(false); @@ -1027,7 +1026,7 @@ public: void DisplayPiece(uint16 instance, ConstTrackPiecePtr piece, const XYZPoint16 &vox, TileEdge direction) const override { if (this->mode->instance != instance) return; - this->mode->SetFixedPiece(piece, vox.x, vox.y, vox.z, direction); + this->mode->SetFixedPiece(piece, vox, direction); this->mode->UpdateDisplay(false); this->mode->SetState(BS_FIXED); } @@ -1105,7 +1104,7 @@ public: void DisplayPiece(uint16 instance, ConstTrackPiecePtr piece, const XYZPoint16 &vox, TileEdge direction) const override { if (this->mode->instance != instance) return; - this->mode->SetFixedPiece(piece, vox.x, vox.y, vox.z, direction); + this->mode->SetFixedPiece(piece, vox, direction); this->mode->UpdateDisplay(false); } }; @@ -1339,18 +1338,16 @@ void CoasterBuildMode::UpdateDisplay(bool mousepos_changed) return; } /* Found ground, is the position the same? */ - if (mousepos_changed && fdata.voxel_pos.x == this->track_xpos && fdata.voxel_pos.y == this->track_ypos && fdata.voxel_pos.z == this->track_zpos) { + if (mousepos_changed && fdata.voxel_pos == this->track_pos) { return; } - this->track_xpos = fdata.voxel_pos.x; - this->track_ypos = fdata.voxel_pos.y; - this->track_zpos = fdata.voxel_pos.z; + this->track_pos = fdata.voxel_pos; } _additions.Clear(); EnableWorldAdditions(); - PositionedTrackPiece ptp(XYZPoint16(this->track_xpos, this->track_ypos, this->track_zpos), this->cur_piece); + PositionedTrackPiece ptp(this->track_pos, this->cur_piece); CoasterInstance *ci = static_cast(_rides_manager.GetRideInstance(this->instance)); if (ptp.CanBePlaced()) ci->PlaceTrackPieceInAdditions(ptp); - vp->arrow_cursor.SetCursor(XYZPoint16(this->track_xpos, this->track_ypos, this->track_zpos), (CursorType)(CUR_TYPE_ARROW_NE + this->direction)); + vp->arrow_cursor.SetCursor(this->track_pos, (CursorType)(CUR_TYPE_ARROW_NE + this->direction)); } -- 2.2.1