Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
listeners.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <Strings/components/utils/converters/converters.h>
6 
8 #include <Strings/components/classes/events/events.h>
9 
14 {
15 private:
16  int active_listener_index = -1;
17 
18 public:
19  void Draw()
20  {
21  if (!show)
22  {
23  return;
24  }
25 
26  if (ImGui::Begin("Event Listeners", &show))
27  {
29  ImGui::Columns(2);
30  ImGui::SetColumnWidth(0, (200.0f * *Blam::Globals::GetGlobalAsFloat("ui_scale_factor")));
31 
32  std::vector<BlamEventListener*> listeners = BlamStrings::Events::GetListeners();
33 
35  {
36  for (int i = 0; i < listeners.size(); i++)
37  {
38  BlamEventListener* listener = listeners.at(i);
39 
40  bool is_active_item = false;
41 
42  if (i == active_listener_index)
43  {
44  is_active_item = true;
45  }
46 
47  if (ImGui::Selectable(listener->name.c_str()))
48  {
49  active_listener_index = i;
50  }
51 
53  {
55  ImGui::PushTextWrapPos(450.0f);
56  ImGui::Text("listener information");
58 
59  std::string listener_name = "name: " + listener->name;
60  std::string listener_address = "address: 0x" + BlamStrings::Converters::BytesToString(&listener, sizeof(&listener));
61  std::string listener_priority = "priority: " + std::to_string(listener->GetPriority());
62  std::string listener_sub_count = "subscribed event count: " + std::to_string(listener->GetSubscribedEvents().size());
63 
64  ImGui::Text(listener_name.c_str());
65  ImGui::Text(listener_address.c_str());
66  ImGui::Text(listener_priority.c_str());
67  ImGui::Text(listener_sub_count.c_str());
68 
71  }
72  }
73 
75  }
76 
78 
79  if (active_listener_index < 0)
80  {
81  ImGui::Text("select a listener to view information");
82  }
83  else if (active_listener_index > listeners.size())
84  {
85  std::string message = "selected index " + std::to_string(active_listener_index) +
86  " was too high (max is " + std::to_string(listeners.size()) + ")";
87 
88  ImGui::Text(message.c_str());
89  }
90  else
91  {
92  BlamEventListener* listener = listeners.at(active_listener_index);
93 
94  std::string listener_name = "name: " + listener->name;
95  std::string listener_address = "address: 0x" + BlamStrings::Converters::BytesToString(&listener, sizeof(&listener));
96  std::string listener_priority = "priority: " + std::to_string(listener->GetPriority());
97  std::string listener_sub_count = "subscribed event count: " + std::to_string(listener->GetSubscribedEvents().size());
98 
99  ImGui::Text(listener_name.c_str());
100  ImGui::Text(listener_address.c_str());
101  ImGui::Text(listener_priority.c_str());
102  ImGui::Text(listener_sub_count.c_str());
103  }
104  }
105  ImGui::End();
106  }
107 };
ImGui::BeginTooltip
IMGUI_API void BeginTooltip()
Definition: imgui.cpp:7362
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
ImGui::ListBoxFooter
IMGUI_API void ListBoxFooter()
Definition: imgui_widgets.cpp:5668
ImGui::NextColumn
IMGUI_API void NextColumn()
Definition: imgui_widgets.cpp:7445
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:403
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ImGui::SetColumnWidth
IMGUI_API void SetColumnWidth(int column_index, float width)
Definition: imgui_widgets.cpp:7297
BlamImGuiWindow
Class representing an ImGUI window.
Definition: imgui.h:31
ImVec2
Definition: imgui.h:179
ImGui::IsItemHovered
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags=0)
Definition: imgui.cpp:3061
BlamImGuiWindow_EventListenerViewer::Draw
void Draw()
Draws the contents of the group.
Definition: listeners.hpp:19
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
ImGui::GetColumnWidth
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition: imgui_widgets.cpp:7262
ImGui::Text
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui_widgets.cpp:238
ImGui::PopTextWrapPos
IMGUI_API void PopTextWrapPos()
Definition: imgui.cpp:6313
ImGui::EndTooltip
IMGUI_API void EndTooltip()
Definition: imgui.cpp:7402
ImGui::Selectable
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5469
globals.h
ImGui::Columns
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui_widgets.cpp:7572
imgui.h
ImGui::Separator
IMGUI_API void Separator()
Definition: imgui_widgets.cpp:1284
ImGui::PushTextWrapPos
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x=0.0f)
Definition: imgui.cpp:6306
BlamImGuiWindow_EventListenerViewer
Class for the event listener viewer.
Definition: listeners.hpp:13
ImGui::ListBoxHeader
IMGUI_API bool ListBoxHeader(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5614