Auto bake frames! new attributes!
This commit is contained in:
+14
-7
@@ -17,6 +17,17 @@ using namespace anm2ed::util;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
Options save_options_get(const Settings& settings)
|
||||
{
|
||||
Flags flags{};
|
||||
if (settings.fileIsSerializeGroups) flags |= SERIALIZE_GROUPS;
|
||||
if (settings.fileIsSerializeRegions) flags |= SERIALIZE_REGIONS;
|
||||
if (settings.fileIsSerializeSounds) flags |= SERIALIZE_SOUNDS;
|
||||
if (settings.fileIsKeepRedundantFrameRegionValues) flags |= SERIALIZE_REDUNDANT_FRAME_REGION_VALUES;
|
||||
if (settings.fileIsBakeSpecialInterpolatedFrames) flags |= SERIALIZE_BAKE_SPECIAL_INTERPOLATED_FRAMES;
|
||||
return {.flags = flags};
|
||||
}
|
||||
|
||||
void Documents::update(Taskbar& taskbar, Manager& manager, Settings& settings, Resources& resources, bool& isQuitting)
|
||||
{
|
||||
auto viewport = ImGui::GetMainViewport();
|
||||
@@ -42,14 +53,10 @@ namespace anm2ed::imgui
|
||||
document.lastAutosaveTime += ImGui::GetIO().DeltaTime;
|
||||
if (document.lastAutosaveTime > time::SECOND_M)
|
||||
{
|
||||
auto compatibility = (Compatibility)settings.fileCompatibility;
|
||||
auto bakeFrames = settings.fileBakeSpecialInterpolatedFramesOnSave;
|
||||
auto isRoundScale = settings.bakeIsRoundScale;
|
||||
auto isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto options = save_options_get(settings);
|
||||
manager.command_push({i,
|
||||
[compatibility, bakeFrames, isRoundScale, isRoundRotation](Manager& manager,
|
||||
Document& document)
|
||||
{ manager.autosave(document, compatibility, bakeFrames, isRoundScale, isRoundRotation); }});
|
||||
[options](Manager& manager, Document& document)
|
||||
{ manager.autosave(document, options); }});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-81
@@ -23,30 +23,31 @@ using namespace glm;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
bool Taskbar::save_requires_special_prompt(Manager& manager, Settings& settings, int index) const
|
||||
Options save_options_get(Settings& settings)
|
||||
{
|
||||
auto* document = manager.get(index);
|
||||
return document && settings.fileIsSpecialInterpolatedFramesOnSaveReminder &&
|
||||
document->anm2.is_special_interpolated_frames();
|
||||
Flags flags{};
|
||||
if (settings.fileIsSerializeGroups) flags |= SERIALIZE_GROUPS;
|
||||
if (settings.fileIsSerializeRegions) flags |= SERIALIZE_REGIONS;
|
||||
if (settings.fileIsSerializeSounds) flags |= SERIALIZE_SOUNDS;
|
||||
if (settings.fileIsKeepRedundantFrameRegionValues) flags |= SERIALIZE_REDUNDANT_FRAME_REGION_VALUES;
|
||||
if (settings.fileIsBakeSpecialInterpolatedFrames) flags |= SERIALIZE_BAKE_SPECIAL_INTERPOLATED_FRAMES;
|
||||
return {.flags = flags};
|
||||
}
|
||||
|
||||
bool Taskbar::save_execute(Manager& manager, Settings& settings, const PendingSave& request, bool bakeFrames)
|
||||
bool Taskbar::save_execute(Manager& manager, Settings& settings, const PendingSave& request)
|
||||
{
|
||||
return manager.save(request.index, request.path, (Compatibility)settings.fileCompatibility, bakeFrames,
|
||||
settings.bakeIsRoundScale, settings.bakeIsRoundRotation);
|
||||
return manager.save(request.index, request.path, save_options_get(settings));
|
||||
}
|
||||
|
||||
void Taskbar::save_enqueue(Manager& manager, Settings& settings, const PendingSave& request, bool bakeFrames)
|
||||
void Taskbar::save_enqueue(Manager& manager, Settings& settings, const PendingSave& request)
|
||||
{
|
||||
auto index = request.index;
|
||||
auto path = request.path;
|
||||
auto compatibility = (Compatibility)settings.fileCompatibility;
|
||||
auto isRoundScale = settings.bakeIsRoundScale;
|
||||
auto isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto options = save_options_get(settings);
|
||||
|
||||
manager.command_push({.runManager =
|
||||
[=](Manager& manager)
|
||||
{ manager.save(index, path, compatibility, bakeFrames, isRoundScale, isRoundRotation); }});
|
||||
{ manager.save(index, path, options); }});
|
||||
}
|
||||
|
||||
bool Taskbar::save_request(Manager& manager, Settings& settings, int index, const std::filesystem::path& path,
|
||||
@@ -55,26 +56,13 @@ namespace anm2ed::imgui
|
||||
auto* document = manager.get(index);
|
||||
if (!document) return false;
|
||||
|
||||
if (settings.fileIsSpecialInterpolatedFramesOnSaveReminder && document->anm2.is_special_interpolated_frames())
|
||||
{
|
||||
pendingSave = {.index = index,
|
||||
.path = path,
|
||||
.isOpen = true,
|
||||
.disableReminder = false,
|
||||
.autoBakeFrames = settings.fileBakeSpecialInterpolatedFramesOnSave,
|
||||
.isQueued = isQueued};
|
||||
specialInterpolatedFramesReminderPopup.open();
|
||||
return false;
|
||||
}
|
||||
|
||||
PendingSave request{.index = index, .path = path};
|
||||
auto bakeFrames = settings.fileBakeSpecialInterpolatedFramesOnSave;
|
||||
if (isQueued)
|
||||
{
|
||||
save_enqueue(manager, settings, request, bakeFrames);
|
||||
save_enqueue(manager, settings, request);
|
||||
return true;
|
||||
}
|
||||
return save_execute(manager, settings, request, bakeFrames);
|
||||
return save_execute(manager, settings, request);
|
||||
}
|
||||
|
||||
bool Taskbar::save_manual(Manager& manager, Settings& settings, int index, const std::filesystem::path& path)
|
||||
@@ -139,9 +127,7 @@ namespace anm2ed::imgui
|
||||
|
||||
if (ImGui::MenuItem(localize.get(BASIC_SAVE), settings.shortcutSave.c_str(), false, document))
|
||||
{
|
||||
if (save_requires_special_prompt(manager, settings, manager.selected))
|
||||
save_request(manager, settings, manager.selected, document->path, true);
|
||||
else if (settings.fileIsWarnOverwrite)
|
||||
if (settings.fileIsWarnOverwrite)
|
||||
overwritePopup.open();
|
||||
else
|
||||
save_request(manager, settings, manager.selected, document->path, true);
|
||||
@@ -334,63 +320,13 @@ namespace anm2ed::imgui
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
specialInterpolatedFramesReminderPopup.trigger();
|
||||
if (ImGui::BeginPopupModal(specialInterpolatedFramesReminderPopup.label(),
|
||||
&specialInterpolatedFramesReminderPopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
ImGui::TextWrapped("%s", localize.get(LABEL_SPECIAL_INTERPOLATED_FRAMES_REMINDER_PROMPT));
|
||||
ImGui::Spacing();
|
||||
ImGui::Checkbox(localize.get(LABEL_DONT_NOTIFY_ME_AGAIN), &pendingSave.disableReminder);
|
||||
ImGui::BeginDisabled(!pendingSave.disableReminder);
|
||||
ImGui::Checkbox(localize.get(LABEL_AUTOMATICALLY_BAKE_THESE_FRAMES_ON_SAVE), &pendingSave.autoBakeFrames);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(3);
|
||||
if (ImGui::Button(localize.get(LABEL_SAVE_BAKE_FRAMES), widgetSize))
|
||||
{
|
||||
if (pendingSave.disableReminder) settings.fileIsSpecialInterpolatedFramesOnSaveReminder = false;
|
||||
settings.fileBakeSpecialInterpolatedFramesOnSave = pendingSave.autoBakeFrames;
|
||||
if (pendingSave.isQueued)
|
||||
save_enqueue(manager, settings, pendingSave, true);
|
||||
else
|
||||
save_execute(manager, settings, pendingSave, true);
|
||||
pendingSave = {};
|
||||
specialInterpolatedFramesReminderPopup.close();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(localize.get(LABEL_SAVE_DONT_BAKE_FRAMES), widgetSize))
|
||||
{
|
||||
if (pendingSave.disableReminder) settings.fileIsSpecialInterpolatedFramesOnSaveReminder = false;
|
||||
settings.fileBakeSpecialInterpolatedFramesOnSave = pendingSave.autoBakeFrames;
|
||||
if (pendingSave.isQueued)
|
||||
save_enqueue(manager, settings, pendingSave, false);
|
||||
else
|
||||
save_execute(manager, settings, pendingSave, false);
|
||||
pendingSave = {};
|
||||
specialInterpolatedFramesReminderPopup.close();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize))
|
||||
{
|
||||
pendingSave = {};
|
||||
specialInterpolatedFramesReminderPopup.close();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
specialInterpolatedFramesReminderPopup.end();
|
||||
|
||||
aboutPopup.end();
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_NEW], shortcut::GLOBAL)) dialog.file_save(Dialog::ANM2_CREATE);
|
||||
if (shortcut(manager.chords[SHORTCUT_OPEN], shortcut::GLOBAL)) dialog.file_open(Dialog::ANM2_OPEN, true);
|
||||
if (shortcut(manager.chords[SHORTCUT_SAVE], shortcut::GLOBAL))
|
||||
{
|
||||
if (save_requires_special_prompt(manager, settings))
|
||||
save_request(manager, settings, manager.selected, {}, true);
|
||||
else if (settings.fileIsWarnOverwrite)
|
||||
if (settings.fileIsWarnOverwrite)
|
||||
overwritePopup.open();
|
||||
else
|
||||
save_request(manager, settings, manager.selected, {}, true);
|
||||
|
||||
@@ -24,9 +24,6 @@ namespace anm2ed::imgui
|
||||
{
|
||||
int index{-1};
|
||||
std::filesystem::path path{};
|
||||
bool isOpen{};
|
||||
bool disableReminder{};
|
||||
bool autoBakeFrames{};
|
||||
bool isQueued{};
|
||||
};
|
||||
|
||||
@@ -40,18 +37,14 @@ namespace anm2ed::imgui
|
||||
PopupHelper generatePopup{PopupHelper(LABEL_TASKBAR_GENERATE_ANIMATION_FROM_GRID)};
|
||||
PopupHelper changePopup{PopupHelper(LABEL_CHANGE_ALL_FRAME_PROPERTIES, imgui::POPUP_NORMAL_NO_HEIGHT)};
|
||||
PopupHelper overwritePopup{PopupHelper(LABEL_TASKBAR_OVERWRITE_FILE, imgui::POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper specialInterpolatedFramesReminderPopup{
|
||||
PopupHelper(LABEL_SPECIAL_INTERPOLATED_FRAMES_REMINDER_POPUP, imgui::POPUP_NORMAL_NO_HEIGHT)};
|
||||
PopupHelper renderPopup{PopupHelper(LABEL_TASKBAR_RENDER_ANIMATION, imgui::POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper configurePopup{PopupHelper(LABEL_TASKBAR_CONFIGURE)};
|
||||
PopupHelper aboutPopup{PopupHelper(LABEL_TASKBAR_ABOUT)};
|
||||
Settings editSettings{};
|
||||
bool isQuittingMode{};
|
||||
PendingSave pendingSave{};
|
||||
|
||||
bool save_requires_special_prompt(Manager&, Settings&, int = -1) const;
|
||||
bool save_execute(Manager&, Settings&, const PendingSave&, bool);
|
||||
void save_enqueue(Manager&, Settings&, const PendingSave&, bool);
|
||||
bool save_execute(Manager&, Settings&, const PendingSave&);
|
||||
void save_enqueue(Manager&, Settings&, const PendingSave&);
|
||||
bool save_request(Manager&, Settings&, int = -1, const std::filesystem::path& = {}, bool = false);
|
||||
|
||||
public:
|
||||
|
||||
@@ -1530,14 +1530,16 @@ namespace anm2ed::imgui
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
|
||||
bool isDropLineActive{};
|
||||
bool isDropLineAfter{};
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (auto payload = ImGui::AcceptDragDropPayload(
|
||||
"Region Drag Drop",
|
||||
ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect))
|
||||
{
|
||||
auto isDropAfter = is_drop_after(regionRowMin, regionRowMax);
|
||||
drop_line_draw(ImGui::GetWindowDrawList(), regionChildMin, regionChildMax, isDropAfter);
|
||||
isDropLineActive = true;
|
||||
isDropLineAfter = is_drop_after(regionRowMin, regionRowMax);
|
||||
|
||||
auto payloadIds = (int*)(payload->Data);
|
||||
int payloadCount = (int)(payload->DataSize / sizeof(int));
|
||||
@@ -1553,7 +1555,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
std::sort(indices.begin(), indices.end());
|
||||
auto movedIds = window.dragSelection;
|
||||
auto targetIndex = i + (isDropAfter ? 1 : 0);
|
||||
auto targetIndex = i + (isDropLineAfter ? 1 : 0);
|
||||
auto targetSpritesheetReference = spritesheetReference;
|
||||
manager.command_push(
|
||||
{manager.selected, [&window, indices, movedIds, targetIndex,
|
||||
@@ -1595,6 +1597,9 @@ namespace anm2ed::imgui
|
||||
if (isReferenced) ImGui::PushFont(resources.fonts[font::ITALICS].get(), font::SIZE);
|
||||
ImGui::TextUnformatted(nameCStr);
|
||||
if (isReferenced) ImGui::PopFont();
|
||||
|
||||
if (isDropLineActive)
|
||||
drop_line_draw(ImGui::GetWindowDrawList(), regionChildMin, regionChildMax, isDropLineAfter);
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -68,25 +68,23 @@ namespace anm2ed::imgui::wizard
|
||||
input_int_range(localize.get(LABEL_STACK_SIZE), temporary.fileSnapshotStackSize, 0, 100);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_STACK_SIZE));
|
||||
|
||||
ImGui::SeparatorText(localize.get(LABEL_COMPATIBILITY));
|
||||
ImGui::RadioButton(localize.get(LABEL_ISAAC), &temporary.fileCompatibility, ISAAC);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_COMPATIBILITY_ISAAC));
|
||||
ImGui::SeparatorText(localize.get(LABEL_SERIALIZATION));
|
||||
ImGui::Checkbox(localize.get(LABEL_GROUPS), &temporary.fileIsSerializeGroups);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SERIALIZE_GROUPS));
|
||||
ImGui::SameLine();
|
||||
ImGui::RadioButton(localize.get(LABEL_ANM2ED), &temporary.fileCompatibility, ANM2ED);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_COMPATIBILITY_ANM2ED));
|
||||
ImGui::Checkbox(localize.get(LABEL_REGIONS), &temporary.fileIsSerializeRegions);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SERIALIZE_REGIONS));
|
||||
ImGui::SameLine();
|
||||
ImGui::RadioButton(localize.get(LABEL_ANM2ED_LIMITED), &temporary.fileCompatibility, ANM2ED_LIMITED);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_COMPATIBILITY_ANM2ED_LIMITED));
|
||||
ImGui::Checkbox(localize.get(LABEL_SOUNDS), &temporary.fileIsSerializeSounds);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SERIALIZE_SOUNDS));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_SPECIAL_INTERPOLATED_FRAMES_REMINDER_ON_SAVE),
|
||||
&temporary.fileIsSpecialInterpolatedFramesOnSaveReminder);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SPECIAL_INTERPOLATED_FRAMES_REMINDER_ON_SAVE));
|
||||
ImGui::Checkbox(localize.get(LABEL_KEEP_REDUNDANT_FRAME_REGION_VALUES),
|
||||
&temporary.fileIsKeepRedundantFrameRegionValues);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_KEEP_REDUNDANT_FRAME_REGION_VALUES));
|
||||
|
||||
ImGui::BeginDisabled(temporary.fileIsSpecialInterpolatedFramesOnSaveReminder);
|
||||
ImGui::Checkbox(localize.get(LABEL_BAKE_SPECIAL_INTERPOLATED_FRAMES_ON_SAVE),
|
||||
&temporary.fileBakeSpecialInterpolatedFramesOnSave);
|
||||
&temporary.fileIsBakeSpecialInterpolatedFrames);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_SPECIAL_INTERPOLATED_FRAMES_ON_SAVE));
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SeparatorText(localize.get(LABEL_OPTIONS));
|
||||
ImGui::Checkbox(localize.get(LABEL_OVERWRITE_WARNING), &temporary.fileIsWarnOverwrite);
|
||||
|
||||
Reference in New Issue
Block a user