Skip to content
Draft
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
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "5.0.1",
"geode": "5.3.0",
"version": "v1.13.1",
"gd": {
"win": "2.2081",
Expand Down
11 changes: 11 additions & 0 deletions src/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ static void handleType() {
sizeof(T) == 4 ? (isSigned ? ImGuiDataType_S32 : ImGuiDataType_U32) :
isSigned ? ImGuiDataType_S64 : ImGuiDataType_U64;
fnPtr = +[](ZStringView name, T& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::DragScalar(name.c_str(), dataType, &prop);
};
return ListenerResult::Stop;
}).leak();

devtools::EnumerableFnEvent<T>().listen([](typename devtools::EnumerableFnEvent<T>::Fn*& fnPtr) {
fnPtr = +[](ZStringView label, T* value, std::span<std::pair<T, ZStringView> const> items) {
DevTools::get()->setUsedAPI(true);
ImGui::Text("%s:", label.c_str());
size_t i = 0;
bool changed = false;
Expand Down Expand Up @@ -112,6 +114,7 @@ bool devtools::button(ZStringView label) {
// checkbox
devtools::PropertyFnEvent<bool>().listen([](devtools::PropertyFnEvent<bool>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, bool& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::Checkbox(name.c_str(), &prop);
};
return ListenerResult::Stop;
Expand All @@ -120,6 +123,7 @@ bool devtools::button(ZStringView label) {
// string
devtools::PropertyFnEvent<std::string>().listen([](devtools::PropertyFnEvent<std::string>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, std::string& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::InputText(name.c_str(), &prop);
};
return ListenerResult::Stop;
Expand All @@ -128,6 +132,7 @@ bool devtools::button(ZStringView label) {
// colors
devtools::PropertyFnEvent<ccColor3B>().listen([](devtools::PropertyFnEvent<ccColor3B>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, ccColor3B& prop) {
DevTools::get()->setUsedAPI(true);
auto color = ImVec4(
prop.r / 255.f,
prop.g / 255.f,
Expand All @@ -140,12 +145,14 @@ bool devtools::button(ZStringView label) {
prop.b = static_cast<GLubyte>(color.z * 255);
return true;
}

return false;
};
return ListenerResult::Stop;
}).leak();
devtools::PropertyFnEvent<ccColor4B>().listen([](devtools::PropertyFnEvent<ccColor4B>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, ccColor4B& prop) {
DevTools::get()->setUsedAPI(true);
auto color = ImVec4(
prop.r / 255.f,
prop.g / 255.f,
Expand All @@ -165,6 +172,7 @@ bool devtools::button(ZStringView label) {
}).leak();
devtools::PropertyFnEvent<ccColor4F>().listen([](devtools::PropertyFnEvent<ccColor4F>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, ccColor4F& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::ColorEdit4(name.c_str(), reinterpret_cast<float*>(&prop));
};
return ListenerResult::Stop;
Expand All @@ -173,19 +181,22 @@ bool devtools::button(ZStringView label) {
// points/sizes
devtools::PropertyFnEvent<CCPoint>().listen([](devtools::PropertyFnEvent<CCPoint>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, CCPoint& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::DragFloat2(name.c_str(), reinterpret_cast<float*>(&prop));
};
return ListenerResult::Stop;
}).leak();

devtools::PropertyFnEvent<CCSize>().listen([](devtools::PropertyFnEvent<CCSize>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, CCSize& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::DragFloat2(name.c_str(), reinterpret_cast<float*>(&prop));
};
return ListenerResult::Stop;
}).leak();
devtools::PropertyFnEvent<CCRect>().listen([](devtools::PropertyFnEvent<CCRect>::Fn*& fnPtr) {
fnPtr = +[](ZStringView name, CCRect& prop) {
DevTools::get()->setUsedAPI(true);
return ImGui::DragFloat4(name.c_str(), reinterpret_cast<float*>(&prop));
};
return ListenerResult::Stop;
Expand Down
8 changes: 8 additions & 0 deletions src/DevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,11 @@ bool DevTools::shouldUseGDWindow() const {
return Mod::get()->getSettingValue<bool>("should-use-gd-window");

}

bool DevTools::usedAPI() {
return m_usedAPI;
}

void DevTools::setUsedAPI(bool used) {
m_usedAPI = used;
}
4 changes: 4 additions & 0 deletions src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DevTools {
bool m_shouldRelayout = false;
bool m_showModGraph = false;
bool m_pauseGame = false;
bool m_usedAPI = false;
Settings m_settings;
ImGuiID m_dockspaceID;
ImFont* m_defaultFont = nullptr;
Expand Down Expand Up @@ -140,4 +141,7 @@ class DevTools {
void toggle();

bool isVisible();

bool usedAPI();
void setUsedAPI(bool used);
};
59 changes: 55 additions & 4 deletions src/pages/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <Geode/ui/SimpleAxisLayout.hpp>
#include <Geode/ui/Layout.hpp>
#include <Geode/utils/file.hpp>
#include <Geode/ui/Button.hpp>
#include <Geode/ui/NineSlice.hpp>

using namespace geode::prelude;

Expand Down Expand Up @@ -49,15 +51,19 @@ void DevTools::drawNodeAttributes(CCNode* node) {
drawTextureAttributes(node);
drawMenuItemAttributes(node);

setUsedAPI(false);
for (auto& callback : m_customCallbacks) {
ImGui::PushID(&callback);
callback(node);
ImGui::PopID();
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
// fixes that extra separator for nodes that the API isn't used on
if (usedAPI()) {
ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
}

drawLayoutOptionsAttributes(node);

Expand Down Expand Up @@ -280,6 +286,9 @@ void DevTools::drawAxisGapAttribute(CCNode* node) {
}

void DevTools::drawTextureAttributes(CCNode* node) {
if (auto nineSlice = typeinfo_cast<geode::NineSlice*>(node)) {
node = nineSlice->getBatchNode();
}
if (auto textureProtocol = typeinfo_cast<CCTextureProtocol*>(node)) {
if (auto texture = textureProtocol->getTexture()) {
if (auto spriteNode = typeinfo_cast<CCSprite*>(node)) {
Expand Down Expand Up @@ -309,8 +318,8 @@ void DevTools::drawTextureAttributes(CCNode* node) {
if (ImGui::Checkbox("Rotate Rect", &isRectRotated)) {
spriteNode->setTextureRect(spriteNode->getTextureRect(), isRectRotated, spriteNode->getContentSize());
}
ImGui::NewLine();
}
ImGui::NewLine();
auto* cachedTextures = CCTextureCache::sharedTextureCache()->m_pTextures;
for (auto [key, obj] : CCDictionaryExt<std::string, CCTexture2D*>(cachedTextures)) {
if (obj == texture) {
Expand Down Expand Up @@ -373,6 +382,48 @@ void DevTools::drawMenuItemAttributes(CCNode* node) {
}
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
}
if (auto button = typeinfo_cast<geode::Button*>(node)) {

if (ImGui::Button(U8STR(FEATHER_LINK " Activate##activatebutton"))) {
button->selected();
button->activate();
}
checkbox("Enabled##enabledbutton", button, &geode::Button::isEnabled, &geode::Button::setEnabled);

float touchMult = button->getTouchMultiplier();
if (ImGui::DragFloat("Touch Size Multiplier##buttonsizemult", &touchMult, .1f)) {
button->setTouchMultiplier(touchMult);
}

float scaleMult = button->getScaleMultiplier();
if (ImGui::DragFloat("Scale Multiplier (AnimationType::Scale)##buttonscalemult", &scaleMult, .1f)) {
button->setScaleMultiplier(scaleMult);
}

float selectedDuration = button->getSelectedDuration();
if (ImGui::DragFloat("Selected Duration##buttonselectedduration", &selectedDuration, .1f)) {
button->setSelectedDuration(selectedDuration);
}

float unselectedDuration = button->getUnselectedDuration();
if (ImGui::DragFloat("Unselected Duration##buttonunselectedduration", &unselectedDuration, .1f)) {
button->setUnselectedDuration(unselectedDuration);
}

auto moveOffset = button->getMoveOffset();

float moveOffsetArr[2] = {
moveOffset.x,
moveOffset.y
};
if (ImGui::DragFloat2("Move Offset (AnimationType::Move)##buttonmoveoffset", moveOffsetArr)) {
button->setMoveOffset({moveOffsetArr[0], moveOffsetArr[1]});
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
Expand Down
Loading