Skip to content

Commit

Permalink
frontend: Various minor improvements.
Browse files Browse the repository at this point in the history
Made a few more menus reset values to the default in response to the UI
clear input.

Made the minimum info text size less unreasonable, and fixed a locale
issue in the font/size selection menu when parsing option strings.

Made the keyboard mode menu toggle items on double click or UI select.

Made the menuless sliders menu remember the last slider shown (this
probably broke when sliders were moved out of the UI manager itself).

Made a few menus just update the highlighted options when it's adjusted
rather than unnecessarily rebuilding the menu.

Made a few more menus reset on being reactivated to cope with scripts or
other things changing stuff out from under them.
  • Loading branch information
cuavas committed Nov 13, 2021
1 parent 90c4b00 commit b23bf4a
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 150 deletions.
51 changes: 36 additions & 15 deletions src/frontend/mame/ui/analogipt.cpp
Expand Up @@ -189,6 +189,13 @@ void menu_analog::custom_render(void *selectedref, float top, float bottom, floa
}


void menu_analog::menu_activated()
{
// scripts could have changed something in the mean time
reset(reset_options::REMEMBER_POSITION);
}


void menu_analog::handle(event const *ev)
{
// handle events
Expand Down Expand Up @@ -313,9 +320,11 @@ void menu_analog::handle(event const *ev)
case ANALOG_ITEM_SENSITIVITY: settings.sensitivity = newval; break;
}
data.field.get().set_user_settings(settings);
data.cur = newval;

// rebuild the menu
reset(reset_options::REMEMBER_POSITION);
// update the menu item
ev->item->set_subtext(item_text(data.type, newval));
ev->item->set_flags((data.cur <= data.min) ? FLAG_RIGHT_ARROW : (data.cur >= data.max) ? FLAG_LEFT_ARROW : FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW);
}
}
}
Expand All @@ -334,7 +343,6 @@ void menu_analog::populate(float &customtop, float &custombottom)

// add the items
std::string text;
std::string subtext;
for (item_data &data : m_item_data)
{
// get the user settings
Expand All @@ -359,38 +367,31 @@ void menu_analog::populate(float &customtop, float &custombottom)
default:
case ANALOG_ITEM_KEYSPEED:
text = string_format(_("%1$s Increment/Decrement Speed"), field->name());
subtext = string_format("%d", settings.delta);
data.cur = settings.delta;
break;

case ANALOG_ITEM_CENTERSPEED:
text = string_format(_("%1$s Auto-centering Speed"), field->name());
subtext = string_format("%d", settings.centerdelta);
data.cur = settings.centerdelta;
break;

case ANALOG_ITEM_REVERSE:
text = string_format(_("%1$s Reverse"), field->name());
subtext.assign(settings.reverse ? "On" : "Off");
data.cur = settings.reverse;
break;

case ANALOG_ITEM_SENSITIVITY:
text = string_format(_("%1$s Sensitivity"), field->name());
subtext = string_format("%d", settings.sensitivity);
data.cur = settings.sensitivity;
break;
}

// put on arrows
uint32_t flags(0U);
if (data.cur > data.min)
flags |= FLAG_LEFT_ARROW;
if (data.cur < data.max)
flags |= FLAG_RIGHT_ARROW;

// append a menu item
item_append(std::move(text), std::move(subtext), flags, &data);
item_append(
std::move(text),
item_text(data.type, data.cur),
(data.cur <= data.min) ? FLAG_RIGHT_ARROW : (data.cur >= data.max) ? FLAG_LEFT_ARROW : FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW,
&data);
}

item_append(menu_item_type::SEPARATOR);
Expand Down Expand Up @@ -454,4 +455,24 @@ void menu_analog::find_fields()
m_visible_fields = m_field_data.size();
}


std::string menu_analog::item_text(int type, int value)
{
switch (type)
{
default:
case ANALOG_ITEM_KEYSPEED:
return string_format("%d", value);

case ANALOG_ITEM_CENTERSPEED:
return string_format("%d", value);

case ANALOG_ITEM_REVERSE:
return value ? _("On") : _("Off");

case ANALOG_ITEM_SENSITIVITY:
return string_format("%d", value);
}
}

} // namespace ui
3 changes: 3 additions & 0 deletions src/frontend/mame/ui/analogipt.h
Expand Up @@ -28,6 +28,7 @@ class menu_analog : public menu

protected:
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
virtual void menu_activated() override;

private:
enum
Expand Down Expand Up @@ -70,6 +71,8 @@ class menu_analog : public menu

void find_fields();

static std::string item_text(int type, int value);

item_data_vector m_item_data;
field_data_vector m_field_data;
std::string m_prompt;
Expand Down

0 comments on commit b23bf4a

Please sign in to comment.