diff options
Diffstat (limited to 'src/ui/widget/unit-menu.cpp')
| -rw-r--r-- | src/ui/widget/unit-menu.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index b4271762c..362f5d90f 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -54,6 +54,27 @@ UnitMenu::setUnitType(UnitType unit_type) return true; } +/** Removes all unit entries, then adds the unit type to the widget. + This extracts the corresponding + units from the unit map matching the given type, and appends them + to the dropdown widget. It causes the primary unit for the given + unit_type to be selected. */ +bool +UnitMenu::resetUnitType(UnitType unit_type) +{ + clear_text(); + + return setUnitType(unit_type); +} + +/** Adds a unit, possibly user-defined, to the menu. */ +void +UnitMenu::addUnit(Unit const& u) +{ + _unit_table.addUnit(u, false); + append_text(u.abbr); +} + /** Returns the Unit object corresponding to the current selection in the dropdown widget */ Unit |
