#pragma once #include #include #include #include #include #include #include #include "image.h" #include "model/draw.h" #include "model/frames.h" #include "model/model.h" // Document edits as plain functions of the model. Each returns the uids of the elements it created or changed that // the caller may want to select (the first one is the focus). Selection itself stays with the UI. using Uids = std::vector; using ImageGet = std::function; struct RowTarget { bool isGroup = false; int type = NONE; int id = -1; int groupId = -1; }; struct GridOptions { IVec2 start{}; IVec2 size{}; Vec2 pivot{}; int columns = 0; int count = 0; int delay = 0; bool isMakeRegions = false; std::string regionNameFormat; }; struct ChangeTargets { std::set references; std::set animations; bool isRoot = false; bool isLayers = false; bool isNulls = false; }; struct AnimationTarget { int animationIndex = -1; int groupId = -1; bool isAfter = false; bool isInto = false; }; // Frame properties that can be copied on their own. // Each frame property: the tracks that have it (all but triggers, layers only, or triggers only) and what copying it // takes from a source frame. #define FRAME_PROPERTIES(X) \ X(POSITION, FRAMES, target.position = source.position) \ X(SCALE, FRAMES, target.scale = source.scale) \ X(ROTATION, FRAMES, target.rotation = source.rotation) \ X(SKEW, FRAMES, target.skew = source.skew) \ X(PIVOT, LAYERS, target.pivot = source.pivot) \ X(CROP, LAYERS, target.crop = source.crop) \ X(SIZE, LAYERS, target.size = source.size) \ X(REGION, LAYERS, target.regionId = source.regionId; target.crop = source.crop; target.size = source.size; \ target.pivot = source.pivot) \ X(TINT, FRAMES, target.tint = source.tint) \ X(COLOR_OFFSET, FRAMES, target.colorOffset = source.colorOffset) \ X(VISIBLE, FRAMES, target.isVisible = source.isVisible) \ X(INTERPOLATION, FRAMES, target.interpolation = source.interpolation) \ X(DURATION, FRAMES, target.duration = source.duration) \ X(SHADER, LAYERS, target.shaderId = source.shaderId) \ X(DEPTH, LAYERS, target.depth = source.depth) \ X(BLUR, LAYERS, target.blur = source.blur) \ X(CHILD, LAYERS, target.childAnimation = source.childAnimation; target.childMode = source.childMode; \ target.childStart = source.childStart; target.isChildStartRandom = source.isChildStartRandom; \ target.isChildRestart = source.isChildRestart) \ X(EVENT, TRIGGERS, target.eventIds = source.eventIds) \ X(SOUNDS, TRIGGERS, target.soundIds = source.soundIds) enum class FrameProperty { #define X(property, tracks, ...) property, FRAME_PROPERTIES(X) #undef X COUNT }; bool is_frame_property_valid(FrameProperty, ItemType); void frame_property_copy(Frame&, const Frame&, FrameProperty); Uids frames_property_set(Model&, const std::set&, FrameProperty, const Frame&); std::map> frames_by_track_get(const std::set&); Uids frame_insert(Model&, Reference, int); void frames_delete(Model&, const std::set&); Uids frames_duplicate(Model&, const std::set&, Reference); void frames_reverse(Model&, const std::set&); Uids frames_bake(Model&, const std::set&, int, BakeOptions); Uids frame_split(Model&, Reference, int); Uids frames_split(Model&, const std::set&, int); Uids frames_move(Model&, const std::set&, Reference, int); void frame_durations_set(Model&, const std::map&); void trigger_at_frame_set(Model&, Reference, int); Uids frames_paste(Model&, Reference, const std::set&, const std::string&, int, std::string*); Uids root_bake_into(Model&, const std::set&, const std::set&, BakeOptions); void items_remove(Model&, int, const std::map>&, const std::map>&); Uids items_group(Model&, int, int, const std::set&, const std::string&); void items_move(Model&, int, int, const std::set&, const std::set&, RowTarget, bool, bool); void animation_length_fit(Model&, int); int item_add(Model&, ItemType, int, int, Layer, Null, int, Destination); std::set animation_group_ids_get(const Model&); std::set animation_group_indices_get(const Model&, int); void animation_groups_remove(Model&, const std::set&); Uids animation_add(Model&, int, int, int, const std::string&); void animations_remove(Model&, const std::set&, const std::set&); Uids animations_move(Model&, const std::set&, const std::set&, AnimationTarget); void animations_group(Model&, const std::set&, const std::string&); Uids animations_paste(Model&, const std::string&, int, int, std::set&, std::string*); Uids animations_merge(Model&, int, std::set, Merge, bool, const std::set&); std::string region_name_get(const std::string&, int); void regions_generate(Model&, const std::set&, const std::set&, const std::string&, RegionFrameMapping); void regions_scan(Model&); void region_frames_sync(Model&); void regions_paste(Model&, int, const std::string&, int, std::string*); Uids animation_grid_generate(Model&, const std::vector&, const GridOptions&); Uids frames_change_apply(Model&, const ChangeTargets&, FrameChange, ChangeType); bool regions_trim(Model&, int, const std::set&, const Image&); std::optional spritesheet_pack(Model&, int, const Image&, int); std::optional spritesheets_merge(Model&, const std::set&, const ImageGet&, bool, bool, bool, Origin); // Where a spritesheet path of a document (this one, or a library) points, from this document. using SpritesheetPathGet = std::function; Model animation_layers_flatten(Model, const LibraryGet&, const SpritesheetPathGet&, const std::set& = {}); void content_remove(Model&, ElementType, const std::set&, int, const LibraryGet&, const SpritesheetPathGet&); Model isaac_bridge(Model); bool file_merge(Model&, const std::filesystem::path&, const std::filesystem::path&, FileMergePreset);