1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 16:54:52 +01:00
Files
OpenRCT2/src/openrct2/actions/GameActionResult.cpp
Aaron van Geffen 05e56517ab Adopt existing namespaces into OpenRCT2 namespace (#22368)
* Put all of TitleSequenceManager into the same namespace

* Move RideConstructionState into the OpenRCT2 namespace

* Adopt existing namespaces into OpenRCT2 namespace

This adds `using namespace OpenRCT2` to compilation units where appropriate,
as a means to get the codebase to compile until these units have been placed
in a namespace of their own.
2024-07-26 09:59:58 +02:00

47 lines
1.2 KiB
C++

#include "GameActionResult.h"
#include "../localisation/Formatting.h"
#include <algorithm>
using namespace OpenRCT2;
namespace OpenRCT2::GameActions
{
Result::Result(GameActions::Status error, StringId title, StringId message, uint8_t* args /*= nullptr*/)
: Error(error)
, ErrorTitle(title)
, ErrorMessage(message)
{
if (args != nullptr)
{
std::copy_n(args, ErrorMessageArgs.size(), ErrorMessageArgs.begin());
}
}
struct StringVariantVisitor
{
const void* ErrorMessageArgs{};
std::string operator()(const std::string& str) const
{
return str;
}
std::string operator()(const StringId strId) const
{
return FormatStringIDLegacy(strId, ErrorMessageArgs);
}
};
std::string GameActions::Result::GetErrorTitle() const
{
return std::visit(StringVariantVisitor{ ErrorMessageArgs.data() }, ErrorTitle);
}
std::string GameActions::Result::GetErrorMessage() const
{
return std::visit(StringVariantVisitor{ ErrorMessageArgs.data() }, ErrorMessage);
}
} // namespace OpenRCT2::GameActions