@@ -14,8 +14,14 @@ class Input : public CustomFormElement {
14
14
std::string mPlaceholder {};
15
15
std::string mDefault {};
16
16
17
- Input (std::string name, std::string text, std::string placeholder = {}, std::string defaultVal = {})
18
- : CustomFormElement(std::move(name), std::move(text)),
17
+ Input (
18
+ std::string name,
19
+ std::string text,
20
+ std::string placeholder = {},
21
+ std::string defaultVal = {},
22
+ std::string tooltip = {}
23
+ )
24
+ : CustomFormElement(std::move(name), std::move(text), std::move(tooltip)),
19
25
mPlaceholder (std::move(placeholder)),
20
26
mDefault(std::move(defaultVal)) {}
21
27
~Input () override = default ;
@@ -46,8 +52,8 @@ class Toggle : public CustomFormElement {
46
52
public:
47
53
bool mDefault = false ;
48
54
49
- Toggle (std::string name, std::string text, bool defaultVal = false )
50
- : CustomFormElement(std::move(name), std::move(text)),
55
+ Toggle (std::string name, std::string text, bool defaultVal = false , std::string tooltip = {} )
56
+ : CustomFormElement(std::move(name), std::move(text), std::move(tooltip) ),
51
57
mDefault (defaultVal) {}
52
58
~Toggle () override = default ;
53
59
@@ -73,8 +79,14 @@ class Dropdown : public CustomFormElement {
73
79
std::vector<std::string> mOptions {};
74
80
size_t mDefault {};
75
81
76
- Dropdown (std::string name, std::string text, std::vector<std::string> options, size_t defaultVal = 0 )
77
- : CustomFormElement(std::move(name), std::move(text)),
82
+ Dropdown (
83
+ std::string name,
84
+ std::string text,
85
+ std::vector<std::string> options,
86
+ size_t defaultVal = 0 ,
87
+ std::string tooltip = {}
88
+ )
89
+ : CustomFormElement(std::move(name), std::move(text), std::move(tooltip)),
78
90
mOptions (std::move(options)),
79
91
mDefault(defaultVal) {}
80
92
~Dropdown () override = default ;
@@ -127,8 +139,16 @@ class Slider : public CustomFormElement {
127
139
}
128
140
}
129
141
130
- Slider (std::string name, std::string text, double min, double max, double step, double defaultVal)
131
- : CustomFormElement(std::move(name), std::move(text)),
142
+ Slider (
143
+ std::string name,
144
+ std::string text,
145
+ double min,
146
+ double max,
147
+ double step,
148
+ double defaultVal,
149
+ std::string tooltip = {}
150
+ )
151
+ : CustomFormElement(std::move(name), std::move(text), std::move(tooltip)),
132
152
mMin (min),
133
153
mMax(max),
134
154
mStep(step),
@@ -174,8 +194,14 @@ class StepSlider : public CustomFormElement {
174
194
}
175
195
}
176
196
177
- StepSlider (std::string name, std::string text, std::vector<std::string> steps, size_t defaultVal = 0 )
178
- : CustomFormElement(std::move(name), std::move(text)),
197
+ StepSlider (
198
+ std::string name,
199
+ std::string text,
200
+ std::vector<std::string> steps,
201
+ size_t defaultVal = 0 ,
202
+ std::string tooltip = {}
203
+ )
204
+ : CustomFormElement(std::move(name), std::move(text), std::move(tooltip)),
179
205
mSteps (std::move(steps)),
180
206
mDefault(defaultVal) {
181
207
validate ();
@@ -233,12 +259,7 @@ class CustomForm::CustomFormImpl : public FormImpl {
233
259
void append (std::shared_ptr<FormElementBase> const & element) { mElements .push_back (element); }
234
260
235
261
bool sendTo (Player& player, Callback callback, bool update = false ) {
236
- std::vector<std::shared_ptr<CustomFormElement>> elements{};
237
- for (auto & element : mElements ) {
238
- if (element->getCategory () == FormElementBase::Category::Custom)
239
- elements.push_back (std::reinterpret_pointer_cast<CustomFormElement>(element));
240
- }
241
- auto handler = std::make_unique<handler::CustomFormHandler>(std::move (callback), std::move (elements));
262
+ auto handler = std::make_unique<handler::CustomFormHandler>(std::move (callback), mElements );
242
263
return sendImpl (player, serialize (), std::move (handler), update);
243
264
}
244
265
@@ -305,24 +326,31 @@ CustomForm& CustomForm::appendInput(
305
326
std::string const & name,
306
327
std::string const & text,
307
328
std::string const & placeholder,
308
- std::string const & defaultVal
329
+ std::string const & defaultVal,
330
+ std::string const & tooltip
309
331
) {
310
- impl->append (std::make_shared<Input>(name, text, placeholder, defaultVal));
332
+ impl->append (std::make_shared<Input>(name, text, placeholder, defaultVal, tooltip ));
311
333
return *this ;
312
334
}
313
335
314
- CustomForm& CustomForm::appendToggle (std::string const & name, std::string const & text, bool defaultVal) {
315
- impl->append (std::make_shared<Toggle>(name, text, defaultVal));
336
+ CustomForm& CustomForm::appendToggle (
337
+ std::string const & name,
338
+ std::string const & text,
339
+ bool defaultVal,
340
+ std::string const & tooltip
341
+ ) {
342
+ impl->append (std::make_shared<Toggle>(name, text, defaultVal, tooltip));
316
343
return *this ;
317
344
}
318
345
319
346
CustomForm& CustomForm::appendDropdown (
320
347
std::string const & name,
321
348
std::string const & text,
322
349
std::vector<std::string> const & options,
323
- size_t defaultVal
350
+ size_t defaultVal,
351
+ std::string const & tooltip
324
352
) {
325
- impl->append (std::make_shared<Dropdown>(name, text, options, defaultVal));
353
+ impl->append (std::make_shared<Dropdown>(name, text, options, defaultVal, tooltip ));
326
354
return *this ;
327
355
}
328
356
@@ -332,19 +360,21 @@ CustomForm& CustomForm::appendSlider(
332
360
double min,
333
361
double max,
334
362
double step,
335
- double defaultVal
363
+ double defaultVal,
364
+ std::string const & tooltip
336
365
) {
337
- impl->append (std::make_shared<Slider>(name, text, min, max, step, defaultVal));
366
+ impl->append (std::make_shared<Slider>(name, text, min, max, step, defaultVal, tooltip ));
338
367
return *this ;
339
368
}
340
369
341
370
CustomForm& CustomForm::appendStepSlider (
342
371
std::string const & name,
343
372
std::string const & text,
344
373
std::vector<std::string> const & steps,
345
- size_t defaultVal
374
+ size_t defaultVal,
375
+ std::string const & tooltip
346
376
) {
347
- impl->append (std::make_shared<StepSlider>(name, text, steps, defaultVal));
377
+ impl->append (std::make_shared<StepSlider>(name, text, steps, defaultVal, tooltip ));
348
378
return *this ;
349
379
}
350
380
0 commit comments