mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-08 18:13:02 -04:00
98 lines
2.2 KiB
C++
98 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "button.hpp"
|
|
#include "component.hpp"
|
|
#include "document.hpp"
|
|
#include "ui.hpp"
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace dusk::ui {
|
|
|
|
class SteppedCarousel : public Component {
|
|
public:
|
|
struct Props {
|
|
int min = 0;
|
|
int max = 0;
|
|
int step = 1;
|
|
std::function<int()> getValue;
|
|
std::function<void(int)> onChange;
|
|
std::function<Rml::String(int)> formatValue;
|
|
};
|
|
|
|
SteppedCarousel(Rml::Element* parent, Props props);
|
|
|
|
bool focus() override;
|
|
void update() override;
|
|
bool handle_nav_command(NavCommand cmd);
|
|
|
|
private:
|
|
void apply(int value);
|
|
|
|
Props mProps;
|
|
Rml::Element* mPrevElem = nullptr;
|
|
Rml::Element* mNextElem = nullptr;
|
|
Rml::Element* mValueElem = nullptr;
|
|
};
|
|
|
|
enum class GraphicsOption {
|
|
InternalResolution,
|
|
ShadowResolution,
|
|
Resampler,
|
|
BloomMode,
|
|
BloomMultiplier,
|
|
DepthOfFieldMode,
|
|
};
|
|
|
|
Rml::String format_graphics_setting_value(GraphicsOption option, int value);
|
|
|
|
struct GraphicsTunerProps {
|
|
GraphicsOption option;
|
|
Rml::String title;
|
|
Rml::String helpText;
|
|
int valueMin = 0;
|
|
int valueMax = 0;
|
|
int defaultValue = 0;
|
|
int step = 1;
|
|
};
|
|
|
|
class GraphicsTuner : public Document {
|
|
public:
|
|
explicit GraphicsTuner(GraphicsTunerProps props, bool prelaunch);
|
|
|
|
void show() override;
|
|
void hide(bool close) override;
|
|
void update() override;
|
|
bool focus() override;
|
|
bool visible() const override;
|
|
|
|
protected:
|
|
bool handle_nav_command(Rml::Event& event, NavCommand cmd) override;
|
|
|
|
private:
|
|
template <typename T, typename... Args>
|
|
requires std::is_base_of_v<Component, T> T& add_component(Args&&... args) {
|
|
auto child = std::make_unique<T>(std::forward<Args>(args)...);
|
|
T& ref = *child;
|
|
mComponents.emplace_back(std::move(child));
|
|
return ref;
|
|
}
|
|
|
|
void reset_default();
|
|
|
|
GraphicsOption mOption;
|
|
int mValueMin = 0;
|
|
int mValueMax = 0;
|
|
int mDefaultValue = 0;
|
|
std::vector<std::unique_ptr<Component> > mComponents;
|
|
SteppedCarousel* mCarousel;
|
|
Rml::Element* mRoot;
|
|
bool mPrelaunch;
|
|
};
|
|
|
|
} // namespace dusk::ui
|