Skip to content
Open
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
8 changes: 5 additions & 3 deletions src/DevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ void DevTools::drawPage(const char* name, void(DevTools::*pageFun)()) {
if (ImGui::Begin(name, nullptr, ImGuiWindowFlags_HorizontalScrollbar)) {
(this->*pageFun)();

#ifdef GEODE_IS_MOBILE
//#ifdef GEODE_IS_MOBILE why..?
mobileScrollBehavior();
#endif
//#endif
}
ImGui::End();
}
Expand Down Expand Up @@ -279,6 +279,8 @@ void DevTools::draw(GLRenderCtx* ctx) {
#ifdef GEODE_IS_WINDOWS
setMouseCursor();
#endif

//ImGui::ShowDemoWindow();
}

void DevTools::setupFonts() {
Expand Down Expand Up @@ -332,7 +334,7 @@ void DevTools::setup() {

#ifdef GEODE_IS_MOBILE
ImGui::GetIO().FontGlobalScale = 2.f;
ImGui::GetStyle().ScrollbarSize = 60.f;
ImGui::GetStyle().ScrollbarSize = 30.f;
// ImGui::GetStyle().TabBarBorderSize = 60.f;
#endif
}
Expand Down
7 changes: 7 additions & 0 deletions src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,17 @@ void DevTools::newFrame() {

// TODO: text input

//bruh
#ifdef GEODE_IS_WINDOWS
io.AddKeyEvent(ImGuiKey_ModAlt, (GetAsyncKeyState(VK_MENU) & 0x8000) != 0);
io.AddKeyEvent(ImGuiKey_ModCtrl, (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0);
io.AddKeyEvent(ImGuiKey_ModShift, (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0);
#else
auto* kb = director->getKeyboardDispatcher();
io.KeyAlt = kb->getAltKeyPressed() || kb->getCommandKeyPressed(); // look
io.KeyCtrl = kb->getControlKeyPressed();
io.KeyShift = kb->getShiftKeyPressed();
#endif

#ifdef GEODE_IS_MOBILE
auto ime = DevToolsIMEDelegate::get();
Expand Down
143 changes: 117 additions & 26 deletions src/pages/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void DevTools::drawBasicAttributes(CCNode* node) {

ImGui::Text("Address: %s", fmt::to_string(fmt::ptr(node)).c_str());
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_COPY " Copy"))) {
if (ImGui::SmallButton(U8STR(FEATHER_COPY " Copy"))) {
clipboard::write(
fmt::format("{:#x}", reinterpret_cast<uintptr_t>(node))
);
Expand All @@ -117,7 +117,7 @@ void DevTools::drawBasicAttributes(CCNode* node) {
std::string nodeID = node->getID();
ImGui::Text("Node ID: %s", nodeID.c_str());
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_COPY " Copy##copynodeid"))) {
if (ImGui::SmallButton(U8STR(FEATHER_COPY " Copy##copynodeid"))) {
clipboard::write(nodeID);
}
} else {
Expand Down Expand Up @@ -175,6 +175,13 @@ void DevTools::drawBasicAttributes(CCNode* node) {
node->setTag(tag);
}

if (auto particle = typeinfo_cast<CCParticleSystemQuad*>(node)) {
std::string ps = GameToolbox::saveParticleToString(particle).c_str();
if (ImGui::InputText("Particle String", &ps, 256)) {
GameToolbox::particleFromString(ps.c_str(), particle, 0);
}
}

if (auto delegate = typeinfo_cast<CCTouchDelegate*>(node)) {
if (auto handler = CCTouchDispatcher::get()->findHandler(delegate)) {
auto priority = handler->getPriority();
Expand All @@ -190,6 +197,18 @@ void DevTools::drawBasicAttributes(CCNode* node) {
ImGui::SameLine();
checkbox("Flip Y", sprite, &CCSprite::isFlipY, &CCSprite::setFlipY);
}

if (auto layer = typeinfo_cast<CCLayer*>(node)) {
checkbox("Touch", layer, &CCLayer::isTouchEnabled, &CCLayer::setTouchEnabled);
ImGui::SameLine();
checkbox("Mouse", layer, &CCLayer::isMouseEnabled, &CCLayer::setMouseEnabled);
ImGui::SameLine();
checkbox("Keypad", layer, &CCLayer::isKeypadEnabled, &CCLayer::setKeypadEnabled);
ImGui::SameLine();
checkbox("Keyboard", layer, &CCLayer::isKeyboardEnabled, &CCLayer::setKeyboardEnabled);

checkbox("Accelerometer Enabled", layer, &CCLayer::isAccelerometerEnabled, &CCLayer::setAccelerometerEnabled);
}

checkbox("Visible", node, &CCNode::isVisible, &CCNode::setVisible);
checkbox(
Expand Down Expand Up @@ -259,11 +278,45 @@ void DevTools::drawColorAttributes(CCNode* node) {
}

void DevTools::drawLabelAttributes(CCNode* node) {
if (auto labelNode = typeinfo_cast<CCLabelProtocol*>(node)) {
std::string str = labelNode->getString();
if (auto label = typeinfo_cast<CCLabelProtocol*>(node)) {
// Abuse matjson to support escape seq and stuff
std::string str = matjson::Value(label->getString()).dump();
if (ImGui::InputText("Text", &str, 256)) {
labelNode->setString(str.c_str());
auto parse = matjson::parseAs<std::string>(str);
if (parse.err()) {
ImGui::BeginErrorTooltip();
ImGui::Text("Parse error: %s", parse.err().value_or("unk").c_str());
ImGui::EndTooltip();
}
else label->setString(parse.unwrapOrDefault().c_str());
}
}
if (auto label = typeinfo_cast<CCLabelBMFont*>(node)) {

std::string fnt = label->m_sFntFile.c_str();
if (ImGui::InputText("Fnt File", &fnt, 256)) {
auto exists = cocos::fileExistsInSearchPaths(fnt.c_str());
if (exists) label->setFntFile(fnt.c_str());
else {
ImGui::BeginErrorTooltip();
ImGui::Text("File not found: %s!", fnt.c_str());
ImGui::EndTooltip();
}
}

if (ImGui::InputInt("Extra Kerning", &label->m_nExtraKerning)) label->setExtraKerning(label->m_nExtraKerning); //inlined btw
if (ImGui::DragFloat("Width", &label->m_fWidth, 0.1f)) if (label->m_fWidth) label->setWidth(label->m_fWidth);

const char* alignmentItems[] = { "Left", "Center", "Right" };
int currentAlignment = static_cast<int>(label->m_pAlignment);
if (ImGui::Combo("Alignment", &currentAlignment, alignmentItems, IM_ARRAYSIZE(alignmentItems))) {
label->m_pAlignment = static_cast<CCTextAlignment>(currentAlignment);
label->setAlignment(label->m_pAlignment);
}

/*if (ImGui::Checkbox("Line Break Without Spaces", &label->m_bLineBreakWithoutSpaces)) {
label->setLineBreakWithoutSpace(label->m_bLineBreakWithoutSpaces);
}*/
}
}

Expand All @@ -281,6 +334,15 @@ void DevTools::drawAxisGapAttribute(CCNode* node) {

void DevTools::drawTextureAttributes(CCNode* node) {
if (auto textureProtocol = typeinfo_cast<CCTextureProtocol*>(node)) {

ccBlendFunc blend = textureProtocol->getBlendFunc();
unsigned int blendVals[2] = { blend.src, blend.dst };
if (ImGui::InputInt2("Blend Func", reinterpret_cast<int*>(blendVals))) {
ccBlendFunc newBlend = { static_cast<GLenum>(blendVals[0]), static_cast<GLenum>(blendVals[1]) };
textureProtocol->setBlendFunc(newBlend);
}
ImGui::NewLine();

if (auto texture = textureProtocol->getTexture()) {
if (auto spriteNode = typeinfo_cast<CCSprite*>(node)) {
auto* cachedFrames = CCSpriteFrameCache::sharedSpriteFrameCache()->m_pSpriteFrames;
Expand Down Expand Up @@ -336,43 +398,72 @@ void DevTools::drawTextureAttributes(CCNode* node) {

void DevTools::drawMenuItemAttributes(CCNode* node) {
if (auto menuItemNode = typeinfo_cast<CCMenuItem*>(node)) {
//selector
const auto selector = menuItemNode->m_pfnSelector;
if (!selector) {
std::string addr = "N/A";
ImGui::Text("CCMenuItem selector: %s", addr.c_str());
} else {
}
else {
const auto addr = formatAddressIntoOffset(addresser::getNonVirtual(selector), true);
ImGui::Text("CCMenuItem selector: %s", addr.c_str());
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_COPY " Copy##copymenuitem"))) {
if (ImGui::SmallButton(U8STR(FEATHER_COPY " Copy##copymenuitem"))) {
const auto addrNoModule = formatAddressIntoOffset(addresser::getNonVirtual(selector), false);
clipboard::write(addrNoModule);
}
}
if (ImGui::Button(U8STR(FEATHER_LINK " Activate##activatemenuitem"))) {
menuItemNode->activate();
//listener
const auto listener = menuItemNode->m_pListener;
if (!listener) {
std::string addr = "N/A";
ImGui::Text("CCMenuItem listener: %s", addr.c_str());
}
checkbox("Enabled##enabledmenuitem", menuItemNode, &CCMenuItem::isEnabled, &CCMenuItem::setEnabled);

if (auto menuItemSpriteExtra = typeinfo_cast<CCMenuItemSpriteExtra*>(menuItemNode)) {
bool animationEnabled = menuItemSpriteExtra->m_animationEnabled;
if (ImGui::Checkbox("Animation Enabled##menuitemanimationenabled", &animationEnabled)) {
menuItemSpriteExtra->m_animationEnabled = animationEnabled;
}
float sizeMult = menuItemSpriteExtra->m_fSizeMult;
if (ImGui::DragFloat("Size Multiplier##menuitemsizemult", &sizeMult, .1f)) {
menuItemSpriteExtra->setSizeMult(sizeMult);
}
float scaleMultiplier = menuItemSpriteExtra->m_scaleMultiplier;
if (ImGui::DragFloat("Scale Multipler##menuitemscalemultiplier", &scaleMultiplier, .03f)) {
menuItemSpriteExtra->m_scaleMultiplier = scaleMultiplier;
else {
const auto addr = fmt::to_string(fmt::ptr(node));
ImGui::Text("CCMenuItem listener: %s", addr.c_str());
if (auto listenerNode = typeinfo_cast<CCNode*>(listener)) {
ImGui::SameLine();
if (ImGui::SmallButton("Select Node##selmenuitemlistener")) m_selectedNode = listenerNode;
if (ImGui::IsItemHovered()) highlightNode(listenerNode, HighlightMode::Hovered);
}
float baseScale = menuItemSpriteExtra->m_baseScale;
if (ImGui::DragFloat("Base Scale##menuitembasescale", &baseScale, .03f)) {
menuItemSpriteExtra->m_baseScale = baseScale;
ImGui::SameLine();
if (ImGui::SmallButton(U8STR(FEATHER_COPY " Copy##copymenuitemlistener"))) {
const auto addrNoModule = formatAddressIntoOffset(addresser::getNonVirtual(listener), false);
clipboard::write(addrNoModule);
}
}

if (ImGui::Button(U8STR(FEATHER_LINK " Activate##activatemenuitem"))) menuItemNode->activate();
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_LINK " Select##activatemenuitem"))) menuItemNode->selected();
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_LINK " Unselect##activatemenuitem"))) menuItemNode->unselected();
ImGui::SameLine();
checkbox("Enabled##enabledmenuitem", menuItemNode, &CCMenuItem::isEnabled, &CCMenuItem::setEnabled);

if (auto extra = typeinfo_cast<CCMenuItemSpriteExtra*>(menuItemNode)) {
std::string m_activateSound = extra->m_activateSound.c_str();
if (ImGui::InputText("Activate Sound", &m_activateSound, 256)) extra->m_activateSound = m_activateSound.c_str();
std::string m_selectSound = extra->m_selectSound.c_str();
if (ImGui::InputText("Select Sound", &m_selectSound, 256)) extra->m_selectSound = m_selectSound.c_str();

ImGui::Checkbox("Animation Enabled##menuitemanimationenabled", &extra->m_animationEnabled);
if (extra->m_animationEnabled) {
ImGui::DragFloat("Selected duration##menuitem""m_duration", &extra->m_duration, .03f);
ImGui::DragFloat("Unselected duration##menuitem""m_unselectedDuration", &extra->m_unselectedDuration, .03f);
if (ImGui::DragFloat("Size Multiplier##menuitemsizemult", &extra->m_fSizeMult, .01f)) {
extra->setSizeMult(extra->m_fSizeMult);
}
ImGui::DragFloat("Scale Multipler##menuitemscalemultiplier", &extra->m_scaleMultiplier, .01f);
ImGui::DragFloat("Base Scale##menuitembasescale", &extra->m_baseScale, .01f);
};

ImGui::DragFloat("##menuitemcolordip", &extra->m_colorDip, .01f);
ImGui::SameLine();
ImGui::Checkbox("Color Dip##menuitemcolorenabled", &extra->m_colorEnabled);
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
Expand Down
44 changes: 43 additions & 1 deletion src/pages/GeometryDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Geode/binding/GJDropDownLayer.hpp>
#include <Geode/ui/Layout.hpp>
#include <Geode/ui/SimpleAxisLayout.hpp>
#include "../fonts/FeatherIcons.hpp"

void drawRowAxisArrow(
ImDrawList& foreground,
Expand Down Expand Up @@ -384,7 +385,48 @@ void DevTools::drawGD(GLRenderCtx* gdCtx) {
"Geometry Dash ({}x{})###devtools/geometry-dash",
winSize.width, winSize.height
);
if (ImGui::Begin(title.c_str())) {
bool gameStayAlive = true;
if (ImGui::Begin(title.c_str(), &gameStayAlive, ImGuiWindowFlags_MenuBar)) {

if (!gameStayAlive) game::exit(true);

if (ImGui::BeginMenuBar()) {
if (ImGui::MenuItem(U8STR(FEATHER_SAVE " Save"))) {
AppDelegate::get()->trySaveGame(0);
}

ImGui::SameLine();

static float time;
auto currentTime = CCDirector::get()->getScheduler()->getTimeScale();
time = currentTime > 0 ? currentTime : time;

if (ImGui::MenuItem(U8STR(
m_pauseGame ? FEATHER_LOCK " Resume" : FEATHER_UNLOCK " Pause"
))) {
m_pauseGame ^= 1;
if (m_pauseGame) {
FMODAudioEngine::sharedEngine()->pauseAllAudio();
CCDirector::get()->getScheduler()->setTimeScale(0.0f);
}
else {
FMODAudioEngine::sharedEngine()->resumeAllAudio();
CCDirector::get()->getScheduler()->setTimeScale(time);
}
}

ImGui::SameLine();
if (ImGui::MenuItem(U8STR(FEATHER_PACKAGE " Reload"))) {
GameManager::get()->reloadAll(0, 0, 0);
}

ImGui::SameLine();
if (ImGui::MenuItem(U8STR(FEATHER_REFRESH_CW " Restart"))) {
game::restart(true);
}
}
ImGui::EndMenuBar();

auto list = ImGui::GetWindowDrawList();
auto ratio = gdCtx->size().x / gdCtx->size().y;

Expand Down
Loading