styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-ui.h
Go to the documentation of this file.
1#pragma once
2#define NOMINMAX
3#undef ERROR
4#include "API/SKSEMenuFramework.h"
5
6using namespace ImGuiMCP;
7
8namespace StyyxUtil {
9 struct UIUtil {
10
14 static void HelpMarker(const char* desc)
15 {
16 TextDisabled("(?)");
17 if (BeginItemTooltip())
18 {
19 PushTextWrapPos(GetFontSize() * 35.0f);
20 TextUnformatted(desc);
21 PopTextWrapPos();
22 EndTooltip();
23 }
24 }
25
41 template <class T>
42 static bool SettingSlider(const char* a_label, T& a_sliderVariable, const T &a_sliderMin, const T &a_sliderMax, const char* a_sliderFormat,
43 const char* a_helpText, const float a_sliderWidth = 200.0f, const std::function<void(T)> &a_onSliderChanged = nullptr)
44 {
45 SetNextItemWidth(a_sliderWidth);
46
47 constexpr auto data_type = std::is_integral_v<T> ? ImGuiDataType_S32 : ImGuiDataType_Float;
48
49 const bool changed = SliderScalar(a_label, data_type, &a_sliderVariable, &a_sliderMin, &a_sliderMax, a_sliderFormat);
50 if (changed && a_onSliderChanged)
51 a_onSliderChanged(a_sliderVariable);
52 SameLine();
53 HelpMarker(a_helpText);
54 return changed;
55 }
56
57 static bool SetCheckbox(const char* a_label, bool& a_settingVariable, const char* a_helpText, const std::function<void(bool)>& a_onCheckbox = nullptr)
58 {
59 const bool changed = Checkbox(a_label, &a_settingVariable);
60 if (changed && a_onCheckbox)
61 a_onCheckbox(a_settingVariable);
62 SameLine();
63 HelpMarker(a_helpText);
64 return changed;
65 }
66
67 };
68
69
70}
71
72
Definition st-actor.h:7
Definition st-ui.h:9
static void HelpMarker(const char *desc)
Draw a ? that pops up some help text in SKSE Menu Framework.
Definition st-ui.h:14
static bool SettingSlider(const char *a_label, T &a_sliderVariable, const T &a_sliderMin, const T &a_sliderMax, const char *a_sliderFormat, const char *a_helpText, const float a_sliderWidth=200.0f, const std::function< void(T)> &a_onSliderChanged=nullptr)
Template to easily set up a slider with help text and have it optionally run a function if the slider...
Definition st-ui.h:42
static bool SetCheckbox(const char *a_label, bool &a_settingVariable, const char *a_helpText, const std::function< void(bool)> &a_onCheckbox=nullptr)
Definition st-ui.h:57