Files
OpenRCT2-Web/src/openrct2/object/StringTable.h
T

63 lines
1.7 KiB
C++
Raw Normal View History

/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
2018-06-15 14:07:34 +02:00
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../core/JsonFwd.hpp"
2017-12-11 13:06:59 +00:00
#include "../localisation/Language.h"
2018-06-22 23:03:20 +02:00
#include <string>
#include <vector>
struct IReadObjectContext;
namespace OpenRCT2
{
struct IStream;
}
enum class ObjectStringID : uint8_t
2017-12-11 13:06:59 +00:00
{
UNKNOWN = 255,
NAME = 0,
DESCRIPTION,
SCENARIO_NAME = 0,
PARK_NAME = 1,
SCENARIO_DETAILS = 2,
CAPACITY = 2,
VEHICLE_NAME = 3,
2017-12-11 13:06:59 +00:00
};
struct StringTableEntry
{
ObjectStringID Id = ObjectStringID::UNKNOWN;
2018-06-22 23:03:20 +02:00
uint8_t LanguageId = LANGUAGE_UNDEFINED;
2017-12-05 12:55:33 +00:00
std::string Text;
};
class StringTable
{
private:
std::vector<StringTableEntry> _strings;
2020-08-12 19:44:59 +01:00
static ObjectStringID ParseStringId(const std::string& s);
public:
2017-12-11 13:06:59 +00:00
StringTable() = default;
2018-06-22 23:03:20 +02:00
StringTable(const StringTable&) = delete;
StringTable& operator=(const StringTable&) = delete;
2017-12-11 13:06:59 +00:00
void Read(IReadObjectContext* context, OpenRCT2::IStream* stream, ObjectStringID id);
2020-08-12 19:44:59 +01:00
/**
* @note root is deliberately left non-const: json_t behaviour changes when const
*/
void ReadJson(json_t& root);
2018-06-22 23:03:20 +02:00
void Sort();
std::string GetString(ObjectStringID id) const;
std::string GetString(uint8_t language, ObjectStringID id) const;
void SetString(ObjectStringID id, uint8_t language, const std::string& text);
2016-11-30 23:32:47 +01:00
};