Statistics Dialog: remove mode toggle in favor of an All Scenarios menu entry
Closes #2886.
(cherry-picked from commit b5f1e1a48a
)
This commit is contained in:
parent
27279f96e1
commit
1871a32995
4 changed files with 23 additions and 105 deletions
|
@ -255,6 +255,8 @@ TODO! REMOVE ALL DUPLICATE ENTRIES FOR CHANGES THAT BELONG UNDER THE 1.13.13 - 1
|
|||
* Fixed [scenario] map_file= being unusable in most circumstances.
|
||||
|
||||
## Version 1.14.3+dev
|
||||
### User interface
|
||||
* Improved the layout of the Statistics dialog.
|
||||
|
||||
## Version 1.14.3
|
||||
### AI
|
||||
|
|
|
@ -440,78 +440,15 @@
|
|||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
horizontal_grow = true
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[menu_button]
|
||||
id = "scenario_menu"
|
||||
definition = "default"
|
||||
[/menu_button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = all
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[horizontal_listbox]
|
||||
id = "tab_bar"
|
||||
|
||||
[list_definition]
|
||||
[row]
|
||||
[column]
|
||||
{_GUI_STATS_TAB_BAR}
|
||||
[/column]
|
||||
[/row]
|
||||
[/list_definition]
|
||||
|
||||
[list_data]
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[widget]
|
||||
id = "tab_label"
|
||||
label = _ "Scenario"
|
||||
[/widget]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[widget]
|
||||
id = "tab_label"
|
||||
label = _ "Campaign"
|
||||
[/widget]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_data]
|
||||
|
||||
[/horizontal_listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
grow_factor = 0
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[menu_button]
|
||||
id = "scenario_menu"
|
||||
definition = "default"
|
||||
[/menu_button]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
|
|
@ -30,24 +30,21 @@
|
|||
#include "gui/widgets/window.hpp"
|
||||
#include "team.hpp"
|
||||
#include "units/types.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
namespace dialogs
|
||||
{
|
||||
|
||||
static bool use_campaign = false;
|
||||
|
||||
REGISTER_DIALOG(statistics_dialog)
|
||||
|
||||
statistics_dialog::statistics_dialog(const team& current_team)
|
||||
: current_team_(current_team)
|
||||
, campaign_(statistics::calculate_stats(current_team.save_id_or_number()))
|
||||
, scenarios_(statistics::level_stats(current_team.save_id_or_number()))
|
||||
, scenario_index_(scenarios_.size() - 1)
|
||||
, selection_index_(scenarios_.size()) // The extra All Scenarios menu entry makes size() a valid initial index.
|
||||
, main_stat_table_()
|
||||
{
|
||||
set_restore(true);
|
||||
|
@ -65,24 +62,19 @@ void statistics_dialog::pre_show(window& window)
|
|||
// Set up scenario menu
|
||||
//
|
||||
std::vector<config> menu_items;
|
||||
|
||||
// Keep this first!
|
||||
menu_items.emplace_back("label", _("All Scenarios"));
|
||||
|
||||
for(const auto& scenario : scenarios_) {
|
||||
menu_items.emplace_back("label", *scenario.first);
|
||||
}
|
||||
|
||||
menu_button& scenario_menu = find_widget<menu_button>(&window, "scenario_menu", false);
|
||||
|
||||
scenario_menu.set_values(menu_items, scenario_index_);
|
||||
scenario_menu.set_values(menu_items, selection_index_);
|
||||
scenario_menu.connect_click_handler(std::bind(&statistics_dialog::on_scenario_select, this, std::ref(window)));
|
||||
|
||||
//
|
||||
// Set up tab toggle
|
||||
//
|
||||
listbox& tab_bar = find_widget<listbox>(&window, "tab_bar", false);
|
||||
tab_bar.select_row(use_campaign);
|
||||
|
||||
connect_signal_notify_modified(tab_bar,
|
||||
std::bind(&statistics_dialog::on_tab_select, this, std::ref(window)));
|
||||
|
||||
//
|
||||
// Set up primary stats list
|
||||
//
|
||||
|
@ -96,7 +88,7 @@ void statistics_dialog::pre_show(window& window)
|
|||
|
||||
inline const statistics::stats& statistics_dialog::current_stats()
|
||||
{
|
||||
return use_campaign ? campaign_ : *scenarios_[scenario_index_].second;
|
||||
return selection_index_ == 0 ? campaign_ : *scenarios_[selection_index_ - 1].second;
|
||||
}
|
||||
|
||||
void statistics_dialog::add_stat_row(window& window, const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost)
|
||||
|
@ -194,7 +186,7 @@ void statistics_dialog::update_lists(window& window)
|
|||
//
|
||||
// Update damage stats list
|
||||
//
|
||||
const bool show_this_turn = use_campaign || scenario_index_ + 1 == scenarios_.size();
|
||||
const bool show_this_turn = selection_index_ == scenarios_.size();
|
||||
|
||||
listbox& damage_list = find_widget<listbox>(&window, "stats_list_damage", false);
|
||||
|
||||
|
@ -217,24 +209,12 @@ void statistics_dialog::update_lists(window& window)
|
|||
);
|
||||
}
|
||||
|
||||
void statistics_dialog::on_tab_select(window& window)
|
||||
{
|
||||
const bool is_campaign_tab = find_widget<listbox>(&window, "tab_bar", false).get_selected_row() == 1;
|
||||
|
||||
if(use_campaign != is_campaign_tab) {
|
||||
use_campaign = is_campaign_tab;
|
||||
|
||||
update_lists(window);
|
||||
}
|
||||
}
|
||||
|
||||
void statistics_dialog::on_scenario_select(window& window)
|
||||
{
|
||||
const std::size_t new_index = find_widget<menu_button>(&window, "scenario_menu", false).get_value();
|
||||
|
||||
if(scenario_index_ != new_index) {
|
||||
scenario_index_ = new_index;
|
||||
|
||||
if(selection_index_ != new_index) {
|
||||
selection_index_ = new_index;
|
||||
update_lists(window);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
/**
|
||||
* Picks out the stats structure that was selected for displaying.
|
||||
*/
|
||||
inline const statistics::stats & current_stats();
|
||||
inline const statistics::stats& current_stats();
|
||||
|
||||
void add_stat_row(window& window, const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost = true);
|
||||
|
||||
|
@ -58,14 +58,13 @@ private:
|
|||
|
||||
void on_primary_list_select(window& window);
|
||||
void on_scenario_select(window& window);
|
||||
void on_tab_select(window& window);
|
||||
|
||||
const team& current_team_;
|
||||
|
||||
const statistics::stats campaign_;
|
||||
const statistics::levels scenarios_;
|
||||
|
||||
std::size_t scenario_index_;
|
||||
std::size_t selection_index_;
|
||||
|
||||
std::vector<const statistics::stats::str_int_map*> main_stat_table_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue