Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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#include "PlatformUtils.h"
25
26#include "imgui_internal.h" // ImTextCharFromUtf8
27#include <regex>
28#include <stdio.h> // sscanf
29
30static const std::regex TEXT_COLOR_REGEX = std::regex(R"(#[a-fA-F\d]{6})");
31static const int TEXT_COLOR_MAX_LEN = 5000;
32
33// --------------------------------
34// ImTextFeeder
35
36RoR::ImTextFeeder::ImTextFeeder(ImDrawList* _drawlist, ImVec2 _origin)
37 : drawlist(_drawlist), origin(_origin), cursor(_origin)
38{
39 line_height = ImGui::GetTextLineHeight();
40}
41
42void RoR::ImTextFeeder::AddInline(ImU32 color, ImVec2 text_size, const char* text_begin, const char* text_end)
43{
44 drawlist->AddText(this->cursor, color, text_begin, text_end);
45 this->cursor.x += text_size.x;
46 this->size.x = std::max(this->cursor.x - this->origin.x, this->size.x);
47 this->size.y = std::max(this->size.y, text_size.y);
48}
49
50void RoR::ImTextFeeder::AddWrapped(ImU32 color, float wrap_width, const char* text_begin, const char* text_end)
51{
52 ImVec2 size = ImGui::CalcTextSize(text_begin, text_end);
53 const float cur_width = this->cursor.x - this->origin.x;
54 if (wrap_width > 0.f && cur_width + size.x > wrap_width)
55 {
56 this->NextLine();
57 }
58
59 // Trim blanks at the start of new line (not first line), like ImGui::TextWrapped() does.
60 bool recalc_size = false;
61 if (this->cursor.x == this->origin.x && this->cursor.y != this->origin.y)
62 {
63 while ((*text_begin == ' ' || *text_begin == '\t'))
64 {
65 ++text_begin;
66 recalc_size = true;
67 if (text_begin == text_end)
68 return; // Nothing more to draw
69 }
70 }
71
72 if (recalc_size)
73 size = ImGui::CalcTextSize(text_begin, text_end);
74
75 this->AddInline(color, size, text_begin, text_end);
76}
77
78void RoR::ImTextFeeder::AddMultiline(ImU32 color, float wrap_width, const char* text_begin, const char* text_end)
79{
80 const char* text_pos = text_begin;
81 const char* tok_begin = nullptr;
82 while (text_pos != text_end)
83 {
84 // Decode and advance one character
85 unsigned int c = (unsigned int)*text_pos;
86 int bytes_advance = 1;
87 if (c >= 0x80)
88 bytes_advance = ImTextCharFromUtf8(&c, text_pos, text_end);
89
90 if (c == '\r')
91 {} // Ignore carriage return
92 else if (c == '\n')
93 {
94 if (tok_begin != nullptr)
95 {
96 this->AddWrapped(color, wrap_width, tok_begin, text_pos); // Print the token
97 }
98 tok_begin = nullptr;
99 this->NextLine();
100 }
101 else if (c == ' ' || c == '\t')
102 {
103 if (tok_begin != nullptr)
104 {
105 this->AddWrapped(color, wrap_width, tok_begin, text_pos); // Print the token
106 tok_begin = nullptr;
107 }
108 this->AddWrapped(color, wrap_width, text_pos, text_pos + bytes_advance); // Print the blank
109 }
110 else
111 {
112 if (tok_begin == nullptr)
113 tok_begin = text_pos;
114 }
115 text_pos += bytes_advance;
116 }
117
118 if (tok_begin != nullptr)
119 {
120 this->AddWrapped(color, wrap_width, tok_begin, text_end); // Print last token
121 }
122}
123
124void RoR::ImTextFeeder::AddRectWrapped(ImVec2 size, ImVec2 spacing, float wrap_width, ImVec2& out_rect_min)
125{
126 // Wrap if requested and if we're not on far left side
127 const float cur_width = this->cursor.x - this->origin.x;
128 if (wrap_width > 0.f && cur_width > 0.f && cur_width + size.x > wrap_width)
129 {
130 this->NextLine();
131 }
132
133 // Output the cursor for drawing
134 out_rect_min = this->cursor;
135
136 // Update cursor
137 this->cursor.x += size.x + spacing.x;
138 this->line_height = std::max(this->line_height, size.y + spacing.y);
139 this->size.x = std::max(this->size.x, this->cursor.x - this->origin.x);
140 this->size.y = std::max(this->size.y, (this->cursor.y + this->line_height) - this->origin.y);
141}
142
144{
145 this->size.y += this->line_height;
146 this->cursor.x = this->origin.x;
147 this->cursor.y += this->line_height;
148 this->line_height = ImGui::GetTextLineHeight();
149}
150
151// --------------------------------
152// Global functions
153
154// Internal helper
155inline 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); }
156
157// A nice spinner https://github.com/ocornut/imgui/issues/1901#issuecomment-444929973
158void RoR::LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed)
159{
160 ImGuiWindow* window = ImGui::GetCurrentWindow();
161 if (window->SkipItems)
162 {
163 return;
164 }
165
166 ImGuiContext& g = *GImGui;
167 const ImGuiID id = window->GetID(label);
168
169 const ImVec2 pos = window->DC.CursorPos;
170 const float circle_radius = indicator_radius / 10.0f;
171 const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f, pos.y + indicator_radius * 2.0f));
172 ImGui::ItemSize(bb, ImGui::GetStyle().FramePadding.y);
173 if (!ImGui::ItemAdd(bb, id))
174 {
175 return;
176 }
177
178 const float t = g.Time;
179 const auto degree_offset = 2.0f * IM_PI / circle_count;
180
181 for (int i = 0; i < circle_count; ++i)
182 {
183 const auto x = indicator_radius * std::sin(degree_offset * i);
184 const auto y = indicator_radius * std::cos(degree_offset * i);
185 const auto growth = std::max(0.0f, std::sin(t * speed - i * degree_offset));
186 ImVec4 color;
187 color.x = main_color.x * growth + backdrop_color.x * (1.0f - growth);
188 color.y = main_color.y * growth + backdrop_color.y * (1.0f - growth);
189 color.z = main_color.z * growth + backdrop_color.z * (1.0f - growth);
190 color.w = 1.0f;
191
192 window->DrawList->AddCircleFilled(ImVec2(pos.x + indicator_radius + x,
193 pos.y + indicator_radius - y),
194 circle_radius + growth * circle_radius,
195 ImGui::GetColorU32(color));
196
197 }
198}
199
200//source: https://github.com/ocornut/imgui/issues/1982#issuecomment-408834301
201void RoR::DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle)
202{
203 ImDrawList* draw_list = ImGui::GetWindowDrawList();
204
205 float cos_a = cosf(angle);
206 float sin_a = sinf(angle);
207 ImVec2 pos[4] =
208 {
209 center + ImRotate(ImVec2(-size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
210 center + ImRotate(ImVec2(+size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
211 center + ImRotate(ImVec2(+size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a),
212 center + ImRotate(ImVec2(-size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a)
213 };
214 ImVec2 uvs[4] =
215 {
216 ImVec2(0.0f, 0.0f),
217 ImVec2(1.0f, 0.0f),
218 ImVec2(1.0f, 1.0f),
219 ImVec2(0.0f, 1.0f)
220 };
221
222 draw_list->AddImageQuad(tex_id, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], IM_COL32_WHITE);
223}
224
225std::string RoR::StripColorMarksFromText(std::string const& text)
226{
227 return std::regex_replace(text, TEXT_COLOR_REGEX, "");
228}
229
230ImVec2 RoR::DrawColorMarkedText(ImDrawList* drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const& line)
231{
232 ImTextFeeder feeder(drawlist, text_cursor);
233 int r,g,b, dark_r,dark_g,dark_b;
234 ColorToInts(default_color, r,g,b);
235 ColorToInts(App::GetGuiManager()->GetTheme().color_mark_max_darkness, dark_r, dark_g, dark_b);
236 std::smatch color_match;
237 std::string::const_iterator seg_start = line.begin();
238 while (std::regex_search(seg_start, line.end(), color_match, TEXT_COLOR_REGEX)) // Find next marker
239 {
240 // Print segment before the color marker (if any)
241 std::string::const_iterator seg_end = color_match[0].first;
242 if (seg_start != seg_end)
243 {
244 feeder.AddMultiline(ImColor(r,g,b,(int)(override_alpha*255)), wrap_width, &*seg_start, &*seg_end);
245 }
246 // Prepare for printing segment after color marker
247 sscanf(color_match.str(0).c_str(), "#%2x%2x%2x", &r, &g, &b);
248 if (r==0 && g==0 && b==0)
249 {
250 ColorToInts(default_color, r,g,b);
251 }
252 else if (r < dark_r && g < dark_g && b < dark_b)
253 {
254 // If below darkness limit, invert the color to lighen it up.
255 r = 255-r;
256 g = 255-g;
257 b = 255-b;
258 }
259 seg_start = color_match[0].second;
260 }
261
262 // Print final segment (if any)
263 if (seg_start != line.begin() + line.length())
264 {
265 const char* end_ptr = &line.c_str()[line.length()];
266 feeder.AddMultiline(ImColor(r,g,b,(int)(override_alpha*255)), wrap_width, &*seg_start, end_ptr);
267 }
268
269 return feeder.size;
270}
271
272void RoR::ImTextWrappedColorMarked(std::string const& text)
273{
274 ImVec2 text_pos = ImGui::GetCursorScreenPos();
275 ImVec2 text_size = RoR::DrawColorMarkedText(ImGui::GetWindowDrawList(),
276 text_pos,
277 ImGui::GetStyle().Colors[ImGuiCol_Text],
278 /*override_alpha=*/1.f,
279 ImGui::GetWindowContentRegionWidth() - ImGui::GetCursorPosX(),
280 text);
281 // From `ImGui::TextEx()` ...
282 ImRect bb(text_pos, text_pos + text_size);
283 ImGui::ItemSize(text_size);
284 ImGui::ItemAdd(bb, 0);
285}
286
287bool RoR::DrawGCheckbox(CVar* cvar, const char* label)
288{
289 bool val = cvar->getBool();
290 if (ImGui::Checkbox(label, &val))
291 {
292 cvar->setVal(val);
293 return true;
294 }
295 return false;
296}
297
298void RoR::DrawGIntCheck(CVar* cvar, const char* label)
299{
300 bool val = (cvar->getInt() != 0);
301 if (ImGui::Checkbox(label, &val))
302 {
303 cvar->setVal(val ? 1 : 0);
304 }
305}
306
307void RoR::DrawGIntBox(CVar* cvar, const char* label)
308{
309 int val = cvar->getInt();
310 if (ImGui::InputInt(label, &val, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue))
311 {
312 cvar->setVal(val);
313 }
314}
315
316void RoR::DrawGIntSlider(CVar* cvar, const char* label, int v_min, int v_max)
317{
318 int val = cvar->getInt();
319
320 if (ImGui::SliderInt(label, &val, v_min, v_max))
321 {
322 cvar->setVal(val);
323 }
324}
325
326void RoR::DrawGFloatSlider(CVar* cvar, const char* label, float v_min, float v_max)
327{
328 float val = cvar->getFloat();
329
330 if (ImGui::SliderFloat(label, &val, v_min, v_max, "%.2f"))
331 {
332 cvar->setVal(val);
333 }
334}
335
336void RoR::DrawGFloatBox(CVar* cvar, const char* label)
337{
338 float fval = cvar->getFloat();
339 if (ImGui::InputFloat(label, &fval, 0.f, 0.f, "%.3f", ImGuiInputTextFlags_EnterReturnsTrue))
340 {
341 cvar->setVal(fval);
342 }
343}
344
345void RoR::DrawGTextEdit(CVar* cvar, const char* label, Str<1000>& buf)
346{
347 if (ImGui::InputText(label, buf.GetBuffer(), buf.GetCapacity(), ImGuiInputTextFlags_EnterReturnsTrue))
348 {
349 cvar->setStr(buf.GetBuffer());
350 }
351 if (ImGui::IsItemActive())
352 {
353 ImGui::TextDisabled("(hit Enter key to submit)");
354 }
355 else
356 {
357 buf.Assign(cvar->getStr().c_str());
358 }
359}
360
361bool RoR::DrawGCombo(CVar* cvar, const char* label, const char* values)
362{
363 int selection = cvar->getInt();
364 if (ImGui::Combo(label, &selection, values))
365 {
366 cvar->setVal(selection);
367 return true;
368 }
369 return false;
370}
371
372Ogre::TexturePtr RoR::FetchIcon(const char* name)
373{
374 try
375 {
376 Ogre::TexturePtr tex = Ogre::static_pointer_cast<Ogre::Texture>(
377 Ogre::TextureManager::getSingleton().createOrRetrieve(name, "FlagsRG").first);
378
379 // Load the texture now to catch FileNotFoundException early. This is more efficient than
380 // lazy loading because: (1) the texture will be loaded on first use anyway, and
381 // (2) catching exceptions here is safer than during ImGui rendering.
382 if (!tex->isLoaded())
383 {
384 tex->load();
385 }
386 return tex;
387 }
388 catch (...)
389 {
390 return Ogre::TexturePtr(); // null
391 }
392}
393
394ImDrawList* RoR::GetImDummyFullscreenWindow(const std::string& name /* = "RoR_TransparentFullscreenWindow"*/)
395{
396 ImVec2 screen_size = ImGui::GetIO().DisplaySize;
397
398 // Dummy fullscreen window to draw to
399 int window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar| ImGuiWindowFlags_NoInputs
400 | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus;
401 ImGui::SetNextWindowPos(ImVec2(0,0));
402 ImGui::SetNextWindowSize(screen_size);
403 ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0,0,0,0)); // Fully transparent background!
404 ImGui::Begin(name.c_str(), NULL, window_flags);
405 ImDrawList* drawlist = ImGui::GetWindowDrawList();
406 ImGui::End();
407 ImGui::PopStyleColor(1); // WindowBg
408
409 return drawlist;
410}
411
412void RoR::ImAddItemToComboboxString(std::string& target, std::string const& item)
413{
414 // Items must be separated by single NUL character ('\0').
415 // -------------------------------------------------------
416
417 if (target == "")
418 {
419 target += item;
420 }
421 else
422 {
423 // Get current size (not counting trailing NUL)
424 size_t prev_size = target.size();
425
426 // Make space for 1 separating NUL
427 target.resize(prev_size + 1, '\0');
428
429 // Insert new item after the separator
430 target.insert(target.begin() + prev_size + 1, item.begin(), item.end());
431 }
432}
433
434void RoR::ImTerminateComboboxString(std::string& target)
435{
436 // Items must be separated by double NUL character ("\0\0").
437 // ---------------------------------------------------------
438
439 // Get current size (not counting trailing NUL)
440 size_t prev_size = target.size();
441
442 // Make space for 2 trailing with NULs
443 target.resize(prev_size + 2, '\0');
444}
445
447{
448 ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
449 if (App::GetInputEngine()->getEventValue(input_event))
450 {
452 }
453 std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
454 const ImVec2 PAD = ImVec2(2.f, 0.f);
455 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
456 ImGui::BeginChildFrame(ImGuiID(input_event), ImGui::CalcTextSize(text.c_str()) + PAD*2);
457 ImGui::TextColored(col, "%s", text.c_str());
458 ImGui::EndChildFrame();
459 ImGui::PopStyleVar(); // FramePadding
460}
461
462bool RoR::ImDrawEventHighlightedButton(events input_event, bool* btn_hovered /*=nullptr*/, bool* btn_active /*=nullptr*/)
463{
464 ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
465 if (App::GetInputEngine()->getEventValue(input_event))
466 {
468 }
469 std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
470 const ImVec2 PAD = ImVec2(2.f, 0.f);
471 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
472 ImGui::PushStyleColor(ImGuiCol_Text, col);
473 ImGui::PushID(input_event);
474 const bool retval = ImGui::Button(text.c_str());
475 if (btn_hovered != nullptr)
476 {
477 *btn_hovered = ImGui::IsItemHovered();
478 }
479 if (btn_active != nullptr)
480 {
481 *btn_active = ImGui::IsItemActive();
482 }
483 ImGui::PopID(); // input_event
484 ImGui::PopStyleColor(); // Text
485 ImGui::PopStyleVar(); // FramePadding
486 return retval;
487}
488
490{
491 ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
492 if (App::GetInputEngine()->isKeyDown(key))
493 {
495 }
496 std::string text = App::GetInputEngine()->getModifierKeyName(key);
497 const ImVec2 PAD = ImVec2(2.f, 0.f);
498 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
499 ImGui::BeginChildFrame(ImGuiID(key), ImGui::CalcTextSize(text.c_str()) + PAD*2);
500 ImGui::TextColored(col, "%s", text.c_str());
501 ImGui::EndChildFrame();
502 ImGui::PopStyleVar(); // FramePadding
503}
504
506{
507 std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
508 const ImVec2 PAD = ImVec2(2.f, 0.f);
509 return ImGui::CalcTextSize(text.c_str()) + PAD*2;
510}
511
512bool RoR::ImButtonHoldToConfirm(const std::string& btn_idstr, const bool smallbutton, const float time_limit)
513{
514 if (smallbutton)
515 ImGui::SmallButton(btn_idstr.c_str());
516 else
517 ImGui::Button(btn_idstr.c_str());
518
519 // When recording the active button, take full ID stack into account
520 static const ImGuiID IMGUIID_INVALID = 0u;
521 static ImGuiID active_id = IMGUIID_INVALID;
522 static float active_time_left = 0.f;
523 const ImGuiID btn_id = ImGui::GetCurrentWindow()->GetID(btn_idstr.c_str());
524
525 if (ImGui::IsItemActive())
526 {
527 if (active_id != btn_id)
528 {
529 active_id = btn_id;
530 active_time_left = time_limit;
531 }
532 else
533 {
534 active_time_left -= ImGui::GetIO().DeltaTime;
535 if (active_time_left <= 0.f)
536 {
537 active_id = IMGUIID_INVALID;
538 return true;
539 }
540 }
541
542 ImGui::BeginTooltip();
543 std::string text = _L("Hold to confirm");
544 ImGui::TextDisabled(text.c_str());
545 ImGui::ProgressBar(active_time_left/time_limit, ImVec2(ImGui::CalcTextSize(text.c_str()).x, 8.f), "");
546 ImGui::EndTooltip();
547 }
548 else if (btn_id == active_id)
549 {
550 active_id = IMGUIID_INVALID;
551 }
552
553 return false;
554}
555
556bool RoR::ImMoveTextInputCursorToEnd(const char* label)
557{
558 ImGuiWindow* window = ImGui::GetCurrentWindow();
559 const ImGuiID id = window->GetID(label);
560 ImGuiContext& g = *GImGui;
561
562 // NB: we are only allowed to access 'edit_state' if we are the active widget.
563 ImGuiInputTextState* state = NULL;
564 if (g.InputTextState.ID != id)
565 {
566 return false;
567 }
568
569 state = &g.InputTextState;
570 // based on `ImGuiInputTextState::CursorClamp()`
571 state->Stb.cursor = state->CurLenW;
572 state->Stb.select_start = 0;
573 state->Stb.select_end = 0;
574
575 return true;
576}
577
578bool RoR::GetScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, ImVec2& out_screen)
579{
580 ImVec2 screen_size = ImGui::GetIO().DisplaySize;
581 World2ScreenConverter world2screen(
582 App::GetCameraManager()->GetCamera()->getViewMatrix(true), App::GetCameraManager()->GetCamera()->getProjectionMatrix(), Ogre::Vector2(screen_size.x, screen_size.y));
583 Ogre::Vector3 pos_xyz = world2screen.Convert(world_pos);
584 if (pos_xyz.z < 0.f)
585 {
586 out_screen.x = pos_xyz.x;
587 out_screen.y = pos_xyz.y;
588 return true;
589 }
590 return false;
591}
592
594void RoR::ImDummyHyperlink(std::string caption)
595{
596 const ImVec4 LINKCOLOR = ImVec4(0.3, 0.5, 0.9, 1.0);
597 ImGui::PushStyleColor(0, LINKCOLOR); //Text
598 ImVec2 cursorBefore = ImGui::GetCursorScreenPos();
599 ImGui::Text(caption.c_str());
600 ImVec2 textSize = ImGui::CalcTextSize(caption.c_str());
601 ImGui::GetWindowDrawList()->AddLine(
602 cursorBefore + ImVec2(0, textSize.y), cursorBefore + textSize, //from-to
603 ImColor(LINKCOLOR));
604 if (ImGui::IsItemHovered())
605 {
606 ImGui::SetMouseCursor(7);//Hand cursor
607 }
608 ImGui::PopStyleColor(1); //Text
609}
610
612void RoR::ImHyperlink(std::string url, std::string caption /*= ""*/, bool tooltip /* = true */)
613{
614 if (caption == "") { caption = url; tooltip = false; }
615 ImDummyHyperlink(caption);
616 if (ImGui::IsItemClicked())
617 {
618 RoR::OpenUrlInDefaultBrowser(url); // PlatformUtils.h
619 }
620 if (tooltip && ImGui::IsItemHovered())
621 {
622 ImGui::BeginTooltip();
623 ImDummyHyperlink(url);
624 ImGui::EndTooltip();
625 }
626}
#define _L
static const std::regex TEXT_COLOR_REGEX
Definition GUIUtils.cpp:30
void ColorToInts(ImVec4 v, int &r, int &g, int &b)
Definition GUIUtils.cpp:155
static const int TEXT_COLOR_MAX_LEN
Definition GUIUtils.cpp:31
Platform-specific utilities. We use narrow UTF-8 encoded strings as paths. Inspired by http://utf8eve...
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition CVar.h:53
float getFloat() const
Definition CVar.h:96
std::string const & getStr() const
Definition CVar.h:95
bool getBool() const
Definition CVar.h:98
void setStr(std::string const &str)
Definition CVar.h:83
void setVal(T val)
Definition CVar.h:72
int getInt() const
Definition CVar.h:97
GuiTheme & GetTheme()
Definition GUIManager.h:168
std::string getEventCommandTrimmed(int eventID)
Omits 'EXPL' modifier.
Ogre::String getModifierKeyName(OIS::KeyCode key)
Wrapper for classic c-string (local buffer) Refresher: strlen() excludes '\0' terminator; strncat() A...
Definition Str.h:36
char * GetBuffer()
Definition Str.h:48
size_t GetCapacity() const
Definition Str.h:49
Str & Assign(const char *src)
Definition Str.h:55
< Keeps data close for faster access.
Definition Utils.h:83
Ogre::Vector3 Convert(Ogre::Vector3 world_pos)
Definition Utils.h:90
void OpenUrlInDefaultBrowser(std::string const &url)
InputEngine * GetInputEngine()
CameraManager * GetCameraManager()
GUIManager * GetGuiManager()
void ImDrawEventHighlighted(events input_event)
Definition GUIUtils.cpp:446
void ImDummyHyperlink(std::string caption)
Looks and behaves (mouuse cursor) like a hypertext, but doesn't open URL.
Definition GUIUtils.cpp:594
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:230
void DrawGFloatBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:336
void DrawGTextEdit(CVar *cvar, const char *label, Str< 1000 > &buf)
Definition GUIUtils.cpp:345
void ImHyperlink(std::string url, std::string caption="", bool tooltip=true)
Full-featured hypertext with tooltip showing full URL.
Definition GUIUtils.cpp:612
ImDrawList * GetImDummyFullscreenWindow(const std::string &name="RoR_TransparentFullscreenWindow")
Definition GUIUtils.cpp:394
bool ImDrawEventHighlightedButton(events input_event, bool *btn_hovered=nullptr, bool *btn_active=nullptr)
Definition GUIUtils.cpp:462
void DrawGIntSlider(CVar *cvar, const char *label, int v_min, int v_max)
Definition GUIUtils.cpp:316
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
Definition GUIUtils.cpp:272
void DrawGIntBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:307
void ImTerminateComboboxString(std::string &target)
Definition GUIUtils.cpp:434
ImVec2 ImCalcEventHighlightedSize(events input_event)
Definition GUIUtils.cpp:505
bool GetScreenPosFromWorldPos(Ogre::Vector3 const &world_pos, ImVec2 &out_screen)
Definition GUIUtils.cpp:578
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:201
void ImAddItemToComboboxString(std::string &target, std::string const &item)
Definition GUIUtils.cpp:412
void ImDrawModifierKeyHighlighted(OIS::KeyCode key)
Definition GUIUtils.cpp:489
void DrawGFloatSlider(CVar *cvar, const char *label, float v_min, float v_max)
Definition GUIUtils.cpp:326
bool DrawGCheckbox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:287
std::string StripColorMarksFromText(std::string const &text)
Definition GUIUtils.cpp:225
void DrawGIntCheck(CVar *cvar, const char *label)
Definition GUIUtils.cpp:298
bool DrawGCombo(CVar *cvar, const char *label, const char *values)
Definition GUIUtils.cpp:361
Ogre::TexturePtr FetchIcon(const char *name)
Definition GUIUtils.cpp:372
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:158
bool ImMoveTextInputCursorToEnd(const char *label)
Definition GUIUtils.cpp:556
bool ImButtonHoldToConfirm(const std::string &btn_idstr, const bool smallbutton, const float time_limit)
Definition GUIUtils.cpp:512
Helper for drawing multiline wrapped & colored text.
Definition GUIUtils.h:28
ImVec2 size
Accumulated text size.
Definition GUIUtils.h:44
ImTextFeeder(ImDrawList *_drawlist, ImVec2 _origin)
Definition GUIUtils.cpp:36
void AddInline(ImU32 color, ImVec2 text_size, const char *text, const char *text_end)
No wrapping or trimming.
Definition GUIUtils.cpp:42
void AddRectWrapped(ImVec2 size, ImVec2 spacing, float wrap_width, ImVec2 &out_rect_min)
Reserves space for i.e. an image. wrap_width=-1.f disables wrapping.
Definition GUIUtils.cpp:124
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:50
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:78