Faction Select: fixed changes persisting even if you cancel the dialog
(cherry-picked from commit c2c613325b
)
This commit is contained in:
parent
a1a46b059d
commit
9c9fbe4649
3 changed files with 29 additions and 1 deletions
|
@ -51,6 +51,8 @@
|
|||
### Miscellaneous and bug fixes
|
||||
* Added an advanced preference to enable experimental PRNG combat.
|
||||
* Fixed MP admins being unable to observe private games.
|
||||
* Fixed MP faction, leader, and leader gender changes persisting even if the
|
||||
selection dialog is dismissed.
|
||||
|
||||
## Version 1.14.3
|
||||
### AI
|
||||
|
|
|
@ -46,6 +46,9 @@ faction_select::faction_select(ng::flg_manager& flg_manager, const std::string&
|
|||
: flg_manager_(flg_manager)
|
||||
, tc_color_(color)
|
||||
, side_(side)
|
||||
, last_faction_(flg_manager.current_faction_index())
|
||||
, last_leader_(flg_manager.current_leader_index())
|
||||
, last_gender_(flg_manager.current_gender_index())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -184,7 +187,6 @@ void faction_select::on_leader_select(window& window)
|
|||
{
|
||||
flg_manager_.set_current_leader(find_widget<menu_button>(&window, "leader_menu", false).get_value());
|
||||
|
||||
|
||||
// TODO: should we decouple this from the flg manager and instead just check the unit type directly?
|
||||
// If that's done so, we'd need to come up with a different check for Random availability.
|
||||
gender_toggle_.set_members_enabled([this](const std::string& gender)->bool {
|
||||
|
@ -214,5 +216,24 @@ void faction_select::update_leader_image(window& window)
|
|||
find_widget<image>(&window, "leader_image", false).set_label(leader_image);
|
||||
}
|
||||
|
||||
void faction_select::post_show(window& window)
|
||||
{
|
||||
//
|
||||
// If we're canceling, restore the previous selections. It might be worth looking
|
||||
// into only making selections at all here in post_show, but that would require a
|
||||
// refactor of the flg_manager class.
|
||||
//
|
||||
// Also, note it's important to set these in the order of faction -> leader -> gender
|
||||
// or the saved indices will be invalid!
|
||||
//
|
||||
// -- vultraz, 2018-06-16
|
||||
//
|
||||
if(get_retval() != retval::OK) {
|
||||
flg_manager_.set_current_faction(last_faction_);
|
||||
flg_manager_.set_current_leader(last_leader_);
|
||||
flg_manager_.set_current_gender(last_gender_);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui2
|
||||
|
|
|
@ -41,12 +41,17 @@ private:
|
|||
|
||||
group<std::string> gender_toggle_;
|
||||
|
||||
const int last_faction_, last_leader_, last_gender_;
|
||||
|
||||
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const override;
|
||||
|
||||
/** Inherited from modal_dialog. */
|
||||
virtual void pre_show(window& window) override;
|
||||
|
||||
/** Inherited from modal_dialog. */
|
||||
virtual void post_show(window& window) override;
|
||||
|
||||
/** Callbacks */
|
||||
void on_faction_select(window& window);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue