2016-06-25 03:52:58 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2016-06-25 03:52:58 +02:00
|
|
|
*
|
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
|
2016-06-25 03:52:58 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-06-25 03:52:58 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../common.h"
|
2020-10-03 18:11:50 +02:00
|
|
|
#include "../core/JsonFwd.hpp"
|
2018-01-05 22:17:33 +01:00
|
|
|
#include "../drawing/Drawing.h"
|
2016-06-25 11:48:54 +02:00
|
|
|
|
2018-06-22 23:03:20 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-05-29 19:26:02 +02:00
|
|
|
struct Image;
|
2020-07-30 23:19:53 +02:00
|
|
|
struct IReadObjectContext;
|
2020-07-30 23:01:22 +02:00
|
|
|
namespace OpenRCT2
|
|
|
|
{
|
2020-07-30 23:19:53 +02:00
|
|
|
struct IStream;
|
2020-07-30 23:01:22 +02:00
|
|
|
}
|
2016-06-25 03:52:58 +02:00
|
|
|
|
|
|
|
class ImageTable
|
|
|
|
{
|
2016-06-25 11:48:54 +02:00
|
|
|
private:
|
2018-06-22 23:03:20 +02:00
|
|
|
std::unique_ptr<uint8_t[]> _data;
|
2016-06-25 11:48:54 +02:00
|
|
|
std::vector<rct_g1_element> _entries;
|
|
|
|
|
2020-08-12 20:44:59 +02:00
|
|
|
/**
|
|
|
|
* Container for a G1 image, additional information and RAII. Used by ReadJson
|
|
|
|
*/
|
|
|
|
struct RequiredImage;
|
2021-08-29 15:39:42 +02:00
|
|
|
[[nodiscard]] std::vector<std::pair<std::string, Image>> GetImageSources(IReadObjectContext* context, json_t& jsonImages);
|
2021-08-23 20:09:43 +02:00
|
|
|
[[nodiscard]] static std::vector<std::unique_ptr<ImageTable::RequiredImage>> ParseImages(
|
|
|
|
IReadObjectContext* context, std::string s);
|
2020-08-12 20:44:59 +02:00
|
|
|
/**
|
|
|
|
* @note root is deliberately left non-const: json_t behaviour changes when const
|
|
|
|
*/
|
2021-08-23 20:09:43 +02:00
|
|
|
[[nodiscard]] static std::vector<std::unique_ptr<ImageTable::RequiredImage>> ParseImages(
|
2021-05-29 19:26:02 +02:00
|
|
|
IReadObjectContext* context, std::vector<std::pair<std::string, Image>>& imageSources, json_t& el);
|
2021-08-23 20:09:43 +02:00
|
|
|
[[nodiscard]] static std::vector<std::unique_ptr<ImageTable::RequiredImage>> LoadObjectImages(
|
2020-08-12 20:44:59 +02:00
|
|
|
IReadObjectContext* context, const std::string& name, const std::vector<int32_t>& range);
|
2021-08-23 20:09:43 +02:00
|
|
|
[[nodiscard]] static std::vector<int32_t> ParseRange(std::string s);
|
|
|
|
[[nodiscard]] static std::string FindLegacyObject(const std::string& name);
|
2020-08-12 20:44:59 +02:00
|
|
|
|
2016-06-25 03:52:58 +02:00
|
|
|
public:
|
2017-12-11 14:06:59 +01:00
|
|
|
ImageTable() = default;
|
2018-06-22 23:03:20 +02:00
|
|
|
ImageTable(const ImageTable&) = delete;
|
|
|
|
ImageTable& operator=(const ImageTable&) = delete;
|
2016-06-25 11:48:54 +02:00
|
|
|
~ImageTable();
|
|
|
|
|
2020-07-30 23:01:22 +02:00
|
|
|
void Read(IReadObjectContext* context, OpenRCT2::IStream* stream);
|
2020-08-12 20:44:59 +02:00
|
|
|
/**
|
|
|
|
* @note root is deliberately left non-const: json_t behaviour changes when const
|
|
|
|
*/
|
|
|
|
void ReadJson(IReadObjectContext* context, json_t& root);
|
2018-06-22 23:03:20 +02:00
|
|
|
const rct_g1_element* GetImages() const
|
|
|
|
{
|
|
|
|
return _entries.data();
|
|
|
|
}
|
|
|
|
uint32_t GetCount() const
|
|
|
|
{
|
2020-04-22 17:09:29 +02:00
|
|
|
return static_cast<uint32_t>(_entries.size());
|
2018-06-22 23:03:20 +02:00
|
|
|
}
|
|
|
|
void AddImage(const rct_g1_element* g1);
|
2016-10-04 19:14:29 +02:00
|
|
|
};
|