Skip to content

Commit

Permalink
remove imgui so ios can at least build
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Jul 11, 2024
1 parent 8d9f016 commit 0dc9714
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 410 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,4 @@ foreach(MODULE ${MODULES_LIST})
endif()
endforeach()

#if("$ENV{USERNAME}" STREQUAL "talgo")
#add_definitions(-DFREEMOVE)
#endif()

CPMAddPackage("gh:matcool/gd-imgui-cocos#4eb5777") # specify a commit!

target_link_libraries(${PROJECT_NAME} imgui-cocos)

setup_geode_mod(${PROJECT_NAME})
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.8

- Removed all imgui code so that wine players can use qolmod

# 1.4.7

- Fixed the UI Button disappearing if you have Transition Customizer enabled
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.2.0",
"version": "v1.4.7",
"version": "v1.4.8",
"gd": {
"win": "2.206",
"android": "2.206"
Expand Down
48 changes: 0 additions & 48 deletions src/Client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,6 @@ class Client
mod = Mod::get();
}

void draw()
{
Module::descMod = "";

over = false;

style();
instance = this;

ImGui::Begin("draw", 0, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoMouseInputs);
ImGui::SetWindowPos(ImVec2(0, 0));
ImGui::SetWindowSize(ImGui::GetIO().DisplaySize);

auto v = std::vector<float> {};
for (size_t i = 0; i < windows.size(); i++)
{
v.push_back(windows[i]->windowPos.x);
}
std::sort(v.begin(), v.end(), std::greater<float>());
std::reverse(v.begin(), v.end());

bool a = false;
for (size_t i = 0; i < windows.size(); i++)
{
//windows[i]->a = a;
//windows[i]->i = windows[i]->getIndex(v, windows[i]->windowPos.x);
//a = !a;

//if (windows[i]->draw(false/*CompactMode::instance->enabled*/ ? tileSizeCompact : tileSize, animStatus))
//over = true;
}

ImGui::SetNextWindowFocus();

ImGui::GetIO().WantCaptureMouse = over;
}

void style()
{
ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = true;

ImGuiStyle* style = &ImGui::GetStyle();

style->FramePadding = ImVec2(0, 0);
style->WindowRounding = 0.0f;
style->WindowPadding = ImVec2(0, 0);
}

//[[deprecated("GetModuleEnabled has been deprecated due to lag, please rember to cache the module :3")]]
static bool GetModuleEnabled(std::string id)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Client/ColourUtility.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef QOLMOD_IMGUI

#include "ColourUtility.h"

ImColor ColourUtility::GetColour(ClientColour colour)
Expand Down Expand Up @@ -36,4 +38,6 @@ ImColor ColourUtility::GetColour(ClientColour colour)
}

return ImColor(255, 0, 255);
}
}

#endif
4 changes: 4 additions & 0 deletions src/Client/ColourUtility.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifdef QOLMOD_IMGUI
#include <imgui-cocos.hpp>
#endif

class ColourUtility
{
Expand Down Expand Up @@ -42,7 +44,9 @@ class ColourUtility
GradientRight,
};

#ifdef QOLMOD_IMGUI
static ImColor GetColour(ClientColour colour);
#endif

static inline int pastel = 0;

Expand Down
23 changes: 5 additions & 18 deletions src/Client/DrawUtils.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#pragma once

#ifdef QOLMOD_IMGUI
#include <imgui-cocos.hpp>
#endif

class DrawUtils
{
public:
#ifdef QOLMOD_IMGUI
static inline ImFont* title = nullptr;
static inline ImFont* mod = nullptr;

Expand All @@ -23,9 +26,7 @@ class DrawUtils

static void drawRect(ImVec2 pos, ImVec2 size, ImColor colour)
{
#ifdef GEODE_IS_WINDOWS
ImGui::GetWindowDrawList()->AddRectFilled(pos, addImVec2(pos, size), colour, 0.0f);
#endif
}

static ImColor LerpColor(const ImColor& c1, const ImColor& c2, float t) {
Expand All @@ -41,7 +42,6 @@ class DrawUtils

static void drawGradient(ImVec2 apos, ImVec2 size, ImColor colour, ImColor colour2)
{
#ifdef GEODE_IS_WINDOWS
auto list = ImGui::GetWindowDrawList();

for (size_t i = 0; i < size.x; i++)
Expand All @@ -51,12 +51,10 @@ class DrawUtils
list->AddLine(pos, addImVec2(pos, ImVec2(0, size.y)), LerpColor(colour, colour2, i / size.x));
}

#endif
}

static void anchoredText(ImVec2 pos, ImVec2 size, std::string text, ImColor colour = ImColor(ImVec4(255, 255, 255, 255)), ImVec2 anchor = ImVec2(0.5f, 0.5f))
{
#ifdef GEODE_IS_WINDOWS
float s = size.x / ImGui::CalcTextSize(text.c_str()).x;
if (s > 1)
s = 1;
Expand All @@ -65,7 +63,6 @@ class DrawUtils


ImGui::TextColored(colour, text.c_str());
#endif
}

static ImColor imColorFromccColor3B(geode::prelude::ccColor3B col)
Expand All @@ -91,21 +88,11 @@ class DrawUtils
return false;
}

#endif

