Allow create new or load party after selecting scenario
This commit is contained in:
@@ -65,6 +65,8 @@ extern cCustomGraphics spec_scen_g;
|
|||||||
extern std::map<eSkill,short> skill_max;
|
extern std::map<eSkill,short> skill_max;
|
||||||
extern void give_help_and_record(short help1, short help2, bool help_forced = false);
|
extern void give_help_and_record(short help1, short help2, bool help_forced = false);
|
||||||
extern void post_load();
|
extern void post_load();
|
||||||
|
extern void start_new_game(bool force = false);
|
||||||
|
extern void do_load();
|
||||||
|
|
||||||
short sign_mode,person_graphic,store_person_graphic,store_sign_mode;
|
short sign_mode,person_graphic,store_person_graphic,store_sign_mode;
|
||||||
long num_talk_entries;
|
long num_talk_entries;
|
||||||
@@ -1815,6 +1817,7 @@ class cChooseScenario {
|
|||||||
|
|
||||||
bool doSelectScenario(int which) {
|
bool doSelectScenario(int which) {
|
||||||
int page = dynamic_cast<cStack&>(me["list"]).getPage();
|
int page = dynamic_cast<cStack&>(me["list"]).getPage();
|
||||||
|
scen_header_type scen;
|
||||||
if(page == 0) {
|
if(page == 0) {
|
||||||
scen_header_type prefab;
|
scen_header_type prefab;
|
||||||
switch(which) {
|
switch(which) {
|
||||||
@@ -1827,56 +1830,75 @@ class cChooseScenario {
|
|||||||
prefab.prog_make_ver[0] = 2;
|
prefab.prog_make_ver[0] = 2;
|
||||||
prefab.prog_make_ver[1] = 0;
|
prefab.prog_make_ver[1] = 0;
|
||||||
prefab.prog_make_ver[2] = 0;
|
prefab.prog_make_ver[2] = 0;
|
||||||
me.setResult<scen_header_type>(prefab);
|
scen = prefab;
|
||||||
me.toast(true);
|
|
||||||
} else {
|
} else {
|
||||||
int scen_hit = which + (page - 1) * 3;
|
int scen_hit = which + (page - 1) * 3;
|
||||||
if(scen_hit >= scen_headers.size()) return false;
|
if(scen_hit >= scen_headers.size()) return false;
|
||||||
|
scen = scen_headers[scen_hit];
|
||||||
// Show text files, Offer to load prefab party
|
}
|
||||||
auto scen = scen_headers[scen_hit];
|
std::vector<std::string> choices;
|
||||||
std::vector<fs::path> files = extra_files(locate_scenario(scen.file));
|
std::vector<std::function<void(cButtonPanel&)>> handlers;
|
||||||
if(!files.empty()){
|
// If no party is loaded, offer to load default or create new
|
||||||
std::vector<std::string> choices;
|
if(!party_in_memory){
|
||||||
std::vector<std::function<void(cButtonPanel&)>> handlers;
|
choices.push_back("Create new party");
|
||||||
|
handlers.push_back([](cButtonPanel& dlg) -> void {
|
||||||
for(fs::path file : files){
|
start_new_game();
|
||||||
std::string ext = file.extension().string();
|
if(party_in_memory){
|
||||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
dlg->getControl("done").show();
|
||||||
if(ext == ".sav"){
|
|
||||||
choices.push_back("Load premade party: " + file.filename().string());
|
|
||||||
handlers.push_back([file](cButtonPanel&) -> void {
|
|
||||||
if(!load_party(file, univ, spec_scen_g)) {
|
|
||||||
std::cout << "Failed to load save file: " << file << std::endl;
|
|
||||||
}else{
|
|
||||||
finish_load_party();
|
|
||||||
if(overall_mode != MODE_STARTUP)
|
|
||||||
post_load();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
choices.push_back("Open file: " + file.filename().string());
|
|
||||||
handlers.push_back([file](cButtonPanel&) -> void {
|
|
||||||
launchURL("file://" + file.string());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
choices.push_back("Load a party");
|
||||||
|
handlers.push_back([](cButtonPanel& dlg) -> void {
|
||||||
|
do_load();
|
||||||
|
if(party_in_memory){
|
||||||
|
dlg->getControl("done").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
cButtonPanel panel(choices, handlers, scen.name, "Launch", &me);
|
// Show text files, Offer to load prefab party
|
||||||
dynamic_cast<cPict&>(panel->getControl("pic")).setPict(scen.intro_pic,PIC_SCEN);
|
std::vector<fs::path> files = extra_files(locate_scenario(scen.file));
|
||||||
if(panel.show()){
|
for(fs::path file : files){
|
||||||
// Launch pressed.
|
std::string ext = file.extension().string();
|
||||||
me.setResult<scen_header_type>(scen);
|
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
||||||
me.toast(true);
|
if(ext == ".sav"){
|
||||||
};
|
choices.push_back("Load premade party: " + file.filename().string());
|
||||||
|
handlers.push_back([file](cButtonPanel& dlg) -> void {
|
||||||
|
if(!load_party(file, univ, spec_scen_g)) {
|
||||||
|
std::cout << "Failed to load save file: " << file << std::endl;
|
||||||
|
}else{
|
||||||
|
finish_load_party();
|
||||||
|
if(overall_mode != MODE_STARTUP)
|
||||||
|
post_load();
|
||||||
|
dlg->getControl("done").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
choices.push_back("Open file: " + file.filename().string());
|
||||||
|
handlers.push_back([file](cButtonPanel&) -> void {
|
||||||
|
launchURL("file://" + file.string());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// No extra files. Just launch
|
}
|
||||||
else{
|
|
||||||
|
if(!choices.empty()){
|
||||||
|
cButtonPanel panel(choices, handlers, scen.name, "Launch", &me);
|
||||||
|
if(!party_in_memory){
|
||||||
|
panel->getControl("done").hide();
|
||||||
|
}
|
||||||
|
dynamic_cast<cPict&>(panel->getControl("pic")).setPict(scen.intro_pic,PIC_SCEN);
|
||||||
|
if(panel.show()){
|
||||||
|
// Launch pressed.
|
||||||
me.setResult<scen_header_type>(scen);
|
me.setResult<scen_header_type>(scen);
|
||||||
me.toast(true);
|
me.toast(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// No extra files. Just launch
|
||||||
|
else{
|
||||||
|
me.setResult<scen_header_type>(scen);
|
||||||
|
me.toast(true);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,9 +91,6 @@ void handle_startup_button_click(eStartButton btn, eKeyMod mods) {
|
|||||||
|
|
||||||
force_party = true;
|
force_party = true;
|
||||||
start_new_game(true);
|
start_new_game(true);
|
||||||
} else {
|
|
||||||
cChoiceDlog("need-party").show();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user