Skip to content

Commit

Permalink
Unit Create: fixed unit selection not persisting between uses (fixes #…
Browse files Browse the repository at this point in the history
…2822)

I had been unconditionally selecting the first entry after setting the active
sorting option. This overrode the previous unit selection.

Regression from 6b52d16.

(cherry-picked from commit ccce105)
  • Loading branch information
Vultraz committed Oct 7, 2018
1 parent 65092a4 commit 6ae7c8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -64,6 +64,7 @@
* Fixed regression where unit filters in [disable] weapon specials would not
match the attacking unit.
* Fixed images with no alpha channel rendering incorrectly.
* Fixed unit selection not persisting between uses of Create Unit.

## Version 1.13.12
### Security fixes
Expand Down
5 changes: 3 additions & 2 deletions src/gui/dialogs/unit_create.cpp
Expand Up @@ -138,7 +138,7 @@ void unit_create::pre_show(window& window)
list.add_row(row_data);

// Select the previous choice, if any.
if(choice_.empty() != true && choice_ == i.first) {
if(!choice_.empty() && choice_ == i.first) {
list.select_last_row();
}
}
Expand All @@ -151,7 +151,8 @@ void unit_create::pre_show(window& window)
list.register_translatable_sorting_option(0, [this](const int i) { return (*units_[i]).race()->plural_name().str(); });
list.register_translatable_sorting_option(1, [this](const int i) { return (*units_[i]).type_name().str(); });

list.set_active_sorting_option({0, listbox::SORT_ASCENDING}, true);
// Select the first entry on sort if no previous selection was provided.
list.set_active_sorting_option({0, listbox::SORT_ASCENDING}, choice_.empty());

list_item_clicked(window);
}
Expand Down

0 comments on commit 6ae7c8e

Please sign in to comment.