Skip to content

Commit

Permalink
v5 (pizdec)
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyAdd committed Nov 25, 2024
1 parent 477b859 commit 1e9ed0f
Show file tree
Hide file tree
Showing 33 changed files with 859 additions and 6,091 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ build-*/

# ILY vscode
**/.vscode
.idea/

# Local History for Visual Studio Code
.history/

# clangd
.cache/
Expand All @@ -58,4 +60,5 @@ build-*/
.vs/

# CLion
/cmake-build-*/
.idea/
/cmake-build-*/
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(GDH VERSION 1.0.0)

add_compile_definitions(UNICODE _UNICODE)

file(GLOB_RECURSE SOURCES src/*.cpp)
add_library(${PROJECT_NAME} SHARED ${SOURCES})

Expand All @@ -23,7 +21,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE libs)

set(HAS_IMGUI ON)
add_subdirectory(libs/imgui)
CPMAddPackage("gh:matcool/gd-imgui-cocos#fbd4103")
CPMAddPackage("gh:matcool/gd-imgui-cocos#8973953")
target_link_libraries(${PROJECT_NAME} imgui-cocos imgui)

setup_geode_mod(${PROJECT_NAME})
29 changes: 0 additions & 29 deletions LICENSE.txt

This file was deleted.

57 changes: 37 additions & 20 deletions libs/imgui/imgui-theme.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
#include <imgui.h>

void ApplyColor() {
static void ApplyGuiColors(bool invert) {
auto* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_WindowBg] = ImColor(27, 27, 29, 250);
colors[ImGuiCol_Button] = ImColor(165, 255, 190);
colors[ImGuiCol_ButtonHovered] = ImColor(105, 210, 160);
colors[ImGuiCol_ButtonActive] = ImColor(85, 170, 130);
colors[ImGuiCol_Border] = ImColor(64, 64, 64);
colors[ImGuiCol_TitleBg] = ImColor(58,58,58);

auto invertColor = [](const ImVec4& color) -> ImVec4 {
return ImVec4(1.0f - color.x, 1.0f - color.y, 1.0f - color.z, color.w);
};

colors[ImGuiCol_Text] = invert ? invertColor(ImColor(225, 225, 225, 225)) : ImColor(225, 225, 225, 225).Value;
colors[ImGuiCol_WindowBg] = invert ? invertColor(ImColor(27, 27, 29, 250)) : ImColor(27, 27, 29, 250).Value;
colors[ImGuiCol_Border] = invert ? invertColor(ImColor(64, 64, 64)) : ImColor(64, 64, 64).Value;
colors[ImGuiCol_TitleBg] = invert ? invertColor(ImColor(58, 58, 58)) : ImColor(58, 58, 58).Value;
colors[ImGuiCol_TitleBgActive] = colors[ImGuiCol_TitleBg];
colors[ImGuiCol_TitleBgCollapsed] = colors[ImGuiCol_TitleBg];
colors[ImGuiCol_ScrollbarBg] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_FrameBg] = ImColor(52,52,52);
colors[ImGuiCol_FrameBgHovered] = ImColor(72,72,72);
colors[ImGuiCol_FrameBgActive] = ImColor(90,90,90);
colors[ImGuiCol_ResizeGrip] = ImColor(58,58,58);
colors[ImGuiCol_ResizeGripHovered] = ImColor(77,77,77);
colors[ImGuiCol_ResizeGripActive] = ImColor(94,94,94);
colors[ImGuiCol_FrameBg] = invert ? invertColor(ImColor(52, 52, 52)) : ImColor(52, 52, 52).Value;
colors[ImGuiCol_FrameBgHovered] = invert ? invertColor(ImColor(72, 72, 72)) : ImColor(72, 72, 72).Value;
colors[ImGuiCol_FrameBgActive] = invert ? invertColor(ImColor(90, 90, 90)) : ImColor(90, 90, 90).Value;
colors[ImGuiCol_ResizeGrip] = invert ? invertColor(ImColor(58, 58, 58)) : ImColor(58, 58, 58).Value;
colors[ImGuiCol_ResizeGripHovered] = invert ? invertColor(ImColor(77, 77, 77)) : ImColor(77, 77, 77).Value;
colors[ImGuiCol_ResizeGripActive] = invert ? invertColor(ImColor(94, 94, 94)) : ImColor(94, 94, 94).Value;
colors[ImGuiCol_PopupBg] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_Header] = ImColor(50,50,52);
colors[ImGuiCol_HeaderHovered] = ImColor(70,70,72);
colors[ImGuiCol_HeaderActive] = ImColor(88,88,90);
colors[ImGuiCol_Tab] = ImColor(50,50,52);
colors[ImGuiCol_TabHovered] = ImColor(70,70,72);
colors[ImGuiCol_TabActive] = ImColor(88,88,90);
colors[ImGuiCol_Header] = invert ? invertColor(ImColor(50, 50, 52)) : ImColor(50, 50, 52).Value;
colors[ImGuiCol_HeaderHovered] = invert ? invertColor(ImColor(70, 70, 72)) : ImColor(70, 70, 72).Value;
colors[ImGuiCol_HeaderActive] = invert ? invertColor(ImColor(88, 88, 90)) : ImColor(88, 88, 90).Value;
colors[ImGuiCol_Tab] = invert ? invertColor(ImColor(50, 50, 52)) : ImColor(50, 50, 52).Value;
colors[ImGuiCol_TabHovered] = invert ? invertColor(ImColor(70, 70, 72)) : ImColor(70, 70, 72).Value;
colors[ImGuiCol_TabActive] = invert ? invertColor(ImColor(88, 88, 90)) : ImColor(88, 88, 90).Value;
}

static void ApplyColorV4() {
auto* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Button] = ImColor(165, 255, 190);
colors[ImGuiCol_ButtonHovered] = ImColor(105, 210, 160);
colors[ImGuiCol_ButtonActive] = ImColor(85, 170, 130);
}

static void ApplyColorV3() {
auto* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Button] = ImColor(164, 201, 254);
colors[ImGuiCol_ButtonHovered] = ImColor(147, 180, 228);
colors[ImGuiCol_ButtonActive] = ImColor(131, 160, 203);
}

void ApplyStyle(float scale) {
static void ApplyStyle(float scale) {
ImGuiStyle& style = ImGui::GetStyle();

style.WindowPadding = ImVec2(10.f * scale, 10.f * scale);
Expand Down
137 changes: 45 additions & 92 deletions libs/imgui/imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,108 +1107,61 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
}
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS

// bool ImGui::Checkbox(const char* label, bool* v, float scale)
// {
// ImGuiWindow* window = GetCurrentWindow();
// if (window->SkipItems)
// return false;

// ImGuiContext& g = *GImGui;
// const ImGuiStyle& style = g.Style;
// const ImGuiID id = window->GetID(label);
// const ImVec2 label_size = CalcTextSize(label, NULL, true);

// const float square_sz = GetFrameHeight();
// const ImVec2 pos = window->DC.CursorPos;
// const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
// ItemSize(total_bb, style.FramePadding.y);
// if (!ItemAdd(total_bb, id))
// {
// IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
// return false;
// }

// bool hovered, held;
// bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
// if (pressed)
// {
// *v = !(*v);
// MarkItemEdited(id);
// }

// const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
// RenderNavHighlight(total_bb, id);
// RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
// ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
// bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
// if (mixed_value)
// {
// // Undocumented tristate/mixed/indeterminate checkbox (#2644)
// // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox)
// ImVec2 pad(ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)), ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)));
// window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding);
// }
// else if (*v)
// {
// const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
// RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
// }

// ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
// if (g.LogEnabled)
// LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
// if (label_size.x > 0.0f)
// RenderText(label_pos, label);

// IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
// return pressed;
// }

std::string removeTrailingHash(std::string_view str) {
auto it = str.find("##");
if (it != std::string::npos) {
return std::string(str.substr(0, it));
}
return std::string(str);
}

// Custom checkbox
bool ImGui::Checkbox(const char* label, bool* v, float scale)
{
ImVec2 buttonPosition = ImGui::GetCursorScreenPos();
ImDrawList* drawList = ImGui::GetWindowDrawList();

float buttonWidth = 35.0f * scale;
float buttonHeight = 22.0f * scale;
float buttonRadius = buttonHeight * 0.50f;
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;

ImGui::InvisibleButton(label, ImVec2(buttonWidth + ImGui::CalcTextSize(removeTrailingHash(label).c_str()).x + 4.f * scale, buttonHeight));
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);

bool buttonClicked = false;
if (ImGui::IsItemClicked()) {
*v = !*v;
buttonClicked = true;
const float square_sz = GetFrameHeight();
const ImVec2 pos = window->DC.CursorPos;
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
ItemSize(total_bb, style.FramePadding.y);
if (!ItemAdd(total_bb, id))
{
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
return false;
}

float interpolationFactor = *v ? 1.0f : 0.0f;
ImGuiContext& imguiContext = *GImGui;
float animationSpeed = 0.08f;
if (imguiContext.LastActiveId == imguiContext.CurrentWindow->GetID(label)) {
float animationProgress = ImSaturate(imguiContext.LastActiveIdTimer / animationSpeed);
interpolationFactor = *v ? animationProgress : 1.0f - animationProgress;
bool hovered, held;
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
if (pressed)
{
*v = !(*v);
MarkItemEdited(id);
}

const ImU32 backgroundColor = ImGui::GetColorU32(ImLerp(ImGui::IsItemHovered() ? ImColor(81, 87, 94).Value : ImColor(67, 72, 78).Value, ImColor(165, 255, 190).Value, interpolationFactor));
const ImVec2 buttonEndPosition(buttonPosition.x + buttonWidth, buttonPosition.y + buttonHeight);
drawList->AddRectFilled(buttonPosition, buttonEndPosition, backgroundColor, buttonHeight * 0.5f);
const ImU32 circleColor = *v ? IM_COL32(0, 90, 5, int(ImGui::GetStyle().Alpha * 255)) : IM_COL32(140, 144, 153, int(ImGui::GetStyle().Alpha * 255));
const float circlePositionX = buttonPosition.x + buttonRadius + interpolationFactor * (buttonWidth - buttonRadius * 2.0f);
drawList->AddCircleFilled(ImVec2(circlePositionX, buttonPosition.y + buttonRadius), buttonRadius - 1.5f, circleColor);
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
RenderNavHighlight(total_bb, id);
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
if (mixed_value)
{
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
// This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox)
ImVec2 pad(ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)), ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)));
window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding);
}
else if (*v)
{
const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
}

const ImVec2 textPosition(buttonPosition.x + buttonWidth + 5.0f, buttonPosition.y + buttonHeight / 2.0f - ImGui::GetTextLineHeight() / 2.0f);
drawList->AddText(textPosition, ImGui::GetColorU32(ImGuiCol_Text), removeTrailingHash(label).c_str());
ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
if (g.LogEnabled)
LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
if (label_size.x > 0.0f)
RenderText(label_pos, label);

return buttonClicked;
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
return pressed;
}

template<typename T>
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 8 additions & 27 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
{
"geode": "4.0.0-beta.1",
"geode": "4.0.1",
"gd": {
"win": "2.2074"
"win": "2.2074",
"android": "2.2074",
"mac": "2.2074",
"ios": "2.2074"
},
"id": "tobyadd.gdh",
"name": "GDH",
"version": "v4.9.0-beta.1",
"version": "v5.0.0",
"developer": "TobyAdd",
"description": "GDH is an open-source Geometry Dash mod menu that aims to improve the game's performance and add new features",
"early-load": true,
"links": {
"homepage": "https://tobyadd.github.io/GDH",
"source": "https://github.com/TobyAdd/GDH",
"community": "https://discord.gg/ahYEz4MAwP"
},
"issues": {
"info": "Report bugs on GitHub issues page",
"url": "https://github.com/TobyAdd/GDH/issues"
},
"tags": [
"universal",
"interface",
"utility",
"offline",
"enhancement",
"cheat"
],
"resources": {
"sprites": [
"res/screenshot.png"
]
}
"description": "",
"early-load": true
}
Binary file removed res/screenshot.png
Binary file not shown.
61 changes: 61 additions & 0 deletions src/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once
#include <map>
#include <string>
#include <matjson.hpp>
#include <fstream>
#include <filesystem>

static const auto folderPath = geode::Mod::get()->getSaveDir();
static const auto folderMacroPath = folderPath / "Macros";
extern std::filesystem::path folderShowcasesPath;
static const auto fileDataPath = folderPath / "config2.json";

class Config {
public:
static Config& get() {
static Config instance;
return instance;
}

Config(const Config&) = delete;
Config& operator=(const Config&) = delete;

void load(const std::filesystem::path& filepath) {
std::ifstream inFile(filepath);
if (inFile.is_open()) {
std::string file_contents((std::istreambuf_iterator<char>(inFile)), std::istreambuf_iterator<char>());

auto result = matjson::parse(file_contents);
if (!result.isErr()) {
jsonData = result.unwrap();
}

inFile.close();
}
}

void save(const std::filesystem::path& filepath) const {
std::ofstream outFile(filepath);
if (outFile.is_open()) {
outFile << jsonData.dump(4);
outFile.close();
}
}

template<typename T>
T get(const std::string& key, const T& defaultValue) const {
if (jsonData.contains(key)) {
return jsonData[key].as<T>().unwrap();
}
return defaultValue;
}

template<typename T>
void set(const std::string& key, const T& value) {
jsonData[key] = value;
}

private:
Config() = default;
matjson::Value jsonData;
};
Loading

1 comment on commit 1e9ed0f

@icyiscool1234
Copy link

Choose a reason for hiding this comment

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

v5????????

Please sign in to comment.