From ea8119ed2e8d7d832296e23a4a5f96d0e5eb580c Mon Sep 17 00:00:00 2001 From: Fleeym Date: Wed, 21 Oct 2026 22:07:37 +0300 Subject: [PATCH] port to Geode v6 and GD 2.2091 - migrate GEODE_EVENT_EXPORT_NORES - fix some issues for no pch builds - update std::filesystem usage to asp::fs - some random whitespace changes, thanks neovim --- include/API.hpp | 28 ++++++++++++++-------------- mod.json | 12 ++++++------ src/DevTools.cpp | 3 +++ src/backend.cpp | 16 ++++++++-------- src/pages/Attributes.cpp | 24 ++++++++++++------------ src/pages/Tree.cpp | 1 + 6 files changed, 44 insertions(+), 40 deletions(-) diff --git a/include/API.hpp b/include/API.hpp index 0e74c3d..27d9ab1 100644 --- a/include/API.hpp +++ b/include/API.hpp @@ -53,11 +53,11 @@ namespace devtools { /// @brief Checks if DevTools is currently open. /// @return True if DevTools is open, false otherwise. - inline bool isOpen() GEODE_EVENT_EXPORT_NORES(&isOpen, ()); + GEODE_EVENT_EXPORT(bool, isOpen, (), ()); /// @brief Checks if the mouse is in the DevTools window. /// @return True if the mouse is in the DevTools window, false otherwise. - inline bool isMouseInDevTools() GEODE_EVENT_EXPORT_NORES(&isMouseInDevTools, ()); + GEODE_EVENT_EXPORT(bool, isMouseInDevTools, (), ()); /// @brief Waits for DevTools to be loaded and then calls the provided callback. /// @param callback The function to call once DevTools is loaded. @@ -109,7 +109,7 @@ namespace devtools { /// @brief Renders a label in the DevTools UI. /// @param text The text to display in the label. /// @warning This function should only ever be called from within a registered node callback. - inline void label(geode::ZStringView text) GEODE_EVENT_EXPORT_NORES(&label, (text)); + GEODE_EVENT_EXPORT(void, label, (geode::ZStringView text), (text)); /// @brief Renders an enumerable property editor using radio buttons for the given value in the DevTools UI. /// @param label The label for the enumerable property. @@ -139,7 +139,7 @@ namespace devtools { /// @param label The label for the button. /// @return True if the button was clicked, false otherwise. /// @warning This function should only ever be called from within a registered node callback. - inline bool button(geode::ZStringView label) GEODE_EVENT_EXPORT_NORES(&button, (label)); + GEODE_EVENT_EXPORT(bool, button, (geode::ZStringView label), (label)); /// @brief Renders a button in the DevTools UI and calls the provided callback if the button is clicked. /// @param label The label for the button. @@ -152,19 +152,19 @@ namespace devtools { } } - inline void newLine() GEODE_EVENT_EXPORT_NORES(&newLine, ()); - inline void sameLine() GEODE_EVENT_EXPORT_NORES(&sameLine, ()); - inline void separator() GEODE_EVENT_EXPORT_NORES(&separator, ()); - inline void nextItemWidth(float width) GEODE_EVENT_EXPORT_NORES(&nextItemWidth, (width)); - inline void indent() GEODE_EVENT_EXPORT_NORES(&indent, ()); - inline void unindent() GEODE_EVENT_EXPORT_NORES(&unindent, ()); + GEODE_EVENT_EXPORT(void, newLine, (), ()); + GEODE_EVENT_EXPORT(void, sameLine, (), ()); + GEODE_EVENT_EXPORT(void, separator, (), ()); + GEODE_EVENT_EXPORT(void, nextItemWidth, (float width), (width)); + GEODE_EVENT_EXPORT(void, indent, (), ()); + GEODE_EVENT_EXPORT(void, unindent, (), ()); - inline bool combo( + GEODE_EVENT_EXPORT(bool, combo, ( geode::ZStringView label, int& current, std::span items, int maxHeight = -1 - ) GEODE_EVENT_EXPORT_NORES(&combo, (label, current, items, maxHeight)); + ), (label, current, items, maxHeight)); template > requires @@ -179,12 +179,12 @@ namespace devtools { ); } - inline bool radio(geode::ZStringView label, int& current, int num) GEODE_EVENT_EXPORT_NORES(&radio, (label, current, num)); + GEODE_EVENT_EXPORT(bool, radio, (geode::ZStringView label, int& current, int num), (label, current, num)); template bool radio(geode::ZStringView label, T& current, U value) { return radio(label, reinterpret_cast(current), reinterpret_cast(value)); } - inline void inputMultiline(geode::ZStringView label, std::string& text) GEODE_EVENT_EXPORT_NORES(&inputMultiline, (label, text)); + GEODE_EVENT_EXPORT(void, inputMultiline, (geode::ZStringView label, std::string& text), (label, text)); } diff --git a/mod.json b/mod.json index f626712..6fbbccb 100644 --- a/mod.json +++ b/mod.json @@ -1,11 +1,11 @@ { - "geode": "5.8.2", + "geode": "5.11.2", "version": "v1.14.0", "gd": { - "win": "2.2081", - "android": "2.2081", - "mac": "2.2081", - "ios": "2.2081" + "win": "2.2091", + "android": "2.2091", + "mac": "2.2091", + "ios": "2.2091" }, "id": "geode.devtools", "name": "DevTools", @@ -47,4 +47,4 @@ "resources/*.png" ] } -} \ No newline at end of file +} diff --git a/src/DevTools.cpp b/src/DevTools.cpp index d843d9a..d5e83a8 100644 --- a/src/DevTools.cpp +++ b/src/DevTools.cpp @@ -8,6 +8,9 @@ #include "platform/platform.hpp" #include #include +#include +#include +#include #include "ImGui.hpp" template<> diff --git a/src/backend.cpp b/src/backend.cpp index 30cd68e..c2b7ff1 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -35,7 +35,7 @@ CCPoint getMousePos_H() { mouse = toCocos(ImVec2(x, y)); } - + return mouse; } @@ -48,7 +48,7 @@ void DevTools::setupPlatform() { io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // use static since imgui does not own the pointer! - static const auto iniPath = (Mod::get()->getSaveDir() / "imgui.ini").u8string(); + static const auto iniPath = (Mod::get()->getSaveDir() / "imgui.ini").string(); io.IniFilename = reinterpret_cast(iniPath.c_str()); unsigned char* pixels; @@ -91,7 +91,7 @@ class DevToolsIMEDelegate : public CCIMEDelegate { } return false; } - + bool detachWithIME() override { if (CCIMEDelegate::detachWithIME()) { m_attached = false; @@ -202,7 +202,7 @@ namespace { ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex); static_assert(sizeof(CCPoint) == sizeof(ccVertex2F), "so the cocos devs were right then"); - + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli.data()); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, colors.data()); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uvs.data()); @@ -352,8 +352,8 @@ class $modify(CCMouseDispatcher) { class $modify(CCTouchDispatcher) { static void onModify(auto& self) { - /* - * some mods hook this instead of using normal touch delegates for some reason + /* + * some mods hook this instead of using normal touch delegates for some reason * for example QOLMod, even in the rewrite * so i added hook priority */ @@ -377,7 +377,7 @@ class $modify(CCTouchDispatcher) { const auto pos = toVec2(touch->getLocation()); GEODE_MOBILE(io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);) io.AddMousePosEvent(pos.x, pos.y); - + if (DevTools::get()->shouldUseGDWindow()) { auto win = ImGui::GetMainViewport()->Size; const auto gdRect = getGDWindowRect(); @@ -446,7 +446,7 @@ class $modify(CCIMEDispatcher) { return; default: break; } - + std::string str(text, len); io.AddInputCharactersUTF8(str.c_str()); } diff --git a/src/pages/Attributes.cpp b/src/pages/Attributes.cpp index 299a285..80eb888 100644 --- a/src/pages/Attributes.cpp +++ b/src/pages/Attributes.cpp @@ -88,7 +88,7 @@ void DevTools::drawBasicAttributes(CCNode* node) { file::pick(file::PickMode::SaveFile, file::FilePickOptions { .filters = {{ .description = "PNG Image", .files = {"*.png"} }} }), - [node = WeakRef(node)](Result> result) { + [node = WeakRef(node)](file::PickResult result) { auto nodePtr = node.lock(); if (!nodePtr) return; @@ -97,7 +97,7 @@ void DevTools::drawBasicAttributes(CCNode* node) { int width, height; auto bytes = renderToBytes(nodePtr, width, height); - auto path = string::pathToString(*file); + auto path = file->string(); if (!path.ends_with(".png")) { path += ".png"; } @@ -202,7 +202,7 @@ void DevTools::drawBasicAttributes(CCNode* node) { ImGui::SameLine(); checkbox("Flip Y", sprite, &CCSprite::isFlipY, &CCSprite::setFlipY); } - + checkbox("Visible", node, &CCNode::isVisible, &CCNode::setVisible); checkbox( "Ignore Anchor Point for Position", @@ -225,7 +225,7 @@ void DevTools::drawColorAttributes(CCNode* node) { static_cast(_color[1] * 255), static_cast(_color[2] * 255) }); - + gradient->setStartOpacity(static_cast(_color[3] * 255)); } } @@ -238,7 +238,7 @@ void DevTools::drawColorAttributes(CCNode* node) { static_cast(_color[1] * 255), static_cast(_color[2] * 255) }); - + gradient->setEndOpacity(static_cast(_color[3] * 255)); } } @@ -260,7 +260,7 @@ void DevTools::drawColorAttributes(CCNode* node) { static_cast(_color[1] * 255), static_cast(_color[2] * 255) }); - + rgbaNode->setOpacity(static_cast(_color[3] * 255)); } } @@ -467,7 +467,7 @@ void DevTools::drawLayoutOptionsAttributes(CCNode* node) { } if (hasMinRelativeScale) { if (ImGui::DragFloat("Min Relative Scale##simplescale1", &minRelativeScale)) { - + opts->setMinRelativeScale(minRelativeScale); updateLayout = true; } @@ -680,7 +680,7 @@ void DevTools::drawLayoutOptionsAttributes(CCNode* node) { updateLayout = true; } if (hasCrossAxisAlignment) { - + ImGui::Text("Cross Axis Alignment"); bool updateAlignment = false; updateAlignment |= ImGui::RadioButton( @@ -767,7 +767,7 @@ void DevTools::drawLayoutOptionsAttributes(CCNode* node) { void DevTools::drawLayoutAttributes(CCNode* node){ if (auto rawLayout = node->getLayout()) { ImGui::Text("Layout: %s", typeid(*rawLayout).name()); - + if (ImGui::Button(U8STR(FEATHER_REFRESH_CW " Update Layout"))) { node->updateLayout(); } @@ -932,7 +932,7 @@ void DevTools::drawLayoutAttributes(CCNode* node){ auto direction = static_cast(layout->getMainAxisDirection()); ImGui::Text("Main Axis Direction"); bool updateDirection = false; - + updateDirection |= ImGui::RadioButton( axisDirection.c_str(), &direction, static_cast(AxisDirection::FrontToBack) ); @@ -995,10 +995,10 @@ void DevTools::drawLayoutAttributes(CCNode* node){ } if (hasMinRelativeScale) { if (ImGui::DragFloat("Min Relative Scale", &minRelativeScale)) { - + layout->setMinRelativeScale(minRelativeScale); updateLayout = true; - + } } diff --git a/src/pages/Tree.cpp b/src/pages/Tree.cpp index c0586c0..666e387 100644 --- a/src/pages/Tree.cpp +++ b/src/pages/Tree.cpp @@ -3,6 +3,7 @@ #include "../DevTools.hpp" #include "../platform/utils.hpp" #include +#include #include #include #include "../ImGui.hpp"