Holy vibecode Batman!
This commit is contained in:
1 parent
7db835e6d4
commit
1bc5199e3b
140 files changed
+11888
-9481
No files matched your search
+67
-10
@@ -8,9 +8,10 @@
|
||||
#include <imgui/backends/imgui_impl_sdl3.h>
|
||||
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "path.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
|
||||
using namespace anm2ed::imgui;
|
||||
using namespace anm2ed::util;
|
||||
@@ -66,6 +67,10 @@ namespace anm2ed
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_DROP_BEGIN:
|
||||
spritesheetDropPaths.clear();
|
||||
soundDropPaths.clear();
|
||||
break;
|
||||
case SDL_EVENT_DROP_FILE:
|
||||
{
|
||||
std::string droppedFile = event.drop.data ? event.drop.data : "";
|
||||
@@ -86,24 +91,46 @@ namespace anm2ed
|
||||
}
|
||||
else if (path::is_extension(droppedPath, "png"))
|
||||
{
|
||||
if (auto document = manager.get())
|
||||
document->spritesheet_add(droppedPath);
|
||||
else
|
||||
spritesheetDropPaths.push_back(droppedPath);
|
||||
}
|
||||
else if (path::is_extension(droppedPath, "wav") || path::is_extension(droppedPath, "ogg"))
|
||||
{
|
||||
soundDropPaths.push_back(droppedPath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_DROP_COMPLETE:
|
||||
{
|
||||
if (auto document = manager.get(); document)
|
||||
{
|
||||
if (!spritesheetDropPaths.empty())
|
||||
{
|
||||
auto paths = spritesheetDropPaths;
|
||||
manager.command_push({manager.selected, [paths](Manager&, Document& document)
|
||||
{ document.spritesheets_add(paths); }});
|
||||
}
|
||||
if (!soundDropPaths.empty())
|
||||
{
|
||||
auto paths = soundDropPaths;
|
||||
manager.command_push({manager.selected, [paths](Manager&, Document& document)
|
||||
{ document.sounds_add(paths); }});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!spritesheetDropPaths.empty())
|
||||
{
|
||||
toasts.push(localize.get(TOAST_ADD_SPRITESHEET_FAILED));
|
||||
logger.warning(localize.get(TOAST_ADD_SPRITESHEET_FAILED, anm2ed::ENGLISH));
|
||||
}
|
||||
}
|
||||
else if (path::is_extension(droppedPath, "wav") || path::is_extension(droppedPath, "ogg"))
|
||||
{
|
||||
if (auto document = manager.get())
|
||||
document->sound_add(droppedPath);
|
||||
else
|
||||
if (!soundDropPaths.empty())
|
||||
{
|
||||
toasts.push(localize.get(TOAST_ADD_SOUND_FAILED));
|
||||
logger.warning(localize.get(TOAST_ADD_SOUND_FAILED, anm2ed::ENGLISH));
|
||||
}
|
||||
}
|
||||
spritesheetDropPaths.clear();
|
||||
soundDropPaths.clear();
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_USER: // Opening files
|
||||
@@ -131,10 +158,40 @@ namespace anm2ed
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (ImGui::GetTopMostPopupModal() == nullptr)
|
||||
{
|
||||
constexpr ImGuiKey DOCUMENT_SHORTCUT_KEYS[] = {ImGuiKey_1, ImGuiKey_2, ImGuiKey_3, ImGuiKey_4, ImGuiKey_5,
|
||||
ImGuiKey_6, ImGuiKey_7, ImGuiKey_8, ImGuiKey_9, ImGuiKey_0};
|
||||
for (int i = 0; i < (int)(sizeof(DOCUMENT_SHORTCUT_KEYS) / sizeof(DOCUMENT_SHORTCUT_KEYS[0])); ++i)
|
||||
{
|
||||
if (i >= (int)manager.documents.size()) break;
|
||||
if (ImGui::Shortcut(ImGuiMod_Ctrl | DOCUMENT_SHORTCUT_KEYS[i], ImGuiInputFlags_RouteGlobal))
|
||||
{
|
||||
manager.set(i);
|
||||
manager.pendingSelected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
taskbar.update(manager, settings, resources, dialog, isQuitting);
|
||||
documents.update(taskbar, manager, settings, resources, isQuitting);
|
||||
dockspace.update(taskbar, documents, manager, settings, resources, dialog, clipboard);
|
||||
|
||||
if (!dockspace.is_canvas_focused_get())
|
||||
{
|
||||
float uiScaleDelta{};
|
||||
if (imgui::shortcut(manager.chords[SHORTCUT_ZOOM_IN], shortcut::GLOBAL)) uiScaleDelta += UI_SCALE_STEP;
|
||||
if (imgui::shortcut(manager.chords[SHORTCUT_ZOOM_OUT], shortcut::GLOBAL)) uiScaleDelta -= UI_SCALE_STEP;
|
||||
if (uiScaleDelta != 0.0f)
|
||||
{
|
||||
settings.uiScale = std::clamp(settings.uiScale + uiScaleDelta, UI_SCALE_MIN, UI_SCALE_MAX);
|
||||
ImGui::GetStyle().FontScaleMain = settings.uiScale;
|
||||
}
|
||||
}
|
||||
|
||||
toasts.update();
|
||||
manager.commands_run();
|
||||
|
||||
SDL_GetWindowSize(window, &settings.windowSize.x, &settings.windowSize.y);
|
||||
SDL_GetWindowPosition(window, &settings.windowPosition.x, &settings.windowPosition.y);
|
||||
|
||||
Reference in new issue
Block a user