diff --git a/mod.json b/mod.json index 27b6ef6..1dbf406 100644 --- a/mod.json +++ b/mod.json @@ -1,5 +1,5 @@ { - "geode": "5.0.1", + "geode": "5.3.0", "version": "v1.13.1", "gd": { "win": "2.2081", diff --git a/src/DevTools.cpp b/src/DevTools.cpp index ffe7243..c0a77c4 100644 --- a/src/DevTools.cpp +++ b/src/DevTools.cpp @@ -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(); } @@ -279,6 +279,8 @@ void DevTools::draw(GLRenderCtx* ctx) { #ifdef GEODE_IS_WINDOWS setMouseCursor(); #endif + + //ImGui::ShowDemoWindow(); } void DevTools::setupFonts() { @@ -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 } diff --git a/src/backend.cpp b/src/backend.cpp index 394efa5..765b3b4 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -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(); diff --git a/src/pages/Attributes.cpp b/src/pages/Attributes.cpp index fa49020..ce353f2 100644 --- a/src/pages/Attributes.cpp +++ b/src/pages/Attributes.cpp @@ -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(node)) ); @@ -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 { @@ -175,6 +175,13 @@ void DevTools::drawBasicAttributes(CCNode* node) { node->setTag(tag); } + if (auto particle = typeinfo_cast(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(node)) { if (auto handler = CCTouchDispatcher::get()->findHandler(delegate)) { auto priority = handler->getPriority(); @@ -190,6 +197,18 @@ void DevTools::drawBasicAttributes(CCNode* node) { ImGui::SameLine(); checkbox("Flip Y", sprite, &CCSprite::isFlipY, &CCSprite::setFlipY); } + + if (auto layer = typeinfo_cast(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( @@ -259,11 +278,45 @@ void DevTools::drawColorAttributes(CCNode* node) { } void DevTools::drawLabelAttributes(CCNode* node) { - if (auto labelNode = typeinfo_cast(node)) { - std::string str = labelNode->getString(); + if (auto label = typeinfo_cast(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(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(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(label->m_pAlignment); + if (ImGui::Combo("Alignment", ¤tAlignment, alignmentItems, IM_ARRAYSIZE(alignmentItems))) { + label->m_pAlignment = static_cast(currentAlignment); + label->setAlignment(label->m_pAlignment); } + + /*if (ImGui::Checkbox("Line Break Without Spaces", &label->m_bLineBreakWithoutSpaces)) { + label->setLineBreakWithoutSpace(label->m_bLineBreakWithoutSpaces); + }*/ } } @@ -281,6 +334,15 @@ void DevTools::drawAxisGapAttribute(CCNode* node) { void DevTools::drawTextureAttributes(CCNode* node) { if (auto textureProtocol = typeinfo_cast(node)) { + + ccBlendFunc blend = textureProtocol->getBlendFunc(); + unsigned int blendVals[2] = { blend.src, blend.dst }; + if (ImGui::InputInt2("Blend Func", reinterpret_cast(blendVals))) { + ccBlendFunc newBlend = { static_cast(blendVals[0]), static_cast(blendVals[1]) }; + textureProtocol->setBlendFunc(newBlend); + } + ImGui::NewLine(); + if (auto texture = textureProtocol->getTexture()) { if (auto spriteNode = typeinfo_cast(node)) { auto* cachedFrames = CCSpriteFrameCache::sharedSpriteFrameCache()->m_pSpriteFrames; @@ -336,43 +398,72 @@ void DevTools::drawTextureAttributes(CCNode* node) { void DevTools::drawMenuItemAttributes(CCNode* node) { if (auto menuItemNode = typeinfo_cast(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(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(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(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(); diff --git a/src/pages/GeometryDash.cpp b/src/pages/GeometryDash.cpp index 41479e3..a82c2a5 100644 --- a/src/pages/GeometryDash.cpp +++ b/src/pages/GeometryDash.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "../fonts/FeatherIcons.hpp" void drawRowAxisArrow( ImDrawList& foreground, @@ -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;