1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Re-introduce basic scenario text objects

This commit is contained in:
Aaron van Geffen
2024-10-27 14:53:27 +01:00
parent 7b614f2287
commit f7ae40bac8
7 changed files with 90 additions and 20 deletions

View File

@@ -1299,7 +1299,7 @@ constexpr std::array _objectTypeNames = {
"Scenery groups",
"Park entrances",
"Water",
"ScenarioText",
"Scenario Text",
"Terrain Surface",
"Terrain Edges",
"Stations",

View File

@@ -355,6 +355,7 @@
<ClInclude Include="object\SceneryGroupEntry.h" />
<ClInclude Include="object\SceneryGroupObject.h" />
<ClInclude Include="object\SceneryObject.h" />
<ClInclude Include="object\ScenarioTextObject.h" />
<ClInclude Include="object\SmallSceneryEntry.h" />
<ClInclude Include="object\SmallSceneryObject.h" />
<ClInclude Include="object\StationObject.h" />
@@ -880,6 +881,7 @@
<ClCompile Include="object\ResourceTable.cpp" />
<ClCompile Include="object\RideObject.cpp" />
<ClCompile Include="object\SceneryGroupObject.cpp" />
<ClCompile Include="object\ScenarioTextObject.cpp" />
<ClCompile Include="object\SmallSceneryObject.cpp" />
<ClCompile Include="object\StationObject.cpp" />
<ClCompile Include="object\StringTable.cpp" />

View File

@@ -38,6 +38,7 @@
#include "PathAdditionObject.h"
#include "PeepNamesObject.h"
#include "RideObject.h"
#include "ScenarioTextObject.h"
#include "SceneryGroupObject.h"
#include "SmallSceneryObject.h"
#include "StationObject.h"
@@ -363,6 +364,7 @@ namespace OpenRCT2::ObjectFactory
result = std::make_unique<WaterObject>();
break;
case ObjectType::ScenarioText:
result = std::make_unique<ScenarioTextObject>();
break;
case ObjectType::TerrainSurface:
result = std::make_unique<TerrainSurfaceObject>();
@@ -414,6 +416,8 @@ namespace OpenRCT2::ObjectFactory
return ObjectType::ParkEntrance;
if (s == "water")
return ObjectType::Water;
if (s == "scenario_text")
return ObjectType::ScenarioText;
if (s == "terrain_surface")
return ObjectType::TerrainSurface;
if (s == "terrain_edge")

View File

@@ -23,7 +23,7 @@ constexpr uint16_t kMaxPathAdditionObjects = 255;
constexpr uint16_t kMaxSceneryGroupObjects = 255;
constexpr uint16_t kMaxParkEntranceObjects = 4;
constexpr uint16_t kMaxWaterObjects = 1;
constexpr uint16_t kMaxScenarioTextObjects = 0;
constexpr uint16_t kMaxScenarioTextObjects = 1;
constexpr uint16_t kMaxTerrainSurfaceObjects = 255;
constexpr uint16_t kMaxTerrainEdgeObjects = 255;
constexpr uint16_t kMaxStationObjects = 255;

View File

@@ -0,0 +1,46 @@
/*****************************************************************************
* Copyright (c) 2014-2024 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 "ScenarioTextObject.h"
#include "../Context.h"
#include "../PlatformEnvironment.h"
#include "../core/Guard.hpp"
#include "../core/Json.hpp"
using namespace OpenRCT2;
void ScenarioTextObject::Load()
{
}
void ScenarioTextObject::Unload()
{
}
void ScenarioTextObject::ReadJson(IReadObjectContext* context, json_t& root)
{
Guard::Assert(root.is_object(), "ScenarioTextObject::ReadJson expects parameter root to be an object");
PopulateTablesFromJson(context, root);
}
std::string ScenarioTextObject::GetScenarioName()
{
return GetStringTable().GetString(ObjectStringID::SCENARIO_NAME);
}
std::string ScenarioTextObject::GetParkName()
{
return GetStringTable().GetString(ObjectStringID::PARK_NAME);
}
std::string ScenarioTextObject::GetScenarioDetails()
{
return GetStringTable().GetString(ObjectStringID::SCENARIO_DETAILS);
}

View File

@@ -0,0 +1,29 @@
/*****************************************************************************
* Copyright (c) 2014-2024 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 "../core/IStream.hpp"
#include "Object.h"
#include <string>
class ScenarioTextObject final : public Object
{
public:
static constexpr ObjectType kObjectType = ObjectType::ScenarioText;
void ReadJson(IReadObjectContext* context, json_t& root) override;
void Load() override;
void Unload() override;
std::string GetScenarioName();
std::string GetParkName();
std::string GetScenarioDetails();
};

View File

@@ -41,6 +41,7 @@
#include "../object/ObjectEntryManager.h"
#include "../object/ObjectList.h"
#include "../object/ObjectManager.h"
#include "../object/ScenarioTextObject.h"
#include "../object/WaterEntry.h"
#include "../platform/Platform.h"
#include "../profiling/Profiling.h"
@@ -107,25 +108,14 @@ void ScenarioReset(GameState_t& gameState)
gameState.HistoricalProfit = gameState.InitialCash - gameState.BankLoan;
gameState.Cash = gameState.InitialCash;
auto& objManager = GetContext()->GetObjectManager();
if (auto* object = objManager.GetLoadedObject(ObjectType::ScenarioText, 0))
{
auto normalisedName = ScenarioSources::NormaliseName(gameState.ScenarioName);
auto* textObject = reinterpret_cast<ScenarioTextObject*>(object);
StringId localisedStringIds[3];
if (LanguageGetLocalisedScenarioStrings(normalisedName, localisedStringIds))
{
if (localisedStringIds[0] != STR_NONE)
{
gameState.ScenarioName = LanguageGetString(localisedStringIds[0]);
}
if (localisedStringIds[1] != STR_NONE)
{
gameState.Park.Name = LanguageGetString(localisedStringIds[1]);
}
if (localisedStringIds[2] != STR_NONE)
{
gameState.ScenarioDetails = LanguageGetString(localisedStringIds[2]);
}
}
gameState.ScenarioName = textObject->GetScenarioName();
gameState.Park.Name = textObject->GetParkName();
gameState.ScenarioDetails = textObject->GetScenarioDetails();
}
// Set the last saved game path
@@ -154,7 +144,6 @@ void ScenarioReset(GameState_t& gameState)
MapCountRemainingLandRights();
Staff::ResetStats();
auto& objManager = GetContext()->GetObjectManager();
gameState.LastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
if (gameState.LastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
{