/// <summary>
/// z = width, w = height
/// </summary>
static bool pointWithinRect(ImVec2 point, ImVec4 rect)
{
if (point.x > rect.x && point.y > rect.y)
{
if (point.x < rect.x + rect.z && point.y < rect.y + rect.w)
{
return true;
}
}

return false;
}

enum animType
{
Expand Down
106 changes: 0 additions & 106 deletions src/Client/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,6 @@ class Module

void drawModule(CCPoint pointTopLeft);

virtual bool Draw(ImVec2 tileSize)
{
ImVec2 pos = ImGui::GetCursorPos();

DrawUtils::drawRect(pos, tileSize, ColourUtility::GetColour(DrawUtils::mouseWithinRect(ImVec4(pos.x, pos.y, tileSize.x, tileSize.y)) ? (ImGui::IsMouseDown(ImGuiMouseButton_Left) ? ColourUtility::ClientColour::Pressed : ColourUtility::ClientColour::Hovered) : ColourUtility::ClientColour::WindowBG));

DrawUtils::anchoredText(DrawUtils::addImVec2(pos, ImVec2(3, 0)), tileSize, name.c_str(), ColourUtility::GetColour(enabled ? ColourUtility::Accent : ColourUtility::Text), ImVec2(0, 0.5f));

ImGui::SetCursorPos(pos);
if (DrawUtils::mouseWithinRect(ImVec4(pos.x, pos.y, tileSize.x, tileSize.y)))
{
descMod = description;

if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{
enabled = !enabled;

this->save();
return true;
}
}

return false;
}

virtual void onChange()
{
if (delegate)
Expand Down Expand Up @@ -186,58 +161,6 @@ class InputModule : public Module, public TextInputDelegate
float getFloatValue();
int getIntValue();

bool Draw(ImVec2 tileSize)
{
ImVec2 pos = ImGui::GetCursorPos();

DrawUtils::drawRect(pos, tileSize, ColourUtility::GetColour(ColourUtility::ClientColour::WindowBG));
DrawUtils::drawRect(ImVec2(pos.x + 4, pos.y + 4), ImVec2(tileSize.x - 4 - 4, tileSize.y - 4 - 4), ColourUtility::GetColour(ColourUtility::ClientColour::InputField));

if (selected == this)
{
if ((int)(round(ImGui::GetTime() / 0.5f)) % 2 == 0)
{
DrawUtils::drawRect(ImVec2(pos.x + 4 + 2 + (ImGui::CalcTextSize(text.c_str()).x), pos.y + 4 + 4), ImVec2(2, tileSize.y - 4 - 4 - 4 - 4), ColourUtility::GetColour(ColourUtility::ClientColour::InputCarot));
}
}

std::stringstream s;

for (size_t i = 0; i < format.size(); i++)
{
if (format[i] == '%')
{
s << text;
}
else
{
s << format[i];
}
}

DrawUtils::anchoredText(ImVec2(pos.x + 4 + 2, pos.y + 4), ImVec2(tileSize.x - (4 + 4) - (2 + 2), tileSize.y - 4 - 4), s.str(), ImColor(255, 255, 255), ImVec2(0.0f, 0.5f));

ImGui::SetCursorPos(pos);

if (DrawUtils::mouseWithinRect(ImVec4(pos.x + 4, pos.y + 4, tileSize.x - 4 - 4, tileSize.y - 4 - 4)))
{
if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
{
selected = this;
}
}

if (selected == this)
this->save();

onChange();

if (DrawUtils::mouseWithinRect(ImVec4(pos.x, pos.y, tileSize.x, tileSize.y)))
Module::descMod = description;

return false;
}

void save()
{
geode::prelude::Mod::get()->setSavedValue<std::string>(id + "_value", text);
Expand Down Expand Up @@ -318,22 +241,6 @@ class ColourModule : public Module
this->load();
}

bool Draw(ImVec2 tileSize)
{
ImVec2 pos = ImGui::GetCursorPos();

auto v = name;
//name = "";
auto res = Module::Draw(tileSize);
//name = v;

float height = tileSize.y - 10;

DrawUtils::drawRect(DrawUtils::addImVec2(DrawUtils::addImVec2(pos, tileSize), ImVec2(-(5 + height), -(5 + height))), ImVec2(height, height), DrawUtils::imColorFromccColor3B(colour));

return res;
}

void save()
{
geode::prelude::Mod::get()->setSavedValue<ccColor3B>(id + "_value", colour);
Expand Down Expand Up @@ -548,19 +455,6 @@ class InfoModule : public Module
description = d;
}

bool Draw(ImVec2 tileSize)
{
ImVec2 pos = ImGui::GetCursorPos();

DrawUtils::drawRect(pos, tileSize, ColourUtility::GetColour(ColourUtility::ClientColour::WindowBG));
DrawUtils::anchoredText(pos, tileSize, name.c_str(), ColourUtility::GetColour(ColourUtility::Text));

if (DrawUtils::mouseWithinRect(ImVec4(pos.x, pos.y, tileSize.x, tileSize.y)))
Module::descMod = description;

return false;
}

void save()
{
}
Expand Down
Loading

1 comment on commit 0dc9714

@chemreal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch ios never be worked on

Please sign in to comment.