Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rsrc/dialogs/pick-scenario.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<button name='x' def-key='x' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>X</button>
<button name='y' def-key='y' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>Y</button>
<button name='z' def-key='z' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>Z</button>
<button name='#' def-key='shift 3' type='tiny' relative='neg pos-in' anchor='j' top='0' left='32'>#</button>

<button name='cancel' type='regular' top='330' left='5'>Cancel</button>
<button name='prev' type='left' def-key='left' relative='pos pos-in' rel-anchor='prev' top='0' left='14'/>
Expand Down
9 changes: 5 additions & 4 deletions src/fileio/fileio_scen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, eLoadScenario
return false;
}
port_item_list(&item_data);
scenario.import_legacy(temp_scenario);
scenario.import_legacy(item_data);
scenario.import_legacy(temp_scenario, load_type == eLoadScenario::ONLY_HEADER);
if(load_type == eLoadScenario::FULL){
scenario.ter_types[23].fly_over = false;
scenario.import_legacy(item_data);
}

// TODO: Consider skipping the fread and assignment when len is 0
scenario.special_items.resize(50);
Expand Down Expand Up @@ -295,8 +298,6 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, eLoadScenario

fclose(file_id);

scenario.ter_types[23].fly_over = false;

scenario.scen_file = file_to_load;
if(load_type == eLoadScenario::ONLY_HEADER) return true;
load_spec_graphics_v1(scenario.scen_file);
Expand Down
19 changes: 17 additions & 2 deletions src/game/boe.dlgutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,16 @@ class cChooseScenario {
for(auto& hdr : scen_headers){
// I just checked, and the scenario editor will let you name your scenario "" or " "!
std::string name = name_alphabetical(hdr.name);
if(!name.empty())
me[name.substr(0, 1)].show();
if(!name.empty()){
// Starts with a letter:
if(me.hasControl(name.substr(0, 1))){
me[name.substr(0, 1)].show();
}
// Starts with a digit:
else if(name[0] >= '0' && name[0] <= '9'){
me["#"].show();
}
}
}
}

Expand Down Expand Up @@ -1870,6 +1878,7 @@ class cChooseScenario {
stk.setPage(0);
return true;
});
// Letter buttons scroll to an alphabetical position:
for(int i = 0; i < 26; ++i){
std::string letter(1, (char)('a' + i));
me[letter].attachClickHandler([this](cDialog& me, std::string letter, eKeyMod) -> bool {
Expand All @@ -1883,6 +1892,12 @@ class cChooseScenario {
return true;
});
}
// Number button scrolls to scenarios that start with symbols or digits:
me["#"].attachClickHandler([this](cDialog& me, std::string letter, eKeyMod) -> bool {
auto& stk = dynamic_cast<cStack&>(me["list"]);
stk.setPage(1);
return true;
});

put_scen_info();

Expand Down
2 changes: 2 additions & 0 deletions src/game/boe.fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ std::string name_alphabetical(std::string a) {
// The scenario editor will let you prepend whitespace to a scenario name :(
boost::algorithm::trim_left(a);
std::transform(a.begin(), a.end(), a.begin(), tolower);
// Some party makers start with the name of the corresponding scenario in quotes
if(a.substr(0,1) == "\"") a.erase(a.begin(), a.begin() + 1);
if(a.substr(0,2) == "a ") a.erase(a.begin(), a.begin() + 2);
else if(a.substr(0,4) == "the ") a.erase(a.begin(), a.begin() + 4);
return a;
Expand Down
5 changes: 4 additions & 1 deletion src/scenario/scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ cScenario::cItemStorage::cItemStorage() : ter_type(-1), property(0) {
item_odds[i] = 0;
}

void cScenario::import_legacy(legacy::scenario_data_type& old){
void cScenario::import_legacy(legacy::scenario_data_type& old, bool header_only){
is_legacy = true;
// TODO eventually the absence of feature flags here will replace is_legacy altogether
feature_flags = {};
Expand Down Expand Up @@ -267,6 +267,9 @@ void cScenario::import_legacy(legacy::scenario_data_type& old){
rating = eContentRating(old.rating);
// TODO: Is this used anywhere?
uses_custom_graphics = old.uses_custom_graphics;

if(header_only) return;

boats.resize(30);
horses.resize(30);
for(short i = 0; i < 30; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/scenario/scenario.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class cScenario {
towns.back()->init_start();
}

void import_legacy(legacy::scenario_data_type& old);
void import_legacy(legacy::scenario_data_type& old, bool header_only = false);
void import_legacy(legacy::scen_item_data_type& old);
void writeTo(cTagFile& file) const;
void readFrom(const cTagFile& file);
Expand Down
Loading