Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions include/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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<char const*> items,
int maxHeight = -1
) GEODE_EVENT_EXPORT_NORES(&combo, (label, current, items, maxHeight));
), (label, current, items, maxHeight));

template <UnderlyingIntegral T, typename R = std::initializer_list<geode::ZStringView>>
requires
Expand All @@ -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 <UnderlyingIntegral T, UnderlyingIntegral U>
bool radio(geode::ZStringView label, T& current, U value) {
return radio(label, reinterpret_cast<int&>(current), reinterpret_cast<int&>(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));
}
12 changes: 6 additions & 6 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -47,4 +47,4 @@
"resources/*.png"
]
}
}
}
3 changes: 3 additions & 0 deletions src/DevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "platform/platform.hpp"
#include <Geode/loader/Log.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/loader/ModEvent.hpp>
#include <Geode/ui/BasedButtonSprite.hpp>
#include <Geode/ui/OverlayManager.hpp>
#include "ImGui.hpp"

template<>
Expand Down
16 changes: 8 additions & 8 deletions src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CCPoint getMousePos_H() {

mouse = toCocos(ImVec2(x, y));
}

return mouse;
}

Expand All @@ -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<const char*>(iniPath.c_str());

unsigned char* pixels;
Expand Down Expand Up @@ -91,7 +91,7 @@ class DevToolsIMEDelegate : public CCIMEDelegate {
}
return false;
}

bool detachWithIME() override {
if (CCIMEDelegate::detachWithIME()) {
m_attached = false;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
*/
Expand All @@ -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();
Expand Down Expand Up @@ -446,7 +446,7 @@ class $modify(CCIMEDispatcher) {
return;
default: break;
}

std::string str(text, len);
io.AddInputCharactersUTF8(str.c_str());
}
Expand Down
24 changes: 12 additions & 12 deletions src/pages/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::optional<std::filesystem::path>> result) {
[node = WeakRef(node)](file::PickResult result) {
auto nodePtr = node.lock();
if (!nodePtr) return;

Expand All @@ -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";
}
Expand Down Expand Up @@ -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",
Expand All @@ -225,7 +225,7 @@ void DevTools::drawColorAttributes(CCNode* node) {
static_cast<GLubyte>(_color[1] * 255),
static_cast<GLubyte>(_color[2] * 255)
});

gradient->setStartOpacity(static_cast<GLubyte>(_color[3] * 255));
}
}
Expand All @@ -238,7 +238,7 @@ void DevTools::drawColorAttributes(CCNode* node) {
static_cast<GLubyte>(_color[1] * 255),
static_cast<GLubyte>(_color[2] * 255)
});

gradient->setEndOpacity(static_cast<GLubyte>(_color[3] * 255));
}
}
Expand All @@ -260,7 +260,7 @@ void DevTools::drawColorAttributes(CCNode* node) {
static_cast<GLubyte>(_color[1] * 255),
static_cast<GLubyte>(_color[2] * 255)
});

rgbaNode->setOpacity(static_cast<GLubyte>(_color[3] * 255));
}
}
Expand Down Expand Up @@ -467,7 +467,7 @@ void DevTools::drawLayoutOptionsAttributes(CCNode* node) {
}
if (hasMinRelativeScale) {
if (ImGui::DragFloat("Min Relative Scale##simplescale1", &minRelativeScale)) {

opts->setMinRelativeScale(minRelativeScale);
updateLayout = true;
}
Expand Down Expand Up @@ -680,7 +680,7 @@ void DevTools::drawLayoutOptionsAttributes(CCNode* node) {
updateLayout = true;
}
if (hasCrossAxisAlignment) {

ImGui::Text("Cross Axis Alignment");
bool updateAlignment = false;
updateAlignment |= ImGui::RadioButton(
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -932,7 +932,7 @@ void DevTools::drawLayoutAttributes(CCNode* node){
auto direction = static_cast<int>(layout->getMainAxisDirection());
ImGui::Text("Main Axis Direction");
bool updateDirection = false;

updateDirection |= ImGui::RadioButton(
axisDirection.c_str(), &direction, static_cast<int>(AxisDirection::FrontToBack)
);
Expand Down Expand Up @@ -995,10 +995,10 @@ void DevTools::drawLayoutAttributes(CCNode* node){
}
if (hasMinRelativeScale) {
if (ImGui::DragFloat("Min Relative Scale", &minRelativeScale)) {

layout->setMinRelativeScale(minRelativeScale);
updateLayout = true;

}
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../DevTools.hpp"
#include "../platform/utils.hpp"
#include <Geode/ui/OverlayManager.hpp>
#include <Geode/loader/Mod.hpp>
#include <misc/cpp/imgui_stdlib.h>
#include <Geode/utils/string.hpp>
#include "../ImGui.hpp"
Expand Down
Loading