Move title commands to their own source files

This commit is contained in:
Hielke Morsink 2022-06-18 17:21:33 +02:00
parent debdb0bcda
commit 6bfba88845
No known key found for this signature in database
GPG Key ID: FE0B343DF883E7F2
24 changed files with 513 additions and 86 deletions

View File

@ -27,7 +27,6 @@ struct rct_drawpixelinfo;
struct rct_window;
union rct_window_event;
struct track_design_file_ref;
struct TitleSequence;
struct TextInputSession;
struct scenario_index_entry;

View File

@ -497,6 +497,16 @@
<ClInclude Include="scripting\bindings\world\ScTile.hpp" />
<ClInclude Include="sprites.h" />
<ClInclude Include="System.hpp" />
<ClInclude Include="title\Command\End.h" />
<ClInclude Include="title\Command\FollowEntity.h" />
<ClInclude Include="title\Command\LoadPark.h" />
<ClInclude Include="title\Command\LoadScenario.h" />
<ClInclude Include="title\Command\Restart.h" />
<ClInclude Include="title\Command\RotateView.h" />
<ClInclude Include="title\Command\SetLocation.h" />
<ClInclude Include="title\Command\SetSpeed.h" />
<ClInclude Include="title\Command\SetZoom.h" />
<ClInclude Include="title\Command\Wait.h" />
<ClInclude Include="title\TitleScreen.h" />
<ClInclude Include="title\TitleSequence.h" />
<ClInclude Include="title\TitleSequenceManager.h" />
@ -941,6 +951,16 @@
<ClCompile Include="scripting\HookEngine.cpp" />
<ClCompile Include="scripting\Plugin.cpp" />
<ClCompile Include="scripting\ScriptEngine.cpp" />
<ClCompile Include="title\Command\End.cpp" />
<ClCompile Include="title\Command\FollowEntity.cpp" />
<ClCompile Include="title\Command\LoadPark.cpp" />
<ClCompile Include="title\Command\LoadScenario.cpp" />
<ClCompile Include="title\Command\Restart.cpp" />
<ClCompile Include="title\Command\RotateView.cpp" />
<ClCompile Include="title\Command\SetLocation.cpp" />
<ClCompile Include="title\Command\SetSpeed.cpp" />
<ClCompile Include="title\Command\SetZoom.cpp" />
<ClCompile Include="title\Command\Wait.cpp" />
<ClCompile Include="title\TitleScreen.cpp" />
<ClCompile Include="title\TitleSequence.cpp" />
<ClCompile Include="title\TitleSequenceManager.cpp" />
@ -975,4 +995,4 @@
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>

View File

