Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
TextureCatalog.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DataBanks.hpp"
4
5#include <cstddef>
6#include <cstdint>
7#include <expected>
8#include <filesystem>
9#include <optional>
10#include <span>
11#include <string>
12#include <string_view>
13#include <vector>
14
15namespace monopoly::data
16{
17 class ResourcePaths;
18 // Les valeurs sont les tags HMD_board_* de Dat_Mon/dat_3d.h.
20 {
21 CityHigh = 0,
22 CityMedium = 1,
23 ClassicHigh = 2,
25 };
26
27
28 enum class TextureResolution : std::uint16_t
29 {
30 Pixels128 = 128,
31 Pixels256 = 256
32 };
33
34
35 enum class TextureRole : std::uint8_t
36 {
39 Common,
45 };
46
47
48 // Le même nom de fichier existe dans plusieurs répertoires du jeu.
49 // Cette provenance fait donc partie de la référence de ressource.
60
61
63 {
64 std::uint16_t x = 0;
65 std::uint16_t y = 0;
66
67 constexpr bool operator==(const TextureCoordinate&) const = default;
68 };
69
70
72 {
73 std::uint16_t width = 0;
74 std::uint16_t height = 0;
75
76 constexpr bool operator==(const TextureDimensions&) const = default;
77 };
78
79
86
87
97
98
99 enum class TextureProvision : std::uint8_t
100 {
103 };
104
105
114
115
124
125
133
134
136 std::expected<BoardTextureRecipe, TextureCatalogError>;
137
138
140 {
143 int city = 0;
144 int currency = 13;
145 // Absolute asset directory selected and validated by the options owner.
146 std::filesystem::path customRoot;
147 };
148
149
150 // Paths from UDUTILS_LoadBoardTextureSet / SwitchToBoardEURO. Photos,
151 // names and 2D views for city -1 are relative to customRoot; all other
152 // locations remain relative to the stock ResourcePaths roots.
153 // The original filename and the High/Medium mesh directory are preserved.
154 [[nodiscard]] std::expected<std::string, TextureCatalogError>
156 BoardMeshKind mesh,
157 TextureLocation location,
158 std::string_view fileName,
159 const BoardTextureContext& context);
160
161 [[nodiscard]] std::expected<std::filesystem::path, std::string>
163 BoardMeshKind mesh, TextureLocation location, std::string_view fileName,
164 const BoardTextureContext& context);
165
166
177
178
179 inline constexpr std::size_t LegacyTextureCorpusSize = 1001;
180
181
182 [[nodiscard]] constexpr bool isValidBoardMeshKind(
183 BoardMeshKind mesh) noexcept
184 {
185 switch (mesh)
186 {
191 return true;
192 }
193
194 return false;
195 }
196
197
199 TextureResolution resolution) noexcept
200 {
201 return
202 resolution == TextureResolution::Pixels128 ||
203 resolution == TextureResolution::Pixels256;
204 }
205
206
207 [[nodiscard]] std::string_view textureCatalogErrorCodeName(
208 TextureCatalogErrorCode code) noexcept;
209
210
212 BoardMeshKind mesh) noexcept
213 {
214 return static_cast<DataTag>(mesh);
215 }
216
217
219 BoardMeshKind mesh) noexcept
220 {
222 }
223
224
225 // UDBoard.cpp:992-995 (USA_VERSION): city 0 uses HMD_boardmed;
226 // every non-zero city, including the future custom sentinel, uses
227 // HMD_board_citymed. The source always selects the medium board here.
229 int city) noexcept
230 {
231 return city == 0
234 }
235
236
237 [[nodiscard]] constexpr bool isCityMesh(
238 BoardMeshKind mesh) noexcept
239 {
240 return
241 mesh == BoardMeshKind::CityHigh ||
243 }
244
245
246 [[nodiscard]] constexpr bool isHighDetailMesh(
247 BoardMeshKind mesh) noexcept
248 {
249 return
250 mesh == BoardMeshKind::CityHigh ||
252 }
253
254
256 TextureResolution resolution) noexcept
257 {
258 if (!isValidTextureResolution(resolution))
259 {
260 return {};
261 }
262
263 const auto side = static_cast<std::uint16_t>(resolution);
264 return {side, side};
265 }
266
267
268 [[nodiscard]] std::span<const TextureCoordinate>
270
271 [[nodiscard]] std::span<const TextureCoordinate>
273
274 [[nodiscard]] std::span<const std::string_view>
275 cityPhotoTextureNames(TextureResolution resolution) noexcept;
276
277 [[nodiscard]] std::span<const std::string_view>
279 BoardMeshKind mesh,
280 TextureResolution resolution) noexcept;
281
282 [[nodiscard]] std::span<const std::string_view>
284 BoardMeshKind mesh,
285 TextureResolution resolution) noexcept;
286
287 [[nodiscard]] std::span<const std::string_view>
289 BoardMeshKind mesh,
290 TextureResolution resolution) noexcept;
291
292 [[nodiscard]] std::span<const std::string_view>
294 BoardMeshKind mesh,
295 TextureResolution resolution) noexcept;
296
297 [[nodiscard]] std::span<const std::string_view>
299 BoardMeshKind mesh,
300 TextureResolution resolution) noexcept;
301
302 [[nodiscard]] std::string_view europeanGoOverlayTextureName(
303 TextureResolution resolution) noexcept;
304
305 [[nodiscard]] std::span<const std::string_view>
307
308 // Inventaire physique reconstructible des BMP TexInfo distribués avec la
309 // source : Boards, Cities, Currency et Languages. Les chemins utilisent
310 // '/' et sont relatifs au répertoire historique monopoly/.
311 [[nodiscard]] const std::vector<LegacyTextureAsset>&
313
314 // Reproduit UDUTILS_SwitchToBoardUSA. Pour les meshes classiques en
315 // 128 px, le code historique gardait les textures intégrées au HMD.
317 BoardMeshKind mesh,
318 TextureResolution resolution);
319
320 // Reproduit la composition de UDUTILS_SwitchToBoardEURO. Les numéros de
321 // langue, plateau et devise restent un contexte de résolution de chemin
322 // fourni par le caller; les noms, l'ordre et les overlays sont complets.
324 BoardMeshKind mesh,
325 TextureResolution resolution);
326}
unsigned index
std::uint32_t DataId
Definition DataBanks.hpp:10
constexpr DataId boardMeshDataId(BoardMeshKind mesh) noexcept
constexpr DataTag boardMeshTag(BoardMeshKind mesh) noexcept
constexpr bool isHighDetailMesh(BoardMeshKind mesh) noexcept
constexpr DataId EmptyDataId
Definition DataBanks.hpp:13
std::span< const TextureCoordinate > europeanTextureCoordinates(BoardMeshKind mesh) noexcept
std::uint16_t DataTag
Definition DataBanks.hpp:11
constexpr std::size_t LegacyTextureCorpusSize
std::string_view textureCatalogErrorCodeName(TextureCatalogErrorCode code) noexcept
std::span< const std::string_view > cityPhotoTextureNames(TextureResolution resolution) noexcept
std::span< const std::string_view > europeanLanguageTextureNames(BoardMeshKind mesh, TextureResolution resolution) noexcept
constexpr BoardMeshKind usaBoardMeshForCity(int city) noexcept
std::string_view europeanGoOverlayTextureName(TextureResolution resolution) noexcept
BoardTextureRecipeResult buildUsaTextureRecipe(BoardMeshKind mesh, TextureResolution resolution)
constexpr TextureDimensions textureDimensions(TextureResolution resolution) noexcept
std::span< const std::string_view > twoDimensionalBoardTextureNames() noexcept
constexpr bool isCityMesh(BoardMeshKind mesh) noexcept
constexpr bool isValidTextureResolution(TextureResolution resolution) noexcept
std::expected< BoardTextureRecipe, TextureCatalogError > BoardTextureRecipeResult
std::span< const std::string_view > europeanBoardOverlayTextureNames(BoardMeshKind mesh, TextureResolution resolution) noexcept
constexpr bool isValidBoardMeshKind(BoardMeshKind mesh) noexcept
std::span< const std::string_view > europeanCurrencyTextureNames(BoardMeshKind mesh, TextureResolution resolution) noexcept
std::expected< std::string, TextureCatalogError > boardTextureRelativePath(BoardMeshKind mesh, TextureLocation location, std::string_view fileName, const BoardTextureContext &context)
std::expected< std::filesystem::path, std::string > resolveBoardTexturePath(const ResourcePaths &stockPaths, BoardMeshKind mesh, TextureLocation location, std::string_view fileName, const BoardTextureContext &context)
std::span< const std::string_view > usaCityNameTextureNames(BoardMeshKind mesh, TextureResolution resolution) noexcept
const std::vector< LegacyTextureAsset > & legacyTextureCorpusManifest()
constexpr DataId packDataId(std::uint16_t group, DataTag tag) noexcept
Definition DataBanks.hpp:39
std::span< const TextureCoordinate > usaTextureCoordinates(BoardMeshKind mesh) noexcept
std::span< const std::string_view > commonTextureNames(BoardMeshKind mesh, TextureResolution resolution) noexcept
BoardTextureRecipeResult buildEuropeanTextureRecipe(BoardMeshKind mesh, TextureResolution resolution)
std::vector< TextureReference > textures
constexpr bool operator==(const TextureCoordinate &) const =default
constexpr bool operator==(const TextureDimensions &) const =default
std::optional< TextureOverlayReference > overlay