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

Commit

Permalink
Rainbow Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Jan 13, 2024
1 parent 6127f88 commit ba7ee91
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 31 deletions.
38 changes: 37 additions & 1 deletion src/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,43 @@ void GUI::loadStyle(std::string name)
styleFile.close();
}

void GUI::setStyle()
{
ImGuiStyle& style = ImGui::GetStyle();

float r = Settings::get<float>("menu/window/color/r", 1.f);
float g = Settings::get<float>("menu/window/color/g", 0.f);
float b = Settings::get<float>("menu/window/color/b", 0.f);

if (Settings::get<bool>("menu/window/rainbow/enabled"))
{
ImGui::ColorConvertHSVtoRGB(
ImGui::GetTime() * Settings::get<float>("menu/window/rainbow/speed", .4f),
Settings::get<float>("menu/window/rainbow/brightness", .8f),
Settings::get<float>("menu/window/rainbow/brightness"),
r, g, b
);

style.Colors[ImGuiCol_Border] = { r, g, b, 1 };
style.Colors[ImGuiCol_TitleBg] = { r, g, b, 1 };
style.Colors[ImGuiCol_TitleBgCollapsed] = { r, g, b, 1 };
style.Colors[ImGuiCol_TitleBgActive] = { r, g, b, 1 };

style.Colors[ImGuiCol_Tab] = { r * .85f, g * .85f, b * .85f, 1 };
style.Colors[ImGuiCol_TabActive] = { r * .85f, g * .85f, b * .85f, 1 };
style.Colors[ImGuiCol_TabHovered] = { r * .70f, g * .70f, b * .70f, 1 };
style.Colors[ImGuiCol_TabUnfocused] = { r * .60f, g * .60f, b * .60f, 1 };
style.Colors[ImGuiCol_TabUnfocusedActive] = { r * .60f, g * .60f, b * .60f, 1 };
}
else
{
style.Colors[ImGuiCol_TitleBg] = { r, g, b, 1.f };
style.Colors[ImGuiCol_TitleBgActive] = { r, g, b, 1.f };
style.Colors[ImGuiCol_TitleBgCollapsed] = { r, g, b, 1.f };
}
}

bool GUI::shouldRender()
{
return isVisible && !shortcutLoop;
}
}
1 change: 1 addition & 0 deletions src/GUI/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace GUI

void saveStyle(std::string name);
void loadStyle(std::string name);
void setStyle();

bool shouldRender();
};
16 changes: 4 additions & 12 deletions src/GUI/Widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

inline ImVec2 operator+(const ImVec2& a, const ImVec2& b)
{
return {a.x + b.x, a.y + b.y};
return { a.x + b.x, a.y + b.y };
}
inline ImVec2 operator-(const ImVec2& a, const ImVec2& b)
{
return {a.x - b.x, a.y - b.y};
return { a.x - b.x, a.y - b.y };
}

bool GUI::button(std::string name)
Expand Down Expand Up @@ -83,9 +83,8 @@ bool GUI::hotkey(std::string name, int* keyPointer, const ImVec2& size_arg)
if (focus_requested || user_clicked)
{
if (g.ActiveId != id)
{
*keyPointer = 0;
}

ImGui::SetActiveID(id, window);
ImGui::FocusWindow(window);
}
Expand Down Expand Up @@ -119,9 +118,7 @@ bool GUI::hotkey(std::string name, int* keyPointer, const ImVec2& size_arg)
ImGui::ClearActiveID();
}
else
{
*keyPointer = key;
}
}

char buf_display[64] = "None";
Expand All @@ -130,13 +127,9 @@ bool GUI::hotkey(std::string name, int* keyPointer, const ImVec2& size_arg)
style.FrameRounding);

if (*keyPointer != 0 && g.ActiveId != id)
{
strcpy_s(buf_display, KeyNames[*keyPointer]);
}
else if (g.ActiveId == id)
{
strcpy_s(buf_display, "<Press a key>");
}

