Auto spritesheet reload; operator symbols on Change All Frame Properties buttons
- Settings > File > Auto Spritesheet Reload (on by default, every 2 s): spritesheets whose files change on disk are reloaded as one undoable edit; ones with unsaved pixel edits are left alone, and the editor's own saves don't trigger a reload. Document::spritesheets_reload is shared with the Reload action. - Change buttons read "= Adjust", "+ Add", "- Subtract", "× Multiply", "÷ Divide". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d8ab5ff018
commit
993957decf
10 files changed
+76
-25
No files matched your search
@@ -8,6 +8,13 @@ namespace anm2ed::imgui
|
||||
{
|
||||
if (auto document = manager.get(); document)
|
||||
if (settings.windowIsAnimationPreview) animationPreview.tick(manager, settings, deltaSeconds);
|
||||
|
||||
if (!settings.fileIsAutoReloadSpritesheets) return;
|
||||
spritesheetReloadTime += deltaSeconds;
|
||||
if (spritesheetReloadTime < settings.fileAutoReloadInterval) return;
|
||||
spritesheetReloadTime = 0.0f;
|
||||
for (auto& document : manager.documents)
|
||||
if (auto ids = document.spritesheets_changed_get(); !ids.empty()) document.spritesheets_reload(ids);
|
||||
}
|
||||
|
||||
void Dockspace::update(Taskbar& taskbar, Documents& documents, Manager& manager, Settings& settings,
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
AnimationPreview animationPreview;
|
||||
bool isCanvasFocused{};
|
||||
float spritesheetReloadTime{};
|
||||
AnimationsPanel animations{};
|
||||
RegionsPanel regions{};
|
||||
PanelState events{};
|
||||
|
||||
@@ -268,25 +268,7 @@ namespace anm2ed::imgui
|
||||
TOOLTIP_REMOVE_UNUSED_SPRITESHEETS);
|
||||
actions.add(
|
||||
ACTION_RELOAD, isAny,
|
||||
[&]()
|
||||
{
|
||||
command_push(panel,
|
||||
[selection](Document& document)
|
||||
{
|
||||
document.edit_apply(EDIT_RELOAD_SPRITESHEETS,
|
||||
[&](model::Model&)
|
||||
{
|
||||
for (auto id : selection)
|
||||
document.texture_reload(id);
|
||||
});
|
||||
for (auto id : selection)
|
||||
if (auto spritesheet = spritesheet_get(document, id))
|
||||
{
|
||||
document.spritesheet_hash_set_saved(id);
|
||||
toast_log(Level::INFO, TOAST_RELOAD_SPRITESHEET, id, path::to_utf8(spritesheet->path));
|
||||
}
|
||||
});
|
||||
},
|
||||
[&]() { command_push(panel, [selection](Document& document) { document.spritesheets_reload(selection); }); },
|
||||
TOOLTIP_RELOAD_SPRITESHEETS);
|
||||
actions.add(
|
||||
ACTION_REPLACE, isOne, [&]() { dialog.file_open(Dialog::SPRITESHEET_REPLACE); }, TOOLTIP_REPLACE_SPRITESHEET);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "change_all_frame_properties.hpp"
|
||||
|
||||
#include <format>
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -29,17 +31,18 @@ namespace anm2ed::imgui::wizard
|
||||
|
||||
struct ChangeButton
|
||||
{
|
||||
const char* symbol;
|
||||
StringType label;
|
||||
StringType tooltip;
|
||||
ChangeType type;
|
||||
};
|
||||
|
||||
constexpr ChangeButton CHANGE_BUTTONS[CHANGE_TYPE_COUNT] = {
|
||||
{LABEL_ADJUST, TOOLTIP_ADJUST, ChangeType::ADJUST},
|
||||
{BASIC_ADD, TOOLTIP_ADD_VALUES, ChangeType::ADD},
|
||||
{LABEL_SUBTRACT, TOOLTIP_SUBTRACT_VALUES, ChangeType::SUBTRACT},
|
||||
{LABEL_MULTIPLY, TOOLTIP_MULTIPLY_VALUES, ChangeType::MULTIPLY},
|
||||
{LABEL_DIVIDE, TOOLTIP_DIVIDE_VALUES, ChangeType::DIVIDE}};
|
||||
{"=", LABEL_ADJUST, TOOLTIP_ADJUST, ChangeType::ADJUST},
|
||||
{"+", BASIC_ADD, TOOLTIP_ADD_VALUES, ChangeType::ADD},
|
||||
{"-", LABEL_SUBTRACT, TOOLTIP_SUBTRACT_VALUES, ChangeType::SUBTRACT},
|
||||
{"\u00D7", LABEL_MULTIPLY, TOOLTIP_MULTIPLY_VALUES, ChangeType::MULTIPLY},
|
||||
{"\u00F7", LABEL_DIVIDE, TOOLTIP_DIVIDE_VALUES, ChangeType::DIVIDE}};
|
||||
|
||||
struct ComponentRow
|
||||
{
|
||||
@@ -325,7 +328,8 @@ namespace anm2ed::imgui::wizard
|
||||
for (auto& button : CHANGE_BUTTONS)
|
||||
{
|
||||
if (&button != CHANGE_BUTTONS) ImGui::SameLine();
|
||||
if (ImGui::Button(localize.get(button.label), rowWidgetSize)) frame_change(button.type);
|
||||
if (ImGui::Button(std::format("{} {}", button.symbol, localize.get(button.label)).c_str(), rowWidgetSize))
|
||||
frame_change(button.type);
|
||||
ImGui::SetItemTooltip("%s", localize.get(button.tooltip));
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
@@ -66,6 +66,15 @@ namespace anm2ed::imgui::wizard
|
||||
ImGui::Checkbox(localize.get(BASIC_ENABLED), &temporary.fileIsAutosave);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_AUTOSAVE_ENABLED));
|
||||
|
||||
ImGui::SeparatorText(localize.get(LABEL_AUTO_SPRITESHEET_RELOAD));
|
||||
ImGui::Checkbox(localize.get(BASIC_ENABLED), &temporary.fileIsAutoReloadSpritesheets);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_AUTO_SPRITESHEET_RELOAD));
|
||||
ImGui::BeginDisabled(!temporary.fileIsAutoReloadSpritesheets);
|
||||
input_float_range(localize.get(LABEL_INTERVAL), temporary.fileAutoReloadInterval, AUTO_RELOAD_INTERVAL_MIN,
|
||||
AUTO_RELOAD_INTERVAL_MAX, AUTO_RELOAD_INTERVAL_STEP, AUTO_RELOAD_INTERVAL_STEP, "%.1f s");
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_AUTO_SPRITESHEET_RELOAD_INTERVAL));
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SeparatorText(localize.get(LABEL_SNAPSHOTS));
|
||||
input_int_range(localize.get(LABEL_STACK_SIZE), temporary.fileSnapshotStackSize, 0, 100);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_STACK_SIZE));
|
||||
|
||||
Reference in new issue
Block a user