OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
UI.cpp
Go to the documentation of this file.
1 
8 #include "imgui/imgui.h"
9 
10 #include "global.h"
11 #include "Camera.h"
12 #include "Console.h"
13 #include "Game.h"
14 #include "Log.h"
15 #include "Menu.h"
16 #include "Render.h"
17 #include "RunTime.h"
18 #include "SoundManager.h"
19 #include "TextureManager.h"
20 #include "World.h"
21 #include "system/Window.h"
22 #include "utils/time.h"
23 #include "UI.h"
24 
25 #include <glm/gtc/matrix_transform.hpp>
26 
28 bool UI::visible = false;
29 unsigned int UI::fontTex;
30 std::string UI::iniFilename;
31 std::string UI::logFilename;
32 bool UI::metaKeyIsActive = false;
33 
34 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
35 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
36 std::list<std::tuple<int, int, int, int>> UI::motionEvents;
37 std::list<std::tuple<int, int>> UI::scrollEvents;
38 
39 void UI::setSize(glm::i32vec2 s) {
40  ImGuiIO& io = ImGui::GetIO();
41  io.DisplaySize = ImVec2(s.x, s.y);
42 }
43 
46  return -1;
47  if (imguiShader.addUniform("screen") < 0)
48  return -2;
49  if (imguiShader.addUniform("textureSampler") < 0)
50  return -3;
51 
52  iniFilename = RunTime::getBaseDir() + "/imgui.ini";
53  logFilename = RunTime::getBaseDir() + "/imgui_log.txt";
54 
55  ImGuiIO& io = ImGui::GetIO();
57  io.DeltaTime = 1.0f / 60.0f;
58 
59  io.IniFilename = iniFilename.c_str();
60  io.LogFilename = logFilename.c_str();
61 
73  io.KeyMap[ImGuiKey_A] = aKey;
74  io.KeyMap[ImGuiKey_C] = cKey;
75  io.KeyMap[ImGuiKey_V] = vKey;
76  io.KeyMap[ImGuiKey_X] = xKey;
77  io.KeyMap[ImGuiKey_Y] = yKey;
78  io.KeyMap[ImGuiKey_Z] = zKey;
79 
84 
85  // Load font texture
87  unsigned char* pixels;
88  int width, height;
89  io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
90  fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
91  TextureStorage::SYSTEM, -1, true);
93  io.Fonts->TexID = bm;
94 
95  // Set up OpenRaider style
96  ImGuiStyle& style = ImGui::GetStyle();
97  style.Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
98  style.Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
99  style.Colors[ImGuiCol_Border] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
100  style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.60f);
101  style.Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f);
102  style.Colors[ImGuiCol_TitleBg] = ImVec4(0.50f, 0.70f, 1.00f, 0.45f);
103  style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.65f, 1.00f, 0.20f);
104  style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.40f, 0.65f, 1.00f, 0.15f);
105  style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.65f, 1.00f, 0.30f);
106  style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.65f, 1.00f, 0.40f);
107  style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(1.00f, 0.16f, 0.16f, 0.40f);
108  style.Colors[ImGuiCol_ComboBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.99f);
109  style.Colors[ImGuiCol_CheckHovered] = ImVec4(1.00f, 0.40f, 0.40f, 0.45f);
110  style.Colors[ImGuiCol_CheckActive] = ImVec4(0.65f, 0.50f, 0.50f, 0.55f);
111  style.Colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
112  style.Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
113  style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(1.00f, 0.20f, 0.22f, 1.00f);
114  style.Colors[ImGuiCol_Button] = ImVec4(1.00f, 0.20f, 0.20f, 0.60f);
115  style.Colors[ImGuiCol_ButtonHovered] = ImVec4(1.00f, 0.20f, 0.18f, 1.00f);
116  style.Colors[ImGuiCol_ButtonActive] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
117  style.Colors[ImGuiCol_Header] = ImVec4(0.21f, 0.54f, 1.00f, 0.45f);
118  style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.22f, 0.56f, 1.00f, 0.80f);
119  style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.00f, 0.31f, 1.00f, 1.00f);
120  style.Colors[ImGuiCol_Column] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
121  style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.60f, 0.40f, 0.40f, 1.00f);
122  style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
123  style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
124  style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
125  style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
126  style.Colors[ImGuiCol_CloseButton] = ImVec4(0.21f, 0.56f, 1.00f, 0.50f);
127  style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.21f, 0.32f, 1.00f, 0.60f);
128  style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
129  style.Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
130  style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
131  style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
132  style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
133  style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
134  style.Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
135  style.WindowPadding = ImVec2(2, 2);
136  style.WindowRounding = 9;
137  style.FramePadding = ImVec2(2, 1);
138  style.ItemSpacing = ImVec2(2, 2);
139  style.ItemInnerSpacing = ImVec2(1, 1);
140  style.TouchExtraPadding = ImVec2(0, 0);
141  style.TreeNodeSpacing = 3;
142  style.ScrollbarWidth = 10;
143 
144  return 0;
145 }
146 
148  ImGuiIO& io = ImGui::GetIO();
150 
151  static unsigned long lastTime = 0;
152  io.DeltaTime = ((float)(systemTimerGet() - lastTime)) / 1000.0f;
153  lastTime = systemTimerGet();
154  if (io.DeltaTime <= 0.0f)
155  io.DeltaTime = 1.0f / 60.0f;
156 
157  ImGui::NewFrame();
158 
159  if (!(visible || Console::isVisible() || Menu::isVisible())) {
160  while (!motionEvents.empty()) {
161  auto i = motionEvents.front();
162  Game::handleMouseMotion(std::get<0>(i), std::get<1>(i),
163  std::get<2>(i), std::get<3>(i));
164  motionEvents.pop_front();
165  }
166  }
167 
168  while (!keyboardEvents.empty()) {
169  auto i = keyboardEvents.front();
170 
171  if (!(visible || Console::isVisible() || Menu::isVisible())) {
172  for (int n = forwardAction; n < ActionEventCount; n++) {
173  if (RunTime::getKeyBinding((ActionEvents)n) == std::get<0>(i))
174  Game::handleAction((ActionEvents)n, !std::get<1>(i));
175  }
176  }
177 
178  if (std::get<1>(i)) {
179  if ((!io.WantCaptureKeyboard) || (!(visible || Console::isVisible() || Menu::isVisible()))) {
180  if (!metaKeyIsActive) {
181  if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
182  visible = !visible;
183  }
184 
185  if (RunTime::getKeyBinding(consoleAction) == std::get<0>(i)) {
187  }
188 
189  if (RunTime::getKeyBinding(menuAction) == std::get<0>(i)) {
191  }
192  }
193  }
194  }
195 
196  keyboardEvents.pop_front();
197  }
198 
199  bool clicked = !clickEvents.empty();
200  clickEvents.clear();
201  motionEvents.clear();
202  scrollEvents.clear();
203 
204  // Allow clicking into the game to hide debug UI
205  if ((visible || Console::isVisible()) && ((!io.WantCaptureMouse) && clicked)) {
206  visible = false;
207  Console::setVisible(false);
208  }
209 
212 
213  bool input = !(visible || Console::isVisible() || Menu::isVisible());
214  if (Window::getMousegrab() != input)
215  Window::setMousegrab(input);
216 
217  io.MouseWheel = 0;
218 }
219 
220 void UI::display() {
221  if (RunTime::getShowFPS() && (!Menu::isVisible())) {
222  if (ImGui::Begin("Debug Overlay", nullptr, ImVec2(0, 0), -1.0f,
226  ImGui::Text("%d FPS", RunTime::getFPS());
227  ImGui::Text("X: %.1f (%.2f)", Camera::getPosition().x, Camera::getRotation().x);
228  ImGui::Text("Y: %.2f (%.2f)", Camera::getPosition().y, Camera::getRotation().y);
229  ImGui::Text("Z: %.2f (%d)", Camera::getPosition().z, Camera::getRoom());
230 
231  auto window = ImGui::GetWindowSize();
232  auto screen = Window::getSize();
233  ImGui::SetWindowPos(ImVec2(10, screen.y - window.y - 10));
234  }
235  ImGui::End();
236  }
237 
238  if (Game::isLoaded())
240 
242  Menu::display();
243 
244  if (!visible) {
245  ImGui::Render();
246  return;
247  }
248 
249  static bool showTestWindow = false;
250  static bool showStyleWindow = false;
251  if (ImGui::Begin("Engine", &visible, ImVec2(500, 600))) {
256 
257  if (ImGui::CollapsingHeader("ImGui/Debug UI Help")) {
260  if (ImGui::Button("Show/Hide Test Window")) {
261  showTestWindow = !showTestWindow;
262  }
263  ImGui::SameLine();
264  if (ImGui::Button("Show/Hide Style Editor")) {
265  showStyleWindow = !showStyleWindow;
266  }
267  }
268 
269  if (ImGui::CollapsingHeader("ShaderTexture Test")) {
270  static ShaderTexture* st = nullptr;
271  static int index = 0;
272  ImGui::SliderInt("SkeletalModel", &index, 0, getWorld().sizeSkeletalModel() - 1);
273 
274  static glm::mat4 MVP(1.0f);
275  static bool dirty = true, redraw = false;
276  static float zoom = 1.0f;
277  static float pos[3];
278  static float rot[3];
279 
280  if (ImGui::SliderFloat3("Position", pos, -100.0f, 100.0f)) {
281  //dirty = true;
282  }
283  if (ImGui::SliderFloat3("Rotation", rot, -6.0f, 6.0f)) {
284  //dirty = true;
285  }
286  if (ImGui::SliderFloat("Zoom", &zoom, -1.0f, 2.0f)) {
287  //dirty = true;
288  }
289 
290  if (dirty) {
291  static glm::mat4 projection = glm::perspective(45.0f, 1.0f, 0.1f, 2000.0f);
292 
293  glm::mat4 rotateX = glm::rotate(glm::mat4(1.0f), rot[0], glm::vec3(1.0f, 0.0f, 0.0f));
294  glm::mat4 rotateY = glm::rotate(glm::mat4(1.0f), rot[1], glm::vec3(0.0f, 1.0f, 0.0f));
295  glm::mat4 rotateZ = glm::rotate(glm::mat4(1.0f), rot[2], glm::vec3(0.0f, 0.0f, 1.0f));
296  glm::mat4 rotate = rotateZ * rotateX * rotateY;
297  glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos[0], pos[1], pos[2]));
298  //glm::mat4 view = glm::inverse(rotate * translate);
299  glm::mat4 view = rotate * translate;
300  glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(zoom, zoom, zoom));
301  MVP = projection * view * scale;
302 
303  redraw = true;
304  dirty = false;
305  }
306 
307  if ((index >= 0) && (index < getWorld().sizeSkeletalModel())) {
308  auto& sm = getWorld().getSkeletalModel(index);
309  if ((sm.size() > 0) && (sm.get(0).size() > 0)) {
310  if (ImGui::Button("(Re)Create ShaderTexture...")) {
311  if (st != nullptr) {
312  delete st;
313  st = nullptr;
314  }
315  if (st == nullptr) {
316  st = new ShaderTexture();
317  redraw = true;
318  }
319  }
320  if ((st != nullptr) && redraw) {
321  st->clear();
322  sm.display(MVP, 0, 0, st);
323  redraw = false;
324  Log::get(LOG_DEBUG) << "Rendered new ShaderTexture!" << Log::endl;
325  }
326  } else {
327  ImGui::Text("Selected SkeletalModel has no animation/frame!");
328  }
329  } else {
330  ImGui::Text("No SkeletalModels loaded!");
331  }
332 
333  if (st != nullptr) {
336  ImGui::GetColumnWidth() * 2 / 3));
337  }
338  }
339  }
340  ImGui::End();
341 
342  if (showTestWindow)
344 
345  if (showStyleWindow)
347 
348  ImGui::Render();
349 }
350 
351 void UI::shutdown() {
352  ImGui::Shutdown();
353 }
354 
355 void UI::handleKeyboard(KeyboardButton key, bool pressed) {
356  ImGuiIO& io = ImGui::GetIO();
357  io.KeysDown[key] = pressed;
360 
361  keyboardEvents.push_back(std::make_tuple(key, pressed));
362 
363  if ((key == leftguiKey) || (key == rightguiKey))
364  metaKeyIsActive = pressed;
365 }
366 
367 void UI::handleText(char* text, bool notFinished) {
368  if (notFinished)
369  return;
370 
371  ImGuiIO& io = ImGui::GetIO();
372  while (*text != '\0') {
373  io.AddInputCharacter(*text);
374  text++;
375  }
376 }
377 
378 void UI::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
379  ImGuiIO& io = ImGui::GetIO();
380  io.MousePos = ImVec2((float)x, (float)y);
381  if (button == leftmouseKey) {
382  io.MouseDown[0] = !released;
383  } else if (button == rightmouseKey) {
384  io.MouseDown[1] = !released;
385  } else if (button == middlemouseKey) {
386  io.MouseDown[2] = !released;
387  } else if (button == fourthmouseKey) {
388  io.MouseDown[3] = !released;
389  } else if (button == fifthmouseKey) {
390  io.MouseDown[4] = !released;
391  }
392 
393  clickEvents.push_back(std::make_tuple(x, y, button, released));
394 }
395 
396 void UI::handleMouseMotion(int xrel, int yrel, int xabs, int yabs) {
397  ImGuiIO& io = ImGui::GetIO();
398  io.MousePos = ImVec2((float)xabs, (float)yabs);
399 
400  motionEvents.push_back(std::make_tuple(xrel, yrel, xabs, yabs));
401 }
402 
403 void UI::handleMouseScroll(int xrel, int yrel) {
404  ImGuiIO& io = ImGui::GetIO();
405  io.MouseWheel += yrel;
406 
407  scrollEvents.push_back(std::make_tuple(xrel, yrel));
408 }
409 
410 void UI::handleControllerAxis(float value, KeyboardButton axis) {
411  Game::handleControllerAxis(value, axis);
412 }
413 
414 void UI::handleControllerButton(KeyboardButton button, bool released) {
415  if (visible || Console::isVisible())
416  return;
417 
418  if (Menu::isVisible()) {
419  if (button == aButton) {
420  handleKeyboard(enterKey, !released);
421  } else if (button == padUp) {
422  handleKeyboard(upKey, !released);
423  } else if (button == padDown) {
424  handleKeyboard(downKey, !released);
425  } else if (button == padLeft) {
426  handleKeyboard(leftKey, !released);
427  } else if (button == padRight) {
428  handleKeyboard(rightKey, !released);
429  } else if (button == startButton) {
430  if (!released)
431  Menu::setVisible(false);
432  }
433  } else {
434  if (button == aButton) {
435  Game::handleAction(jumpAction, released);
436  } else if (button == bButton) {
437  Game::handleAction(crouchAction, released);
438  } else if (button == xButton) {
439  Game::handleAction(useAction, released);
440  } else if (button == yButton) {
442  } else if (button == padUp) {
444  } else if (button == padDown) {
446  } else if (button == padLeft) {
447  Game::handleAction(leftAction, released);
448  } else if (button == padRight) {
449  Game::handleAction(rightAction, released);
450  } else if (button == leftShoulder) {
451  Game::handleAction(walkAction, released);
452  } else if (button == startButton) {
453  if (!released)
454  Menu::setVisible(true);
455  }
456  }
457 }
458 
459 void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
460  if (cmd_lists_count == 0)
461  return;
462 
463  static ShaderBuffer vert, uv, col;
464 
465  glEnable(GL_SCISSOR_TEST);
466  Shader::set2DState(true);
467 
468  imguiShader.use();
470  vert.bindBuffer(0, 2);
471  uv.bindBuffer(1, 2);
472  col.bindBuffer(2, 4);
473 
479  for (int i = 0; i < cmd_lists_count; i++) {
480  auto& commands = cmd_lists[i]->commands;
481  auto& buffer = cmd_lists[i]->vtx_buffer;
482 
483  int offset = 0;
484  for (int n = 0; n < commands.size(); n++) {
485  std::vector<glm::vec2> vertices;
486  std::vector<glm::vec2> uvs;
487  std::vector<glm::vec4> colors;
488 
489  for (int v = 0; v < commands[n].vtx_count; v++) {
490  vertices.push_back(glm::vec2(buffer[offset + v].pos.x, buffer[offset + v].pos.y));
491  uvs.push_back(glm::vec2(buffer[offset + v].uv.x, buffer[offset + v].uv.y));
492 
493  float r, g, b, a;
494  a = ((buffer[offset + v].col & 0xFF000000) >> 24) / 255.0f;
495  b = ((buffer[offset + v].col & 0x00FF0000) >> 16) / 255.0f;
496  g = ((buffer[offset + v].col & 0x0000FF00) >> 8) / 255.0f;
497  r = (buffer[offset + v].col & 0x000000FF) / 255.0f;
498  colors.push_back(glm::vec4(r, g, b, a));
499  }
500 
501  offset += commands[n].vtx_count;
502 
503  vert.bufferData(vertices);
504  uv.bufferData(uvs);
505  col.bufferData(colors);
506 
507  auto bm = static_cast<BufferManager*>(commands[n].texture_id);
508  assert(bm != nullptr);
509  imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
510 
511  glScissor(commands[n].clip_rect.x,
512  Window::getSize().y - commands[n].clip_rect.w,
513  commands[n].clip_rect.z - commands[n].clip_rect.x,
514  commands[n].clip_rect.w - commands[n].clip_rect.y);
515 
516  glDrawArrays(GL_TRIANGLES, 0, vertices.size());
517  }
518  }
519 
520  vert.unbind(0);
521  uv.unbind(1);
522  col.unbind(2);
523 
524  Shader::set2DState(false);
525  glDisable(GL_SCISSOR_TEST);
526 }
527 
528 // --------------------------------------
529 // *INDENT-OFF*
530 
531 const char* UI::imguiShaderVertex = R"!?!(
532 #version 330 core
533 
534 layout(location = 0) in vec2 vertexPosition_screen;
535 layout(location = 1) in vec2 vertexUV;
536 layout(location = 2) in vec4 vertexColor;
537 
538 out vec2 UV;
539 out vec4 FragColor;
540 
541 uniform vec2 screen;
542 
543 void main() {
544  vec2 halfScreen = screen / 2;
545  vec2 vertexPosition_homogenous = (vertexPosition_screen - halfScreen) / halfScreen;
546 
547  gl_Position = vec4(vertexPosition_homogenous.x, -vertexPosition_homogenous.y, 0, 1);
548  UV = vertexUV;
549  FragColor = vertexColor;
550 }
551 )!?!";
552 
553 const char* UI::imguiShaderFragment = R"!?!(
554 #version 330 core
555 
556 in vec2 UV;
557 in vec4 FragColor;
558 
559 out vec4 color;
560 
561 uniform sampler2D textureSampler;
562 
563 void main() {
564  color = texture(textureSampler, UV) * FragColor;
565 }
566 )!?!";
567 
568 // --------------------------------------
569 // *INDENT-ON*
570 
static std::string logFilename
Definition: UI.h:47
static void handleMouseScroll(int xrel, int yrel)
Definition: UI.cpp:403
static void display()
Definition: Console.cpp:73
Definition: global.h:61
void bufferData(int elem, int size, void *data)
Definition: Shader.cpp:18
IMGUI_API ImVec2 GetWindowSize()
Definition: imgui.cpp:3523
Definition: global.h:61
static int initialize()
Definition: UI.cpp:44
IMGUI_API bool CollapsingHeader(const char *label, const char *str_id=NULL, bool display_frame=true, bool default_open=false)
Definition: imgui.cpp:4332
static const char * imguiShaderFragment
Definition: UI.h:57
Definition: global.h:63
static std::list< std::tuple< int, int > > scrollEvents
Definition: UI.h:53
static void display()
Definition: Menu.cpp:84
IMGUI_API void SetWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
Definition: imgui.cpp:3510
static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs)
Definition: Game.cpp:101
Time handling utilities.
static void setClipboard(const char *s)
Definition: Window.cpp:149
static void handleControllerAxis(float value, KeyboardButton axis)
Definition: Game.cpp:108
IMGUI_API void GetTexDataAsRGBA32(unsigned char **out_pixels, int *out_width, int *out_height, int *out_bytes_per_pixel=NULL)
Definition: imgui.cpp:7294
void * TexID
Definition: imgui.h:905
static void handleControllerAxis(float value, KeyboardButton axis)
Definition: UI.cpp:410
Definition: global.h:61
static void handleControllerButton(KeyboardButton button, bool released)
Definition: UI.cpp:414
static void displayUI()
Definition: Camera.cpp:214
IMGUI_API void End()
Definition: imgui.cpp:3137
static void display()
void(* SetClipboardTextFn)(const char *text)
Definition: imgui.h:579
World Model.
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:4654
Definition: global.h:40
Definition: imgui.h:61
static std::list< std::tuple< KeyboardButton, bool > > keyboardEvents
Definition: UI.h:50
static void displayUI()
Definition: Render.cpp:193
static glm::vec3 getPosition()
Definition: Camera.h:27
bool KeyShift
Definition: imgui.h:600
Main Menu.
KeyboardButton
Definition: global.h:34
const char * IniFilename
Definition: imgui.h:555
ImVec2 FramePadding
Definition: imgui.h:528
Definition: global.h:45
Sound Source Manager.
IMGUI_API void Shutdown()
Definition: imgui.cpp:1909
World & getWorld()
Definition: main.cpp:32
bool KeyCtrl
Definition: imgui.h:599
Included everywhere.
static std::string getBaseDir()
Definition: RunTime.h:23
float TreeNodeSpacing
Definition: imgui.h:535
static Shader imguiShader
Definition: UI.h:55
Definition: global.h:47
void bindBuffer()
Definition: Shader.cpp:29
void loadUniform(int uni, glm::vec2 vec)
Definition: Shader.cpp:118
static const char * imguiShaderVertex
Definition: UI.h:56
static LogLevel & get(int level)
Definition: Log.cpp:14
int compile(const char *vertex, const char *fragment)
Definition: Shader.cpp:139
static const char * getClipboard()
Definition: Window.cpp:157
static unsigned int fontTex
Definition: UI.h:45
static bool visible
Definition: UI.h:44
static bool getTextInput()
Definition: Window.cpp:135
static void display()
Definition: UI.cpp:220
Definition: global.h:45
static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs)
Definition: UI.cpp:396
static std::string iniFilename
Definition: UI.h:46
const char *(* GetClipboardTextFn)()
Definition: imgui.h:578
Definition: imgui.h:50
Global Logging Utility.
bool WantCaptureMouse
Definition: imgui.h:611
static void setTextInput(bool t)
Definition: Window.cpp:127
Definition: global.h:45
static unsigned long getFPS()
Definition: RunTime.h:41
Definition: global.h:39
const char * LogFilename
Definition: imgui.h:556
Windowing Interface.
IMGUI_API void Render()
Definition: imgui.cpp:2012
#define assert(x)
Definition: global.h:124
static bool getMousegrab()
Definition: Window.cpp:113
ActionEvents
Definition: global.h:15
Console Window.
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0), bool repeat_when_held=false)
Definition: imgui.cpp:4055
static void handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released)
Definition: UI.cpp:378
static int getRoom()
Definition: Camera.h:43
World Renderer.
ImVec2 MousePos
Definition: imgui.h:595
void(* RenderDrawListsFn)(ImDrawList **const draw_lists, int count)
Definition: imgui.h:574
#define LOG_DEBUG
Definition: Log.h:22
bool KeysDown[512]
Definition: imgui.h:601
ImVector< ImDrawCmd > commands
Definition: imgui.h:831
Definition: global.h:63
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition: imgui.cpp:6653
Definition: imgui.h:546
IMGUI_API bool SliderFloat3(const char *label, float v[3], float v_min, float v_max, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:4929
static bool isVisible()
Definition: Console.h:20
static BufferManager * getBufferManager(int tex, TextureStorage store)
static bool isVisible()
Definition: Menu.h:22
static std::list< std::tuple< int, int, int, int > > motionEvents
Definition: UI.h:52
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:1736
Definition: global.h:47
Definition: global.h:48
ImVec2 ItemSpacing
Definition: imgui.h:530
static void handleAction(ActionEvents action, bool isFinished)
Definition: Game.cpp:84
Definition: global.h:50
SkeletalModel & getSkeletalModel(unsigned long index)
Definition: World.cpp:85
IMGUI_API ImGuiStyle & GetStyle()
Definition: imgui.cpp:1741
static const char endl
Definition: Log.h:35
Runtime Configuration Storage.
IMGUI_API void SameLine(int column_x=0, int spacing_w=-1)
Definition: imgui.cpp:6551
IMGUI_API void ShowStyleEditor(ImGuiStyle *ref=NULL)
Definition: imgui.cpp:8423
static void display()
Definition: RunTime.cpp:86
static KeyboardButton getKeyBinding(ActionEvents event)
Definition: RunTime.cpp:56
bool MouseDown[5]
Definition: imgui.h:596
IMGUI_API void ShowUserGuide()
Definition: imgui.cpp:8399
ImVector< ImDrawVert > vtx_buffer
Definition: imgui.h:832
void clear()
Definition: Shader.cpp:84
static void inputPositionCallback(int x, int y)
Definition: Window.cpp:171
ImVec2 ItemInnerSpacing
Definition: imgui.h:531
Definition: Shader.h:54
static void handleKeyboard(KeyboardButton key, bool pressed)
Definition: UI.cpp:355
ImVec2 DisplaySize
Definition: imgui.h:552
static void renderImGui(ImDrawList **const draw_lists, int count)
Definition: UI.cpp:459
ImVec4 Colors[ImGuiCol_COUNT]
Definition: imgui.h:539
IMGUI_API void Text(const char *fmt,...)
Definition: imgui.cpp:3802
UI/Event Manager.
int addUniform(const char *name)
Definition: Shader.cpp:101
void use()
Definition: Shader.cpp:134
Texture Registry.
float ScrollbarWidth
Definition: imgui.h:537
float WindowRounding
Definition: imgui.h:526
IMGUI_API void Separator()
Definition: imgui.cpp:6448
float MouseWheel
Definition: imgui.h:597
Definition: global.h:61
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
Definition: imgui.cpp:4163
static const float scale
Definition: Sprite.cpp:15
Definition: global.h:54
Definition: global.h:47
float DeltaTime
Definition: imgui.h:553
int getTexture()
Definition: Shader.h:46
Camera, View Frustum.
static glm::vec2 getRotation()
Definition: Camera.h:29
static void setMousegrab(bool g)
Definition: Window.cpp:105
static void shutdown()
Definition: UI.cpp:351
static bool metaKeyIsActive
Definition: UI.h:48
Definition: global.h:47
static std::list< std::tuple< unsigned int, unsigned int, KeyboardButton, bool > > clickEvents
Definition: UI.h:51
IMGUI_API void NewFrame()
Definition: imgui.cpp:1746
Definition: global.h:63
static void setVisible(bool v)
Definition: Console.h:21
static bool getShowFPS()
Definition: RunTime.h:38
static int loadBufferSlot(unsigned char *image=nullptr, unsigned int width=256, unsigned int height=256, ColorMode mode=ColorMode::RGBA, unsigned int bpp=32, TextureStorage s=TextureStorage::GAME, int slot=-1, bool filter=true)
Loads Buffer as texture.
static void eventsFinished()
Definition: UI.cpp:147
static void handleText(char *text, bool notFinished)
Definition: UI.cpp:367
IMGUI_API void ShowTestWindow(bool *open=NULL)
Definition: imgui.cpp:8529
static void setVisible(bool v)
Definition: Menu.h:23
ImVec2 TouchExtraPadding
Definition: imgui.h:532
IMGUI_API bool Begin(const char *name="Debug", bool *p_opened=NULL, const ImVec2 &initial_size=ImVec2(0, 0), float bg_alpha=-1.0f, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:2735
ImFontAtlas * Fonts
Definition: imgui.h:562
ImVec2 WindowPadding
Definition: imgui.h:524
static void setSize(glm::i32vec2 s)
Definition: UI.cpp:39
static void set2DState(bool on, bool depth=true)
Definition: Shader.cpp:266
Gameplay Handler.
or_time_t systemTimerGet()
Read the system timer.
Definition: time.cpp:15
static void display()
void unbind(int location)
Definition: Shader.cpp:49
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:4878
static glm::i32vec2 getSize()
Definition: Window.cpp:71
Definition: global.h:44
IMGUI_API void AddInputCharacter(ImWchar c)
Definition: imgui.cpp:585
static bool isLoaded()
Definition: Game.h:19
bool WantCaptureKeyboard
Definition: imgui.h:612
void(* ImeSetInputScreenPosFn)(int x, int y)
Definition: imgui.h:588
int KeyMap[ImGuiKey_COUNT]
Definition: imgui.h:559