const ImRect clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y);
ImVec2 render_pos = frame_bb.Min + style.FramePadding;
Expand All @@ -158,9 +151,8 @@ bool GUI::modalPopup(std::string name, const std::function<void()>& popupFunctio
if (GUI::shouldRender())
{
if (ImGui::Button("Cancel"))
{
ImGui::CloseCurrentPopup();
}

ImGui::EndPopup();
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Macrobot/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../Common.h"
#include "../GUI/GUI.h"
#include "../Settings.h"
#include "../types/GJGameLevel.hpp"
#include "AudioRecord.h"
#include "Clickpacks.h"
#include "Macrobot.h"
Expand Down Expand Up @@ -336,9 +337,9 @@ void Recorder::stop_audio()
{
AudioRecord::stop();

void* level = MBO(void*, Common::getBGL(), 1504); // found in playlayer_init
gd::GJGameLevel* level = MBO(void*, Common::getBGL(), 1504); // found in playlayer_init

std::string level_id = std::to_string(MBO(int, level, 268) - MBO(int, level, 272));
std::string level_id = std::to_string(level->m_levelID);

std::string video_path = "GDMO/renders/" + level_id + "/final.mp4";

Expand Down
43 changes: 27 additions & 16 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,14 @@ void init()
GUI::checkbox("Startpos Switcher", Settings::get<bool*>("level/startpos_switcher"));

GUI::arrowButton("Startpos Switcher Settings");
GUI::modalPopup(
"Startpos Switcher Settings",
[] {
if (GUI::button("Switch Left"))
StartposSwitcher::change(false);
GUI::modalPopup("Startpos Switcher Settings",[] {
if (GUI::button("Switch Left"))
StartposSwitcher::change(false);

if (GUI::button("Switch Right"))
StartposSwitcher::change(true);
},
ImGuiWindowFlags_AlwaysAutoResize);
if (GUI::button("Switch Right"))
StartposSwitcher::change(true);
},
ImGuiWindowFlags_AlwaysAutoResize);

GUI::checkbox("Replay Last Checkpoint", Settings::get<bool*>("level/replay_checkpoint"));

Expand All @@ -198,19 +196,31 @@ void init()
if (GUI::inputFloat("Window Opacity", &windowOpacity, 0.f, 1.f))
Settings::set<float>("menu/window/opacity", windowOpacity);

float windowColor[3]{};
windowColor[0] = Settings::get<float>("menu/window/color/r", 1.f);
windowColor[1] = Settings::get<float>("menu/window/color/g", 0.f);
windowColor[2] = Settings::get<float>("menu/window/color/b", 0.f);
GUI::checkbox("Rainbow Menu", Settings::get<bool*>("menu/window/rainbow/enabled"));

GUI::arrowButton("Rainbow Menu Settings");
GUI::modalPopup("Rainbow Menu Settings", [] {
float speed = Settings::get<float>("menu/window/rainbow/speed", .4f);
if (GUI::inputFloat("Rainbow Speed", &speed, .1f, 2.f))
Settings::set<float>("menu/window/rainbow/speed", speed);

float brightness = Settings::get<float>("menu/window/rainbow/brightness", .8f);
if (GUI::inputFloat("Rainbow Brightness", &brightness, .1f, 2.f))
Settings::set<float>("menu/window/rainbow/brightness", brightness);
},
ImGuiWindowFlags_AlwaysAutoResize);

float windowColor[3]{
Settings::get<float>("menu/window/color/r", 1.f),
Settings::get<float>("menu/window/color/g", .0f),
Settings::get<float>("menu/window/color/b", .0f)
};

if (GUI::colorEdit("Window Color", windowColor))
{
Settings::set<float>("menu/window/color/r", windowColor[0]);
Settings::set<float>("menu/window/color/g", windowColor[1]);
Settings::set<float>("menu/window/color/b", windowColor[2]);
ImGui::GetStyle().Colors[ImGuiCol_TitleBg] = {windowColor[0], windowColor[1], windowColor[2], 1.f};
ImGui::GetStyle().Colors[ImGuiCol_TitleBgActive] = {windowColor[0], windowColor[1], windowColor[2], 1.f};
ImGui::GetStyle().Colors[ImGuiCol_TitleBgCollapsed] = {windowColor[0], windowColor[1], windowColor[2], 1.f};
}
});
GUI::addWindow(menuSettings);
Expand Down Expand Up @@ -256,6 +266,7 @@ void render()
}

GUI::draw();
GUI::setStyle();

if (DiscordRPCManager::core)
DiscordRPCManager::core->RunCallbacks();
Expand Down

0 comments on commit ba7ee91

Please sign in to comment.