diff --git a/src/imgui/dockspace.cpp b/src/imgui/dockspace.cpp index 6221ed7..66238cc 100644 --- a/src/imgui/dockspace.cpp +++ b/src/imgui/dockspace.cpp @@ -11,7 +11,7 @@ namespace anm2ed::imgui if (!settings.fileIsAutoReloadSpritesheets) return; spritesheetReloadTime += deltaSeconds; - if (spritesheetReloadTime < settings.fileAutoReloadInterval) return; + if (spritesheetReloadTime < AUTO_RELOAD_INTERVAL) return; spritesheetReloadTime = 0.0f; for (auto& document : manager.documents) if (auto ids = document.spritesheets_changed_get(); !ids.empty()) document.spritesheets_reload(ids); diff --git a/src/imgui/window/timeline/menus.cpp b/src/imgui/window/timeline/menus.cpp index 1b5dd99..65db714 100644 --- a/src/imgui/window/timeline/menus.cpp +++ b/src/imgui/window/timeline/menus.cpp @@ -160,42 +160,49 @@ namespace anm2ed::imgui auto source = property_source_get(); auto sourceFrame = source ? model.frame_get(*source) : nullptr; auto clipboardFrame = property_clipboard_frame_get(); - auto clipboard_menu_add = [&](ActionType type, std::function isFrameEnabled, std::function frameRun, - int propertyType, std::function is_property_enabled, - std::function property_run) + // A submenu of the properties a frame type has. + auto properties_get = [&](int itemType, std::function is_property_enabled, + std::function property_run) { Action properties{.label = LABEL_PROPERTY}; for (int i = 0; i < (int)edit::FrameProperty::COUNT; ++i) { auto property = (edit::FrameProperty)i; - if (!edit::is_frame_property_valid(property, (ItemType)propertyType)) continue; + if (!edit::is_frame_property_valid(property, (ItemType)itemType)) continue; properties.children.push_back({.label = FRAME_PROPERTY_LABELS[i], .isEnabled = [=]() { return is_property_enabled(property); }, .run = [=]() { property_run(property); }}); } properties.isEnabled = [children = properties.children]() { return std::ranges::any_of(children, is_action_enabled); }; + return properties; + }; + auto clipboard_menu_add = + [&](ActionType type, std::function isFrameEnabled, std::function frameRun, Action property) + { actions.add({.label = ACTION_INFOS[type].label, .children = {{.label = BASIC_FRAME, .shortcut = ACTION_INFOS[type].shortcut, .isEnabled = isFrameEnabled, .run = frameRun}, - properties}}); + property}}); }; auto sourceType = source ? source->itemType : NONE; + auto is_source = [=](edit::FrameProperty) { return sourceFrame != nullptr; }; clipboard_menu_add( - ACTION_CUT, [=, this]() { return !selectedFrames.empty(); }, [this]() { cut(); }, sourceType, - [=](edit::FrameProperty) { return sourceFrame != nullptr; }, - [this](edit::FrameProperty property) { property_cut(property); }); + ACTION_CUT, [=, this]() { return !selectedFrames.empty(); }, [this]() { cut(); }, + properties_get(sourceType, is_source, [this](edit::FrameProperty property) { property_cut(property); })); clipboard_menu_add( - ACTION_COPY, [=, this]() { return !copyFrames.empty(); }, [this]() { copy(); }, sourceType, - [=](edit::FrameProperty) { return sourceFrame != nullptr; }, - [this](edit::FrameProperty property) { property_copy(property); }); + ACTION_COPY, [=, this]() { return !copyFrames.empty(); }, [this]() { copy(); }, + properties_get(sourceType, is_source, [this](edit::FrameProperty property) { property_copy(property); })); + // Only one property is ever on the clipboard, so pasting one is a single item. + auto clipboardProperty = (edit::FrameProperty)frameClipboard.property; clipboard_menu_add( ACTION_PASTE, [&]() { return !clipboard.is_empty(); }, [this]() { paste(); }, - clipboardFrame ? frameClipboard.itemType : NONE, - [this](edit::FrameProperty property) { return is_property_pasteable(property); }, - [this](edit::FrameProperty property) { property_paste(property); }); + {.label = LABEL_PROPERTY, + .isEnabled = [=, this]() + { return clipboardFrame && frameClipboard.property != -1 && is_property_pasteable(clipboardProperty); }, + .run = [=, this]() { property_paste(clipboardProperty); }}); // The numbered row has its own (marker) menu. if (isRulerHovered) actions_popup_draw("##Context Menu", actions, settings); diff --git a/src/imgui/wizard/configure.cpp b/src/imgui/wizard/configure.cpp index 4b1ba91..d37f337 100644 --- a/src/imgui/wizard/configure.cpp +++ b/src/imgui/wizard/configure.cpp @@ -67,13 +67,10 @@ namespace anm2ed::imgui::wizard ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_AUTOSAVE_ENABLED)); ImGui::SeparatorText(localize.get(LABEL_AUTO_SPRITESHEET_RELOAD)); + ImGui::PushID(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::PopID(); ImGui::SeparatorText(localize.get(LABEL_SNAPSHOTS)); input_int_range(localize.get(LABEL_STACK_SIZE), temporary.fileSnapshotStackSize, 0, 100); diff --git a/src/resource/strings.hpp b/src/resource/strings.hpp index d3452ef..e2c0502 100644 --- a/src/resource/strings.hpp +++ b/src/resource/strings.hpp @@ -423,7 +423,7 @@ namespace anm2ed X(LABEL_SHORTCUTS_TAB, "Shortcuts", "Atajos", "Сочетания клавиш", "快捷键", "단축키") \ X(LABEL_SHORTCUT_COLUMN, "Shortcut", "Atajo", "Сочетание клавиш", "快捷方式", "단축") \ X(LABEL_SNAP, "Snap", "Ajustar", "Привязка", "吸附", "맞추기") \ - X(LABEL_SNAPSHOTS, "Snapshots", "Snapshots", "Снапшоты", "快照", "스냅숏") \ + X(LABEL_SNAPSHOTS, "Undo/Redo", "Deshacer/Rehacer", "Отмена/Повтор", "撤销/重做", "실행 취소/다시 실행") \ X(LABEL_SOUND, "Sound", "Sonido", "Звук", "声音", "사운드") \ X(LABEL_SOUNDS, "Sounds", "Sonidos", "Звук", "声音", "사운드") \ X(LABEL_SOUNDS_WINDOW, "Sounds###Sounds", "Sonidos###Sounds", "Звук###Sounds", "声音###Sounds", "사운드###Sounds") \ @@ -534,7 +534,6 @@ namespace anm2ed X(TEXT_SELECT_FRAME, "Select a frame first!", "¡Selecciona primero un frame!", "Сначала выберите кадр!", "请先选择帧!", "먼저 프레임을 선택하세요!") \ X(TEXT_SELECT_FRAME_OR_REGION, "Select a frame or region first!", "¡Selecciona primero un frame o región!", "Сначала выберите кадр или регион!", "请先选择帧或区域!", "먼저 프레임 또는 영역을 선택하세요!") \ X(TOOLTIP_AUTO_SPRITESHEET_RELOAD, "Reload spritesheets automatically when their files change on disk.\n(Spritesheets with unsaved edits are left alone.)", "Recarga los spritesheets automáticamente cuando sus archivos cambian en el disco.\n(Los spritesheets con cambios sin guardar no se tocan.)", "Автоматически перезагружать спрайт-листы при изменении их файлов на диске.\n(Спрайт-листы с несохранёнными изменениями не затрагиваются.)", "当图集文件在磁盘上更改时自动重新加载。\n(有未保存修改的图集不受影响。)", "디스크의 파일이 바뀌면 스프라이트 시트를 자동으로 새로고침합니다.\n(저장하지 않은 수정이 있는 스프라이트 시트는 건드리지 않습니다.)") \ - X(TOOLTIP_AUTO_SPRITESHEET_RELOAD_INTERVAL, "How often (in seconds) spritesheet files are checked for changes.", "Cada cuánto (en segundos) se revisan los archivos de spritesheets en busca de cambios.", "Как часто (в секундах) проверять файлы спрайт-листов на изменения.", "检查图集文件更改的间隔(秒)。", "스프라이트 시트 파일의 변경을 확인하는 간격(초).") \ X(TOOLTIP_ISAAC_COMPATIBILITY_WARNING, "Before saving, list anything the game doesn't support and what will happen to it.", "Antes de guardar, muestra lo que el juego no soporta y lo que pasará con ello.", "Перед сохранением показывать всё, что игра не поддерживает, и что с этим произойдёт.", "保存前列出游戏不支持的内容及其处理方式。", "저장하기 전에 게임이 지원하지 않는 항목과 그 처리 방식을 알려줍니다.") \ X(TOOLTIP_MERGE_SPRITESHEETS, "Merge selected spritesheets into the first selected spritesheet.", "Combina los spritesheets seleccionados en el primer spritesheet seleccionado.", "Объединить выбранные спрайт-листы в первый выбранный спрайт-лист.", "将所选图集合并到第一个选中的图集中。", "선택된 스프라이트 시트를 첫 번째 선택된 스프라이트 시트로 병합합니다.") \ X(TEXT_SELECT_SPRITESHEET, "Select a spritesheet first!", "¡Selecciona primero un spritesheet!", "Сначала выберите спрайт-лист!", "请先选择图集!", "먼저 스프라이트 시트를 선택하세요!") \ diff --git a/src/settings.cpp b/src/settings.cpp index 3a9bd44..79f6b0d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -272,7 +272,6 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,991 for (auto [scale, min, max] : {std::tuple{&uiScale, UI_SCALE_MIN, UI_SCALE_MAX}, std::tuple{&renderScale, RENDER_SCALE_MIN, RENDER_SCALE_MAX}}) *scale = std::clamp(*scale < min ? math::unit_to_percent(*scale) : *scale, min, max); - fileAutoReloadInterval = std::clamp(fileAutoReloadInterval, AUTO_RELOAD_INTERVAL_MIN, AUTO_RELOAD_INTERVAL_MAX); } Options Settings::anm2_options_get() const { return {.isExtendedFormat = isFileExtendedFormat}; } diff --git a/src/settings.hpp b/src/settings.hpp index 85fa0ca..299017b 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -25,9 +25,7 @@ namespace anm2ed constexpr auto OUTPUT_PATH_DEFAULT = "./output.gif"; #endif - constexpr auto AUTO_RELOAD_INTERVAL_MIN = 0.5f; - constexpr auto AUTO_RELOAD_INTERVAL_MAX = 60.0f; - constexpr auto AUTO_RELOAD_INTERVAL_STEP = 0.5f; + constexpr auto AUTO_RELOAD_INTERVAL = 3.0f; // seconds between checks of spritesheet files // Scales are percents. constexpr auto UI_SCALE_MIN = 50.0f; constexpr auto UI_SCALE_MAX = 200.0f; @@ -66,7 +64,6 @@ namespace anm2ed X(FILE_IS_WARN_OVERWRITE, fileIsWarnOverwrite, STRING_UNDEFINED, BOOL, true) \ X(FILE_IS_WARN_ISAAC, fileIsWarnIsaac, STRING_UNDEFINED, BOOL, true) \ X(FILE_IS_AUTO_RELOAD_SPRITESHEETS, fileIsAutoReloadSpritesheets, STRING_UNDEFINED, BOOL, true) \ - X(FILE_AUTO_RELOAD_INTERVAL, fileAutoReloadInterval, STRING_UNDEFINED, FLOAT, 2.0f) \ X(FILE_IS_EXTENDED_FORMAT, isFileExtendedFormat, STRING_UNDEFINED, BOOL, false) \ X(FILE_SNAPSHOT_STACK_SIZE, fileSnapshotStackSize, STRING_UNDEFINED, INT, 50) \ \