forked from rosebudai/OpenRCT2-Web
Add buttons to make a ride invisible/visible
This commit is contained in:
8 files changed
+154
-9
No files matched your search
@@ -3849,3 +3849,7 @@ STR_7019 :{SPRITE}{MOVE_X}{27}{STRINGID}
|
||||
STR_7020 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}{MOVE_X}{36}{STRINGID}
|
||||
STR_7021 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}»{MOVE_X}{36}{STRINGID}
|
||||
STR_7022 :{STRING} - -
|
||||
STR_7023 :Make invisible
|
||||
STR_7024 :Makes the whole ride invisible
|
||||
STR_7025 :Make visible
|
||||
STR_7026 :Makes the whole ride visible
|
||||
@@ -1481,6 +1481,10 @@ namespace OpenRCT2
|
||||
STR_LOSS_PER_ITEM_SOLD = 1857,
|
||||
STR_MAINTENANCE_OPTIONS_TIP = 1395,
|
||||
STR_MAIN_COLOUR_SCHEME = 2971,
|
||||
STR_MAKE_INVISIBLE = 7023,
|
||||
STR_MAKE_INVISIBLE_TIP = 7024,
|
||||
STR_MAKE_VISIBLE = 7025,
|
||||
STR_MAKE_VISIBLE_TIP = 7026,
|
||||
STR_MAXIMUM_LENGTH_BEFORE_DEPARTING_TIP = 1214,
|
||||
STR_MAXIMUM_WAITING_TIME = 1212,
|
||||
STR_MAX_CARS_PER_TRAIN_TIP = 5923,
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <openrct2/actions/RideSetPriceAction.h>
|
||||
#include <openrct2/actions/RideSetSettingAction.h>
|
||||
#include <openrct2/actions/RideSetStatusAction.h>
|
||||
#include <openrct2/actions/RideSetVisibilityAction.h>
|
||||
#include <openrct2/audio/Audio.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
@@ -137,6 +138,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
WIDX_OPEN_LIGHT,
|
||||
WIDX_RIDE_TYPE,
|
||||
WIDX_RIDE_TYPE_DROPDOWN,
|
||||
WIDX_MAKE_INVISIBLE,
|
||||
WIDX_MAKE_VISIBLE,
|
||||
|
||||
WIDX_VEHICLE_TYPE = 14,
|
||||
WIDX_VEHICLE_TYPE_DROPDOWN,
|
||||
@@ -277,7 +280,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
makeWidget({296, 62}, { 14, 14}, WidgetType::imgBtn, WindowColour::secondary, ImageId(SPR_G2_RCT1_TEST_BUTTON_0), STR_TEST_RIDE_TIP ),
|
||||
makeWidget({296, 76}, { 14, 14}, WidgetType::imgBtn, WindowColour::secondary, ImageId(SPR_G2_RCT1_OPEN_BUTTON_0), STR_OPEN_RIDE_TIP ),
|
||||
makeWidget({ 3, 180}, {305, 12}, WidgetType::dropdownMenu, WindowColour::secondary, STR_ARG_6_STRINGID ),
|
||||
makeWidget({297, 180}, { 11, 12}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH )
|
||||
makeWidget({297, 180}, { 11, 12}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH ),
|
||||
makeWidget({ 3, 195}, {140, 12}, WidgetType::button, WindowColour::secondary, STR_MAKE_INVISIBLE, STR_MAKE_INVISIBLE_TIP ),
|
||||
makeWidget({151, 195}, {140, 12}, WidgetType::button, WindowColour::secondary, STR_MAKE_VISIBLE, STR_MAKE_VISIBLE_TIP )
|
||||
);
|
||||
|
||||
// 0x009ADDA8
|
||||
@@ -1680,6 +1685,19 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WIDX_MAKE_INVISIBLE:
|
||||
{
|
||||
auto gameAction = GameActions::RideSetVisibilityAction(
|
||||
rideId, GameActions::RideSetVisibilityType::invisible);
|
||||
GameActions::Execute(&gameAction, getGameState());
|
||||
break;
|
||||
}
|
||||
case WIDX_MAKE_VISIBLE:
|
||||
{
|
||||
auto gameAction = GameActions::RideSetVisibilityAction(rideId, GameActions::RideSetVisibilityType::visible);
|
||||
GameActions::Execute(&gameAction, getGameState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1707,7 +1725,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
if (getGameState().cheats.allowArbitraryRideTypeChanges)
|
||||
{
|
||||
newMinHeight += 15;
|
||||
newMinHeight += 30;
|
||||
}
|
||||
|
||||
flags |= WindowFlag::resizable;
|
||||
@@ -2355,7 +2373,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
+ widgetIsPressed(*this, WIDX_OPEN_LIGHT);
|
||||
widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage);
|
||||
|
||||
const int32_t offset = gameState.cheats.allowArbitraryRideTypeChanges ? 15 : 0;
|
||||
const int32_t offset = gameState.cheats.allowArbitraryRideTypeChanges ? 30 : 0;
|
||||
// Anchor main page specific widgets
|
||||
widgets[WIDX_VIEWPORT].right = width - 26;
|
||||
widgets[WIDX_VIEWPORT].bottom = height - (14 + offset);
|
||||
@@ -2366,23 +2384,25 @@ namespace OpenRCT2::Ui::Windows
|
||||
widgets[WIDX_VIEW_DROPDOWN].right = width - 61;
|
||||
widgets[WIDX_VIEW_DROPDOWN].left = width - 71;
|
||||
widgets[WIDX_RIDE_TYPE].right = width - 26;
|
||||
widgets[WIDX_RIDE_TYPE].top = height - 17;
|
||||
widgets[WIDX_RIDE_TYPE].bottom = height - 4;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].left = width - 37;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].right = width - 27;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].top = height - 16;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].bottom = height - 5;
|
||||
widgets[WIDX_RIDE_TYPE].moveToY(height - 32);
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].moveTo({ width - 37, height - 31 });
|
||||
widgets[WIDX_MAKE_INVISIBLE].moveToY(height - 17);
|
||||
widgets[WIDX_MAKE_VISIBLE].moveToY(height - 17);
|
||||
|
||||
if (!gameState.cheats.allowArbitraryRideTypeChanges)
|
||||
{
|
||||
widgets[WIDX_RIDE_TYPE].type = WidgetType::empty;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].type = WidgetType::empty;
|
||||
widgets[WIDX_MAKE_INVISIBLE].type = WidgetType::empty;
|
||||
widgets[WIDX_MAKE_VISIBLE].type = WidgetType::empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets[WIDX_RIDE_TYPE].type = WidgetType::dropdownMenu;
|
||||
widgets[WIDX_RIDE_TYPE].text = ride->getRideTypeDescriptor().Naming.Name;
|
||||
widgets[WIDX_RIDE_TYPE_DROPDOWN].type = WidgetType::button;
|
||||
widgets[WIDX_MAKE_INVISIBLE].type = WidgetType::button;
|
||||
widgets[WIDX_MAKE_VISIBLE].type = WidgetType::button;
|
||||
}
|
||||
|
||||
WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10);
|
||||
|
||||
@@ -123,6 +123,7 @@ enum class GameCommand : int32_t
|
||||
FreezeRideRating,
|
||||
SetGameSpeed,
|
||||
SetRestrictedScenery,
|
||||
setRideVisibility,
|
||||
Count,
|
||||
};
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "RideSetSettingAction.h"
|
||||
#include "RideSetStatusAction.h"
|
||||
#include "RideSetVehicleAction.h"
|
||||
#include "RideSetVisibilityAction.h"
|
||||
#include "ScenarioSetSettingAction.h"
|
||||
#include "ScenerySetRestrictedAction.h"
|
||||
#include "SignSetNameAction.h"
|
||||
@@ -210,6 +211,7 @@ namespace OpenRCT2::GameActions
|
||||
REGISTER_ACTION(MapChangeSizeAction);
|
||||
REGISTER_ACTION(GameSetSpeedAction);
|
||||
REGISTER_ACTION(ScenerySetRestrictedAction);
|
||||
REGISTER_ACTION(RideSetVisibilityAction);
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
REGISTER_ACTION(CustomAction);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "RideSetVisibilityAction.h"
|
||||
|
||||
#include "../Diagnostic.h"
|
||||
#include "../GameState.h"
|
||||
#include "../world/TileElementsView.h"
|
||||
#include "../world/tile_element/TrackElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
RideSetVisibilityAction::RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visiblity)
|
||||
: _rideIndex(rideIndex)
|
||||
, _visibility(visiblity)
|
||||
{
|
||||
}
|
||||
|
||||
void RideSetVisibilityAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("ride", _rideIndex);
|
||||
visitor.Visit("visiblity", _visibility);
|
||||
}
|
||||
|
||||
uint16_t RideSetVisibilityAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void RideSetVisibilityAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_rideIndex) << DS_TAG(_visibility);
|
||||
}
|
||||
|
||||
Result RideSetVisibilityAction::Query(GameState_t& gameState) const
|
||||
{
|
||||
if (EnumValue(_visibility) >= 2)
|
||||
{
|
||||
LOG_ERROR("Invalid visibility type %d", _visibility);
|
||||
return Result(Status::invalidParameters, STR_CANT_CHANGE_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result RideSetVisibilityAction::Execute(GameState_t& gameState) const
|
||||
{
|
||||
for (int32_t y = 1; y <= gameState.mapSize.y; y++)
|
||||
{
|
||||
for (int32_t x = 1; x <= gameState.mapSize.x; x++)
|
||||
{
|
||||
for (auto* trackElement : TileElementsView<TrackElement>(TileCoordsXY{ x, y }))
|
||||
{
|
||||
if (trackElement->GetRideIndex() == _rideIndex)
|
||||
{
|
||||
trackElement->SetInvisible(_visibility == RideSetVisibilityType::invisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result();
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
enum class RideSetVisibilityType : uint8_t
|
||||
{
|
||||
invisible,
|
||||
visible,
|
||||
};
|
||||
|
||||
class RideSetVisibilityAction final : public GameActionBase<GameCommand::setRideVisibility>
|
||||
{
|
||||
private:
|
||||
RideId _rideIndex{ RideId::GetNull() };
|
||||
RideSetVisibilityType _visibility{};
|
||||
|
||||
public:
|
||||
RideSetVisibilityAction() = default;
|
||||
RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visibility);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query(GameState_t& gameState) const override;
|
||||
Result Execute(GameState_t& gameState) const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -136,6 +136,7 @@
|
||||
<ClInclude Include="actions\RideSetColourSchemeAction.h" />
|
||||
<ClInclude Include="actions\RideSetNameAction.h" />
|
||||
<ClInclude Include="actions\RideSetPriceAction.h" />
|
||||
<ClInclude Include="actions\RideSetVisibilityAction.h" />
|
||||
<ClInclude Include="actions\RideSetSettingAction.h" />
|
||||
<ClInclude Include="actions\RideSetStatusAction.h" />
|
||||
<ClInclude Include="actions\RideSetVehicleAction.h" />
|
||||
@@ -754,6 +755,7 @@
|
||||
<ClCompile Include="actions\RideSetSettingAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetStatusAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetVehicleAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetVisibilityAction.cpp" />
|
||||
<ClCompile Include="actions\ScenarioSetSettingAction.cpp" />
|
||||
<ClCompile Include="actions\ScenerySetRestrictedAction.cpp" />
|
||||
<ClCompile Include="actions\SignSetNameAction.cpp" />
|
||||
|
||||
Reference in new issue
Block a user