yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
project_graphics_import_command.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_PROJECT_GRAPHICS_IMPORT_COMMAND_H_
2#define YAZE_APP_EDITOR_OVERWORLD_PROJECT_GRAPHICS_IMPORT_COMMAND_H_
3
4#include <functional>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
13
14namespace yaze::editor {
15
16class ProjectGraphicsSource;
17
18// Access one resource in the active document, resolving its current binding on
19// every call. A replacement must either succeed completely or leave it alone.
20// These callbacks never publish source files or write ROM bytes.
22 std::function<absl::StatusOr<std::vector<uint8_t>>()> read;
23 std::function<absl::Status(const std::vector<uint8_t>&)> replace;
24};
25
26using ProjectGraphicsImportRefresh = std::function<absl::Status()>;
28 std::function<absl::StatusOr<std::string>(const ProjectGraphicsSource&)>;
29
30// Returns an unapplied action; only its caller pushes the parent history step.
31// The prepared definitions participant must be unapplied and internally atomic.
32// Refresh synchronizes pending characters/palettes before definitions render and
33// refreshes the complete view afterward. Palette notifications follow success.
34// On failure all completed participants are reversed, then the restored view is
35// refreshed after PaletteManager restores its tracking and values. A rollback
36// failure is reported and disables further replay of this action.
37// owner and the definitions session must outlive the action.
38absl::StatusOr<std::unique_ptr<UndoAction>> CreateProjectGraphicsImportAction(
40 const ProjectGraphicsImportPlan& plan,
41 std::unique_ptr<UndoAction> prepared_definitions,
43 std::string description = "Import project graphics");
44
45// Normal ProjectGraphicsSource adapter. The resolver belongs to the caller and
46// must identify the same consumer binding, not capture a source path/hash: a
47// successful Publish may change both. Reads and replacements resolve afresh.
48absl::StatusOr<std::unique_ptr<UndoAction>> CreateProjectGraphicsImportAction(
49 std::shared_ptr<ProjectGraphicsSource> source,
51 const ProjectGraphicsImportPlan& plan,
52 std::unique_ptr<UndoAction> prepared_definitions,
54 std::string description = "Import project graphics");
55
56} // namespace yaze::editor
57
58#endif // YAZE_APP_EDITOR_OVERWORLD_PROJECT_GRAPHICS_IMPORT_COMMAND_H_
Editors are the view controllers for the application.
std::function< absl::Status()> ProjectGraphicsImportRefresh
std::function< absl::StatusOr< std::string >(const ProjectGraphicsSource &)> ProjectGraphicsImportResourceResolver
absl::StatusOr< std::unique_ptr< UndoAction > > CreateProjectGraphicsImportAction(ProjectGraphicsImportResourceCallbacks resource, const ProjectGraphicsImportPlan &plan, std::unique_ptr< UndoAction > prepared_definitions, const zelda3::GameData *owner, ProjectGraphicsImportRefresh refresh, std::string description)
std::function< absl::StatusOr< std::vector< uint8_t > >()> read
std::function< absl::Status(const std::vector< uint8_t > &) replace)