Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
listeners.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../debug_ui.h"
4 
5 #include <Strings/components/utils/converters/converters.h>
6 
8 #include <Strings/components/classes/events/events.h>
9 
10 namespace Blam::DebugUI::Windows
11 {
16  {
17  private:
18  int active_listener_index = -1;
19 
20  public:
24  void Draw()
25  {
26  // About Blamite
27  if (show)
28  {
29  if (ImGui::Begin("Event Listeners", &show))
30  {
32 
33  ImGui::Columns(2);
34 
35  ImGui::SetColumnWidth(0, (200.0f * *Blam::Globals::GetGlobalAsFloat("ui_scale_factor")));
36 
37  std::vector<BlamEventListener*> listeners = BlamStrings::Events::GetListeners();
38 
40  {
41  for (int i = 0; i < listeners.size(); i++)
42  {
43  BlamEventListener* listener = listeners.at(i);
44 
45  bool is_active_item = false;
46 
47  if (i == active_listener_index)
48  {
49  is_active_item = true;
50  }
51 
52  if (ImGui::Selectable(listener->name.c_str()))
53  {
54  active_listener_index = i;
55  }
56 
58  {
60  ImGui::PushTextWrapPos(450.0f);
61  ImGui::Text("listener information");
63 
64  std::string listener_name = "name: " + listener->name;
65  std::string listener_address = "address: 0x" + BlamStrings::Converters::BytesToString(&listener, sizeof(&listener));
66  std::string listener_priority = "priority: " + std::to_string(listener->GetPriority());
67  std::string listener_sub_count = "subscribed event count: " + std::to_string(listener->GetSubscribedEvents().size());
68 
69  ImGui::Text(listener_name.c_str());
70  ImGui::Text(listener_address.c_str());
71  ImGui::Text(listener_priority.c_str());
72  ImGui::Text(listener_sub_count.c_str());
73 
76  }
77  }
78 
80  }
81 
83 
84  if (active_listener_index < 0)
85  {
86  ImGui::Text("select a listener to view information");
87  }
88  else if (active_listener_index > listeners.size())
89  {
90  std::string message = "selected index " + std::to_string(active_listener_index) +
91  " was too high (max is " + std::to_string(listeners.size()) + ")";
92 
93  ImGui::Text(message.c_str());
94  }
95  else
96  {
97  BlamEventListener* listener = listeners.at(active_listener_index);
98 
99  std::string listener_name = "name: " + listener->name;
100  std::string listener_address = "address: 0x" + BlamStrings::Converters::BytesToString(&listener, sizeof(&listener));
101  std::string listener_priority = "priority: " + std::to_string(listener->GetPriority());
102  std::string listener_sub_count = "subscribed event count: " + std::to_string(listener->GetSubscribedEvents().size());
103 
104  ImGui::Text(listener_name.c_str());
105  ImGui::Text(listener_address.c_str());
106  ImGui::Text(listener_priority.c_str());
107  ImGui::Text(listener_sub_count.c_str());
108  }
109  }
110  ImGui::End();
111  }
112  }
113  };
114 }
ImGui::BeginTooltip
IMGUI_API void BeginTooltip()
Definition: imgui.cpp:7362
ImGui::ListBoxFooter
IMGUI_API void ListBoxFooter()
Definition: imgui_widgets.cpp:5668
Blam::DebugUI::Windows::EventListenerViewer::Draw
void Draw()
Draws the tag editor window.
Definition: listeners.hpp:24
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:407
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
ImVec2
Definition: imgui.h:179
ImGui::IsItemHovered
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags=0)
Definition: imgui.cpp:3061
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
Blam::DebugUI::ImGUIDrawingGroup::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:362
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
globals.h
ImGui::Columns
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui_widgets.cpp:7572
Blam::DebugUI::Windows::EventListenerViewer
Class for the event listener viewer.
Definition: listeners.hpp:15
ImGui::Separator
IMGUI_API void Separator()
Definition: imgui_widgets.cpp:1284
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: ui.h:26
ImGui::PushTextWrapPos
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x=0.0f)
Definition: imgui.cpp:6306
ImGui::ListBoxHeader
IMGUI_API bool ListBoxHeader(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5614