Skip to content

Commit

Permalink
i deifnetly should
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Nov 28, 2024
1 parent 313ac24 commit 782366c
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 5 deletions.
37 changes: 36 additions & 1 deletion include/QOLModExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,39 @@ Window* windowFromWindowExt(WindowExt* wndExt)

return ListenerResult::Stop;
});
};
};

// idk bro i feel like dying im very tired i dont know what most of this does
// i should sleep
/*
$on_mod(Loaded)
{
int i = 0;
for (Mod* mod : Loader::get()->getAllMods())
{
if (mod->shouldLoad() && mod->getMetadata().getSettings().size() != 0)
{
auto wnd = QOLModExt::createWindow(mod->getID());
wnd->setName(mod->getName());
wnd->setPriority(10000 * (i + 1));
for (auto setting : mod->getMetadata().getSettings())
{
if (setting.second["type"] == "bool")
{
std::string id = fmt::format("{}/{}", mod->getID(), setting.first);
auto mod = QOLModExt::createModule(id);
mod->setName(setting.second["name"].asString().unwrapOr("NULL"));
wnd->addModule(mod);
}
}
QOLModExt::pushWindow(wnd);
i++;
}
}
};
*/
1 change: 1 addition & 0 deletions resources/midgahack.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Size:Titlebar]
69 changes: 66 additions & 3 deletions src/Client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ bool Client::handleKeybinds(enumKeyCodes key, bool isDown, bool isRepeatedKey)

bool Client::useImGuiUI()
{
return true;

if (LaunchArgs::get()->hasLaunchArg("--qolmod:use-imgui-ui"))
return true;

Expand All @@ -82,7 +84,8 @@ void Client::initImGui()

setUIScale(mod->getSavedValue<float>("imgui-ui-scale", 1.0f));

loadImGuiTheme("catppuccin-frappe.ini");
// loadImGuiTheme("catppuccin-frappe.ini");
loadImGuiTheme("midgahack.ini");

sortWindows(true);

Expand Down Expand Up @@ -115,7 +118,7 @@ void Client::drawImGui()
window->drawImGui();
}

// ImGui::ShowStyleEditor();
ImGui::ShowStyleEditor();

if (hoveredModule && !hoveredModule->description.empty())
{
Expand All @@ -133,6 +136,63 @@ void Client::drawImGui()

void Client::sortWindows(bool instant)
{
float x = 15;
std::map<float, float> yMap;
bool stacking = false;

std::sort(Client::instance->windows.begin(), Client::instance->windows.end(), [](Window* a, Window* b)
{
return a->priority < b->priority;
});

for (auto window : windows)
{
if (!yMap.contains(x))
yMap[x] = 15;

if (x + window->getDesiredWindowSize().x > ImGui::GetIO().DisplaySize.x)
{
x = 15;
stacking = true;
}

ImVec2 wndPos = ImVec2(x, yMap[x + window->getDesiredWindowSize().x + 15]);

for (size_t i = 0; i < 8; i++)
{
if (wndPos.y + window->getDesiredWindowSize().y > ImGui::GetIO().DisplaySize.y)
{
x += window->getDesiredWindowSize().x + 15;

wndPos = ImVec2(x, yMap[x + window->getDesiredWindowSize().x + 15]);
}
}

x += window->getDesiredWindowSize().x + 15;
yMap[x] += window->getDesiredWindowSize().y + 15;

wndPos.y += 15;

if (instant)
{
window->setPosition(ccp(wndPos.x, wndPos.y));
window->actualWindowPos = wndPos;
}
else
{
if (window->getActionByTag(69))
window->stopActionByTag(69);

auto action = CCEaseInOut::create(CCMoveTo::create(instant ? 0 : 0.5f, ccp(wndPos.x, wndPos.y)), 2);
action->setTag(69);

window->runAction(action);
window->actualWindowPos = wndPos;
}
}

return;

ImVec2 configSize;

for (auto window : windows)
Expand Down Expand Up @@ -252,7 +312,10 @@ void Client::setUIScale(float scale)

Loader::get()->queueInMainThread([this, oldScale, scale]
{
sortWindows(false);
Loader::get()->queueInMainThread([this, oldScale, scale]
{
sortWindows(false);
});
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/Client/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ void Window::drawImGui()

ImVec2 Window::getDesiredWindowSize()
{
return ImVec2(215, 25 * ((std::min<int>(modules.size(), 40) * closedTimer) + 1));
auto vec = ImVec2(215, 25 * ((std::min<int>(modules.size(), 40) * closedTimer) + 1));

vec.y = clamp<float>(vec.y, 0, ImGui::GetIO().DisplaySize.y - (15 + 15));

return vec;
}

const CCPoint& Window::getPosition()
Expand Down

0 comments on commit 782366c

Please sign in to comment.