Scenario editor can launch unpacked scenario
This commit is contained in:
@@ -28,7 +28,7 @@ enum class eLoadScenario {
|
||||
FULL
|
||||
};
|
||||
std::vector<fs::path> all_scen_dirs();
|
||||
fs::path locate_scenario(std::string scen_name);
|
||||
fs::path locate_scenario(std::string scen_name, bool allow_unpacked = false);
|
||||
bool load_scenario(fs::path file_to_load, cScenario& scenario, eLoadScenario load_type = eLoadScenario::FULL);
|
||||
|
||||
fs::path nav_get_or_decode_party();
|
||||
|
@@ -88,7 +88,7 @@ std::vector<fs::path> all_scen_dirs() {
|
||||
return scen_dirs;
|
||||
}
|
||||
|
||||
fs::path locate_scenario(std::string scen_name) {
|
||||
fs::path locate_scenario(std::string scen_name, bool allow_unpacked) {
|
||||
fs::create_directories(scenDir);
|
||||
std::transform(scen_name.begin(), scen_name.end(), scen_name.begin(), tolower);
|
||||
size_t dot = scen_name.find_first_of('.');
|
||||
@@ -103,15 +103,18 @@ fs::path locate_scenario(std::string scen_name) {
|
||||
std::string fname = iter->path().filename().string().c_str();
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
if(fname == "header.exs") {
|
||||
if(scen_name != "header.exs") continue;
|
||||
// We want to support a scenario whose main filename is header.exs, just in case.
|
||||
// However, any unpacked scenarios would have a header.exs.
|
||||
// So, skip them if they're in a .boes folder.
|
||||
fname = iter->path().parent_path().filename().string().c_str();
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
size_t dot = fname.find_first_of('.');
|
||||
if(dot != std::string::npos && fname.substr(dot) == ".boes")
|
||||
if(scen_name != "header.exs"){
|
||||
// We want to support a scenario whose main filename is header.exs, just in case.
|
||||
// However, any unpacked scenarios would have a header.exs.
|
||||
// So, skip them if they're in a .boes folder.
|
||||
fname = iter->path().parent_path().filename().string().c_str();
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
size_t dot = fname.find_first_of('.');
|
||||
if(dot != std::string::npos && fname.substr(dot) == ".boes")
|
||||
continue;
|
||||
}else if(!allow_unpacked){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(fname != scen_name) continue;
|
||||
size_t dot = fname.find_first_of('.');
|
||||
|
@@ -26,7 +26,6 @@ void end_data_dump();
|
||||
short onm(char x_sector,char y_sector);
|
||||
std::vector<scen_header_type> build_scen_headers();
|
||||
bool load_scenario_header(fs::path filename,scen_header_type& header_entry);
|
||||
fs::path locate_scenario(std::string scen_name);
|
||||
|
||||
void alter_rect(rectangle *r);
|
||||
|
||||
|
@@ -442,7 +442,7 @@ static void handle_scenario_args() {
|
||||
// Add the scenario's path to the search paths put_party_in_scen() uses
|
||||
extra_scen_dirs.push_back(path.parent_path());
|
||||
}else{
|
||||
path = locate_scenario(*scen_arg_path);
|
||||
path = locate_scenario(*scen_arg_path, true);
|
||||
}
|
||||
|
||||
cScenario scenario;
|
||||
@@ -467,7 +467,7 @@ static void handle_scenario_args() {
|
||||
resetting = true;
|
||||
}
|
||||
if(!univ.party.is_in_scenario()){
|
||||
put_party_in_scen(path.filename().string(), scen_arg_town || scen_arg_out_sec);
|
||||
put_party_in_scen(path.filename().string(), scen_arg_town || scen_arg_out_sec, true);
|
||||
}
|
||||
}else{
|
||||
std::cerr << "Failed to load scenario: " << *scen_arg_path << std::endl;
|
||||
|
@@ -107,7 +107,7 @@ short store_pc_graphic;
|
||||
// When the party is placed into a scen from the starting screen, this is called to put the game into game
|
||||
// mode and load in the scen and init the party info
|
||||
// party record already contains scen name
|
||||
void put_party_in_scen(std::string scen_name, bool force) {
|
||||
void put_party_in_scen(std::string scen_name, bool force, bool allow_unpacked) {
|
||||
bool item_took = false;
|
||||
|
||||
// Drop debug mode
|
||||
@@ -142,7 +142,7 @@ void put_party_in_scen(std::string scen_name, bool force) {
|
||||
if(item_took)
|
||||
cChoiceDlog("removed-special-items").show();
|
||||
|
||||
fs::path path = locate_scenario(scen_name);
|
||||
fs::path path = locate_scenario(scen_name, allow_unpacked);
|
||||
if(path.empty()) {
|
||||
showError("Could not find scenario!");
|
||||
return;
|
||||
|
@@ -47,7 +47,7 @@ short trait_present(eTrait which_trait);
|
||||
short race_present(eRace which_race);
|
||||
short wilderness_lore_present(ter_num_t ter);
|
||||
void print_spell_cast(eSpell spell,eSkill which);
|
||||
void put_party_in_scen(std::string scen_name, bool force = false);
|
||||
void put_party_in_scen(std::string scen_name, bool force = false, bool allow_unpacked = false);
|
||||
short party_size(bool only_living);
|
||||
bool all_items_identified();
|
||||
|
||||
|
@@ -104,11 +104,6 @@ extern std::string last_load_file;
|
||||
enum class eLaunchType {LOC,START,ENTRANCE};
|
||||
|
||||
static void launch_scenario(eLaunchType type) {
|
||||
if(boost::ends_with(last_load_file, ".exs")){
|
||||
showError("The scenario editor cannot launch an unpacked scenario directly. You'll need to re-open the scenario from its .boes archive.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure scenario is loaded and currently editing the terrain of a town or outdoor section
|
||||
if(type == eLaunchType::LOC){
|
||||
if(overall_mode >= MODE_MAIN_SCREEN){
|
||||
|
Reference in New Issue
Block a user