mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 05:36:59 -04:00
restrict slider ui to slider fields
This commit is contained in:
@@ -33,13 +33,14 @@ public:
|
|||||||
class Choice;
|
class Choice;
|
||||||
typedef intrusive_ptr<Choice> ChoiceP;
|
typedef intrusive_ptr<Choice> ChoiceP;
|
||||||
|
|
||||||
ChoiceP choices; ///< A choice group of possible choices
|
ChoiceP choices; ///< A choice group of possible choices
|
||||||
OptionalScript script; ///< Script to apply to all values
|
OptionalScript script; ///< Script to apply to all values
|
||||||
OptionalScript default_script; ///< Script that generates the default value
|
OptionalScript default_script; ///< Script that generates the default value
|
||||||
String initial; ///< Initial choice of a new value, or ""
|
String initial; ///< Initial choice of a new value, or ""
|
||||||
String default_name; ///< Name of "default" value
|
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; ///< Colors for the various choices (when color_cardlist)
|
||||||
map<String,Color> choice_colors_cardlist; ///< Colors for the various choices, for in the card list
|
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 initDependencies(Context&, const Dependency&) const override;
|
||||||
void after_reading(Version ver) override;
|
void after_reading(Version ver) override;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ IMPLEMENT_REFLECTION(SliderField) {
|
|||||||
void SliderField::after_reading(Version ver) {
|
void SliderField::after_reading(Version ver) {
|
||||||
Field::after_reading(ver);
|
Field::after_reading(ver);
|
||||||
|
|
||||||
|
is_slider = true;
|
||||||
|
|
||||||
int choice_count = choices->choices.size();
|
int choice_count = choices->choices.size();
|
||||||
|
|
||||||
if (maximum < minimum) swap(minimum, maximum);
|
if (maximum < minimum) swap(minimum, maximum);
|
||||||
|
|||||||
@@ -202,27 +202,21 @@ DropDownChoiceList::DropDownChoiceList(Window* parent, bool is_submenu, ValueVie
|
|||||||
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
||||||
{
|
{
|
||||||
// determine if slider
|
// determine if slider
|
||||||
size_t count = itemCount();
|
if (itemCount() > 1 && field().is_slider) {
|
||||||
if (count > 3) {
|
is_slider = true;
|
||||||
int value;
|
// load slider images if needed
|
||||||
try {
|
if (!slider_loaded) {
|
||||||
String first_item = capitalize(itemText(0));
|
slider_loaded = true;
|
||||||
if (first_item != _("Default")) value = std::stoi(first_item.ToStdString());
|
try {
|
||||||
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
|
|
||||||
is_slider = true;
|
|
||||||
// load slider images if needed
|
|
||||||
if (!slider_loaded) {
|
|
||||||
slider_loaded = true;
|
|
||||||
slider_left = load_resource_image(_("slider_left"));
|
slider_left = load_resource_image(_("slider_left"));
|
||||||
slider_right = load_resource_image(_("slider_right"));
|
slider_right = load_resource_image(_("slider_right"));
|
||||||
slider_center = load_resource_image(_("slider_center"));
|
slider_center = load_resource_image(_("slider_center"));
|
||||||
slider_tick = load_resource_image(_("slider_tick"));
|
slider_tick = load_resource_image(_("slider_tick"));
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
throw InternalError(_("Can't load slider resources"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user