Name row drops, merge sources, playback looping and spritesheet merge options
items_move takes a DropZone, animations_merge MergeSources, Playback::tick PlaybackLoop, and spritesheets_merge SpritesheetMergeOptions.
This commit is contained in:
1 parent
228a15b5b3
commit
ada48aefdd
19 files changed
+78
-53
No files matched your search
+2
-5
@@ -645,12 +645,9 @@ bool Document::spritesheet_pack(int id, int padding)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Document::spritesheets_merge(const std::set<int>& ids, bool isAppendRight, bool isMakeRegions,
|
bool Document::spritesheets_merge(const std::set<int>& ids, SpritesheetMergeOptions options)
|
||||||
bool isMakePrimaryRegion, Origin origin)
|
|
||||||
{
|
{
|
||||||
auto merged = ::spritesheets_merge(
|
auto merged = ::spritesheets_merge(model, ids, [this](int id) { return texture_get(id); }, options);
|
||||||
model, ids, [this](int id) { return texture_get(id); }, isAppendRight, isMakeRegions, isMakePrimaryRegion,
|
|
||||||
origin);
|
|
||||||
if (!merged)
|
if (!merged)
|
||||||
return false;
|
return false;
|
||||||
texture_set(*ids.begin(), std::move(*merged));
|
texture_set(*ids.begin(), std::move(*merged));
|
||||||
|
|||||||
+1
-1
@@ -157,7 +157,7 @@ public:
|
|||||||
void library_reload(int);
|
void library_reload(int);
|
||||||
bool regions_trim(int, const std::set<int>&);
|
bool regions_trim(int, const std::set<int>&);
|
||||||
bool spritesheet_pack(int, int);
|
bool spritesheet_pack(int, int);
|
||||||
bool spritesheets_merge(const std::set<int>&, bool, bool, bool, Origin);
|
bool spritesheets_merge(const std::set<int>&, SpritesheetMergeOptions);
|
||||||
void hash_set();
|
void hash_set();
|
||||||
void clean();
|
void clean();
|
||||||
void change();
|
void change();
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ static void track_entries_merge(std::vector<TrackEntry>& destination, const std:
|
|||||||
|
|
||||||
// Merges source animations into the target (frames appended, prepended, replacing or ignored), optionally deleting
|
// Merges source animations into the target (frames appended, prepended, replacing or ignored), optionally deleting
|
||||||
// the sources. `ungroupIds` dissolves groups afterwards. Returns the merged animation's uid.
|
// the sources. `ungroupIds` dissolves groups afterwards. Returns the merged animation's uid.
|
||||||
Uids animations_merge(Model& model, int target, std::set<int> sources, Merge type, bool isDeleteAfter,
|
Uids animations_merge(Model& model, int target, std::set<int> sources, Merge type, MergeSources sourcesAfter,
|
||||||
const std::set<int>& ungroupIds)
|
const std::set<int>& ungroupIds)
|
||||||
{
|
{
|
||||||
if (!model.animation_get(target))
|
if (!model.animation_get(target))
|
||||||
@@ -346,7 +346,7 @@ Uids animations_merge(Model& model, int target, std::set<int> sources, Merge typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto targetUid = model.animation_get(target)->uid;
|
auto targetUid = model.animation_get(target)->uid;
|
||||||
if (isDeleteAfter)
|
if (sourcesAfter == SOURCES_DELETED)
|
||||||
{
|
{
|
||||||
sources.erase(target);
|
sources.erase(target);
|
||||||
animations_take(model, sources, {});
|
animations_take(model, sources, {});
|
||||||
|
|||||||
+12
-3
@@ -111,7 +111,7 @@ Uids root_bake_into(Model&, const std::set<Reference>&, const std::set<Reference
|
|||||||
|
|
||||||
void items_remove(Model&, int, const std::map<int, std::set<int>>&, const std::map<int, std::set<int>>&);
|
void items_remove(Model&, int, const std::map<int, std::set<int>>&, const std::map<int, std::set<int>>&);
|
||||||
Uids items_group(Model&, int, int, const std::set<int>&, const std::string&);
|
Uids items_group(Model&, int, int, const std::set<int>&, const std::string&);
|
||||||
void items_move(Model&, int, int, const std::set<int>&, const std::set<int>&, RowTarget, bool, bool);
|
void items_move(Model&, int, int, const std::set<int>&, const std::set<int>&, RowTarget, DropZone);
|
||||||
void animation_length_fit(Model&, int);
|
void animation_length_fit(Model&, int);
|
||||||
int item_add(Model&, ItemType, int, int, Layer, Null, int, Destination);
|
int item_add(Model&, ItemType, int, int, Layer, Null, int, Destination);
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ void animations_remove(Model&, const std::set<int>&, const std::set<int>&);
|
|||||||
Uids animations_move(Model&, const std::set<int>&, const std::set<int>&, AnimationTarget);
|
Uids animations_move(Model&, const std::set<int>&, const std::set<int>&, AnimationTarget);
|
||||||
void animations_group(Model&, const std::set<int>&, const std::string&);
|
void animations_group(Model&, const std::set<int>&, const std::string&);
|
||||||
Uids animations_paste(Model&, const std::string&, int, int, std::set<int>&, std::string*);
|
Uids animations_paste(Model&, const std::string&, int, int, std::set<int>&, std::string*);
|
||||||
Uids animations_merge(Model&, int, std::set<int>, Merge, bool, const std::set<int>&);
|
Uids animations_merge(Model&, int, std::set<int>, Merge, MergeSources, const std::set<int>&);
|
||||||
|
|
||||||
std::string region_name_get(const std::string&, int);
|
std::string region_name_get(const std::string&, int);
|
||||||
void regions_generate(Model&, const std::set<int>&, const std::set<Reference>&, const std::string&, RegionFrameMapping);
|
void regions_generate(Model&, const std::set<int>&, const std::set<Reference>&, const std::string&, RegionFrameMapping);
|
||||||
@@ -134,7 +134,16 @@ Uids animation_grid_generate(Model&, const std::vector<Reference>&, const GridOp
|
|||||||
Uids frames_change_apply(Model&, const ChangeTargets&, FrameChange, ChangeType);
|
Uids frames_change_apply(Model&, const ChangeTargets&, FrameChange, ChangeType);
|
||||||
bool regions_trim(Model&, int, const std::set<int>&, const Image&);
|
bool regions_trim(Model&, int, const std::set<int>&, const Image&);
|
||||||
std::optional<Image> spritesheet_pack(Model&, int, const Image&, int);
|
std::optional<Image> spritesheet_pack(Model&, int, const Image&, int);
|
||||||
std::optional<Image> spritesheets_merge(Model&, const std::set<int>&, const ImageGet&, bool, bool, bool, Origin);
|
// How spritesheets merge: side by side or stacked, and the regions made for each sheet.
|
||||||
|
struct SpritesheetMergeOptions
|
||||||
|
{
|
||||||
|
bool isAppendRight = false;
|
||||||
|
bool isMakeRegions = false;
|
||||||
|
bool isMakePrimaryRegion = false;
|
||||||
|
Origin origin = Origin::CUSTOM;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::optional<Image> spritesheets_merge(Model&, const std::set<int>&, const ImageGet&, SpritesheetMergeOptions);
|
||||||
|
|
||||||
// Where a spritesheet path of a document (this one, or a library) points, from this document.
|
// Where a spritesheet path of a document (this one, or a library) points, from this document.
|
||||||
using SpritesheetPathGet = std::function<std::filesystem::path(const Model&, const std::filesystem::path&)>;
|
using SpritesheetPathGet = std::function<std::filesystem::path(const Model&, const std::filesystem::path&)>;
|
||||||
|
|||||||
@@ -110,8 +110,9 @@ std::optional<Image> spritesheet_pack(Model& model, int id, const Image& sheet,
|
|||||||
// Appends sheets to the first, right or below. The result is an SVG (holding any PNG sheets as images) when any of
|
// Appends sheets to the first, right or below. The result is an SVG (holding any PNG sheets as images) when any of
|
||||||
// them is one. The first sheet's path takes the result's extension.
|
// them is one. The first sheet's path takes the result's extension.
|
||||||
std::optional<Image> spritesheets_merge(Model& model, const std::set<int>& ids, const ImageGet& image_get,
|
std::optional<Image> spritesheets_merge(Model& model, const std::set<int>& ids, const ImageGet& image_get,
|
||||||
bool isAppendRight, bool isMakeRegions, bool isMakePrimaryRegion, Origin origin)
|
SpritesheetMergeOptions options)
|
||||||
{
|
{
|
||||||
|
auto [isAppendRight, isMakeRegions, isMakePrimaryRegion, origin] = options;
|
||||||
if (ids.size() < 2)
|
if (ids.size() < 2)
|
||||||
return {};
|
return {};
|
||||||
for (auto id : ids)
|
for (auto id : ids)
|
||||||
|
|||||||
+3
-1
@@ -36,8 +36,10 @@ Uids items_group(Model& model, int animationIndex, int type, const std::set<int>
|
|||||||
// Moves tracks and whole groups next to (or into) a target row. Layers are listed bottom-up, so for them "after" on
|
// Moves tracks and whole groups next to (or into) a target row. Layers are listed bottom-up, so for them "after" on
|
||||||
// screen is "before" in the file.
|
// screen is "before" in the file.
|
||||||
void items_move(Model& model, int animationIndex, int type, const std::set<int>& ids, const std::set<int>& groupIds,
|
void items_move(Model& model, int animationIndex, int type, const std::set<int>& ids, const std::set<int>& groupIds,
|
||||||
RowTarget target, bool isDropAfter, bool isDropIntoGroup)
|
RowTarget target, DropZone zone)
|
||||||
{
|
{
|
||||||
|
auto isDropAfter = zone != DROP_BEFORE;
|
||||||
|
auto isDropIntoGroup = zone == DROP_INSIDE;
|
||||||
if ((target.groupId != -1 && groupIds.contains(target.groupId)) || (target.isGroup && groupIds.contains(target.id)))
|
if ((target.groupId != -1 && groupIds.contains(target.groupId)) || (target.isGroup && groupIds.contains(target.id)))
|
||||||
return;
|
return;
|
||||||
auto entries = track_entries_edit(model, animationIndex, type);
|
auto entries = track_entries_edit(model, animationIndex, type);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
|
|
||||||
@@ -138,6 +139,21 @@ enum class ChangeType
|
|||||||
DIVIDE
|
DIVIDE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Where something dragged lands on a row: before it, into it (a group), or after it.
|
||||||
|
enum DropZone
|
||||||
|
{
|
||||||
|
DROP_BEFORE,
|
||||||
|
DROP_INSIDE,
|
||||||
|
DROP_AFTER
|
||||||
|
};
|
||||||
|
|
||||||
|
// What an animation merge does with the animations merged in.
|
||||||
|
enum MergeSources
|
||||||
|
{
|
||||||
|
SOURCES_KEPT,
|
||||||
|
SOURCES_DELETED
|
||||||
|
};
|
||||||
|
|
||||||
// What a document is written as: the game's copy, the editor's own (embedded in a save), or clipboard text.
|
// What a document is written as: the game's copy, the editor's own (embedded in a save), or clipboard text.
|
||||||
enum SaveMode
|
enum SaveMode
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -18,9 +18,9 @@ void Playback::clamp(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plays the frames [start, end). A playhead outside them starts at start.
|
// Plays the frames [start, end). A playhead outside them starts at start.
|
||||||
void Playback::tick(int fps, int start, int end, bool isLoop, float deltaSeconds)
|
void Playback::tick(int fps, int start, int end, PlaybackLoop loop, float deltaSeconds)
|
||||||
{
|
{
|
||||||
if (isLoop)
|
if (loop == PLAYBACK_LOOP)
|
||||||
isFinished = false;
|
isFinished = false;
|
||||||
if (isFinished || !isPlaying || fps <= 0 || end <= start)
|
if (isFinished || !isPlaying || fps <= 0 || end <= start)
|
||||||
return;
|
return;
|
||||||
@@ -31,7 +31,7 @@ void Playback::tick(int fps, int start, int end, bool isLoop, float deltaSeconds
|
|||||||
time = (float)start;
|
time = (float)start;
|
||||||
time += deltaSeconds * (float)fps;
|
time += deltaSeconds * (float)fps;
|
||||||
|
|
||||||
if (isLoop)
|
if (loop == PLAYBACK_LOOP)
|
||||||
{
|
{
|
||||||
time = (float)start + std::fmod(time - (float)start, (float)(end - start));
|
time = (float)start + std::fmod(time - (float)start, (float)(end - start));
|
||||||
return;
|
return;
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
enum PlaybackLoop
|
||||||
|
{
|
||||||
|
PLAYBACK_ONCE,
|
||||||
|
PLAYBACK_LOOP
|
||||||
|
};
|
||||||
|
|
||||||
class Playback
|
class Playback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -9,7 +15,7 @@ public:
|
|||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
void clamp(int);
|
void clamp(int);
|
||||||
void tick(int, int, int, bool, float);
|
void tick(int, int, int, PlaybackLoop, float);
|
||||||
void decrement(int);
|
void decrement(int);
|
||||||
void increment(int);
|
void increment(int);
|
||||||
};
|
};
|
||||||
@@ -163,8 +163,8 @@ void AnimationPreview::tick(Manager& manager, Settings& settings, float deltaSec
|
|||||||
auto range = animation_play_range_get(*animation);
|
auto range = animation_play_range_get(*animation);
|
||||||
if (!wasPlaybackPlaying)
|
if (!wasPlaybackPlaying)
|
||||||
soundFrame = (int)std::floor(playback.time) - 1;
|
soundFrame = (int)std::floor(playback.time) - 1;
|
||||||
playback.tick(fps, range.x, range.y, (animation->isLoop || settings.playbackIsLoop) && !manager.isRecording,
|
auto isLoop = (animation->isLoop || settings.playbackIsLoop) && !manager.isRecording;
|
||||||
deltaSeconds);
|
playback.tick(fps, range.x, range.y, isLoop ? PLAYBACK_LOOP : PLAYBACK_ONCE, deltaSeconds);
|
||||||
|
|
||||||
// Each frame playback reaches plays its trigger's sound once, however many ticks it lasts or skips.
|
// Each frame playback reaches plays its trigger's sound once, however many ticks it lasts or skips.
|
||||||
auto frame = (int)std::floor(playback.time);
|
auto frame = (int)std::floor(playback.time);
|
||||||
|
|||||||
@@ -227,7 +227,8 @@ static int animations_merge(Document& document, const AnimationMergeOptions& opt
|
|||||||
int merged = -1;
|
int merged = -1;
|
||||||
document.edit_apply(EDIT_MERGE_ANIMATIONS, [&](Model& model) {
|
document.edit_apply(EDIT_MERGE_ANIMATIONS, [&](Model& model) {
|
||||||
animation_overlay_reset(document, sources);
|
animation_overlay_reset(document, sources);
|
||||||
auto uids = animations_merge(model, target, sources, type, isDeleteAfter, ungroupIds);
|
auto uids =
|
||||||
|
animations_merge(model, target, sources, type, isDeleteAfter ? SOURCES_DELETED : SOURCES_KEPT, ungroupIds);
|
||||||
auto indices = animation_indices_get(document, uids);
|
auto indices = animation_indices_get(document, uids);
|
||||||
if (indices.empty())
|
if (indices.empty())
|
||||||
return uids;
|
return uids;
|
||||||
|
|||||||
+2
-7
@@ -1,15 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "model/common.h"
|
||||||
|
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
enum DropZone
|
|
||||||
{
|
|
||||||
DROP_BEFORE,
|
|
||||||
DROP_INSIDE,
|
|
||||||
DROP_AFTER
|
|
||||||
};
|
|
||||||
|
|
||||||
bool is_drop_after(ImVec2, ImVec2);
|
bool is_drop_after(ImVec2, ImVec2);
|
||||||
DropZone drop_zone_get(ImVec2, ImVec2);
|
DropZone drop_zone_get(ImVec2, ImVec2);
|
||||||
void drop_box_draw(ImDrawList*, ImVec2, ImVec2);
|
void drop_box_draw(ImDrawList*, ImVec2, ImVec2);
|
||||||
|
|||||||
@@ -153,15 +153,16 @@ static void spritesheets_merge_popup_update(Panel& panel, SpritesheetsPanel& spr
|
|||||||
popup_buttons_draw(manager, {.confirm = BASIC_MERGE, .isConfirmEnabled = spritesheets.mergeIds.size() > 1});
|
popup_buttons_draw(manager, {.confirm = BASIC_MERGE, .isConfirmEnabled = spritesheets.mergeIds.size() > 1});
|
||||||
if (result == PopupButton::CONFIRM)
|
if (result == PopupButton::CONFIRM)
|
||||||
command_push(panel,
|
command_push(panel,
|
||||||
[ids = spritesheets.mergeIds, isAppendRight = settings.mergeSpritesheetsOrigin == APPEND_RIGHT,
|
[ids = spritesheets.mergeIds,
|
||||||
isMakeRegions = settings.mergeSpritesheetsIsMakeRegions,
|
options = SpritesheetMergeOptions{
|
||||||
isMakePrimaryRegion = settings.mergeSpritesheetsIsMakePrimaryRegion,
|
.isAppendRight = settings.mergeSpritesheetsOrigin == APPEND_RIGHT,
|
||||||
regionOrigin = MERGE_REGION_ORIGINS[settings.mergeSpritesheetsRegionOrigin]](Document& document) {
|
.isMakeRegions = settings.mergeSpritesheetsIsMakeRegions,
|
||||||
|
.isMakePrimaryRegion = settings.mergeSpritesheetsIsMakePrimaryRegion,
|
||||||
|
.origin = MERGE_REGION_ORIGINS[settings.mergeSpritesheetsRegionOrigin]}](Document& document) {
|
||||||
spritesheet_textures_edit(
|
spritesheet_textures_edit(
|
||||||
document, EDIT_MERGE_SPRITESHEETS,
|
document, EDIT_MERGE_SPRITESHEETS,
|
||||||
[&]() {
|
[&]() {
|
||||||
if (!document.spritesheets_merge(ids, isAppendRight, isMakeRegions,
|
if (!document.spritesheets_merge(ids, options))
|
||||||
isMakePrimaryRegion, regionOrigin))
|
|
||||||
return false;
|
return false;
|
||||||
document.selected_ids_set(SelectionKind::SPRITESHEETS, {*ids.begin()});
|
document.selected_ids_set(SelectionKind::SPRITESHEETS, {*ids.begin()});
|
||||||
document.focused_id_set(SelectionKind::SPRITESHEETS, *ids.begin());
|
document.focused_id_set(SelectionKind::SPRITESHEETS, *ids.begin());
|
||||||
|
|||||||
@@ -227,8 +227,7 @@ struct TimelineContext : TimelineState
|
|||||||
void item_remove();
|
void item_remove();
|
||||||
std::vector<Reference> item_references_groupable_get();
|
std::vector<Reference> item_references_groupable_get();
|
||||||
void item_group();
|
void item_group();
|
||||||
void rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, bool isDropAfter,
|
void rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, DropZone zone);
|
||||||
bool isDropIntoGroup = false);
|
|
||||||
void fit_animation_length();
|
void fit_animation_length();
|
||||||
void marker_set(bool, int);
|
void marker_set(bool, int);
|
||||||
void markers_remove();
|
void markers_remove();
|
||||||
|
|||||||
@@ -203,8 +203,7 @@ void TimelineContext::item_group()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineContext::rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, bool isDropAfter,
|
void TimelineContext::rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, DropZone zone)
|
||||||
bool isDropIntoGroup)
|
|
||||||
{
|
{
|
||||||
if (draggedRows.empty())
|
if (draggedRows.empty())
|
||||||
return;
|
return;
|
||||||
@@ -237,9 +236,7 @@ void TimelineContext::rows_move_to_row(std::vector<TimelineRow> draggedRows, Tim
|
|||||||
|
|
||||||
edit_push(
|
edit_push(
|
||||||
EDIT_MOVE_ITEMS,
|
EDIT_MOVE_ITEMS,
|
||||||
[=](Model& model) {
|
[=](Model& model) { return items_move(model, animationIndex, targetType, ids, groupIds, target, zone); },
|
||||||
return items_move(model, animationIndex, targetType, ids, groupIds, target, isDropAfter, isDropIntoGroup);
|
|
||||||
},
|
|
||||||
[=, this](Document& document, const Uids&) {
|
[=, this](Document& document, const Uids&) {
|
||||||
document.selection.uids[SelectionKind::TRACKS] = moved.uids.at(SelectionKind::TRACKS);
|
document.selection.uids[SelectionKind::TRACKS] = moved.uids.at(SelectionKind::TRACKS);
|
||||||
document.selection.uids[SelectionKind::GROUPS] = moved.uids.at(SelectionKind::GROUPS);
|
document.selection.uids[SelectionKind::GROUPS] = moved.uids.at(SelectionKind::GROUPS);
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ void TimelineContext::row_drag_drop(const TimelineRow& row, ImVec2 buttonMin, Im
|
|||||||
else
|
else
|
||||||
drop_line_draw(ImGui::GetWindowDrawList(), childMin, childMax, isDropAfter);
|
drop_line_draw(ImGui::GetWindowDrawList(), childMin, childMax, isDropAfter);
|
||||||
if (payload->IsDelivery())
|
if (payload->IsDelivery())
|
||||||
rows_move_to_row(draggedRows, row, isDropAfter, isDropIntoGroup);
|
rows_move_to_row(draggedRows, row, isDropIntoGroup ? DROP_INSIDE : isDropAfter ? DROP_AFTER : DROP_BEFORE);
|
||||||
}
|
}
|
||||||
ImGui::EndDragDropTarget();
|
ImGui::EndDragDropTarget();
|
||||||
}
|
}
|
||||||
+2
-1
@@ -70,7 +70,8 @@ inline std::vector<Variant> variants_get(const Model& model)
|
|||||||
{
|
{
|
||||||
auto merged = model;
|
auto merged = model;
|
||||||
std::set<int> sources = {0, 1, 2};
|
std::set<int> sources = {0, 1, 2};
|
||||||
animations_merge(merged, 0, sources, type, type == MERGE_PREPEND || type == MERGE_REPLACE, {});
|
animations_merge(merged, 0, sources, type,
|
||||||
|
type == MERGE_PREPEND || type == MERGE_REPLACE ? SOURCES_DELETED : SOURCES_KEPT, {});
|
||||||
variants.emplace_back(name, model_serialize(merged, SAVE_EDITOR));
|
variants.emplace_back(name, model_serialize(merged, SAVE_EDITOR));
|
||||||
}
|
}
|
||||||
return variants;
|
return variants;
|
||||||
|
|||||||
+10
-10
@@ -35,7 +35,7 @@ TEST_CASE("animations_merge keeps one group per name")
|
|||||||
{
|
{
|
||||||
INFO("merge: ", std::string(name));
|
INFO("merge: ", std::string(name));
|
||||||
auto model = fixture_load("03a_groups_nested.anm2");
|
auto model = fixture_load("03a_groups_nested.anm2");
|
||||||
animations_merge(model, 0, {0, 1}, type, false, {});
|
animations_merge(model, 0, {0, 1}, type, SOURCES_KEPT, {});
|
||||||
CHECK(groups_named_count(*model.animation_get(0), "Main") == 1);
|
CHECK(groups_named_count(*model.animation_get(0), "Main") == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ TEST_CASE("edit layer operations")
|
|||||||
[&](Model& anm2) { return items_group(anm2, 0, LAYER, {2}, "New"); }, 1},
|
[&](Model& anm2) { return items_group(anm2, 0, LAYER, {2}, "New"); }, 1},
|
||||||
{"items_move", "03b_groups_legacy_flat.anm2",
|
{"items_move", "03b_groups_legacy_flat.anm2",
|
||||||
[&](Model& anm2) {
|
[&](Model& anm2) {
|
||||||
items_move(anm2, 0, LAYER, {2}, {}, {true, LAYER, 0, -1}, false, true);
|
items_move(anm2, 0, LAYER, {2}, {}, {true, LAYER, 0, -1}, DROP_INSIDE);
|
||||||
return Uids{};
|
return Uids{};
|
||||||
},
|
},
|
||||||
0},
|
0},
|
||||||
@@ -244,7 +244,7 @@ TEST_CASE("edit layer operations")
|
|||||||
},
|
},
|
||||||
0},
|
0},
|
||||||
{"animations_merge", "03a_groups_nested.anm2",
|
{"animations_merge", "03a_groups_nested.anm2",
|
||||||
[&](Model& anm2) { return animations_merge(anm2, 0, {1}, MERGE_APPEND, true, {0}); }, 1},
|
[&](Model& anm2) { return animations_merge(anm2, 0, {1}, MERGE_APPEND, SOURCES_DELETED, {0}); }, 1},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& entry : CASES)
|
for (auto& entry : CASES)
|
||||||
@@ -299,7 +299,7 @@ TEST_CASE("spritesheet pixel edits")
|
|||||||
auto image_get = [&](int id) {
|
auto image_get = [&](int id) {
|
||||||
return id == 0 ? &sheet : &other;
|
return id == 0 ? &sheet : &other;
|
||||||
};
|
};
|
||||||
auto merged = spritesheets_merge(model, {0, 1}, image_get, true, true, false, Origin::TOP_LEFT);
|
auto merged = spritesheets_merge(model, {0, 1}, image_get, {true, true, false, Origin::TOP_LEFT});
|
||||||
REQUIRE(merged);
|
REQUIRE(merged);
|
||||||
CHECK(merged->size == IVec2(80, 64));
|
CHECK(merged->size == IVec2(80, 64));
|
||||||
CHECK(model.content.spritesheets.size() == 1);
|
CHECK(model.content.spritesheets.size() == 1);
|
||||||
@@ -326,9 +326,9 @@ TEST_CASE("markers stay in the editor's copy and bound playback")
|
|||||||
|
|
||||||
Playback playback = {};
|
Playback playback = {};
|
||||||
playback.isPlaying = true;
|
playback.isPlaying = true;
|
||||||
playback.tick(10, 2, 6, true, 0.1f);
|
playback.tick(10, 2, 6, PLAYBACK_LOOP, 0.1f);
|
||||||
CHECK(playback.time == doctest::Approx(3.0f));
|
CHECK(playback.time == doctest::Approx(3.0f));
|
||||||
playback.tick(10, 2, 6, true, 0.5f);
|
playback.tick(10, 2, 6, PLAYBACK_LOOP, 0.5f);
|
||||||
CHECK(playback.time == doctest::Approx(4.0f));
|
CHECK(playback.time == doctest::Approx(4.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,11 +435,11 @@ TEST_CASE("animations_merge moves triggers past the animation placed before them
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto appended = model_make();
|
auto appended = model_make();
|
||||||
animations_merge(appended, 0, {0, 1}, MERGE_APPEND, false, {});
|
animations_merge(appended, 0, {0, 1}, MERGE_APPEND, SOURCES_KEPT, {});
|
||||||
CHECK(appended.animation_get(0)->triggers.frames.at(0).atFrame == 15);
|
CHECK(appended.animation_get(0)->triggers.frames.at(0).atFrame == 15);
|
||||||
|
|
||||||
auto prepended = model_make();
|
auto prepended = model_make();
|
||||||
animations_merge(prepended, 1, {0, 1}, MERGE_PREPEND, false, {});
|
animations_merge(prepended, 1, {0, 1}, MERGE_PREPEND, SOURCES_KEPT, {});
|
||||||
CHECK(prepended.animation_get(1)->triggers.frames.at(0).atFrame == 15);
|
CHECK(prepended.animation_get(1)->triggers.frames.at(0).atFrame == 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ TEST_CASE("SVG spritesheets pack and merge into SVGs")
|
|||||||
return images.at(id);
|
return images.at(id);
|
||||||
};
|
};
|
||||||
auto mixed = model;
|
auto mixed = model;
|
||||||
auto merged = spritesheets_merge(mixed, {0, 1}, image_get, true, false, false, Origin::TOP_LEFT);
|
auto merged = spritesheets_merge(mixed, {0, 1}, image_get, {true, false, false, Origin::TOP_LEFT});
|
||||||
REQUIRE(merged);
|
REQUIRE(merged);
|
||||||
CHECK(merged->is_vector());
|
CHECK(merged->is_vector());
|
||||||
CHECK(merged->size == IVec2(36, 16));
|
CHECK(merged->size == IVec2(36, 16));
|
||||||
@@ -498,7 +498,7 @@ TEST_CASE("SVG spritesheets pack and merge into SVGs")
|
|||||||
|
|
||||||
std::swap(model.content.spritesheets.front().id, model.content.spritesheets.back().id);
|
std::swap(model.content.spritesheets.front().id, model.content.spritesheets.back().id);
|
||||||
images = {{1, &vector}, {0, &raster}};
|
images = {{1, &vector}, {0, &raster}};
|
||||||
REQUIRE(spritesheets_merge(model, {0, 1}, image_get, true, false, false, Origin::TOP_LEFT));
|
REQUIRE(spritesheets_merge(model, {0, 1}, image_get, {true, false, false, Origin::TOP_LEFT}));
|
||||||
CHECK(item_get(model.content.spritesheets, 0)->path == "white.svg");
|
CHECK(item_get(model.content.spritesheets, 0)->path == "white.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ TEST_CASE("track and group selection follow regrouping")
|
|||||||
selection_references_set(selection, anm2, SelectionKind::TRACKS, {{0, LAYER, 0, -1, LAYER, groupId}});
|
selection_references_set(selection, anm2, SelectionKind::TRACKS, {{0, LAYER, 0, -1, LAYER, groupId}});
|
||||||
selection_references_set(selection, anm2, SelectionKind::GROUPS, {{0, LAYER, groupId}});
|
selection_references_set(selection, anm2, SelectionKind::GROUPS, {{0, LAYER, groupId}});
|
||||||
|
|
||||||
selection_edit(anm2, selection, [&] { items_move(anm2, 0, LAYER, {0}, {}, {false, LAYER, 2, -1}, false, false); });
|
selection_edit(anm2, selection, [&] { items_move(anm2, 0, LAYER, {0}, {}, {false, LAYER, 2, -1}, DROP_BEFORE); });
|
||||||
|
|
||||||
UidIndex index(anm2);
|
UidIndex index(anm2);
|
||||||
CHECK(selection_references_get(selection, index, SelectionKind::TRACKS) == std::set<Reference>{{0, LAYER, 0}});
|
CHECK(selection_references_get(selection, index, SelectionKind::TRACKS) == std::set<Reference>{{0, LAYER, 0}});
|
||||||
|
|||||||
Reference in new issue
Block a user