Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
show trajectory, macro random seed, searchbar, show cursor, fix mirro…
Browse files Browse the repository at this point in the history
…r portals in macros, (i think?) fix some shader bugs in recorder
  • Loading branch information
maxnut committed Apr 9, 2024
1 parent 3bdcfad commit 8781ca4
Show file tree
Hide file tree
Showing 16 changed files with 499 additions and 71 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gd": {
"win": "2.204"
},
"version": "v2.8.7",
"version": "v2.9.0",
"id": "maxnu.gd_mega_overlay",
"name": "GD Mega Overlay",
"developers": ["maxnu", "SpaghettDev"],
Expand Down
2 changes: 1 addition & 1 deletion src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Common::calculateFramerate()
else
framerate = GameManager::get()->m_customFPSTarget;// MBO(float, gameManager, 900);

if (framerate < 60.f)
if (framerate < 60.f || framerate > 100000.f)
framerate = 60.f;

cocos2d::CCDirector::sharedDirector()->setAnimationInterval(1.f / framerate);
Expand Down
2 changes: 2 additions & 0 deletions src/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ void GUI::toggle()

isVisible = true;
toggled = !toggled;
//isPaused
cocos2d::CCEGLView::sharedOpenGLView()->showCursor(toggled || !PlayLayer::get() || (PlayLayer::get() && MBO(bool, PlayLayer::get(), 0x2F17)));

// 🔥🔥🔥🔥
hideTimer = toggled ? -FLT_MAX : 0;
Expand Down
3 changes: 1 addition & 2 deletions src/GUI/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ namespace GUI
inline std::vector<Shortcut> shortcuts;
inline std::vector<WindowAction*> windowActions;
inline std::string currentShortcut = "";
inline std::string searchBar = "";
inline json windowPositions;

inline bool isVisible = false;
inline bool shortcutLoop = false;
inline bool toggled = false;

inline bool hasLateInit = false;

inline bool canToggle = false;

inline float hideTimer = 0.0f;
Expand Down
85 changes: 66 additions & 19 deletions src/GUI/Widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ inline ImVec2 operator-(const ImVec2& a, const ImVec2& b)
return {a.x - b.x, a.y - b.y};
}

bool findStringCaseInsensitive(const std::string& strHaystack, const std::string& strNeedle)
{
auto it = std::search(strHaystack.begin(), strHaystack.end(), strNeedle.begin(), strNeedle.end(),
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); });
return (it != strHaystack.end());
}

