styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-fui.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
5#include "API/FUCK_API.h"
6
7namespace StyyxUtil
8{
9struct FUCKUtil
10{
11 static constexpr ImVec4 GREEN{0.2f, 0.6f, 0.3f, 1.0f};
12 static constexpr ImVec4 RED{0.78f, 0.0f, 0.0f, 1.0f};
13
14 static void IndentTextColored(const ImVec4& color, const std::string& text, float indent = 120.f)
15 {
16 FUCK::Indent(indent);
17 FUCK::TextColored(color, text.c_str());
19 }
20
21 static void GreenTitleText(const std::string& text, float indent = 75.f)
22 {
23 FUCK::Indent(indent);
24 FUCK::TextColored(GREEN, text.c_str());
26 }
27
28 static void RedTitleText(const std::string& text, float indent = 75.f)
29 {
30 FUCK::Indent(indent);
31 FUCK::TextColored(RED, text.c_str());
33 }
34
35 template <class T>
36 static bool Checkbox(const char* label, T& value, auto& configEntry, const char* help = nullptr)
37 {
38 if (FUCK::Checkbox(label, &value))
39 {
40 configEntry.SetValue(value);
41 return true;
42 }
43 if (help)
44 {
45 FUCK::SetTooltip(help);
46 }
47 return false;
48 }
49
50 template <class T>
51 static bool SliderInt(const char* label, T& value, auto& configEntry, T min, T max, const char* help = nullptr)
52 {
53 if (FUCK::SliderInt(label, reinterpret_cast<int*>(&value), min, max))
54 {
55 configEntry.SetValue(value);
56 return true;
57 }
58 if (help)
59 {
60 FUCK::SetTooltip(help);
61 }
62
63 return false;
64 }
65
66 template <class T>
67 static bool SliderFloat(const char* label, T& value, auto& configEntry, float min, float max,
68 const char* help = nullptr)
69 {
70 if (FUCK::SliderFloat(label, reinterpret_cast<float*>(&value), min, max))
71 {
72 configEntry.SetValue(value);
73 return true;
74 }
75 if (help)
76 {
77 FUCK::SetTooltip(help);
78 }
79 return false;
80 }
81
82 static bool InputText(const char* label, char* buffer, size_t size, std::string& value, auto& configEntry,
83 const char* help = nullptr)
84 {
85 if (FUCK::InputText(label, buffer, size))
86 {
87 value = buffer;
88 configEntry.SetValue(value);
89 return true;
90 }
91 if (help)
92 {
93 FUCK::SetTooltip(help);
94 }
95 return false;
96 }
97};
98} // namespace StyyxUtil
bool SliderInt(const char *label, int *v, int min, int max, const char *fmt="%d")
Definition FUCK_API.h:1253
void Indent(float width=0.0f)
Definition FUCK_API.h:912
bool InputText(const char *label, char *buf, size_t buf_size, int flags=0)
Definition FUCK_API.h:1237
void Unindent(float width=0.0f)
Definition FUCK_API.h:917
void TextColored(const ImVec4 &color, const char *fmt,...)
Definition FUCK_API.h:1346
bool SliderFloat(const char *label, float *v, float min, float max, const char *fmt="%.3f")
Definition FUCK_API.h:1249
void SetTooltip(const char *fmt)
Definition FUCK_API.h:1335
bool Checkbox(const char *label, bool *v, bool alignFar=true, bool labelLeft=true)
Definition FUCK_API.h:1223
Definition st-actor.h:7
Definition st-fui.h:10
static constexpr ImVec4 RED
Definition st-fui.h:12
static bool Checkbox(const char *label, T &value, auto &configEntry, const char *help=nullptr)
Definition st-fui.h:36
static void RedTitleText(const std::string &text, float indent=75.f)
Definition st-fui.h:28
static void IndentTextColored(const ImVec4 &color, const std::string &text, float indent=120.f)
Definition st-fui.h:14
static bool InputText(const char *label, char *buffer, size_t size, std::string &value, auto &configEntry, const char *help=nullptr)
Definition st-fui.h:82
static bool SliderFloat(const char *label, T &value, auto &configEntry, float min, float max, const char *help=nullptr)
Definition st-fui.h:67
static void GreenTitleText(const std::string &text, float indent=75.f)
Definition st-fui.h:21
static bool SliderInt(const char *label, T &value, auto &configEntry, T min, T max, const char *help=nullptr)
Definition st-fui.h:51
static constexpr ImVec4 GREEN
Definition st-fui.h:11