diff --git a/src/anm2/animation.cpp b/src/anm2/animation.cpp index 4098953..dd3ef18 100644 --- a/src/anm2/animation.cpp +++ b/src/anm2/animation.cpp @@ -28,15 +28,15 @@ namespace anm2ed::anm2 for (auto child = layerAnimationsElement->FirstChildElement("LayerAnimation"); child; child = child->NextSiblingElement("LayerAnimation")) { - layerAnimations[id] = Item(child, LAYER, &id); - layerOrder.push_back(id); + layerAnimations.emplace(id, Item(child, LAYER, &id)); + layerOrder.emplace_back(id); } } if (auto nullAnimationsElement = element->FirstChildElement("NullAnimations")) for (auto child = nullAnimationsElement->FirstChildElement("NullAnimation"); child; child = child->NextSiblingElement("NullAnimation")) - nullAnimations[id] = Item(child, NULL_, &id); + nullAnimations.emplace(id, Item(child, NULL_, &id)); if (auto triggersElement = element->FirstChildElement("Triggers")) triggers = Item(triggersElement, TRIGGER); } diff --git a/src/anm2/content.cpp b/src/anm2/content.cpp index 1d21bf6..1269761 100644 --- a/src/anm2/content.cpp +++ b/src/anm2/content.cpp @@ -7,27 +7,26 @@ namespace anm2ed::anm2 Content::Content(XMLElement* element) { int id{}; - if (auto spritesheetsElement = element->FirstChildElement("Spritesheets")) for (auto child = spritesheetsElement->FirstChildElement("Spritesheet"); child; child = child->NextSiblingElement("Spritesheet")) - spritesheets[id] = Spritesheet(child, id); + spritesheets.emplace(id, Spritesheet(child, id)); if (auto layersElement = element->FirstChildElement("Layers")) for (auto child = layersElement->FirstChildElement("Layer"); child; child = child->NextSiblingElement("Layer")) - layers[id] = Layer(child, id); + layers.emplace(id, Layer(child, id)); if (auto nullsElement = element->FirstChildElement("Nulls")) for (auto child = nullsElement->FirstChildElement("Null"); child; child = child->NextSiblingElement("Null")) - nulls[id] = Null(child, id); + nulls.emplace(id, Null(child, id)); if (auto eventsElement = element->FirstChildElement("Events")) for (auto child = eventsElement->FirstChildElement("Event"); child; child = child->NextSiblingElement("Event")) - events[id] = Event(child, id); + events.emplace(id, Event(child, id)); - if (auto eventsElement = element->FirstChildElement("Sounds")) - for (auto child = eventsElement->FirstChildElement("Sound"); child; child = child->NextSiblingElement("Sound")) - sounds[id] = Sound(child, id); + if (auto soundsElement = element->FirstChildElement("Sounds")) + for (auto child = soundsElement->FirstChildElement("Sound"); child; child = child->NextSiblingElement("Sound")) + sounds.emplace(id, Sound(child, id)); } void Content::serialize(XMLDocument& document, XMLElement* parent) diff --git a/src/imgui/imgui_.cpp b/src/imgui/imgui_.cpp index d751163..eded6f1 100644 --- a/src/imgui/imgui_.cpp +++ b/src/imgui/imgui_.cpp @@ -12,6 +12,23 @@ using namespace glm; namespace anm2ed::imgui { + void theme_set(theme::Type theme) + { + switch (theme) + { + case theme::LIGHT: + ImGui::StyleColorsLight(); + break; + case theme::DARK: + default: + ImGui::StyleColorsDark(); + break; + case theme::CLASSIC: + ImGui::StyleColorsClassic(); + break; + } + } + int input_text_callback(ImGuiInputTextCallbackData* data) { if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) @@ -90,8 +107,7 @@ namespace anm2ed::imgui { if (ImGui::Selectable(label.c_str(), isSelected, flags)) isActivated = true; - if (isBeginEditing || - (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(ImGuiKey_F2) && isSelected) || + if (isBeginEditing || (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(ImGuiKey_F2) && isSelected) || (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))) { editID = id; @@ -298,7 +314,7 @@ namespace anm2ed::imgui { if (ImGui::GetTopMostPopupModal() != nullptr) return false; - if (isRepeat && (type == shortcut::GLOBAL || type == shortcut::FOCUSED)) return chord_repeating(chord); + if (isRepeat) return chord_repeating(chord); int flags = type == shortcut::GLOBAL || type == shortcut::GLOBAL_SET ? ImGuiInputFlags_RouteGlobal : ImGuiInputFlags_RouteFocused; diff --git a/src/imgui/imgui_.h b/src/imgui/imgui_.h index 70eccf3..7f3edc1 100644 --- a/src/imgui/imgui_.h +++ b/src/imgui/imgui_.h @@ -154,6 +154,7 @@ namespace anm2ed::imgui {"Super", ImGuiMod_Super}, }; + void theme_set(types::theme::Type theme); std::string chord_to_string(ImGuiKeyChord); ImGuiKeyChord string_to_chord(const std::string&); float row_widget_width_get(int, float = ImGui::GetContentRegionAvail().x); diff --git a/src/imgui/taskbar.cpp b/src/imgui/taskbar.cpp index 18caf5c..ec38441 100644 --- a/src/imgui/taskbar.cpp +++ b/src/imgui/taskbar.cpp @@ -367,6 +367,15 @@ namespace anm2ed::imgui ImGui::Checkbox("Vsync", &editSettings.isVsync); ImGui::SetItemTooltip("Toggle vertical sync; synchronizes program update rate with monitor refresh rate."); + + ImGui::SeparatorText("Theme"); + + for (int i = 0; i < theme::COUNT; i++) + { + if (i == theme::LIGHT) continue; // TODO; light mode is jank rn so i am soft disabling it + ImGui::RadioButton(theme::STRINGS[i], &editSettings.theme, i); + ImGui::SameLine(); + } } ImGui::EndChild(); @@ -492,6 +501,7 @@ namespace anm2ed::imgui if (ImGui::Button("Save", widgetSize)) { settings = editSettings; + imgui::theme_set((theme::Type)editSettings.theme); manager.chords_set(settings); configurePopup.close(); } diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index a6ba4f7..5fa6600 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -563,7 +563,7 @@ namespace anm2ed::imgui auto cursor = areaType == tool::ANIMATION_PREVIEW || areaType == tool::ALL ? tool::INFO[useTool].cursor : ImGuiMouseCursor_NotAllowed; ImGui::SetMouseCursor(cursor); - ImGui::SetKeyboardFocusHere(-1); + ImGui::SetKeyboardFocusHere(); switch (useTool) { diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 3afc4cb..54ec4e6 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -258,7 +258,7 @@ namespace anm2ed::imgui auto cursor = areaType == tool::SPRITESHEET_EDITOR || areaType == tool::ALL ? tool::INFO[useTool].cursor : ImGuiMouseCursor_NotAllowed; ImGui::SetMouseCursor(cursor); - ImGui::SetKeyboardFocusHere(-1); + ImGui::SetKeyboardFocusHere(); switch (useTool) { diff --git a/src/imgui/window/timeline.cpp b/src/imgui/window/timeline.cpp index e7d7605..675d6b4 100644 --- a/src/imgui/window/timeline.cpp +++ b/src/imgui/window/timeline.cpp @@ -16,7 +16,6 @@ using namespace glm; namespace anm2ed::imgui { constexpr auto COLOR_HIDDEN_MULTIPLIER = vec4(0.5f, 0.5f, 0.5f, 1.000f); - constexpr auto FRAME_TIMELINE_COLOR = ImVec4(0.106f, 0.184f, 0.278f, 1.000f); constexpr auto FRAME_BORDER_COLOR = ImVec4(1.0f, 1.0f, 1.0f, 0.15f); constexpr auto FRAME_BORDER_COLOR_REFERENCED = ImVec4(1.0f, 1.0f, 1.0f, 0.50f); constexpr auto FRAME_MULTIPLE_OVERLAY_COLOR = ImVec4(1.0f, 1.0f, 1.0f, 0.05f); @@ -249,7 +248,9 @@ namespace anm2ed::imgui ImGui::Image(resources.icons[icon].id, icon_size_get()); ImGui::SameLine(); if (isReferenced) ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE); + ImGui::PushStyleColor(ImGuiCol_Text, to_imvec4(color::WHITE)); ImGui::TextUnformatted(label.c_str()); + ImGui::PopStyleColor(); if (isReferenced) ImGui::PopFont(); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4()); @@ -483,7 +484,7 @@ namespace anm2ed::imgui { drawList->AddRectFilled(cursorScreenPos, ImVec2(cursorScreenPos.x + framesSize.x, cursorScreenPos.y + framesSize.y), - ImGui::GetColorU32(FRAME_TIMELINE_COLOR)); + ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Header))); for (int i = frameMin; i < frameMax; i++) { diff --git a/src/imgui/window/tools.cpp b/src/imgui/window/tools.cpp index a9f9603..3c47745 100644 --- a/src/imgui/window/tools.cpp +++ b/src/imgui/window/tools.cpp @@ -50,7 +50,7 @@ namespace anm2ed::imgui if (isSelected) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive)); - if (shortcut(manager.chords[info.shortcut], shortcut::GLOBAL_SET)) tool_use((tool::Type)i); + if (shortcut(manager.chords[info.shortcut], shortcut::GLOBAL_SET, true)) tool_use((tool::Type)i); if (i == tool::COLOR) { diff --git a/src/loader.cpp b/src/loader.cpp index d52617c..4ba059e 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -10,6 +10,8 @@ #include "filesystem_.h" #include "log.h" +#include "imgui_.h" + #include "socket.h" using namespace anm2ed::types; @@ -180,7 +182,12 @@ namespace anm2ed logger.info("Initialized Dear ImGui"); - ImGui::StyleColorsDark(); + imgui::theme_set((theme::Type)settings.theme); + + if (settings.theme == theme::DARK) + ImGui::StyleColorsDark(); + else if (settings.theme == theme::LIGHT) + ImGui::StyleColorsClassic(); ImGui_ImplSDL3_InitForOpenGL(window, glContext); ImGui_ImplOpenGL3_Init("#version 330"); diff --git a/src/settings.h b/src/settings.h index 1699705..5b4dcf2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -44,6 +44,7 @@ namespace anm2ed X(WINDOW_SIZE, windowSize, "Window Size", IVEC2_WH, {1600, 900}) \ X(IS_VSYNC, isVsync, "Vsync", BOOL, true) \ X(UI_SCALE, uiScale, "UI Scale", FLOAT, 1.0f) \ + X(THEME, theme, "Theme", INT, types::theme::DARK) \ \ X(FILE_IS_AUTOSAVE, fileIsAutosave, "Autosave", BOOL, true) \ X(FILE_AUTOSAVE_TIME, fileAutosaveTime, "Autosave Time", INT, 1) \ diff --git a/src/types.h b/src/types.h index ca9edc2..0b8f847 100644 --- a/src/types.h +++ b/src/types.h @@ -13,6 +13,30 @@ namespace anm2ed::types::draw_order }; } +namespace anm2ed::types::theme +{ +#define THEMES \ + X(LIGHT, "Light") \ + X(DARK, "Dark") \ + X(CLASSIC, "ImGui Classic") + + enum Type + { +#define X(symbol, string) symbol, + THEMES +#undef X + COUNT + }; + + constexpr const char* STRINGS[] = { +#define X(symbol, string) string, + THEMES +#undef X + }; + +#undef THEMES +} + namespace anm2ed::types::shortcut { enum Type diff --git a/workshop/metadata.xml b/workshop/metadata.xml index c3b9fc3..9b32984 100644 --- a/workshop/metadata.xml +++ b/workshop/metadata.xml @@ -13,7 +13,7 @@ A reimplementation of [i]The Binding of Isaac: Rebirth[/i]'s proprietary animati [h2]Features[/h2] [list] [*] Extended version of the original proprietary Nicalis animation editor -[*] Smooth [Dear ImGui](https://github.com/ocornut/imgui) interface; docking, dragging and dropping, etc. You might be familiar with it from [Repentogon](https://repentogon.com/). +[*] Smooth [url=https://github.com/ocornut/imgui]Dear ImGui[/url] interface; docking, dragging and dropping, etc. You might be familiar with it from [url=https://repentogon.com/]Repentogon[/url]. [*] Greatly polished in many areas, to assist with all your animating needs [*]New features: [list] @@ -40,6 +40,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas [h3]Happy animating![/h3] [img]https://files.catbox.moe/4auc1c.gif[/img] - 2.2 + 2.3 Public