RunicVTT Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
DebugActions Namespace Reference

Typedefs

using Clock = std::chrono::steady_clock
 

Functions

bool timeElapsedMs (Clock::time_point &last, int ms)
 
bool keyDownImGui (ImGuiKey imguiKey)
 
void ToasterChanged (std::weak_ptr< ImGuiToaster > toaster_, bool on)
 
void ToasterTick (std::weak_ptr< ImGuiToaster > toaster_)
 
void MouseCircleChanged (bool on)
 
void MouseCircleTick ()
 
void FpsOverlayChanged (bool on)
 
void FpsOverlayTick ()
 
void PingLogChanged (bool on)
 
void PingLogTick ()
 
void RegisterToasterToggles (std::weak_ptr< ImGuiToaster > toaster_)
 
void RegisterAllDefaultToggles ()
 

Variables

bool gMasterEnabled = false
 
bool gEnableToasterTest = false
 
Clock::time_point gToasterLast = Clock::now()
 
bool gEnableMouseCircle = false
 
bool gEnableFpsOverlay = false
 
bool gEnablePingLog = false
 
Clock::time_point gPingLast = Clock::now()
 

Typedef Documentation

◆ Clock

using DebugActions::Clock = std::chrono::steady_clock

Definition at line 18 of file DebugActions.h.

Function Documentation

◆ FpsOverlayChanged()

void DebugActions::FpsOverlayChanged ( bool on)
inline

Definition at line 107 of file DebugActions.h.

108 {
109 Logger::instance().log("main", std::string("FPS Overlay ") + (on ? "ENABLED" : "DISABLED"));
110 }
static Logger & instance()
Definition Logger.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FpsOverlayTick()

void DebugActions::FpsOverlayTick ( )
inline

Definition at line 111 of file DebugActions.h.

112 {
113 // Small FPS text in top-left corner
114 ImDrawList* dl = ImGui::GetForegroundDrawList();
115 ImVec2 pos = ImVec2(12, 12);
116 char buf[64];
117 // Use ImGui::GetIO().Framerate or your timing system
118 snprintf(buf, sizeof(buf), "FPS: %.1f", ImGui::GetIO().Framerate);
119 dl->AddText(pos, IM_COL32(255, 255, 255, 220), buf);
120 }
Here is the caller graph for this function:

◆ keyDownImGui()

bool DebugActions::keyDownImGui ( ImGuiKey imguiKey)
inline

Definition at line 31 of file DebugActions.h.

32 {
33 // If you use ImGui backend keys:
34 return ImGui::IsKeyDown(imguiKey);
35 }

◆ MouseCircleChanged()

void DebugActions::MouseCircleChanged ( bool on)
inline

Definition at line 89 of file DebugActions.h.

