made it so campaigns can customize what their difficulty levels look like
This commit is contained in:
parent
823048a9fe
commit
465f92065c
3 changed files with 21 additions and 4 deletions
|
@ -64,6 +64,7 @@
|
|||
name=Heir to the Throne
|
||||
first_scenario=The_Elves_Besieged
|
||||
difficulties=EASY,NORMAL,HARD
|
||||
difficulty_descriptions=&elvish-fighter.png,Fighter;*&elvish-hero.png,Hero;&elvish-champion.png,Champion
|
||||
[/campaign]
|
||||
|
||||
[campaign]
|
||||
|
|
11
src/game.cpp
11
src/game.cpp
|
@ -488,15 +488,20 @@ int play_game(int argc, char** argv)
|
|||
|
||||
state.scenario = campaign["first_scenario"];
|
||||
|
||||
const std::string difficulty_descriptions = translate_string_default(campaign["id"] + "_difficulties",campaign["difficulty_descriptions"]);
|
||||
std::vector<std::string> difficulty_options = config::split(difficulty_descriptions,';');
|
||||
|
||||
const std::vector<std::string> difficulties = config::split(campaign["difficulties"]);
|
||||
|
||||
if(difficulties.empty() == false) {
|
||||
std::vector<std::string> options(difficulties.size());
|
||||
std::transform(difficulties.begin(),difficulties.end(),options.begin(),translate_string);
|
||||
if(difficulty_options.size() != difficulties.size()) {
|
||||
difficulty_options.resize(difficulties.size());
|
||||
std::transform(difficulties.begin(),difficulties.end(),difficulty_options.begin(),translate_string);
|
||||
}
|
||||
|
||||
const int res = gui::show_dialog(disp,NULL,"",
|
||||
string_table["difficulty_level"],
|
||||
gui::OK_CANCEL,&options);
|
||||
gui::OK_CANCEL,&difficulty_options);
|
||||
if(res == -1)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -35,7 +35,18 @@ void process_config(const std::string& element_name, const config& cfg,
|
|||
const map<string,string>& table = cfg.values;
|
||||
const map<string,string>::const_iterator id = table.find("id");
|
||||
|
||||
if(element_name == "message") {
|
||||
if(element_name == "campaign") {
|
||||
const map<string,string>::const_iterator name = table.find("name");
|
||||
const map<string,string>::const_iterator diff = table.find("difficulty_descriptions");
|
||||
if(name != table.end()) {
|
||||
out.insert(std::pair<string,string>(id->second,name->second));
|
||||
}
|
||||
|
||||
if(diff != table.end()) {
|
||||
out.insert(std::pair<string,string>(id->second + "_difficulties",diff->second));
|
||||
}
|
||||
}
|
||||
else if(element_name == "message") {
|
||||
const map<string,string>::const_iterator msg = table.find("message");
|
||||
|
||||
if(id == table.end()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue