Porytiles
Loading...
Searching...
No Matches
tileset_repo.cpp
Go to the documentation of this file.
2
3#include <optional>
4#include <set>
5#include <string>
6
14
15namespace porytiles {
16
18{
19 // Begin transaction for atomic writes
20 PT_TRY_CALL_CHAIN_ERR(writer_->begin_transaction(), void, "Tileset begin transaction failed.");
21
22 // Perform all write operations within the transaction
23
24 // Porymap artifacts
26 metatiles_key, key_provider_->key_for_metatiles_bin(tileset.name()), void, "Tileset save failed.");
27 if (auto result = writer_->write_metatiles_bin(metatiles_key, tileset); !result.has_value()) {
28 std::ignore = writer_->rollback();
29 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{metatiles_key.key(), Style::bold}};
30 return ChainableResult<void>{failed, result};
31 }
32
34 attribute_key, key_provider_->key_for_metatile_attributes_bin(tileset.name()), void, "Tileset save failed.");
35 if (auto result = writer_->write_metatile_attributes_bin(attribute_key, tileset); !result.has_value()) {
36 std::ignore = writer_->rollback();
37 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{attribute_key.key(), Style::bold}};
38 return ChainableResult<void>{failed, result};
39 }
40
42 tiles_png_key, key_provider_->key_for_tiles_png(tileset.name()), void, "Tileset save failed.");
43 if (auto result = writer_->write_tiles_png(tiles_png_key, tileset); !result.has_value()) {
44 std::ignore = writer_->rollback();
45 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{tiles_png_key.key(), Style::bold}};
46 return ChainableResult<void>{failed, result};
47 }
48
49 for (std::size_t i = 0; i < palette::num_palettes; i++) {
51 palette_key, key_provider_->key_for_porymap_palette_n(tileset.name(), i), void, "Tileset save failed.");
52 if (auto result = writer_->write_porymap_palette_n(palette_key, tileset, i); !result.has_value()) {
53 std::ignore = writer_->rollback();
54 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{palette_key.key(), Style::bold}};
55 return ChainableResult<void>{failed, result};
56 }
57 }
58
59 for (const auto &porymap_anim : tileset.porymap_component().anims() | std::views::values) {
60 for (const auto &frame : porymap_anim.frames_values()) {
62 frame_key,
63 key_provider_->key_for_porymap_anim_frame(tileset.name(), porymap_anim.name(), frame.frame_name()),
64 void,
65 "Tileset save failed.");
66 if (auto result =
67 writer_->write_porymap_anim_frame(frame_key, tileset, porymap_anim.name(), frame.frame_name());
68 !result.has_value()) {
69 std::ignore = writer_->rollback();
70 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{frame_key.key(), Style::bold}};
71 return ChainableResult<void>{failed, result};
72 }
73 }
74 }
75
77 generated_anim_code_key,
78 key_provider_->key_for_porymap_anim_params(tileset.name()),
79 void,
80 "Tileset save failed.");
81 if (auto result = writer_->write_porymap_anim_params(generated_anim_code_key, tileset); !result.has_value()) {
82 std::ignore = writer_->rollback();
83 auto failed =
84 FormattableError{"Save failed for '{}'.", FormatParam{generated_anim_code_key.key(), Style::bold}};
85 return ChainableResult<void>{failed, result};
86 }
87
88 // Porytiles artifacts
90 bottom_png_key, key_provider_->key_for_bottom_png(tileset.name()), void, "Tileset save failed.");
91 if (auto result = writer_->write_bottom_png(bottom_png_key, tileset); !result.has_value()) {
92 std::ignore = writer_->rollback();
93 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{bottom_png_key.key(), Style::bold}};
94 return ChainableResult<void>{failed, result};
95 }
96
98 middle_png_key, key_provider_->key_for_middle_png(tileset.name()), void, "Tileset save failed.");
99 if (auto result = writer_->write_middle_png(middle_png_key, tileset); !result.has_value()) {
100 std::ignore = writer_->rollback();
101 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{middle_png_key.key(), Style::bold}};
102 return ChainableResult<void>{failed, result};
103 }
104
105 PT_TRY_ASSIGN_CHAIN_ERR(top_png_key, key_provider_->key_for_top_png(tileset.name()), void, "Tileset save failed.");
106 if (auto result = writer_->write_top_png(top_png_key, tileset); !result.has_value()) {
107 std::ignore = writer_->rollback();
108 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{top_png_key.key(), Style::bold}};
109 return ChainableResult<void>{failed, result};
110 }
111
113 attribute_csv_key, key_provider_->key_for_attributes_csv(tileset.name()), void, "Tileset save failed.");
114 if (auto result = writer_->write_attributes_csv(attribute_csv_key, tileset); !result.has_value()) {
115 std::ignore = writer_->rollback();
116 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{attribute_csv_key.key(), Style::bold}};
117 return ChainableResult<void>{failed, result};
118 }
119
120 for (std::size_t i = 0; i < palette::num_palettes; i++) {
122 porytiles_palette_key,
123 key_provider_->key_for_porytiles_palette_n(tileset.name(), i),
124 void,
125 "Tileset save failed.");
126 if (auto result = writer_->write_porytiles_palette_n(porytiles_palette_key, tileset, i); !result.has_value()) {
127 std::ignore = writer_->rollback();
128 auto failed =
129 FormattableError{"Save failed for '{}'.", FormatParam{porytiles_palette_key.key(), Style::bold}};
130 return ChainableResult<void>{failed, result};
131 }
132 }
133
134 for (const auto &porytiles_anim : tileset.porytiles_component().anims() | std::views::values) {
135 // Save key frame (only present for automatic/hybrid frame linking)
136 if (porytiles_anim.has_key_frame()) {
138 key_frame_key,
139 key_provider_->key_for_porytiles_anim_frame(
140 tileset.name(), porytiles_anim.name(), porytiles_anim.key_frame().frame_name()),
141 void,
142 "Tileset save failed.");
143 if (auto result = writer_->write_porytiles_anim_frame(
144 key_frame_key, tileset, porytiles_anim.name(), porytiles_anim.key_frame().frame_name());
145 !result.has_value()) {
146 std::ignore = writer_->rollback();
147 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{key_frame_key.key(), Style::bold}};
148 return ChainableResult<void>{failed, result};
149 }
150 }
151
152 // Save regular frames
153 for (const auto &frame : porytiles_anim.frames_values()) {
155 frame_key,
156 key_provider_->key_for_porytiles_anim_frame(tileset.name(), porytiles_anim.name(), frame.frame_name()),
157 void,
158 "Tileset save failed.");
159 if (auto result =
160 writer_->write_porytiles_anim_frame(frame_key, tileset, porytiles_anim.name(), frame.frame_name());
161 !result.has_value()) {
162 std::ignore = writer_->rollback();
163 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{frame_key.key(), Style::bold}};
164 return ChainableResult<void>{failed, result};
165 }
166 }
167 }
168
170 anim_json_key, key_provider_->key_for_porytiles_anim_params(tileset.name()), void, "Tileset save failed.");
171 if (auto result = writer_->write_porytiles_anim_params(anim_json_key, tileset); !result.has_value()) {
172 std::ignore = writer_->rollback();
173 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{anim_json_key.key(), Style::bold}};
174 return ChainableResult<void>{failed, result};
175 }
176
177 // Commit all writes atomically
178 if (auto result = writer_->commit(); !result.has_value()) {
179 // Commit failed, attempt rollback (though it may not be necessary after failed commit)
180 std::ignore = writer_->rollback();
181 return ChainableResult<void>{FormattableError{"Tileset commit failed."}, result};
182 }
183
184 // Cache checksums after successful save
186 artifact_keys,
187 key_provider_->get_all_artifact_keys(tileset.name()),
188 void,
189 "Failed to get artifact keys for tileset save.");
190 const auto current_checksums = checksum_provider_->compute_tileset_artifact_checksums(artifact_keys);
191 const auto cache_result = checksum_provider_->cache_tileset_checksums(tileset.name(), current_checksums);
192 if (!cache_result.has_value()) {
193 return FormattableError{cache_result.error()};
194 }
195 return {};
196}
197
199{
200 constexpr auto missing_required_artifact_tag = "missing-required-artifact";
201 constexpr auto missing_required_artifact_msg = "Missing required artifact: '{}'.";
202 constexpr auto missing_optional_artifact_tag = "missing-optional-artifact";
203 constexpr auto missing_optional_artifact_msg = "Missing optional artifact: '{}'.";
204
205 // Fail as late as possible
206 bool fail_at_exit = false;
207
208 // Confirm tileset exists.
209 if (!exists(name)) {
210 return FormattableError{"Tileset '{}' does not exist.", FormatParam{name, Style::bold}};
211 }
212
213 auto porytiles_component = std::make_unique<PorytilesTilesetComponent>();
214 auto porymap_component = std::make_unique<PorymapTilesetComponent>();
215 auto tileset = std::make_unique<Tileset>(name, std::move(porytiles_component), std::move(porymap_component));
216
217 // Porymap artifacts
219 metatiles_key,
220 key_provider_->key_for_metatiles_bin(tileset->name()),
221 std::unique_ptr<Tileset>,
222 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
223 if (!key_provider_->artifact_exists(metatiles_key)) {
224 return FormattableError{missing_required_artifact_msg, FormatParam{metatiles_key.key(), Style::bold}};
225 }
227 reader_->read_metatiles_bin(*tileset, metatiles_key),
228 std::unique_ptr<Tileset>,
229 "Failed to read artifact: '{}'.",
230 FormatParam(metatiles_key.key(), Style::bold));
231
233 attribute_key,
234 key_provider_->key_for_metatile_attributes_bin(tileset->name()),
235 std::unique_ptr<Tileset>,
236 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
237 if (!key_provider_->artifact_exists(attribute_key)) {
238 return FormattableError{missing_required_artifact_msg, FormatParam{attribute_key.key(), Style::bold}};
239 }
241 reader_->read_metatile_attributes_bin(*tileset, attribute_key),
242 std::unique_ptr<Tileset>,
243 "Failed to read artifact: '{}'.",
244 FormatParam(attribute_key.key(), Style::bold));
245
247 tiles_png_key,
248 key_provider_->key_for_tiles_png(tileset->name()),
249 std::unique_ptr<Tileset>,
250 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
251 if (!key_provider_->artifact_exists(tiles_png_key)) {
252 return FormattableError{missing_required_artifact_msg, FormatParam{tiles_png_key.key(), Style::bold}};
253 }
255 reader_->read_tiles_png(*tileset, tiles_png_key),
256 std::unique_ptr<Tileset>,
257 "Failed to read artifact '{}'.",
258 FormatParam(tiles_png_key.key(), Style::bold));
259
260 for (std::size_t i = 0; i < palette::num_palettes; i++) {
262 palette_key,
263 key_provider_->key_for_porymap_palette_n(tileset->name(), i),
264 std::unique_ptr<Tileset>,
265 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
266 if (!key_provider_->artifact_exists(palette_key)) {
267 diag_->error(
268 missing_required_artifact_tag,
269 missing_required_artifact_msg,
270 FormatParam{palette_key.key(), Style::bold});
271 fail_at_exit = true;
272 continue;
273 }
275 reader_->read_porymap_palette_n(*tileset, palette_key, i),
276 std::unique_ptr<Tileset>,
277 "Failed to read artifact '{}'.",
278 FormatParam(palette_key.key(), Style::bold));
279 }
280
282 porymap_anim_params_key,
283 key_provider_->key_for_porymap_anim_params(tileset->name()),
284 std::unique_ptr<Tileset>,
285 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
286
288 porymap_anims,
289 key_provider_->discover_porymap_anims(tileset->name()),
290 std::unique_ptr<Tileset>,
291 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
292
293 for (const auto &porymap_anim_name : porymap_anims) {
295 frames,
296 key_provider_->discover_porymap_anim_frames(tileset->name(), porymap_anim_name),
297 std::unique_ptr<Tileset>,
298 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
299
300 std::vector<std::pair<std::string, ArtifactKey>> frames_keys{};
301 for (const auto &frame_name : frames) {
303 frame_key,
304 key_provider_->key_for_porymap_anim_frame(tileset->name(), porymap_anim_name, frame_name),
305 std::unique_ptr<Tileset>,
306 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
307
308 if (!key_provider_->artifact_exists(frame_key)) {
309 return FormattableError{missing_required_artifact_msg, FormatParam{frame_key.key(), Style::bold}};
310 }
311 frames_keys.emplace_back(frame_name, frame_key);
312 }
313
315 reader_->read_porymap_anim(*tileset, porymap_anim_name, porymap_anim_params_key, frames_keys),
316 std::unique_ptr<Tileset>,
317 "Failed to read animation '{}'.",
318 FormatParam(porymap_anim_name, Style::bold));
319 }
320
321 // Porytiles artifacts
323 bottom_png_key,
324 key_provider_->key_for_bottom_png(tileset->name()),
325 std::unique_ptr<Tileset>,
326 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
327 if (key_provider_->artifact_exists(bottom_png_key)) {
329 reader_->read_bottom_png(*tileset, bottom_png_key),
330 std::unique_ptr<Tileset>,
331 "Failed to read artifact '{}'.",
332 FormatParam(bottom_png_key.key(), Style::bold));
333 }
334
336 middle_png_key,
337 key_provider_->key_for_middle_png(tileset->name()),
338 std::unique_ptr<Tileset>,
339 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
340 if (key_provider_->artifact_exists(middle_png_key)) {
342 reader_->read_middle_png(*tileset, middle_png_key),
343 std::unique_ptr<Tileset>,
344 "Failed to read artifact '{}'.",
345 FormatParam(middle_png_key.key(), Style::bold));
346 }
347
349 top_png_key,
350 key_provider_->key_for_top_png(tileset->name()),
351 std::unique_ptr<Tileset>,
352 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
353 if (key_provider_->artifact_exists(top_png_key)) {
355 reader_->read_top_png(*tileset, top_png_key),
356 std::unique_ptr<Tileset>,
357 "Failed to read artifact '{}'.",
358 FormatParam(top_png_key.key(), Style::bold));
359 }
360
362 attribute_csv_key,
363 key_provider_->key_for_attributes_csv(tileset->name()),
364 std::unique_ptr<Tileset>,
365 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
366 if (key_provider_->artifact_exists(attribute_csv_key)) {
368 reader_->read_attributes_csv(*tileset, attribute_csv_key),
369 std::unique_ptr<Tileset>,
370 "Failed to read artifact '{}'.",
371 FormatParam(attribute_csv_key.key(), Style::bold));
372 }
373 else {
374 diag_->warning(
375 missing_optional_artifact_tag,
376 missing_optional_artifact_msg,
377 FormatParam{attribute_csv_key.key(), Style::bold});
378 diag_->warning_note(missing_optional_artifact_tag, "All attributes will receive default or inferred values.");
379 }
380
381 for (std::size_t i = 0; i < palette::num_palettes; i++) {
383 override_key,
384 key_provider_->key_for_porytiles_palette_n(tileset->name(), i),
385 std::unique_ptr<Tileset>,
386 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
387 if (key_provider_->artifact_exists(override_key)) {
389 reader_->read_porytiles_palette_n(*tileset, override_key, i),
390 std::unique_ptr<Tileset>,
391 "Failed to read artifact '{}'.",
392 FormatParam(override_key.key(), Style::bold));
393 }
394 }
395
396 // Load Porytiles animations using unified read method
398 porytiles_params_key,
399 key_provider_->key_for_porytiles_anim_params(tileset->name()),
400 std::unique_ptr<Tileset>,
401 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
402
403 if (key_provider_->artifact_exists(porytiles_params_key)) {
405 porytiles_anims,
406 key_provider_->discover_porytiles_anims(tileset->name()),
407 std::unique_ptr<Tileset>,
408 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
409
410 for (const auto &anim_name : porytiles_anims) {
411 // Check if key frame exists (only present for automatic/hybrid frame linking)
413 key_frame_key_candidate,
414 key_provider_->key_for_porytiles_anim_frame(tileset->name(), anim_name, "key"),
415 std::unique_ptr<Tileset>,
416 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
417
418 std::optional<ArtifactKey> key_frame_key{};
419 if (key_provider_->artifact_exists(key_frame_key_candidate)) {
420 key_frame_key = key_frame_key_candidate;
421 }
422
424 frame_names,
425 key_provider_->discover_porytiles_anim_frames(tileset->name(), anim_name),
426 std::unique_ptr<Tileset>,
427 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
428
429 // Build frame_keys vector for unified read
430 std::vector<std::pair<std::string, ArtifactKey>> frame_keys{};
431 bool anim_has_missing_frames = false;
432 for (const auto &frame_name : frame_names) {
433 // Skip "key" frame in frame_keys since it's handled separately via key_frame_key
434 if (frame_name == "key") {
435 continue;
436 }
437
439 frame_key,
440 key_provider_->key_for_porytiles_anim_frame(tileset->name(), anim_name, frame_name),
441 std::unique_ptr<Tileset>,
442 diag_->formatter().format(
443 "Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
444
445 if (!key_provider_->artifact_exists(frame_key)) {
446 diag_->error(
447 missing_required_artifact_tag,
448 missing_required_artifact_msg,
449 FormatParam{frame_key.key(), Style::bold});
450 fail_at_exit = true;
451 anim_has_missing_frames = true;
452 continue;
453 }
454 frame_keys.emplace_back(frame_name, frame_key);
455 }
456
457 if (anim_has_missing_frames) {
458 continue; // Skip this animation if it has missing frames
459 }
460
461 // Load complete animation with unified method
463 reader_->read_porytiles_anim(*tileset, anim_name, porytiles_params_key, key_frame_key, frame_keys),
464 std::unique_ptr<Tileset>,
465 "Failed to load Porytiles animation '{}'.",
466 FormatParam(anim_name, Style::bold));
467 }
468
469 // Load primary animation references from same anim.json (validated at compile time)
471 reader_->read_porytiles_primary_anim_references(*tileset, porytiles_params_key),
472 std::unique_ptr<Tileset>,
473 "Failed to load primary animation references.");
474 }
475
476 if (fail_at_exit) {
477 return FormattableError{"Errors while loading tileset '{}'.", FormatParam{tileset->name(), Style::bold}};
478 }
479
480 return tileset;
481}
482
483bool TilesetRepo::exists(const std::string &tileset_name) const
484{
485 return metadata_provider_->exists(tileset_name);
486}
487
488} // namespace porytiles
#define PT_TRY_ASSIGN_CHAIN_ERR(var, expr, return_type,...)
Unwraps a ChainableResult, chaining a new error message on failure.
#define PT_TRY_CALL_CHAIN_ERR(expr, return_type,...)
Unwraps a void ChainableResult, chaining a new error message on failure.
virtual ChainableResult< void > cache_tileset_checksums(const std::string &name, const std::unordered_map< ArtifactKey, std::string > &checksums) const =0
Caches checksums for the given Tileset to persistent storage.
virtual std::unordered_map< ArtifactKey, std::string > compute_tileset_artifact_checksums(const std::vector< ArtifactKey > &keys) const =0
Computes checksums for the given Tileset artifacts.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
A text parameter with associated styling for formatted output.
General-purpose error implementation with formatted message support.
Definition error.hpp:57
static const Style bold
Bold text formatting.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > &params) const
Formats a string with styled parameters using fmtlib syntax.
virtual ChainableResult< ArtifactKey > key_for_porytiles_palette_n(const std::string &tileset_name, std::size_t index) const =0
virtual ChainableResult< ArtifactKey > key_for_porymap_palette_n(const std::string &tileset_name, std::size_t index) const =0
virtual ChainableResult< std::set< std::string > > discover_porytiles_anims(const std::string &tileset_name) const =0
Discovers the names of all Porytiles animations available for a tileset.
virtual ChainableResult< std::vector< ArtifactKey > > get_all_artifact_keys(const std::string &tileset_name) const
Gets the keys for all tileset artifacts (both Porytiles and Porymap) present in the given Tileset.
virtual ChainableResult< std::set< std::string > > discover_porymap_anims(const std::string &tileset_name) const =0
Discovers the names of all Porymap animations available for a tileset.
virtual ChainableResult< ArtifactKey > key_for_attributes_csv(const std::string &tileset_name) const =0
virtual ChainableResult< ArtifactKey > key_for_metatiles_bin(const std::string &tileset_name) const =0
virtual ChainableResult< ArtifactKey > key_for_porytiles_anim_frame(const std::string &tileset_name, const std::string &anim_name, const std::string &frame_name) const =0
virtual ChainableResult< ArtifactKey > key_for_metatile_attributes_bin(const std::string &tileset_name) const =0
virtual ChainableResult< std::set< std::string > > discover_porymap_anim_frames(const std::string &tileset_name, const std::string &anim_name) const =0
Discovers the frame indices for a specific Porymap animation.
virtual ChainableResult< ArtifactKey > key_for_porytiles_anim_params(const std::string &tileset_name) const =0
Returns the key for Porytiles animation parameters.
virtual ChainableResult< ArtifactKey > key_for_porymap_anim_params(const std::string &tileset_name) const =0
virtual ChainableResult< std::set< std::string > > discover_porytiles_anim_frames(const std::string &tileset_name, const std::string &anim_name) const =0
Discovers the frame indices for a specific Porytiles animation.
virtual ChainableResult< ArtifactKey > key_for_middle_png(const std::string &tileset_name) const =0
virtual ChainableResult< ArtifactKey > key_for_porymap_anim_frame(const std::string &tileset_name, const std::string &anim_name, const std::string &frame_name) const =0
virtual ChainableResult< ArtifactKey > key_for_tiles_png(const std::string &tileset_name) const =0
virtual ChainableResult< ArtifactKey > key_for_top_png(const std::string &tileset_name) const =0
virtual ChainableResult< ArtifactKey > key_for_bottom_png(const std::string &tileset_name) const =0
virtual bool artifact_exists(const ArtifactKey &key) const =0
Checks whether an artifact exists in the backing store for the given key.
virtual ChainableResult< void > read_attributes_csv(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_porymap_anim(Tileset &dest, const std::string &anim_name, const ArtifactKey &params_key, const std::vector< std::pair< std::string, ArtifactKey > > &frame_keys) const =0
virtual ChainableResult< void > read_porymap_palette_n(Tileset &dest, const ArtifactKey &src_key, std::size_t index) const =0
virtual ChainableResult< void > read_tiles_png(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_top_png(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_metatile_attributes_bin(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_porytiles_anim(Tileset &dest, const std::string &anim_name, const ArtifactKey &params_key, const std::optional< ArtifactKey > &key_frame_key, const std::vector< std::pair< std::string, ArtifactKey > > &frame_keys) const =0
virtual ChainableResult< void > read_porytiles_palette_n(Tileset &dest, const ArtifactKey &src_key, std::size_t index) const =0
virtual ChainableResult< void > read_middle_png(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_porytiles_primary_anim_references(Tileset &dest, const ArtifactKey &params_key) const =0
virtual ChainableResult< void > read_metatiles_bin(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_bottom_png(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > write_porymap_palette_n(const ArtifactKey &dest_key, const Tileset &src, std::size_t index)=0
virtual ChainableResult< void > write_porytiles_anim_frame(const ArtifactKey &dest_key, const Tileset &src, const std::string &anim_name, const std::string &frame_name)=0
virtual ChainableResult< void > write_porymap_anim_params(const ArtifactKey &dest_key, const Tileset &src)=0
Writes the animation parameters to the Porymap component backing store.
virtual ChainableResult< void > write_porytiles_palette_n(const ArtifactKey &dest_key, const Tileset &src, std::size_t index)=0
virtual ChainableResult< void > write_metatiles_bin(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > begin_transaction()=0
Begins a new transaction for atomic write operations.
virtual ChainableResult< void > write_tiles_png(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > rollback()=0
Rolls back all buffered write operations in the current transaction.
virtual ChainableResult< void > write_bottom_png(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > write_top_png(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > write_porytiles_anim_params(const ArtifactKey &dest_key, const Tileset &src)=0
Writes animation parameters to the Porytiles component backing store.
virtual ChainableResult< void > write_metatile_attributes_bin(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > write_attributes_csv(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > write_middle_png(const ArtifactKey &dest_key, const Tileset &src)=0
virtual ChainableResult< void > write_porymap_anim_frame(const ArtifactKey &dest_key, const Tileset &src, const std::string &anim_name, const std::string &frame_name)=0
virtual ChainableResult< void > commit()=0
Commits all buffered write operations in the current transaction.
virtual bool exists(const std::string &tileset_name) const =0
Checks whether a tileset exists in the backing store for the given tileset name.
ChainableResult< void > save(const Tileset &tileset) const
Persists a given Tileset and caches new artifact checksums.
bool exists(const std::string &tileset_name) const
Checks if the given Tileset exists in the backing store.
ChainableResult< std::unique_ptr< Tileset > > load(const std::string &name) const
Loads an existing Tileset from storage.
A complete tileset containing both Porytiles and Porymap components.
Definition tileset.hpp:12
virtual void warning_note(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged note message associated with a warning.
const TextFormatter & formatter() const
virtual void warning(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged warning message.
virtual void error(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged error message.
std::string name
constexpr std::size_t num_palettes
Definition palette.hpp:21
@ tileset
Configuration scoped to a specific tileset.