bool GUI::button(const std::string& name)
{
bool result = false;
if (GUI::shouldRender())
result = ImGui::Button(name.c_str());
{
result = handleSearch(name, [&]()->bool {
return ImGui::Button(name.c_str());
});
}

if (!result)
result = GUI::Shortcut::handleShortcut(name);
Expand All @@ -37,7 +48,11 @@ bool GUI::checkbox(const std::string& name, bool* value)
{
bool result = false;
if (GUI::shouldRender())
result = customCheckbox(name.c_str(), value);
{
result = handleSearch(name, [&]()->bool {
return customCheckbox(name.c_str(), value);
});
}

if (!result)
{
Expand All @@ -57,7 +72,11 @@ bool GUI::checkbox(const std::string& name, const std::string& settingName, bool
bool value = Settings::get<bool>(settingName, default_value);

if (GUI::shouldRender())
result = customCheckbox(name.c_str(), &value);
{
result = handleSearch(name, [&]()->bool {
return customCheckbox(name.c_str(), &value);
});
}

if (!result)
{
Expand Down Expand Up @@ -250,7 +269,9 @@ bool GUI::combo(const std::string& name, int* value, const char* const items[],
return false;

GUI::pushItemWidth(80);
bool result = ImGui::Combo(name.c_str(), value, items, itemsCount);
bool result = handleSearch(name, [&]()->bool {
return ImGui::Combo(name.c_str(), value, items, itemsCount);
});
GUI::popItemWidth();
return result;
}
Expand All @@ -261,7 +282,9 @@ bool GUI::inputInt(const std::string& name, int* value, int min, int max)
if (GUI::shouldRender())
{
GUI::pushItemWidth(50);
result = ImGui::InputInt(name.c_str(), value, 0);
result = handleSearch(name, [&]()->bool {
return ImGui::InputInt(name.c_str(), value, 0);
});
GUI::popItemWidth();
}

Expand All @@ -279,7 +302,9 @@ bool GUI::inputText(const std::string& name, std::string* value, float width)
if (GUI::shouldRender())
{
GUI::pushItemWidth(width);
result = ImGui::InputText(name.c_str(), value);
result = handleSearch(name, [&]()->bool {
return ImGui::InputText(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand All @@ -292,7 +317,9 @@ bool GUI::inputInt2(const std::string& name, int* value, int min1, int max1, int
if (GUI::shouldRender())
{
GUI::pushItemWidth(90);
result = ImGui::InputInt2(name.c_str(), value, 0);
result = handleSearch(name, [&]()->bool {
return ImGui::InputInt2(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand All @@ -315,7 +342,9 @@ bool GUI::inputFloat2(const std::string& name, float* value, float min1, float m
if (GUI::shouldRender())
{
GUI::pushItemWidth(90);
result = ImGui::InputFloat2(name.c_str(), value, 0);
result = handleSearch(name, [&]()->bool {
return ImGui::InputFloat2(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand All @@ -338,7 +367,9 @@ bool GUI::inputFloat(const std::string& name, float* value, float min, float max
if (GUI::shouldRender())
{
GUI::pushItemWidth(50);
result = ImGui::InputFloat(name.c_str(), value);
result = handleSearch(name, [&]()->bool {
return ImGui::InputFloat(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand Down Expand Up @@ -382,7 +413,9 @@ bool GUI::dragInt(const std::string& name, int* value, int min, int max)
if (GUI::shouldRender())
{
GUI::pushItemWidth(50);
result = ImGui::DragInt(name.c_str(), value);
result = handleSearch(name, [&]()->bool {
return ImGui::DragInt(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand All @@ -400,7 +433,9 @@ bool GUI::dragFloat(const std::string& name, float* value, float min, float max)
if (GUI::shouldRender())
{
GUI::pushItemWidth(50);
result = ImGui::DragFloat(name.c_str(), value);
result = handleSearch(name, [&]()->bool {
return ImGui::DragFloat(name.c_str(), value);
});
GUI::popItemWidth();
}

Expand All @@ -417,14 +452,13 @@ bool GUI::colorEdit(const std::string& name, float* color, bool inputs, bool alp
if (!GUI::shouldRender())
return false;

bool result = false;

if (alpha)
result = ImGui::ColorEdit4(name.c_str(), color, inputs ? 0 : ImGuiColorEditFlags_NoInputs);
else
result = ImGui::ColorEdit3(name.c_str(), color, inputs ? 0 : ImGuiColorEditFlags_NoInputs);

return result;
return handleSearch(name, [&]()->bool
{
if (alpha)
return ImGui::ColorEdit4(name.c_str(), color, inputs ? 0 : ImGuiColorEditFlags_NoInputs);

return ImGui::ColorEdit3(name.c_str(), color, inputs ? 0 : ImGuiColorEditFlags_NoInputs);
});
}

void GUI::marker(const std::string& title, const std::string& description)
Expand Down Expand Up @@ -572,4 +606,17 @@ void GUI::tooltip(const std::string tooltip)
{
if(ImGui::IsItemHovered())
ImGui::SetTooltip(tooltip.c_str());
}

bool GUI::handleSearch(const std::string& label, const std::function<bool()>& function)
{
if(searchBar.size() > 0 && !findStringCaseInsensitive(label, searchBar))
{
ImGui::BeginDisabled();
bool res = function();
ImGui::EndDisabled();
return res;
}

return function();
}
2 changes: 2 additions & 0 deletions src/GUI/Widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ namespace GUI
void tooltip(const std::string);

bool customCheckbox(const char* label, bool* v);

bool handleSearch(const std::string& label, const std::function<bool()>& function);
};
8 changes: 7 additions & 1 deletion src/Hacks/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../JsonPatches/JsonPatches.h"
#include "../Settings.hpp"
#include "Hacks/SafeMode.h"
#include "Hacks/ShowTrajectory.h"
#include "Macrobot/Macrobot.h"

#include <Geode/modify/PlayLayer.hpp>
Expand Down Expand Up @@ -338,6 +339,9 @@ class $modify(PlayerObject)
{
void pushButton(PlayerButton btn)
{
if(ShowTrajectory::isSimulation)
return PlayerObject::pushButton(btn);

if (!clickRegistered)
{
clicks.push_back(GetTickCount());
Expand All @@ -352,7 +356,9 @@ class $modify(PlayerObject)

void releaseButton(PlayerButton btn)
{
click = false;
if(!ShowTrajectory::isSimulation)
click = false;

PlayerObject::releaseButton(btn);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/Hacks/LayoutMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ class $modify(ShaderLayer)

class $modify(EffectGameObject)
{
void triggerObject(GJBaseGameLayer* p0, int p1, gd::vector<int> const* p2)
bool triggerObject(GJBaseGameLayer* p0, int p1, gd::vector<int> const* p2)
{
if (!Settings::get<bool>("level/layout_mode", false))
return EffectGameObject::triggerObject(p0, p1, p2);

int id = this->m_objectID;

if (id == 899 || id == 1006 || id == 1007 || id == 105 || id == 29 || id == 56 || id == 915 || id == 30 || id == 58)
return;
return false;

EffectGameObject::triggerObject(p0, p1, p2);
}
Expand Down
18 changes: 10 additions & 8 deletions src/Hacks/ShowHitboxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace ShowHitboxes;

CCDrawNode* ShowHitboxes::getDrawNode()
{
return MBO(CCDrawNode*, GameManager::get()->getGameLayer(), 11632);
return GameManager::get()->getGameLayer()->m_debugDrawNode;
}

CCRect ShowHitboxes::getObjectRect(cocos2d::CCRect r, float a, float b)
Expand Down Expand Up @@ -45,8 +45,8 @@ void ShowHitboxes::drawForPlayer(CCDrawNode* node, PlayerObject* player)

CCRect* rect1 = reinterpret_cast<CCRect*(__thiscall*)(GameObject*)>(base::get() + 0x13a570)(player);
CCRect rect2 = player->m_vehicleSize >= 1.f ? getObjectRect(*rect1, 0.25f, 0.25f) : getObjectRect(*rect1, 0.4f, 0.4f);
drawRectangleHitbox(node, *rect1, ccColor4B(255, 0, 0, 255));
drawRectangleHitbox(node, rect2, ccColor4B(0, 255, 0, 255));
drawRectangleHitbox(node, *rect1, ccColor4B(255, 0, 0, 5));
drawRectangleHitbox(node, rect2, ccColor4B(0, 255, 0, 5));
}

void ShowHitboxes::forceDraw(GJBaseGameLayer* self, bool editor)
Expand Down Expand Up @@ -153,18 +153,20 @@ class $modify(CCDrawNode)
{
bool drawPolygon(CCPoint *verts, unsigned int count, const ccColor4F &colFill, float borderWidth, const ccColor4F& colBase)
{
ccColor4F colBaseNew = colBase;
ccColor4F colFillNew = colFill;

if (ShowHitboxes::debugDrawing)
{
ccColor4F colBaseNew = colBase;
ccColor4F colFillNew = colFill;

colFillNew = colBaseNew;
borderWidth = Settings::get<float>("level/show_hitbox/size", 0.25f);
colBaseNew.a = Settings::get<int>("level/show_hitbox/border_alpha", 255) / 255.f;
colFillNew.a = Settings::get<int>("level/show_hitbox/fill_alpha", 50) / 255.f;

return CCDrawNode::drawPolygon(verts, count, colFillNew, borderWidth, colBaseNew);
}
return CCDrawNode::drawPolygon(verts, count, colFillNew, borderWidth, colBaseNew);

return CCDrawNode::drawPolygon(verts, count, colFill, borderWidth, colBase);
}
};

Expand Down
Loading

0 comments on commit 8781ca4

Please sign in to comment.