90 {
91 Logger::instance().log("main", std::string("Mouse Circle ") + (on ? "ENABLED" : "DISABLED"));
92 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MouseCircleTick()

void DebugActions::MouseCircleTick ( )
inline

Definition at line 93 of file DebugActions.h.

94 {
95 // Draw a simple circle at mouse (using ImGui draw list for example)
96 ImDrawList* dl = ImGui::GetForegroundDrawList();
97 ImVec2 p = ImGui::GetMousePos();
98 float radius = 14.f;
99 ImU32 colFill = IM_COL32(255, 255, 0, 48);
100 ImU32 colLine = IM_COL32(255, 255, 0, 200);
101 dl->AddCircleFilled(p, radius, colFill, 24);
102 dl->AddCircle(p, radius, colLine, 24, 2.0f);
103 }
Here is the caller graph for this function:

◆ PingLogChanged()

void DebugActions::PingLogChanged ( bool on)
inline

Definition at line 125 of file DebugActions.h.

126 {
127 Logger::instance().log("main", std::string("Ping Log ") + (on ? "ENABLED" : "DISABLED"));
128 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PingLogTick()

void DebugActions::PingLogTick ( )
inline

Definition at line 129 of file DebugActions.h.

130 {
131 // Throttled periodic log
132 if (timeElapsedMs(gPingLast, 1000))
133 {
134 // Replace with a real metric if you have one
135 Logger::instance().log("main", "[net] heartbeat");
136 }
137 }
bool timeElapsedMs(Clock::time_point &last, int ms)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterAllDefaultToggles()

void DebugActions::RegisterAllDefaultToggles ( )
inline

Definition at line 154 of file DebugActions.h.

155 {
156 // Helper shim to avoid direct include dependency in this header:
157 auto add = [](const char* label, bool* f, std::function<void(bool)> oc, std::function<void()> ot)
158 {
159 auto toggle = DebugToggle{
160 label,
161 f,
162 oc,
163 ot};
164
166 };
167
168 add("Debug Mouse Circle", &gEnableMouseCircle, MouseCircleChanged, MouseCircleTick);
169
170 add("FPS Overlay", &gEnableFpsOverlay, FpsOverlayChanged, FpsOverlayTick);
171
172 add("Network Ping Log", &gEnablePingLog, PingLogChanged, PingLogTick);
173 }
static void addToggle(const DebugToggle &t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterToasterToggles()

void DebugActions::RegisterToasterToggles ( std::weak_ptr< ImGuiToaster > toaster_)
inline

Definition at line 140 of file DebugActions.h.

141 {
143 "Toaster Notifications (1–4)",
145 /* onChanged */ [t = toaster_](bool on) { // capture the shared_ptr by value
146 ToasterChanged(t, on); // call your function WITH the arg
147 },
148 /* onTick */ [t = toaster_]() { // capture the shared_ptr by value
149 ToasterTick(t); // call your function WITH the arg
150 },
151 });
152 }
void ToasterChanged(std::weak_ptr< ImGuiToaster > toaster_, bool on)
bool gEnableToasterTest
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeElapsedMs()

bool DebugActions::timeElapsedMs ( Clock::time_point & last,
int ms )
inline

Definition at line 20 of file DebugActions.h.

21 {
22 auto now = Clock::now();
23 if (std::chrono::duration_cast<std::chrono::milliseconds>(now - last).count() >= ms)
24 {
25 last = now;
26 return true;
27 }
28 return false;
29 }
Here is the caller graph for this function:

◆ ToasterChanged()

void DebugActions::ToasterChanged ( std::weak_ptr< ImGuiToaster > toaster_,
bool on )
inline

Definition at line 44 of file DebugActions.h.

45 {
46 Logger::instance().log("main", std::string("Toaster Notification Test ") + (on ? "ENABLED" : "DISABLED"));
47 if (auto t = toaster_.lock())
48 {
49 if (on)
50 {
51 t->Push(ImGuiToaster::Level::Info, "Toaster Debug ON!!", 1.0f);
52 }
53 else
54 {
55 t->Push(ImGuiToaster::Level::Info, "Toaster Debug OFF!!", 1.0f);
56 }
57 }
58 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToasterTick()

void DebugActions::ToasterTick ( std::weak_ptr< ImGuiToaster > toaster_)
inline

Definition at line 60 of file DebugActions.h.

61 {
62 if (auto t = toaster_.lock())
63 {
64 if (ImGui::IsKeyPressed(ImGuiKey_1) && timeElapsedMs(gToasterLast, 200))
65 {
66 t->Push(ImGuiToaster::Level::Info, "Info: Hello!", 5.0f);
67 Logger::instance().log("main", Logger::Level::Info, "[toast] Info Demo");
68 }
69 if (ImGui::IsKeyPressed(ImGuiKey_2) && timeElapsedMs(gToasterLast, 200))
70 {
71 t->Push(ImGuiToaster::Level::Good, "Good: Saved", 4.0f);
72 Logger::instance().log("main", Logger::Level::Success, "[toast] Good Demo");
73 }
74 if (ImGui::IsKeyPressed(ImGuiKey_3) && timeElapsedMs(gToasterLast, 200))
75 {
76 t->Push(ImGuiToaster::Level::Warning, "Warning: Ping high", 6.0f);
77 Logger::instance().log("main", Logger::Level::Warn, "[toast] Warning Demo");
78 }
79 if (ImGui::IsKeyPressed(ImGuiKey_4) && timeElapsedMs(gToasterLast, 200))
80 {
81 t->Push(ImGuiToaster::Level::Error, "Error: Failed op");
82 Logger::instance().log("main", Logger::Level::Error, "[toast] Error Demo");
83 }
84 }
85 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gEnableFpsOverlay

bool DebugActions::gEnableFpsOverlay = false
inline

Definition at line 106 of file DebugActions.h.

◆ gEnableMouseCircle

bool DebugActions::gEnableMouseCircle = false
inline

Definition at line 88 of file DebugActions.h.

◆ gEnablePingLog

bool DebugActions::gEnablePingLog = false
inline

Definition at line 123 of file DebugActions.h.

◆ gEnableToasterTest

bool DebugActions::gEnableToasterTest = false
inline

Definition at line 41 of file DebugActions.h.

◆ gMasterEnabled

bool DebugActions::gMasterEnabled = false
inline

Definition at line 38 of file DebugActions.h.

◆ gPingLast

Clock::time_point DebugActions::gPingLast = Clock::now()
inline

Definition at line 124 of file DebugActions.h.

◆ gToasterLast

Clock::time_point DebugActions::gToasterLast = Clock::now()
inline

Definition at line 42 of file DebugActions.h.