mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
restrict slider ui to slider fields
This commit is contained in:
@@ -40,6 +40,7 @@ public:
|
||||
String default_name; ///< Name of "default" value
|
||||
map<String,Color> choice_colors; ///< Colors for the various choices (when color_cardlist)
|
||||
map<String,Color> choice_colors_cardlist; ///< Colors for the various choices, for in the card list
|
||||
bool is_slider = false; ///< Should the UI be displayed as a slider?
|
||||
|
||||
void initDependencies(Context&, const Dependency&) const override;
|
||||
void after_reading(Version ver) override;
|
||||
|
||||
@@ -35,6 +35,8 @@ IMPLEMENT_REFLECTION(SliderField) {
|
||||
void SliderField::after_reading(Version ver) {
|
||||
Field::after_reading(ver);
|
||||
|
||||
is_slider = true;
|
||||
|
||||
int choice_count = choices->choices.size();
|
||||
|
||||
if (maximum < minimum) swap(minimum, maximum);
|
||||
|
||||
@@ -202,27 +202,21 @@ DropDownChoiceList::DropDownChoiceList(Window* parent, bool is_submenu, ValueVie
|
||||
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
||||
{
|
||||
// determine if slider
|
||||
size_t count = itemCount();
|
||||
if (count > 3) {
|
||||
int value;
|
||||
try {
|
||||
String first_item = capitalize(itemText(0));
|
||||
if (first_item != _("Default")) value = std::stoi(first_item.ToStdString());
|
||||
value = std::stoi(itemText(1).ToStdString());
|
||||
value = std::stoi(itemText(count - 2).ToStdString());
|
||||
value = std::stoi(itemText(count - 1).ToStdString());
|
||||
// the choices are numbers, use a slider
|
||||
if (itemCount() > 1 && field().is_slider) {
|
||||
is_slider = true;
|
||||
// load slider images if needed
|
||||
if (!slider_loaded) {
|
||||
slider_loaded = true;
|
||||
try {
|
||||
slider_left = load_resource_image(_("slider_left"));
|
||||
slider_right = load_resource_image(_("slider_right"));
|
||||
slider_center = load_resource_image(_("slider_center"));
|
||||
slider_tick = load_resource_image(_("slider_tick"));
|
||||
}
|
||||
catch (...) {
|
||||
throw InternalError(_("Can't load slider resources"));
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user