@ -0,0 +1,18 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "End.h"
namespace OpenRCT2::Title
{
int16_t EndCommand::operator()(int16_t timer)
{
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,22 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct EndCommand
{
static constexpr const char* Name = "End Command";
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "FollowEntity.h"
namespace OpenRCT2::Title
{
int16_t FollowEntityCommand::operator()(int16_t timer)
{
// TODO: Set entity to follow
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,32 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "../../Identifiers.h"
#include "../../core/String.hpp"
#include "../../localisation/Localisation.h"
#include <cstdint>
namespace OpenRCT2::Title
{
struct FollowEntityCommand
{
static constexpr const char* Name = "Follow Entity Command";
struct
{
EntityId SpriteIndex;
utf8 SpriteName[USER_STRING_MAX_LENGTH];
} Follow;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "LoadPark.h"
namespace OpenRCT2::Title
{
int16_t LoadParkCommand::operator()(int16_t timer)
{
// TODO: Load park
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,24 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct LoadParkCommand
{
static constexpr const char* Name = "Load Park Command";
uint8_t SaveIndex;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "LoadScenario.h"
namespace OpenRCT2::Title
{
int16_t LoadScenarioCommand::operator()(int16_t timer)
{
// TODO: Load scenario
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,28 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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/String.hpp"
#include <cstdint>
#define TITLE_COMMAND_SCENARIO_LENGTH 64
namespace OpenRCT2::Title
{
struct LoadScenarioCommand
{
static constexpr const char* Name = "Load Scenario Command";
utf8 Scenario[TITLE_COMMAND_SCENARIO_LENGTH];
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,18 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "Restart.h"
namespace OpenRCT2::Title
{
int16_t RestartCommand::operator()(int16_t timer)
{
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,22 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct RestartCommand
{
static constexpr const char* Name = "Restart Command";
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "RotateView.h"
namespace OpenRCT2::Title
{
int16_t RotateViewCommand::operator()(int16_t timer)
{
// TODO: Rotate the view X times
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,24 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct RotateViewCommand
{
static constexpr const char* Name = "Rotate View Command";
uint8_t Rotations;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "SetLocation.h"
namespace OpenRCT2::Title
{
int16_t SetLocationCommand::operator()(int16_t timer)
{
// TODO: Update view location
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,29 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct SetLocationCommand
{
static constexpr const char* Name = "Set Location Command";
// TODO: Use TileCoordsXY instead
struct
{
uint8_t X;
uint8_t Y;
} Location;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "SetSpeed.h"
namespace OpenRCT2::Title
{
int16_t SetSpeedCommand::operator()(int16_t timer)
{
// TODO: Update current zoom level
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,24 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct SetSpeedCommand
{
static constexpr const char* Name = "Set Speed Command";
uint8_t Speed;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,20 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "SetZoom.h"
namespace OpenRCT2::Title
{
int16_t SetZoomCommand::operator()(int16_t timer)
{
// TODO: Update current zoom level
return 0;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,25 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct SetZoomCommand
{
static constexpr const char* Name = "Set Zoom Command";
// TODO: Use ZoomLevel instead
uint8_t Zoom;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,18 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 "Wait.h"
namespace OpenRCT2::Title
{
int16_t WaitCommand::operator()(int16_t timer)
{
return Milliseconds;
}
} // namespace OpenRCT2::Title

View File

@ -0,0 +1,24 @@
/*****************************************************************************
* Copyright (c) 2014-2022 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 <cstdint>
namespace OpenRCT2::Title
{
struct WaitCommand
{
static constexpr const char* Name = "Wait Command";
uint16_t Milliseconds;
int16_t operator()(int16_t timer);
};
} // namespace OpenRCT2::Title

View File

@ -35,6 +35,8 @@
#include <utility>
#include <vector>
using namespace OpenRCT2::Title;
static std::vector<std::string> GetSaves(const std::string& path);
static std::vector<std::string> GetSaves(IZipArchive* zip);
static std::vector<TitleCommand> LegacyScriptRead(const std::vector<uint8_t>& script, std::vector<std::string> saves);
@ -91,7 +93,7 @@ std::unique_ptr<TitleSequence> LoadTitleSequence(const std::string& path)
auto commands = LegacyScriptRead(script, saves);
auto seq = CreateTitleSequence();
auto seq = OpenRCT2::Title::CreateTitleSequence();
seq->Name = Path::GetFileNameWithoutExtension(path);
seq->Path = path;
seq->Saves = saves;

View File

@ -10,98 +10,56 @@
#pragma once
#include "../common.h"
#include "../localisation/Localisation.h"
#include "../openrct2/core/IStream.hpp"
#include "Command/End.h"
#include "Command/FollowEntity.h"
#include "Command/LoadPark.h"
#include "Command/LoadScenario.h"
#include "Command/Restart.h"
#include "Command/RotateView.h"
#include "Command/SetLocation.h"
#include "Command/SetSpeed.h"
#include "Command/SetZoom.h"
#include "Command/Wait.h"
#include <memory>
#include <string>
#include <variant>
#define TITLE_COMMAND_SCENARIO_LENGTH 64
namespace OpenRCT2::Title
{
using TitleCommand = std::variant<
WaitCommand, SetLocationCommand, RotateViewCommand, SetZoomCommand, FollowEntityCommand, RestartCommand,
LoadParkCommand, EndCommand, SetSpeedCommand, LoadScenarioCommand>;
struct WaitCommand
{
uint16_t Milliseconds;
};
struct SetLocationCommand
{
struct
struct TitleSequence
{
uint8_t X;
uint8_t Y;
} Location;
};
struct RotateViewCommand
{
uint8_t Rotations;
};
struct SetZoomCommand
{
uint8_t Zoom;
};
struct FollowEntityCommand
{
struct
std::string Name;
std::string Path;
std::vector<TitleCommand> Commands;
std::vector<std::string> Saves;
bool IsZip = false;
};
struct TitleSequenceParkHandle
{
EntityId SpriteIndex;
utf8 SpriteName[USER_STRING_MAX_LENGTH];
} Follow;
};
struct RestartCommand
{
};
struct LoadParkCommand
{
uint8_t SaveIndex;
};
struct EndCommand
{
};
struct SetSpeedCommand
{
uint8_t Speed;
};
struct LoopCommand
{
};
struct EndLoopCommand
{
};
struct LoadScenarioCommand
{
utf8 Scenario[TITLE_COMMAND_SCENARIO_LENGTH];
};
std::string HintPath;
std::unique_ptr<OpenRCT2::IStream> Stream;
};
using TitleCommand = std::variant<
WaitCommand, SetLocationCommand, RotateViewCommand, SetZoomCommand, FollowEntityCommand, RestartCommand, LoadParkCommand,
EndCommand, SetSpeedCommand, LoopCommand, EndLoopCommand, LoadScenarioCommand>;
constexpr const utf8* TITLE_SEQUENCE_EXTENSION = ".parkseq";
constexpr uint8_t SAVE_INDEX_INVALID = UINT8_MAX;
struct TitleSequence
{
std::string Name;
std::string Path;
[[nodiscard]] std::unique_ptr<TitleSequence> CreateTitleSequence();
[[nodiscard]] std::unique_ptr<TitleSequence> LoadTitleSequence(const std::string& path);
[[nodiscard]] std::unique_ptr<TitleSequenceParkHandle> TitleSequenceGetParkHandle(const TitleSequence& seq, size_t index);
std::vector<TitleCommand> Commands;
std::vector<std::string> Saves;
bool TitleSequenceSave(const TitleSequence& seq);
bool TitleSequenceAddPark(TitleSequence& seq, const utf8* path, const utf8* name);
bool TitleSequenceRenamePark(TitleSequence& seq, size_t index, const utf8* name);
bool TitleSequenceRemovePark(TitleSequence& seq, size_t index);
bool IsZip = false;
};
struct TitleSequenceParkHandle
{
std::string HintPath;
std::unique_ptr<OpenRCT2::IStream> Stream;
};
constexpr const utf8* TITLE_SEQUENCE_EXTENSION = ".parkseq";
constexpr uint8_t SAVE_INDEX_INVALID = UINT8_MAX;
[[nodiscard]] std::unique_ptr<TitleSequence> CreateTitleSequence();
[[nodiscard]] std::unique_ptr<TitleSequence> LoadTitleSequence(const std::string& path);
[[nodiscard]] std::unique_ptr<TitleSequenceParkHandle> TitleSequenceGetParkHandle(const TitleSequence& seq, size_t index);
bool TitleSequenceSave(const TitleSequence& seq);
bool TitleSequenceAddPark(TitleSequence& seq, const utf8* path, const utf8* name);
bool TitleSequenceRenamePark(TitleSequence& seq, size_t index, const utf8* name);
bool TitleSequenceRemovePark(TitleSequence& seq, size_t index);
bool TitleSequenceIsLoadCommand(const TitleCommand& command);
bool TitleSequenceIsLoadCommand(const TitleCommand& command);
} // namespace OpenRCT2::Title