LeviLamina
Loading...
Searching...
No Matches
CustomForm.h
1#pragma once
2
3#include "ll/api/form/FormBase.h"
4#include "mc/world/actor/player/Player.h"
5
6namespace ll::form {
7
8using CustomFormElementResult = std::variant<std::monostate, uint64, double, std::string>;
9using CustomFormResult = std::optional<std::unordered_map<std::string, CustomFormElementResult>>;
10
11class CustomForm : public Form {
12
13 class CustomFormImpl;
14 std::unique_ptr<CustomFormImpl> impl;
15
16public:
17 using Callback = std::function<void(Player&, CustomFormResult const&, FormCancelReason)>;
18
19 LLNDAPI CustomForm();
20
21 LLNDAPI explicit CustomForm(std::string const& title);
22
23 LLAPI ~CustomForm() override;
24
25 LLAPI CustomForm& setTitle(std::string const& title);
26
27 LLAPI CustomForm& setSubmitButton(std::string const& text);
28
29 LLAPI CustomForm& appendHeader(std::string const& text);
30
31 LLAPI CustomForm& appendLabel(std::string const& text);
32
33 LLAPI CustomForm& appendDivider();
34
35 LLAPI CustomForm& appendInput(
36 std::string const& name,
37 std::string const& text,
38 std::string const& placeholder = {},
39 std::string const& defaultVal = {},
40 std::string const& tooltip = {}
41 );
42
43 LLAPI CustomForm& appendToggle(
44 std::string const& name,
45 std::string const& text,
46 bool defaultVal = false,
47 std::string const& tooltip = {}
48 );
49
50 LLAPI CustomForm& appendDropdown(
51 std::string const& name,
52 std::string const& text,
53 std::vector<std::string> const& options,
54 size_t defaultVal = 0,
55 std::string const& tooltip = {}
56 );
57
58 LLAPI CustomForm& appendSlider(
59 std::string const& name,
60 std::string const& text,
61 double min,
62 double max,
63 double step = 0.0,
64 double defaultVal = 0.0,
65 std::string const& tooltip = {}
66 );
67
68 LLAPI CustomForm& appendStepSlider(
69 std::string const& name,
70 std::string const& text,
71 std::vector<std::string> const& steps,
72 size_t defaultVal = 0,
73 std::string const& tooltip = {}
74 );
75
76 LLAPI CustomForm& sendTo(Player& player, Callback callback = {});
77
78 LLAPI CustomForm& sendUpdate(Player& player, Callback callback = {});
79
80 LLAPI std::string getFormData() const;
81};
82
83} // namespace ll::form
Definition Player.h:123
Definition CustomForm.h:11
Definition FormBase.h:12