diff --git a/src/imgui/documents.cpp b/src/imgui/documents.cpp index 70398ad..f2799ee 100644 --- a/src/imgui/documents.cpp +++ b/src/imgui/documents.cpp @@ -454,6 +454,14 @@ namespace anm2ed::imgui } } + if (ImGui::MenuItem(localize.get(LABEL_DOCUMENTS_ADD_AS_LIBRARY), nullptr, false, document)) + { + manager.command_push({manager.selected, [paths = manager.anm2DragDropPaths](Manager&, Document& document) + { document.libraries_add(paths); }}); + drag_drop_reset(); + } + ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LIBRARY_ADD)); + ImGui::Separator(); if (ImGui::MenuItem(localize.get(BASIC_CANCEL))) drag_drop_reset(); diff --git a/src/imgui/window/items.cpp b/src/imgui/window/items.cpp index cab39de..62a42d4 100644 --- a/src/imgui/window/items.cpp +++ b/src/imgui/window/items.cpp @@ -10,7 +10,7 @@ using namespace anm2ed::types; namespace anm2ed::imgui { constexpr int NULL_PROPERTIES_ROWS = 2; - constexpr int LAYER_PROPERTIES_ROWS = 4; + constexpr int LAYER_PROPERTIES_ROWS = 6; auto& layers_get(model::Model& model) { return model.content.layers; } auto& nulls_get(model::Model& model) { return model.content.nulls; } @@ -147,15 +147,17 @@ namespace anm2ed::imgui EDIT_SET_LAYER_PROPERTIES, layers_get, [&](Manager::ItemEdit& layer) { - ImGui::TextUnformatted(localize.get(LABEL_LAYER_SOURCE)); - ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SOURCE)); + ImGui::SeparatorText(localize.get(LABEL_LAYER_SOURCE)); + ImGui::PushID("##Source"); for (auto [label, isAnimation] : {std::pair{LABEL_SPRITESHEET, false}, std::pair{LABEL_ANIMATION, true}}) { - ImGui::SameLine(); + if (isAnimation) ImGui::SameLine(); if (ImGui::RadioButton(localize.get(label), layer.isAnimation == isAnimation)) layer.isAnimation = isAnimation; ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SOURCE)); } + ImGui::PopID(); + ImGui::Separator(); if (!layer.isAnimation) { @@ -167,7 +169,7 @@ namespace anm2ed::imgui } auto libraries = document.choices_get(SelectionKind::LIBRARIES); - libraries.labels.front() = localize.get(TEXT_THIS_FILE); + libraries.labels.front() = localize.get(TEXT_SELF); combo_id_mapped(localize.get(LABEL_LIBRARY), &layer.libraryId, libraries.ids, libraries.labels); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_LIBRARY)); auto names = document.animation_names_get(layer.libraryId); diff --git a/src/imgui/window/libraries.cpp b/src/imgui/window/libraries.cpp index b0eb545..017a2af 100644 --- a/src/imgui/window/libraries.cpp +++ b/src/imgui/window/libraries.cpp @@ -79,53 +79,46 @@ namespace anm2ed::imgui items_clipboard_actions_add(actions, panel, SelectionKind::LIBRARIES, EDIT_PASTE_LIBRARIES, TOAST_DESERIALIZE_LIBRARIES_FAILED, libraries_get); - ListRows rows{.label_get = - [&](int id) - { - auto pathString = path::to_utf8(model::item_get(libraries, id)->path); - return std::vformat(localize.get(FORMAT_SOUND), std::make_format_args(id, pathString)); - }, - .tooltip_draw = - [&](int id) - { - auto loaded = loaded_get(id); - tooltip_name_draw(resources, path::to_utf8(model::item_get(libraries, id)->path)); - ImGui::Text("%s: %d", localize.get(BASIC_ID), id); - if (loaded && loaded->model.isValid) - ImGui::TextUnformatted(localize.get(TOOLTIP_LIBRARY_OPEN)); - else - { - ImGui::Spacing(); - ImGui::TextWrapped("%s", localize.get(TOOLTIP_LIBRARY_INVALID)); - } - }, - .image_get = - [&](int id) - { - auto loaded = loaded_get(id); - auto isValid = loaded && loaded->model.isValid; - auto& texture = resources.icons[isValid ? icon::ANIMATION : icon::NONE]; - return CardImage{.texture = &texture, .size = glm::vec2(texture.size), .isValid = isValid}; - }, - .activate = open, - .children_draw = - [&](int id) - { - auto loaded = loaded_get(id); - if (!loaded || !loaded->model.isValid) return; - auto animations = loaded->model.animations_get(); - auto count = animations.size(); - auto label = std::vformat(localize.get(FORMAT_LIBRARY_ANIMATIONS), std::make_format_args(count)); - ImGui::PushID(id); - if (ImGui::TreeNodeEx(label.c_str(), ImGuiTreeNodeFlags_SpanAvailWidth)) - { - for (auto [index, animation] : animations) - ImGui::BulletText("%s", animation->name.c_str()); - ImGui::TreePop(); - } - ImGui::PopID(); - }, - .cardLines = LIBRARY_CARD_LINES}; + ListRows rows{ + .label_get = + [&](int id) + { + auto pathString = path::to_utf8(model::item_get(libraries, id)->path); + return std::vformat(localize.get(FORMAT_SOUND), std::make_format_args(id, pathString)); + }, + .tooltip_draw = + [&](int id) + { + auto loaded = loaded_get(id); + tooltip_name_draw(resources, path::to_utf8(model::item_get(libraries, id)->path)); + ImGui::Text("%s: %d", localize.get(BASIC_ID), id); + if (loaded && loaded->model.isValid) + { + auto animations = loaded->model.animations_get(); + auto count = animations.size(); + ImGui::SeparatorText( + std::vformat(localize.get(FORMAT_LIBRARY_ANIMATIONS), std::make_format_args(count)).c_str()); + for (auto [index, animation] : animations) + ImGui::BulletText("%s", animation->name.c_str()); + ImGui::Separator(); + ImGui::TextUnformatted(localize.get(TOOLTIP_LIBRARY_OPEN)); + } + else + { + ImGui::Spacing(); + ImGui::TextWrapped("%s", localize.get(TOOLTIP_LIBRARY_INVALID)); + } + }, + .image_get = + [&](int id) + { + auto loaded = loaded_get(id); + auto isValid = loaded && loaded->model.isValid; + auto& texture = resources.icons[isValid ? icon::ANIMATION : icon::NONE]; + return CardImage{.texture = &texture, .size = glm::vec2(texture.size), .isValid = isValid}; + }, + .activate = open, + .cardLines = LIBRARY_CARD_LINES}; list_panel_draw( panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_OPEN}}, [&]() { content_list_draw(panel, SelectionKind::LIBRARIES, item_ids_get(libraries), rows); }, true); diff --git a/src/imgui/window/panel.cpp b/src/imgui/window/panel.cpp index c912ed1..6119ed6 100644 --- a/src/imgui/window/panel.cpp +++ b/src/imgui/window/panel.cpp @@ -254,7 +254,6 @@ namespace anm2ed::imgui else isBreak = row_draw(panel, selection, focus, rows, keys[i], i, arrowKey); if (isBreak) break; - if (rows.children_draw) rows.children_draw(keys[i]); } if (isCards) ImGui::PopStyleVar(); list_select_end(panel, selection, focus, rows, arrowKey); diff --git a/src/imgui/window/panel.hpp b/src/imgui/window/panel.hpp index f34e558..77aa2e5 100644 --- a/src/imgui/window/panel.hpp +++ b/src/imgui/window/panel.hpp @@ -77,7 +77,6 @@ namespace anm2ed::imgui std::function select{}; std::function activate{}; std::function drag_drop_update{}; - std::function children_draw{}; int cardLines{}; bool isFocusItalic{}; }; diff --git a/src/resource/strings.hpp b/src/resource/strings.hpp index 604917a..9de3737 100644 --- a/src/resource/strings.hpp +++ b/src/resource/strings.hpp @@ -279,6 +279,7 @@ namespace anm2ed X(LABEL_AUTO_SPRITESHEET_RELOAD, "Auto Spritesheet Reload", "Recarga Automática de Spritesheets", "Автоперезагрузка спрайт-листов", "自动重新加载图集", "스프라이트 시트 자동 새로고침") \ X(LABEL_CHILD, "Child", "Hijo", "Дочерняя", "子动画", "자식") \ X(LABEL_DETACHABLE_WINDOWS, "Detachable Windows", "Ventanas Desacoplables", "Отделяемые окна", "可分离窗口", "분리 가능한 창") \ + X(LABEL_DOCUMENTS_ADD_AS_LIBRARY, "Add as Library", "Añadir como Biblioteca", "Добавить как библиотеку", "添加为库", "라이브러리로 추가") \ X(LABEL_DOCUMENT_EXTENDED_FORMAT, "Extended Format", "Formato Extendido", "Расширенный формат", "扩展格式", "확장 형식") \ X(LABEL_HOLD, "Hold", "Mantener", "Удерживать", "保持", "유지") \ X(LABEL_ISAAC_COMPATIBILITY_WARNING, "Isaac Compatibility Warning", "Advertencia de Compatibilidad con Isaac", "Предупреждение о совместимости с Isaac", "Isaac 兼容性警告", "Isaac 호환성 경고") \ @@ -575,7 +576,7 @@ namespace anm2ed X(TOOLTIP_LIBRARY_OPEN, "Open the library in its own tab to edit it; saving it updates every file that uses it.", "Abre la biblioteca en su propia pestaña para editarla; al guardarla se actualiza cada archivo que la usa.", "Открыть библиотеку в отдельной вкладке для редактирования; сохранение обновит все файлы, которые её используют.", "在单独的标签页中打开库进行编辑;保存后所有使用它的文件都会更新。", "라이브러리를 자체 탭에서 열어 편집합니다. 저장하면 이를 사용하는 모든 파일이 업데이트됩니다.") \ 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!", "Сначала выберите спрайт-лист!", "请先选择图集!", "먼저 스프라이트 시트를 선택하세요!") \ - X(TEXT_THIS_FILE, "This File", "Este Archivo", "Этот файл", "此文件", "이 파일") \ + X(TEXT_SELF, "Self", "Propio", "Сам", "自身", "자신") \ X(TEXT_TOOL_ANIMATION_PREVIEW, "This tool can only be used in Animation Preview!", "¡Esta herramienta solo se puede usar en Vista previa de animación!", "Этот инструмент можно использовать только в \"Предпросмотре анимации\"!", "该工具只能在“动画预放”中使用!", "이 도구는 애니메이션 프리뷰에서만 사용할 수 있습니다!") \ X(TEXT_TOOL_SPRITESHEET_EDITOR, "This tool can only be used in Spritesheet Editor!", "¡Esta herramienta solo se puede usar en el Editor de spritesheets!", "Этот инструмент можно использовать только в \"Редакторе спрайт-листов\"!", "该工具只能在“图集编辑器”中使用!", "이 도구는 스프라이트 시트 편집기에서만 사용할 수 있습니다!") \ X(TEXT_NEW_ANIMATION, "New Animation", "Nueva Animacion", "Новая анимация", "新动画", "새 애니메이션") \