Started showing on which difficulty levels a campaign was completed
This commit is contained in:
parent
3a813016f9
commit
b21dd2dce1
11 changed files with 121 additions and 37 deletions
|
@ -3,6 +3,8 @@ Version 1.13.0+dev:
|
||||||
* New generic portrait for the Walking Corpse and Soulless
|
* New generic portrait for the Walking Corpse and Soulless
|
||||||
* Language and i18n:
|
* Language and i18n:
|
||||||
* Updated translations:
|
* Updated translations:
|
||||||
|
* User interface:
|
||||||
|
* Started showing on which difficulty levels a campaign was completed.
|
||||||
|
|
||||||
Version 1.13.0:
|
Version 1.13.0:
|
||||||
* Security fixes:
|
* Security fixes:
|
||||||
|
|
|
@ -114,11 +114,42 @@
|
||||||
horizontal_alignment = "left"
|
horizontal_alignment = "left"
|
||||||
border = "all"
|
border = "all"
|
||||||
border_size = 5
|
border_size = 5
|
||||||
[image]
|
[stacked_widget]
|
||||||
id = "icon"
|
id = ""
|
||||||
definition = "default"
|
definition = "default"
|
||||||
linked_group = "icon"
|
linked_group = "icon"
|
||||||
[/image]
|
[stack]
|
||||||
|
[layer]
|
||||||
|
[row]
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
border = "left"
|
||||||
|
border_size = 3
|
||||||
|
[image]
|
||||||
|
id = "victory"
|
||||||
|
definition = "default"
|
||||||
|
label = "misc/laurel.png"
|
||||||
|
[/image]
|
||||||
|
[/column]
|
||||||
|
[/row]
|
||||||
|
[/layer]
|
||||||
|
[layer]
|
||||||
|
[row]
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
border = "left"
|
||||||
|
border_size = 3
|
||||||
|
[image]
|
||||||
|
id = "icon"
|
||||||
|
definition = "default"
|
||||||
|
[/image]
|
||||||
|
[/column]
|
||||||
|
[/row]
|
||||||
|
[/layer]
|
||||||
|
[/stack]
|
||||||
|
[/stacked_widget]
|
||||||
[/column]
|
[/column]
|
||||||
[column]
|
[column]
|
||||||
grow_factor = 1
|
grow_factor = 1
|
||||||
|
|
|
@ -9,6 +9,9 @@ Version 1.13.0+dev:
|
||||||
* Language and i18n:
|
* Language and i18n:
|
||||||
* Updated translations:
|
* Updated translations:
|
||||||
|
|
||||||
|
* User interface:
|
||||||
|
* Started showing on which difficulty levels a campaign was completed.
|
||||||
|
|
||||||
|
|
||||||
Version 1.13.0:
|
Version 1.13.0:
|
||||||
* Security fixes:
|
* Security fixes:
|
||||||
|
|
|
@ -585,10 +585,6 @@ void create_engine::prepare_for_campaign(const std::string& difficulty)
|
||||||
*/
|
*/
|
||||||
std::string create_engine::select_campaign_difficulty(int set_value)
|
std::string create_engine::select_campaign_difficulty(int set_value)
|
||||||
{
|
{
|
||||||
const std::string difficulty_descriptions =
|
|
||||||
current_level().data()["difficulty_descriptions"];
|
|
||||||
std::vector<std::string> difficulty_options =
|
|
||||||
utils::split(difficulty_descriptions, ';');
|
|
||||||
const std::vector<std::string> difficulties =
|
const std::vector<std::string> difficulties =
|
||||||
utils::split(current_level().data()["difficulties"]);
|
utils::split(current_level().data()["difficulties"]);
|
||||||
|
|
||||||
|
@ -619,9 +615,16 @@ std::string create_engine::select_campaign_difficulty(int set_value)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(difficulty_options.size() != difficulties.size())
|
std::string campaign_id = current_level().data()["id"];
|
||||||
|
std::vector<std::string> difficulty_opts =
|
||||||
|
utils::split(current_level().data()["difficulty_descriptions"], ';');
|
||||||
|
if(difficulty_opts.size() != difficulties.size())
|
||||||
{
|
{
|
||||||
difficulty_options = difficulties;
|
difficulty_opts = difficulties;
|
||||||
|
}
|
||||||
|
std::vector<std::pair<std::string, bool> > difficulty_options;
|
||||||
|
for (size_t i = 0; i < difficulties.size(); i++) {
|
||||||
|
difficulty_options.push_back(make_pair(difficulty_opts[i], preferences::is_campaign_completed(campaign_id, difficulties[i])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show gui
|
// show gui
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ void game_launcher::launch_game(RELOAD_GAME_DATA reload)
|
||||||
// don't show The End for multiplayer scenario
|
// don't show The End for multiplayer scenario
|
||||||
// change this if MP campaigns are implemented
|
// change this if MP campaigns are implemented
|
||||||
if(result == VICTORY && state_.classification().campaign_type != game_classification::MULTIPLAYER) {
|
if(result == VICTORY && state_.classification().campaign_type != game_classification::MULTIPLAYER) {
|
||||||
preferences::add_completed_campaign(state_.classification().campaign);
|
preferences::add_completed_campaign(state_.classification().campaign, state_.classification().difficulty);
|
||||||
the_end(disp(), state_.classification().end_text, state_.classification().end_text_duration);
|
the_end(disp(), state_.classification().end_text, state_.classification().end_text_duration);
|
||||||
if(state_.classification().end_credits) {
|
if(state_.classification().end_credits) {
|
||||||
about::show_about(disp(),state_.classification().campaign);
|
about::show_about(disp(),state_.classification().campaign);
|
||||||
|
|
|
@ -56,6 +56,7 @@ bool message_private_on = false;
|
||||||
|
|
||||||
bool haloes = true;
|
bool haloes = true;
|
||||||
|
|
||||||
|
std::map<std::string, std::set<std::string> > completed_campaigns;
|
||||||
std::set<std::string> encountered_units_set;
|
std::set<std::string> encountered_units_set;
|
||||||
std::set<t_translation::t_terrain> encountered_terrains_set;
|
std::set<t_translation::t_terrain> encountered_terrains_set;
|
||||||
|
|
||||||
|
@ -120,6 +121,26 @@ manager::manager() :
|
||||||
preferences::erase("mp_countdown_action_bonus");
|
preferences::erase("mp_countdown_action_bonus");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
completed_campaigns = "A,B,C"
|
||||||
|
[completed_campaigns]
|
||||||
|
[campaign]
|
||||||
|
name = "A"
|
||||||
|
difficulty_levels = "EASY,MEDIUM"
|
||||||
|
[/campaign]
|
||||||
|
[/completed_campaigns]
|
||||||
|
*/
|
||||||
|
BOOST_FOREACH(const std::string &c, utils::split(preferences::get("completed_campaigns"))) {
|
||||||
|
completed_campaigns[c]; // create the elements
|
||||||
|
}
|
||||||
|
if (const config &ccc = preferences::get_child("completed_campaigns")) {
|
||||||
|
BOOST_FOREACH(const config &cc, ccc.child_range("campaign")) {
|
||||||
|
std::set<std::string> &d = completed_campaigns[cc["name"]];
|
||||||
|
std::vector<std::string> nd = utils::split(cc["difficulty_levels"]);
|
||||||
|
std::copy(nd.begin(), nd.end(), std::inserter(d, d.begin()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<std::string> v (utils::split(preferences::get("encountered_units")));
|
const std::vector<std::string> v (utils::split(preferences::get("encountered_units")));
|
||||||
encountered_units_set.insert(v.begin(), v.end());
|
encountered_units_set.insert(v.begin(), v.end());
|
||||||
|
|
||||||
|
@ -148,6 +169,15 @@ manager::manager() :
|
||||||
|
|
||||||
manager::~manager()
|
manager::~manager()
|
||||||
{
|
{
|
||||||
|
config campaigns;
|
||||||
|
typedef const std::pair<std::string, std::set<std::string> > cc_elem;
|
||||||
|
BOOST_FOREACH(cc_elem &elem, completed_campaigns) {
|
||||||
|
config cmp;
|
||||||
|
cmp["name"] = elem.first;
|
||||||
|
cmp["difficulty_levels"] = utils::join(elem.second);
|
||||||
|
campaigns.add_child("campaign", cmp);
|
||||||
|
}
|
||||||
|
preferences::set_child("completed_campaigns", campaigns);
|
||||||
std::vector<std::string> v (encountered_units_set.begin(), encountered_units_set.end());
|
std::vector<std::string> v (encountered_units_set.begin(), encountered_units_set.end());
|
||||||
preferences::set("encountered_units", utils::join(v));
|
preferences::set("encountered_units", utils::join(v));
|
||||||
t_translation::t_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end());
|
t_translation::t_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end());
|
||||||
|
@ -295,20 +325,17 @@ bool is_ignored(const std::string& nick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_completed_campaign(const std::string& campaign_id) {
|
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level) {
|
||||||
std::vector<std::string> completed = utils::split(preferences::get("completed_campaigns"));
|
completed_campaigns[campaign_id].insert(difficulty_level);
|
||||||
|
|
||||||
if(std::find(completed.begin(), completed.end(), campaign_id) != completed.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
completed.push_back(campaign_id);
|
|
||||||
preferences::set("completed_campaigns", utils::join(completed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_campaign_completed(const std::string& campaign_id) {
|
bool is_campaign_completed(const std::string& campaign_id) {
|
||||||
std::vector<std::string> completed = utils::split(preferences::get("completed_campaigns"));
|
return completed_campaigns.count(campaign_id) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
return std::find(completed.begin(), completed.end(), campaign_id) != completed.end();
|
bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level) {
|
||||||
|
std::map<std::string, std::set<std::string> >::iterator it = completed_campaigns.find(campaign_id);
|
||||||
|
return it == completed_campaigns.end() ? false : it->second.count(difficulty_level) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
|
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
|
||||||
|
|
|
@ -53,11 +53,12 @@ class acquaintance;
|
||||||
std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
|
std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
|
||||||
bool add_friend(const std::string& nick, const std::string& notes);
|
bool add_friend(const std::string& nick, const std::string& notes);
|
||||||
bool add_ignore(const std::string& nick, const std::string& reason);
|
bool add_ignore(const std::string& nick, const std::string& reason);
|
||||||
void add_completed_campaign(const std::string& campaign_id);
|
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level);
|
||||||
void remove_acquaintance(const std::string& nick);
|
void remove_acquaintance(const std::string& nick);
|
||||||
bool is_friend(const std::string& nick);
|
bool is_friend(const std::string& nick);
|
||||||
bool is_ignored(const std::string& nick);
|
bool is_ignored(const std::string& nick);
|
||||||
bool is_campaign_completed(const std::string& campaign_id);
|
bool is_campaign_completed(const std::string& campaign_id);
|
||||||
|
bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level);
|
||||||
|
|
||||||
const std::vector<game_config::server_info>& server_list();
|
const std::vector<game_config::server_info>& server_list();
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ namespace gui2
|
||||||
REGISTER_DIALOG(campaign_difficulty)
|
REGISTER_DIALOG(campaign_difficulty)
|
||||||
|
|
||||||
tcampaign_difficulty::tcampaign_difficulty(
|
tcampaign_difficulty::tcampaign_difficulty(
|
||||||
const std::vector<std::string>& items)
|
const std::vector<std::pair<std::string, bool> >& items)
|
||||||
: index_(-1), items_()
|
: index_(-1), items_()
|
||||||
{
|
{
|
||||||
FOREACH(const AUTO & it, items)
|
FOREACH(const AUTO & p, items)
|
||||||
{
|
{
|
||||||
items_.push_back(tlegacy_menu_item(it));
|
items_.push_back(std::make_pair(tlegacy_menu_item(p.first), p.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,17 +83,25 @@ void tcampaign_difficulty::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
|
||||||
FOREACH(const AUTO & item, items_)
|
FOREACH(const AUTO & item, items_)
|
||||||
{
|
{
|
||||||
if(item.is_default()) {
|
if(item.first.is_default()) {
|
||||||
index_ = list.get_item_count();
|
index_ = list.get_item_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
data["icon"]["label"] = item.icon();
|
data["icon"]["label"] = item.first.icon();
|
||||||
data["label"]["label"] = item.label();
|
data["label"]["label"] = item.first.label();
|
||||||
data["label"]["use_markup"] = "true";
|
data["label"]["use_markup"] = "true";
|
||||||
data["description"]["label"] = item.description();
|
data["description"]["label"] = item.first.description();
|
||||||
data["description"]["use_markup"] = "true";
|
data["description"]["use_markup"] = "true";
|
||||||
|
|
||||||
list.add_row(data);
|
list.add_row(data);
|
||||||
|
|
||||||
|
tgrid* grid = list.get_row_grid(list.get_item_count() - 1);
|
||||||
|
assert(grid);
|
||||||
|
|
||||||
|
twidget *widget = grid->find("victory", false);
|
||||||
|
if (widget && !item.second) {
|
||||||
|
widget->set_visible(twidget::tvisible::hidden);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index_ != -1) {
|
if(index_ != -1) {
|
||||||
|
|
|
@ -26,7 +26,10 @@ namespace gui2
|
||||||
class tcampaign_difficulty : public tdialog
|
class tcampaign_difficulty : public tdialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit tcampaign_difficulty(const std::vector<std::string>& items);
|
/**
|
||||||
|
* @param items vector of (difficulty description, already completed) pairs
|
||||||
|
*/
|
||||||
|
explicit tcampaign_difficulty(const std::vector<std::pair<std::string, bool> >& items);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the selected item index after displaying.
|
* Returns the selected item index after displaying.
|
||||||
|
@ -39,7 +42,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int index_;
|
int index_;
|
||||||
std::vector<tlegacy_menu_item> items_;
|
std::vector<std::pair<tlegacy_menu_item, bool> > items_;
|
||||||
|
|
||||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||||
virtual const std::string& window_id() const;
|
virtual const std::string& window_id() const;
|
||||||
|
|
|
@ -131,20 +131,26 @@ void loadgame::show_difficulty_dialog()
|
||||||
|| (!cfg_summary["turn"].empty()) )
|
|| (!cfg_summary["turn"].empty()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::string campaign_id = cfg_summary["campaign"];
|
||||||
const config::const_child_itors &campaigns = game_config_.child_range("campaign");
|
const config::const_child_itors &campaigns = game_config_.child_range("campaign");
|
||||||
std::vector<std::string> difficulty_descriptions;
|
|
||||||
std::vector<std::string> difficulties;
|
std::vector<std::string> difficulties;
|
||||||
|
std::vector<std::pair<std::string, bool> > difficulty_options;
|
||||||
BOOST_FOREACH(const config &campaign, campaigns)
|
BOOST_FOREACH(const config &campaign, campaigns)
|
||||||
{
|
{
|
||||||
if (campaign["id"] == cfg_summary["campaign"]) {
|
if (campaign["id"] == campaign_id) {
|
||||||
difficulty_descriptions = utils::split(campaign["difficulty_descriptions"], ';');
|
|
||||||
difficulties = utils::split(campaign["difficulties"], ',');
|
difficulties = utils::split(campaign["difficulties"], ',');
|
||||||
|
std::vector<std::string> difficulty_opts = utils::split(campaign["difficulty_descriptions"], ';');
|
||||||
|
if (difficulty_opts.size() != difficulties.size()) {
|
||||||
|
difficulty_opts = difficulties;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < difficulties.size(); i++) {
|
||||||
|
difficulty_options.push_back(make_pair(difficulty_opts[i], preferences::is_campaign_completed(campaign_id, difficulties[i])));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (difficulty_descriptions.empty())
|
if (difficulty_options.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -157,7 +163,7 @@ void loadgame::show_difficulty_dialog()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gui2::tcampaign_difficulty difficulty_dlg(difficulty_descriptions);
|
gui2::tcampaign_difficulty difficulty_dlg(difficulty_options);
|
||||||
difficulty_dlg.show(gui_.video());
|
difficulty_dlg.show(gui_.video());
|
||||||
|
|
||||||
if (difficulty_dlg.get_retval() != gui2::twindow::OK) {
|
if (difficulty_dlg.get_retval() != gui2::twindow::OK) {
|
||||||
|
|
|
@ -517,7 +517,7 @@ struct twrapper<gui2::tcampaign_difficulty>
|
||||||
{
|
{
|
||||||
static gui2::tcampaign_difficulty* create()
|
static gui2::tcampaign_difficulty* create()
|
||||||
{
|
{
|
||||||
static std::vector<std::string> items;
|
static std::vector<std::pair<std::string, bool> > items;
|
||||||
|
|
||||||
return new gui2::tcampaign_difficulty(items);
|
return new gui2::tcampaign_difficulty(items);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue