mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
allow additional individual choices in slider fields
This commit is contained in:
@@ -25,6 +25,7 @@ IMPLEMENT_REFLECTION(SliderField) {
|
||||
REFLECT_BASE(Field); // NOTE: don't reflect as a ChoiceField
|
||||
REFLECT(script);
|
||||
REFLECT_N("default", default_script);
|
||||
REFLECT_N("choices", choices->choices);
|
||||
REFLECT(initial);
|
||||
REFLECT(minimum);
|
||||
REFLECT(maximum);
|
||||
@@ -34,6 +35,8 @@ IMPLEMENT_REFLECTION(SliderField) {
|
||||
void SliderField::after_reading(Version ver) {
|
||||
Field::after_reading(ver);
|
||||
|
||||
int choice_count = choices->choices.size();
|
||||
|
||||
if (maximum < minimum) {
|
||||
int temp = maximum;
|
||||
maximum = minimum;
|
||||
@@ -54,6 +57,21 @@ void SliderField::after_reading(Version ver) {
|
||||
catch (...) {
|
||||
initial = wxString::Format(wxT("%i"), minimum);
|
||||
}
|
||||
|
||||
// Move individual choices that are greater than maximum to the end
|
||||
for (int i = 0; i < choice_count; ++i) {
|
||||
try {
|
||||
int choice_int = std::stoi(choices->choices[i].get()->name.ToStdString());
|
||||
if (choice_int >= maximum) {
|
||||
auto it = choices->choices.begin() + i;
|
||||
std::rotate(it, it + 1, choices->choices.end());
|
||||
--i;
|
||||
--choice_count;
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
choices->initIds();
|
||||
}
|
||||
// ----------------------------------------------------------------------------- : SliderStyle
|
||||
|
||||
Reference in New Issue
Block a user