RigsofRods
Soft-body Physics Simulation
GUIUtils.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2013-2020 Petr Ohlidal
4 
5  For more information, see http://www.rigsofrods.org/
6 
7  Rigs of Rods is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License version 3, as
9  published by the Free Software Foundation.
10 
11  Rigs of Rods is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "GUIUtils.h"
21 
22 #include "Actor.h"
23 #include "Utils.h"
24 
25 #include "imgui_internal.h" // ImTextCharFromUtf8
26 #include <regex>
27 #include <stdio.h> // sscanf
28 
29 static const std::regex TEXT_COLOR_REGEX = std::regex(R"(#[a-fA-F\d]{6})");
30 static const int TEXT_COLOR_MAX_LEN = 5000;
31 
32 // --------------------------------
33 // ImTextFeeder
34 
35 void RoR::ImTextFeeder::AddInline(ImU32 color, ImVec2 text_size, const char* text_begin, const char* text_end)
36 {
37  drawlist->AddText(this->cursor, color, text_begin, text_end);
38  this->cursor.x += text_size.x;
39  this->size.x = std::max(this->cursor.x - this->origin.x, this->size.x);
40  this->size.y = std::max(this->size.y, text_size.y);
41 }
42 
43 void RoR::ImTextFeeder::AddWrapped(ImU32 color, float wrap_width, const char* text_begin, const char* text_end)
44 {
45  ImVec2 size = ImGui::CalcTextSize(text_begin, text_end);
46  const float cur_width = this->cursor.x - this->origin.x;
47  if (wrap_width > 0.f && cur_width + size.x > wrap_width)
48  {
49  this->NextLine();
50  }
51 
52  // Trim blanks at the start of new line (not first line), like ImGui::TextWrapped() does.
53  bool recalc_size = false;
54  if (this->cursor.x == this->origin.x && this->cursor.y != this->origin.y)
55  {
56  while ((*text_begin == ' ' || *text_begin == '\t'))
57  {
58  ++text_begin;
59  recalc_size = true;
60  if (text_begin == text_end)
61  return; // Nothing more to draw
62  }
63  }
64 
65  if (recalc_size)
66  size = ImGui::CalcTextSize(text_begin, text_end);
67 
68  this->AddInline(color, size, text_begin, text_end);
69 }
70 
71 void RoR::ImTextFeeder::AddMultiline(ImU32 color, float wrap_width, const char* text_begin, const char* text_end)
72 {
73  const char* text_pos = text_begin;
74  const char* tok_begin = nullptr;
75  while (text_pos != text_end)
76  {
77  // Decode and advance one character
78  unsigned int c = (unsigned int)*text_pos;
79  int bytes_advance = 1;
80  if (c >= 0x80)
81  bytes_advance = ImTextCharFromUtf8(&c, text_pos, text_end);
82 
83  if (c == '\r')
84  {} // Ignore carriage return
85  else if (c == '\n')
86  {
87  if (tok_begin != nullptr)
88  {
89  this->AddWrapped(color, wrap_width, tok_begin, text_pos); // Print the token
90  }
91  tok_begin = nullptr;
92  this->NextLine();
93  }
94  else if (c == ' ' || c == '\t')
95  {
96  if (tok_begin != nullptr)
97  {
98  this->AddWrapped(color, wrap_width, tok_begin, text_pos); // Print the token
99  tok_begin = nullptr;
100  }
101  this->AddWrapped(color, wrap_width, text_pos, text_pos + bytes_advance); // Print the blank
102  }
103  else
104  {
105  if (tok_begin == nullptr)
106  tok_begin = text_pos;
107  }
108  text_pos += bytes_advance;
109  }
110 
111  if (tok_begin != nullptr)
112  {
113  this->AddWrapped(color, wrap_width, tok_begin, text_end); // Print last token
114  }
115 }
116 
118 {
119  const float height = ImGui::GetTextLineHeight();
120  this->size.y += height;
121  this->cursor.x = this->origin.x;
122  this->cursor.y += height;
123 }
124 
125 // --------------------------------
126 // Global functions
127 
128 // Internal helper
129 inline void ColorToInts(ImVec4 v, int&r, int&g, int&b) { r=(int)(v.x*255); g=(int)(v.y*255); b=(int)(v.z*255); }
130 
131 // A nice spinner https://github.com/ocornut/imgui/issues/1901#issuecomment-444929973
132 void RoR::LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed)
133 {
134  ImGuiWindow* window = ImGui::GetCurrentWindow();
135  if (window->SkipItems)
136  {
137  return;
138  }
139 
140  ImGuiContext& g = *GImGui;
141  const ImGuiID id = window->GetID(label);
142 
143  const ImVec2 pos = window->DC.CursorPos;
144  const float circle_radius = indicator_radius / 10.0f;
145  const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f, pos.y + indicator_radius * 2.0f));
146  ImGui::ItemSize(bb, ImGui::GetStyle().FramePadding.y);
147  if (!ImGui::ItemAdd(bb, id))
148  {
149  return;
150  }
151 
152  const float t = g.Time;
153  const auto degree_offset = 2.0f * IM_PI / circle_count;
154 
155  for (int i = 0; i < circle_count; ++i)
156  {
157  const auto x = indicator_radius * std::sin(degree_offset * i);
158  const auto y = indicator_radius * std::cos(degree_offset * i);
159  const auto growth = std::max(0.0f, std::sin(t * speed - i * degree_offset));
160  ImVec4 color;
161  color.x = main_color.x * growth + backdrop_color.x * (1.0f - growth);
162  color.y = main_color.y * growth + backdrop_color.y * (1.0f - growth);
163  color.z = main_color.z * growth + backdrop_color.z * (1.0f - growth);
164  color.w = 1.0f;
165 
166  window->DrawList->AddCircleFilled(ImVec2(pos.x + indicator_radius + x,
167  pos.y + indicator_radius - y),
168  circle_radius + growth * circle_radius,
169  ImGui::GetColorU32(color));
170 
171  }
172 }
173 
174 //source: https://github.com/ocornut/imgui/issues/1982#issuecomment-408834301
175 void RoR::DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle)
176 {
177  ImDrawList* draw_list = ImGui::GetWindowDrawList();
178 
179  float cos_a = cosf(angle);
180  float sin_a = sinf(angle);
181  ImVec2 pos[4] =
182  {
183  center + ImRotate(ImVec2(-size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
184  center + ImRotate(ImVec2(+size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
185  center + ImRotate(ImVec2(+size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a),
186  center + ImRotate(ImVec2(-size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a)
187  };
188  ImVec2 uvs[4] =
189  {
190  ImVec2(0.0f, 0.0f),
191  ImVec2(1.0f, 0.0f),
192  ImVec2(1.0f, 1.0f),
193  ImVec2(0.0f, 1.0f)
194  };
195 
196  draw_list->AddImageQuad(tex_id, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], IM_COL32_WHITE);
197 }
198 
199 std::string RoR::StripColorMarksFromText(std::string const& text)
200 {
201  return std::regex_replace(text, TEXT_COLOR_REGEX, "");
202 }
203 
204 ImVec2 RoR::DrawColorMarkedText(ImDrawList* drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const& line)
205 {
206  ImTextFeeder feeder(drawlist, text_cursor);
207  int r,g,b, dark_r,dark_g,dark_b;
208  ColorToInts(default_color, r,g,b);
209  ColorToInts(App::GetGuiManager()->GetTheme().color_mark_max_darkness, dark_r, dark_g, dark_b);
210  std::smatch color_match;
211  std::string::const_iterator seg_start = line.begin();
212  while (std::regex_search(seg_start, line.end(), color_match, TEXT_COLOR_REGEX)) // Find next marker
213  {
214  // Print segment before the color marker (if any)
215  std::string::const_iterator seg_end = color_match[0].first;
216  if (seg_start != seg_end)
217  {
218  feeder.AddMultiline(ImColor(r,g,b,(int)(override_alpha*255)), wrap_width, &*seg_start, &*seg_end);
219  }
220  // Prepare for printing segment after color marker
221  sscanf(color_match.str(0).c_str(), "#%2x%2x%2x", &r, &g, &b);
222  if (r==0 && g==0 && b==0)
223  {
224  ColorToInts(default_color, r,g,b);
225  }
226  else if (r < dark_r && g < dark_g && b < dark_b)
227  {
228  // If below darkness limit, invert the color to lighen it up.
229  r = 255-r;
230  g = 255-g;
231  b = 255-b;
232  }
233  seg_start = color_match[0].second;
234  }
235 
236  // Print final segment (if any)
237  if (seg_start != line.begin() + line.length())
238  {
239  const char* end_ptr = &line.c_str()[line.length()];
240  feeder.AddMultiline(ImColor(r,g,b,(int)(override_alpha*255)), wrap_width, &*seg_start, end_ptr);
241  }
242 
243  return feeder.size;
244 }
245 
246 void RoR::ImTextWrappedColorMarked(std::string const& text)
247 {
248  ImVec2 text_pos = ImGui::GetCursorScreenPos();
249  ImVec2 text_size = RoR::DrawColorMarkedText(ImGui::GetWindowDrawList(),
250  text_pos,
251  ImGui::GetStyle().Colors[ImGuiCol_Text],
252  /*override_alpha=*/1.f,
253  ImGui::GetWindowContentRegionWidth() - ImGui::GetCursorPosX(),
254  text);
255  // From `ImGui::TextEx()` ...
256  ImRect bb(text_pos, text_pos + text_size);
257  ImGui::ItemSize(text_size);
258  ImGui::ItemAdd(bb, 0);
259 }
260 
261 bool RoR::DrawGCheckbox(CVar* cvar, const char* label)
262 {
263  bool val = cvar->getBool();
264  if (ImGui::Checkbox(label, &val))
265  {
266  cvar->setVal(val);
267  return true;
268  }
269  return false;
270 }
271 
272 void RoR::DrawGIntCheck(CVar* cvar, const char* label)
273 {
274  bool val = (cvar->getInt() != 0);
275  if (ImGui::Checkbox(label, &val))
276  {
277  cvar->setVal(val ? 1 : 0);
278  }
279 }
280 
281 void RoR::DrawGIntBox(CVar* cvar, const char* label)
282 {
283  int val = cvar->getInt();
284  if (ImGui::InputInt(label, &val, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue))
285  {
286  cvar->setVal(val);
287  }
288 }
289 
290 void RoR::DrawGIntSlider(CVar* cvar, const char* label, int v_min, int v_max)
291 {
292  int val = cvar->getInt();
293 
294  if (ImGui::SliderInt(label, &val, v_min, v_max))
295  {
296  cvar->setVal(val);
297  }
298 }
299 
300 void RoR::DrawGFloatSlider(CVar* cvar, const char* label, float v_min, float v_max)
301 {
302  float val = cvar->getFloat();
303 
304  if (ImGui::SliderFloat(label, &val, v_min, v_max, "%.2f"))
305  {
306  cvar->setVal(val);
307  }
308 }
309 
310 void RoR::DrawGFloatBox(CVar* cvar, const char* label)
311 {
312  float fval = cvar->getFloat();
313  if (ImGui::InputFloat(label, &fval, 0.f, 0.f, "%.3f", ImGuiInputTextFlags_EnterReturnsTrue))
314  {
315  cvar->setVal(fval);
316  }
317 }
318 
319 void RoR::DrawGTextEdit(CVar* cvar, const char* label, Str<1000>& buf)
320 {
321  if (ImGui::InputText(label, buf.GetBuffer(), buf.GetCapacity(), ImGuiInputTextFlags_EnterReturnsTrue))
322  {
323  cvar->setStr(buf.GetBuffer());
324  }
325  if (ImGui::IsItemActive())
326  {
327  ImGui::TextDisabled("(hit Enter key to submit)");
328  }
329  else
330  {
331  buf.Assign(cvar->getStr().c_str());
332  }
333 }
334 
335 void RoR::DrawGCombo(CVar* cvar, const char* label, const char* values)
336 {
337  int selection = cvar->getInt();
338  if (ImGui::Combo(label, &selection, values))
339  {
340  cvar->setVal(selection);
341  }
342 }
343 
344 Ogre::TexturePtr RoR::FetchIcon(const char* name)
345 {
346  try
347  {
348  return Ogre::static_pointer_cast<Ogre::Texture>(
349  Ogre::TextureManager::getSingleton().createOrRetrieve(name, "FlagsRG").first);
350  }
351  catch (...) {}
352 
353  return Ogre::TexturePtr(); // null
354 }
355 
356 ImDrawList* RoR::GetImDummyFullscreenWindow(const std::string& name /* = "RoR_TransparentFullscreenWindow"*/)
357 {
358  ImVec2 screen_size = ImGui::GetIO().DisplaySize;
359 
360  // Dummy fullscreen window to draw to
361  int window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar| ImGuiWindowFlags_NoInputs
362  | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus;
363  ImGui::SetNextWindowPos(ImVec2(0,0));
364  ImGui::SetNextWindowSize(screen_size);
365  ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0,0,0,0)); // Fully transparent background!
366  ImGui::Begin(name.c_str(), NULL, window_flags);
367  ImDrawList* drawlist = ImGui::GetWindowDrawList();
368  ImGui::End();
369  ImGui::PopStyleColor(1); // WindowBg
370 
371  return drawlist;
372 }
373 
374 void RoR::ImAddItemToComboboxString(std::string& target, std::string const& item)
375 {
376  // Items must be separated by single NUL character ('\0').
377  // -------------------------------------------------------
378 
379  if (target == "")
380  {
381  target += item;
382  }
383  else
384  {
385  // Get current size (not counting trailing NUL)
386  size_t prev_size = target.size();
387 
388  // Make space for 1 separating NUL
389  target.resize(prev_size + 1, '\0');
390 
391  // Insert new item after the separator
392  target.insert(target.begin() + prev_size + 1, item.begin(), item.end());
393  }
394 }
395 
396 void RoR::ImTerminateComboboxString(std::string& target)
397 {
398  // Items must be separated by double NUL character ("\0\0").
399  // ---------------------------------------------------------
400 
401  // Get current size (not counting trailing NUL)
402  size_t prev_size = target.size();
403 
404  // Make space for 2 trailing with NULs
405  target.resize(prev_size + 2, '\0');
406 }
407 
409 {
410  ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
411  if (App::GetInputEngine()->getEventValue(input_event))
412  {
414  }
415  std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
416  const ImVec2 PAD = ImVec2(2.f, 0.f);
417  ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
418  ImGui::BeginChildFrame(ImGuiID(input_event), ImGui::CalcTextSize(text.c_str()) + PAD*2);
419  ImGui::TextColored(col, "%s", text.c_str());
420  ImGui::EndChildFrame();
421  ImGui::PopStyleVar(); // FramePadding
422 }
423 
424 bool RoR::ImDrawEventHighlightedButton(events input_event, bool* btn_hovered /*=nullptr*/, bool* btn_active /*=nullptr*/)
425 {
426  ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
427  if (App::GetInputEngine()->getEventValue(input_event))
428  {
430  }
431  std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
432  const ImVec2 PAD = ImVec2(2.f, 0.f);
433  ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
434  ImGui::PushStyleColor(ImGuiCol_Text, col);
435  ImGui::PushID(input_event);
436  const bool retval = ImGui::Button(text.c_str());
437  if (btn_hovered != nullptr)
438  {
439  *btn_hovered = ImGui::IsItemHovered();
440  }
441  if (btn_active != nullptr)
442  {
443  *btn_active = ImGui::IsItemActive();
444  }
445  ImGui::PopID(); // input_event
446  ImGui::PopStyleColor(); // Text
447  ImGui::PopStyleVar(); // FramePadding
448  return retval;
449 }
450 
451 void RoR::ImDrawModifierKeyHighlighted(OIS::KeyCode key)
452 {
453  ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
454  if (App::GetInputEngine()->isKeyDown(key))
455  {
457  }
458  std::string text = App::GetInputEngine()->getModifierKeyName(key);
459  const ImVec2 PAD = ImVec2(2.f, 0.f);
460  ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
461  ImGui::BeginChildFrame(ImGuiID(key), ImGui::CalcTextSize(text.c_str()) + PAD*2);
462  ImGui::TextColored(col, "%s", text.c_str());
463  ImGui::EndChildFrame();
464  ImGui::PopStyleVar(); // FramePadding
465 }
466 
468 {
469  std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
470  const ImVec2 PAD = ImVec2(2.f, 0.f);
471  return ImGui::CalcTextSize(text.c_str()) + PAD*2;
472 }
473 
474 bool RoR::ImButtonHoldToConfirm(const std::string& btn_idstr, const bool smallbutton, const float time_limit)
475 {
476  if (smallbutton)
477  ImGui::SmallButton(btn_idstr.c_str());
478  else
479  ImGui::Button(btn_idstr.c_str());
480 
481  // When recording the active button, take full ID stack into account
482  static const ImGuiID IMGUIID_INVALID = 0u;
483  static ImGuiID active_id = IMGUIID_INVALID;
484  static float active_time_left = 0.f;
485  const ImGuiID btn_id = ImGui::GetCurrentWindow()->GetID(btn_idstr.c_str());
486 
487  if (ImGui::IsItemActive())
488  {
489  if (active_id != btn_id)
490  {
491  active_id = btn_id;
492  active_time_left = time_limit;
493  }
494  else
495  {
496  active_time_left -= ImGui::GetIO().DeltaTime;
497  if (active_time_left <= 0.f)
498  {
499  active_id = IMGUIID_INVALID;
500  return true;
501  }
502  }
503 
504  ImGui::BeginTooltip();
505  std::string text = _L("Hold to confirm");
506  ImGui::TextDisabled(text.c_str());
507  ImGui::ProgressBar(active_time_left/time_limit, ImVec2(ImGui::CalcTextSize(text.c_str()).x, 8.f), "");
508  ImGui::EndTooltip();
509  }
510  else if (btn_id == active_id)
511  {
512  active_id = IMGUIID_INVALID;
513  }
514 
515  return false;
516 }
517 
518 bool RoR::GetScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, ImVec2& out_screen)
519 {
520  ImVec2 screen_size = ImGui::GetIO().DisplaySize;
521  World2ScreenConverter world2screen(
522  App::GetCameraManager()->GetCamera()->getViewMatrix(true), App::GetCameraManager()->GetCamera()->getProjectionMatrix(), Ogre::Vector2(screen_size.x, screen_size.y));
523  Ogre::Vector3 pos_xyz = world2screen.Convert(world_pos);
524  if (pos_xyz.z < 0.f)
525  {
526  out_screen.x = pos_xyz.x;
527  out_screen.y = pos_xyz.y;
528  return true;
529  }
530  return false;
531 }
TEXT_COLOR_MAX_LEN
static const int TEXT_COLOR_MAX_LEN
Definition: GUIUtils.cpp:30
RoR::InputEngine::getEventCommandTrimmed
std::string getEventCommandTrimmed(int eventID)
Omits 'EXPL' modifier.
Definition: InputEngine.cpp:831
y
float y
Definition: (ValueTypes) quaternion.h:6
RoR::ImTextWrappedColorMarked
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
Definition: GUIUtils.cpp:246
RoR::ImCalcEventHighlightedSize
ImVec2 ImCalcEventHighlightedSize(events input_event)
Definition: GUIUtils.cpp:467
RoR::ImAddItemToComboboxString
void ImAddItemToComboboxString(std::string &target, std::string const &item)
Definition: GUIUtils.cpp:374
ColorToInts
void ColorToInts(ImVec4 v, int &r, int &g, int &b)
Definition: GUIUtils.cpp:129
RoR::StripColorMarksFromText
std::string StripColorMarksFromText(std::string const &text)
Definition: GUIUtils.cpp:199
RoR::DrawGFloatSlider
void DrawGFloatSlider(CVar *cvar, const char *label, float v_min, float v_max)
Definition: GUIUtils.cpp:300
RoR::FetchIcon
Ogre::TexturePtr FetchIcon(const char *name)
Definition: GUIUtils.cpp:344
RoR::Str::Assign
Str & Assign(const char *src)
Definition: Str.h:55
RoR::ImTextFeeder::cursor
ImVec2 cursor
Next draw position, screen space.
Definition: GUIUtils.h:40
RoR::ImTextFeeder::AddMultiline
void AddMultiline(ImU32 color, float wrap_width, const char *text, const char *text_end)
Wraps substrings separated by blanks. wrap_width=-1.f disables wrapping.
Definition: GUIUtils.cpp:71
RoR::Str::GetBuffer
char * GetBuffer()
Definition: Str.h:48
RoR::DrawGCombo
void DrawGCombo(CVar *cvar, const char *label, const char *values)
Definition: GUIUtils.cpp:335
RoR::App::GetCameraManager
CameraManager * GetCameraManager()
Definition: Application.cpp:275
RoR::App::GetGuiManager
GUIManager * GetGuiManager()
Definition: Application.cpp:269
RoR::DrawGTextEdit
void DrawGTextEdit(CVar *cvar, const char *label, Str< 1000 > &buf)
Definition: GUIUtils.cpp:319
RoR::DrawGIntBox
void DrawGIntBox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:281
RoR::GetScreenPosFromWorldPos
bool GetScreenPosFromWorldPos(Ogre::Vector3 const &world_pos, ImVec2 &out_screen)
Definition: GUIUtils.cpp:518
RoR::ImTextFeeder::size
ImVec2 size
Accumulated text size.
Definition: GUIUtils.h:42
RoR::DrawColorMarkedText
ImVec2 DrawColorMarkedText(ImDrawList *drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const &line)
Draw multiline text with '#rrggbb' color markers. Returns total text size.
Definition: GUIUtils.cpp:204
GUIUtils.h
RoR::ImDrawModifierKeyHighlighted
void ImDrawModifierKeyHighlighted(OIS::KeyCode key)
Definition: GUIUtils.cpp:451
RoR::Str::GetCapacity
size_t GetCapacity() const
Definition: Str.h:49
RoR::CVar::getBool
bool getBool() const
Definition: CVar.h:98
RoR::ImTextFeeder::AddInline
void AddInline(ImU32 color, ImVec2 text_size, const char *text, const char *text_end)
No wrapping or trimming.
Definition: GUIUtils.cpp:35
RoR::DrawGFloatBox
void DrawGFloatBox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:310
RoR::ImTextFeeder::NextLine
void NextLine()
Definition: GUIUtils.cpp:117
RoR::DrawGIntSlider
void DrawGIntSlider(CVar *cvar, const char *label, int v_min, int v_max)
Definition: GUIUtils.cpp:290
RoR::ImTextFeeder
Helper for drawing multiline wrapped & colored text.
Definition: GUIUtils.h:27
Utils.h
RoR::World2ScreenConverter::Convert
Ogre::Vector3 Convert(Ogre::Vector3 world_pos)
Definition: Utils.h:89
Actor.h
RoR::GetImDummyFullscreenWindow
ImDrawList * GetImDummyFullscreenWindow(const std::string &name="RoR_TransparentFullscreenWindow")
Definition: GUIUtils.cpp:356
RoR::GUIManager::GetTheme
GuiTheme & GetTheme()
Definition: GUIManager.h:154
RoR::CVar::getStr
std::string const & getStr() const
Definition: CVar.h:95
RoR::Str< 1000 >
RoR::World2ScreenConverter
< Keeps data close for faster access.
Definition: Utils.h:81
RoR::ImButtonHoldToConfirm
bool ImButtonHoldToConfirm(const std::string &btn_idstr, const bool smallbutton, const float time_limit)
Definition: GUIUtils.cpp:474
RoR::ImDrawEventHighlightedButton
bool ImDrawEventHighlightedButton(events input_event, bool *btn_hovered=nullptr, bool *btn_active=nullptr)
Definition: GUIUtils.cpp:424
RoR::DrawGIntCheck
void DrawGIntCheck(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:272
RoR::CVar
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition: CVar.h:52
RoR::ImTextFeeder::AddWrapped
void AddWrapped(ImU32 color, float wrap_width, const char *text, const char *text_end)
Wraps entire input. Trims leading blanks on extra lines. wrap_width=-1.f disables wrapping.
Definition: GUIUtils.cpp:43
RoR::CVar::setVal
void setVal(T val)
Definition: CVar.h:72
_L
#define _L
Definition: ErrorUtils.cpp:34
RoR::GUIManager::GuiTheme::highlight_text_color
ImVec4 highlight_text_color
Definition: GUIManager.h:76
RoR::App::GetInputEngine
InputEngine * GetInputEngine()
Definition: Application.cpp:271
RoR::ImTerminateComboboxString
void ImTerminateComboboxString(std::string &target)
Definition: GUIUtils.cpp:396
RoR::InputEngine::getModifierKeyName
Ogre::String getModifierKeyName(OIS::KeyCode key)
Definition: InputEngine.cpp:2241
RoR::CVar::getFloat
float getFloat() const
Definition: CVar.h:96
RoR::DrawGCheckbox
bool DrawGCheckbox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:261
RoR::CVar::getInt
int getInt() const
Definition: CVar.h:97
RoR::ImDrawEventHighlighted
void ImDrawEventHighlighted(events input_event)
Definition: GUIUtils.cpp:408
TEXT_COLOR_REGEX
static const std::regex TEXT_COLOR_REGEX
Definition: GUIUtils.cpp:29
RoR::events
events
Definition: InputEngine.h:74
RoR::ImTextFeeder::drawlist
ImDrawList * drawlist
Definition: GUIUtils.h:39
RoR::LoadingIndicatorCircle
void LoadingIndicatorCircle(const char *label, const float indicator_radius, const ImVec4 &main_color, const ImVec4 &backdrop_color, const int circle_count, const float speed)
Draws animated loading spinner.
Definition: GUIUtils.cpp:132
x
float x
Definition: (ValueTypes) quaternion.h:5
RoR::DrawImageRotated
void DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle)
Add rotated textured quad to ImDrawList, source: https://github.com/ocornut/imgui/issues/1982#issueco...
Definition: GUIUtils.cpp:175
RoR::CVar::setStr
void setStr(std::string const &str)
Definition: CVar.h:83