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 /*
25 * Porymap artifacts
26 */
28 metatiles_key, key_provider_->key_for_metatiles_bin(tileset.name()), void, "Tileset save failed.");
29 if (auto result = writer_->write_metatiles_bin(metatiles_key, tileset); !result.has_value()) {
30 std::ignore = writer_->rollback();
31 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{metatiles_key.key(), Style::bold}};
32 return ChainableResult<void>{failed, result};
33 }
34
36 attr_key, key_provider_->key_for_metatile_attributes_bin(tileset.name()), void, "Tileset save failed.");
37 if (auto result = writer_->write_metatile_attributes_bin(attr_key, tileset); !result.has_value()) {
38 std::ignore = writer_->rollback();
39 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{attr_key.key(), Style::bold}};
40 return ChainableResult<void>{failed, result};
41 }
42
44 tiles_png_key, key_provider_->key_for_tiles_png(tileset.name()), void, "Tileset save failed.");
45 if (auto result = writer_->write_tiles_png(tiles_png_key, tileset); !result.has_value()) {
46 std::ignore = writer_->rollback();
47 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{tiles_png_key.key(), Style::bold}};
48 return ChainableResult<void>{failed, result};
49 }
50
51 for (std::size_t i = 0; i < pal::num_pals; i++) {
53 pal_key, key_provider_->key_for_porymap_pal_n(tileset.name(), i), void, "Tileset save failed.");
54 if (auto result = writer_->write_porymap_pal_n(pal_key, tileset, i); !result.has_value()) {
55 std::ignore = writer_->rollback();
56 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{pal_key.key(), Style::bold}};
57 return ChainableResult<void>{failed, result};
58 }
59 }
60
61 for (const auto &porymap_anim : tileset.porymap_component().anims() | std::views::values) {
62 for (const auto &frame : porymap_anim.frames_values()) {
64 frame_key,
65 key_provider_->key_for_porymap_anim_frame(tileset.name(), porymap_anim.name(), frame.frame_name()),
66 void,
67 "Tileset save failed.");
68 if (auto result =
69 writer_->write_porymap_anim_frame(frame_key, tileset, porymap_anim.name(), frame.frame_name());
70 !result.has_value()) {
71 std::ignore = writer_->rollback();
72 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{frame_key.key(), Style::bold}};
73 return ChainableResult<void>{failed, result};
74 }
75 }
76 }
77
79 generated_anim_code_key,
80 key_provider_->key_for_porymap_anim_params(tileset.name()),
81 void,
82 "Tileset save failed.");
83 if (auto result = writer_->write_porymap_anim_params(generated_anim_code_key, tileset); !result.has_value()) {
84 std::ignore = writer_->rollback();
85 auto failed =
86 FormattableError{"Save failed for '{}'.", FormatParam{generated_anim_code_key.key(), Style::bold}};
87 return ChainableResult<void>{failed, result};
88 }
89
90 /*
91 * Porytiles artifacts
92 */
94 bottom_png_key, key_provider_->key_for_bottom_png(tileset.name()), void, "Tileset save failed.");
95 if (auto result = writer_->write_bottom_png(bottom_png_key, tileset); !result.has_value()) {
96 std::ignore = writer_->rollback();
97 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{bottom_png_key.key(), Style::bold}};
98 return ChainableResult<void>{failed, result};
99 }
100
102 middle_png_key, key_provider_->key_for_middle_png(tileset.name()), void, "Tileset save failed.");
103 if (auto result = writer_->write_middle_png(middle_png_key, tileset); !result.has_value()) {
104 std::ignore = writer_->rollback();
105 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{middle_png_key.key(), Style::bold}};
106 return ChainableResult<void>{failed, result};
107 }
108
109 PT_TRY_ASSIGN_CHAIN_ERR(top_png_key, key_provider_->key_for_top_png(tileset.name()), void, "Tileset save failed.");
110 if (auto result = writer_->write_top_png(top_png_key, tileset); !result.has_value()) {
111 std::ignore = writer_->rollback();
112 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{top_png_key.key(), Style::bold}};
113 return ChainableResult<void>{failed, result};
114 }
115
117 attr_csv_key, key_provider_->key_for_attributes_csv(tileset.name()), void, "Tileset save failed.");
118 if (auto result = writer_->write_attributes_csv(attr_csv_key, tileset); !result.has_value()) {
119 std::ignore = writer_->rollback();
120 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{attr_csv_key.key(), Style::bold}};
121 return ChainableResult<void>{failed, result};
122 }
123
124 for (std::size_t i = 0; i < pal::num_pals; i++) {
126 porytiles_pal_key, key_provider_->key_for_porytiles_pal_n(tileset.name(), i), void, "Tileset save failed.");
127 if (auto result = writer_->write_porytiles_pal_n(porytiles_pal_key, tileset, i); !result.has_value()) {
128 std::ignore = writer_->rollback();
129 auto failed = FormattableError{"Save failed for '{}'.", FormatParam{porytiles_pal_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 /*
218 * Porymap artifacts
219 */
221 metatiles_key,
222 key_provider_->key_for_metatiles_bin(tileset->name()),
223 std::unique_ptr<Tileset>,
224 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
225 if (!key_provider_->artifact_exists(metatiles_key)) {
226 return FormattableError{missing_required_artifact_msg, FormatParam{metatiles_key.key(), Style::bold}};
227 }
229 reader_->read_metatiles_bin(*tileset, metatiles_key),
230 std::unique_ptr<Tileset>,
231 "Failed to read artifact: '{}'.",
232 FormatParam(metatiles_key.key(), Style::bold));
233
235 attr_key,
236 key_provider_->key_for_metatile_attributes_bin(tileset->name()),
237 std::unique_ptr<Tileset>,
238 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
239 if (!key_provider_->artifact_exists(attr_key)) {
240 return FormattableError{missing_required_artifact_msg, FormatParam{attr_key.key(), Style::bold}};
241 }
243 reader_->read_metatile_attributes_bin(*tileset, attr_key),
244 std::unique_ptr<Tileset>,
245 "Failed to read artifact: '{}'.",
246 FormatParam(attr_key.key(), Style::bold));
247
249 tiles_png_key,
250 key_provider_->key_for_tiles_png(tileset->name()),
251 std::unique_ptr<Tileset>,
252 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
253 if (!key_provider_->artifact_exists(tiles_png_key)) {
254 return FormattableError{missing_required_artifact_msg, FormatParam{tiles_png_key.key(), Style::bold}};
255 }
257 reader_->read_tiles_png(*tileset, tiles_png_key),
258 std::unique_ptr<Tileset>,
259 "Failed to read artifact '{}'.",
260 FormatParam(tiles_png_key.key(), Style::bold));
261
262 for (std::size_t i = 0; i < pal::num_pals; i++) {
264 pal_key,
265 key_provider_->key_for_porymap_pal_n(tileset->name(), i),
266 std::unique_ptr<Tileset>,
267 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
268 if (!key_provider_->artifact_exists(pal_key)) {
269 diag_->error(
270 missing_required_artifact_tag, missing_required_artifact_msg, FormatParam{pal_key.key(), Style::bold});
271 fail_at_exit = true;
272 continue;
273 }
275 reader_->read_porymap_pal_n(*tileset, pal_key, i),
276 std::unique_ptr<Tileset>,
277 "Failed to read artifact '{}'.",
278 FormatParam(pal_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 /*
322 * Porytiles artifacts
323 */
325 bottom_png_key,
326 key_provider_->key_for_bottom_png(tileset->name()),
327 std::unique_ptr<Tileset>,
328 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
329 if (key_provider_->artifact_exists(bottom_png_key)) {
331 reader_->read_bottom_png(*tileset, bottom_png_key),
332 std::unique_ptr<Tileset>,
333 "Failed to read artifact '{}'.",
334 FormatParam(bottom_png_key.key(), Style::bold));
335 }
336
338 middle_png_key,
339 key_provider_->key_for_middle_png(tileset->name()),
340 std::unique_ptr<Tileset>,
341 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
342 if (key_provider_->artifact_exists(middle_png_key)) {
344 reader_->read_middle_png(*tileset, middle_png_key),
345 std::unique_ptr<Tileset>,
346 "Failed to read artifact '{}'.",
347 FormatParam(middle_png_key.key(), Style::bold));
348 }
349
351 top_png_key,
352 key_provider_->key_for_top_png(tileset->name()),
353 std::unique_ptr<Tileset>,
354 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
355 if (key_provider_->artifact_exists(top_png_key)) {
357 reader_->read_top_png(*tileset, top_png_key),
358 std::unique_ptr<Tileset>,
359 "Failed to read artifact '{}'.",
360 FormatParam(top_png_key.key(), Style::bold));
361 }
362
364 attr_csv_key,
365 key_provider_->key_for_attributes_csv(tileset->name()),
366 std::unique_ptr<Tileset>,
367 diag_->formatter().format("Failed to load tileset '{}'.", FormatParam{tileset->name(), Style::bold}));
368 if (key_provider_->artifact_exists(attr_csv_key)) {
370 reader_->read_attributes_csv(*tileset, attr_csv_key),
371 std::unique_ptr<Tileset>,
372 "Failed to read artifact '{}'.",
373 FormatParam(attr_csv_key.key(), Style::bold));
374 }
375 else {
376 diag_->warning(
377 missing_optional_artifact_tag, missing_optional_artifact_msg, FormatParam{attr_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 < pal::num_pals; i++) {
383 override_key,
384 key_provider_->key_for_porytiles_pal_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_pal_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:63
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< 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_pal_n(const std::string &tileset_name, std::size_t index) 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_porymap_pal_n(const std::string &tileset_name, std::size_t index) const =0
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_tiles_png(Tileset &dest, const ArtifactKey &src_key) const =0
virtual ChainableResult< void > read_porytiles_pal_n(Tileset &dest, const ArtifactKey &src_key, std::size_t index) const =0
virtual ChainableResult< void > read_porymap_pal_n(Tileset &dest, const ArtifactKey &src_key, std::size_t index) 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_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_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_porytiles_pal_n(const ArtifactKey &dest_key, const Tileset &src, std::size_t index)=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_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_porymap_pal_n(const ArtifactKey &dest_key, const Tileset &src, std::size_t index)=0
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:14
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.
constexpr std::size_t num_pals
Definition palette.hpp:21
@ tileset
Configuration scoped to a specific tileset.