Skip to content

Commit

Permalink
allow clicking on overlay text
Browse files Browse the repository at this point in the history
fixes #100
  • Loading branch information
32th-System committed Jul 7, 2023
1 parent 0baa092 commit b4fe472
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 26 deletions.
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_alcostg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace Alcostg {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
27 changes: 21 additions & 6 deletions thprac/src/thprac/thprac_gui_components.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "thprac_gui_components.h"
#include "imgui_internal.h"
#include <Shlwapi.h>
#include <format>

namespace THPrac
{
Expand Down Expand Up @@ -448,19 +449,34 @@ namespace THPrac



void GuiHotKey::OnWidgetUpdate(bool status, bool has_changed)
bool GuiHotKey::OnWidgetUpdate()
{
const char* text = mText ? mText : LocaleGetStr(mTextRef);
std::string realText;
if (mStatus) {
realText = std::format("[{}: {}]", mKeyText, text);
ImGui::PushStyleColor(ImGuiCol_Text, { 0.0f, 1.0f, 0.0f, 1.0f });
} else {
realText = std::format("{}: {}", mKeyText, text);
}

auto cursor = ImGui::GetCursorPos();
ImGui::TextUnformatted(realText.c_str());
ImGui::SetCursorPos(cursor);

if (mStatus)
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "[%s: %s]", mKeyText, text);
ImGui::PopStyleColor();

if (ImGui::InvisibleButton(mKeyText, ImGui::CalcTextSize(realText.c_str())))
return true;
else
ImGui::Text("%s: %s", mKeyText, text);
return;
return false;
}
bool GuiHotKey::operator()(bool use_widget)
{
bool flag = Gui::ImplWin32CheckHotkey(mKey);
if (use_widget)
flag |= OnWidgetUpdate();

if (flag) {
mStatus = !mStatus;
Expand All @@ -475,8 +491,7 @@ namespace THPrac
}
}

if (use_widget)
OnWidgetUpdate(mStatus, flag);


return flag;
}
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_gui_components.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ namespace Gui {
float mXOffset2 = 0.0f;

protected:
virtual void OnWidgetUpdate(bool status, bool has_changed);
bool OnWidgetUpdate();
public:
GuiHotKey(th_glossary_t text_ref, const char* key_text, int vkey, std::initializer_list<HookCtx*> hooks = {})
: mTextRef(text_ref)
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace TH06 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ namespace TH07 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ namespace TH08 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th095.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TH095 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ namespace TH10 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace TH11 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ namespace TH12 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th125.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TH125 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ namespace TH128 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ namespace TH13 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ namespace TH14 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th143.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TH143 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ namespace TH15 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ namespace TH16 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th165.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TH165 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ namespace TH17 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th18.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ namespace TH18 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();

th18_pause_skip_1.Setup();
Expand Down
2 changes: 1 addition & 1 deletion thprac/src/thprac/thprac_th185.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@ namespace TH185 {
SetPos(10.0f, 10.0f);
SetSize(0.0f, 0.0f);
SetWndFlag(
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | 0);
OnLocaleChange();
}
SINGLETON(THOverlay);
Expand Down

0 comments on commit b4fe472

Please sign in to comment.