-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReminderGui.cpp
79 lines (59 loc) · 1.81 KB
/
ReminderGui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "pch.h"
#include "FriendlyReminders.h"
#include "bakkesmod/wrappers/GuiManagerWrapper.h"
std::string FriendlyReminders::GetMenuName()
{
return menuName;
}
std::string FriendlyReminders::GetMenuTitle()
{
return menuName;
}
void FriendlyReminders::SetImGuiContext(uintptr_t ctx)
{
ImGui::SetCurrentContext(reinterpret_cast<ImGuiContext*>(ctx));
GuiManagerWrapper guiManager = gameWrapper->GetGUIManager();
guiManager.LoadFont("Ubuntu-Bold-72", "Ubuntu-Bold.ttf", 72);
}
bool FriendlyReminders::ShouldBlockInput()
{
return ImGui::GetIO().WantCaptureMouse || ImGui::GetIO().WantCaptureKeyboard;
}
bool FriendlyReminders::IsActiveOverlay()
{
return false;
}
void FriendlyReminders::OnOpen(){}
void FriendlyReminders::OnClose(){}
void FriendlyReminders::Render()
{
if (!menuFont) {
auto gui = gameWrapper->GetGUIManager();
menuFont = gui.GetFont("Ubuntu-Bold-72");
}
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs
| ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_AlwaysAutoResize;
std::string text = currentMessage;
if (menuFont)
{
menuFont->Scale = 16.0f / 72.0f * *message_scale;
ImGui::PushFont(menuFont);
}
ImVec2 displaySize = ImGui::GetIO().DisplaySize;
ImVec2 textSize = ImGui::CalcTextSize(text.c_str());
ImGui::SetNextWindowPos(ImVec2(
displaySize.x * *message_position_x - textSize.x * *message_anchor_x,
displaySize.y * *message_position_y - textSize.y * *message_anchor_y
));
ImGui::Begin(menuName.c_str(), (bool*)1, windowFlags);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f);
ImGui::SetCursorPos(ImVec2(0.0f, 0.0f));
ImGui::Text(text.c_str());
ImGui::PopStyleVar(2);
if (menuFont)
{
ImGui::PopFont();
}
ImGui::End();
}