basic support for meta scenario tags
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog escbtn='cancel'>
|
||||
<text size='large' top='9' left='130' width='126' height='17'>Start a Scenario:</text>
|
||||
<text top='9' left='240' width='190' height='40' name='tooltip'></text>
|
||||
<stack name='list'>
|
||||
<page>
|
||||
<!-- Prefab scenarios -->
|
||||
@@ -35,15 +36,33 @@
|
||||
<page default='true' template='scenarios'>
|
||||
<!-- Custom scenarios -->
|
||||
<pict type='dlog' num='16' top='10' left='10'/>
|
||||
|
||||
<pict name='pic1' type='scen' num='0' top='58' left='62'/>
|
||||
<text name='desc1' framed='true' top='34' left='104' width='292' height='80'/>
|
||||
<text outline='double' name='start1' top='32' left='59' width='342' height='84'/>
|
||||
<pict name='tag1-1' type='item' size='small' num='0' top='95' left='110'/>
|
||||
<pict name='tag1-2' type='item' size='small' num='0' top='95' left='134'/>
|
||||
<pict name='tag1-3' type='item' size='small' num='0' top='95' left='158'/>
|
||||
<pict name='tag1-4' type='item' size='small' num='0' top='95' left='182'/>
|
||||
<pict name='tag1-5' type='item' size='small' num='0' top='95' left='206'/>
|
||||
|
||||
<pict name='pic2' type='scen' num='0' top='145' left='62'/>
|
||||
<text name='desc2' framed='true' top='121' left='104' width='292' height='80'/>
|
||||
<text outline='double' name='start2' top='118' left='59' width='342' height='84'/>
|
||||
<pict name='tag2-1' type='item' size='small' num='0' top='181' left='110'/>
|
||||
<pict name='tag2-2' type='item' size='small' num='0' top='181' left='134'/>
|
||||
<pict name='tag2-3' type='item' size='small' num='0' top='181' left='158'/>
|
||||
<pict name='tag2-4' type='item' size='small' num='0' top='181' left='182'/>
|
||||
<pict name='tag2-5' type='item' size='small' num='0' top='181' left='206'/>
|
||||
|
||||
<pict name='pic3' type='scen' num='0' top='232' left='62'/>
|
||||
<text name='desc3' framed='true' top='208' left='104' width='292' height='80'/>
|
||||
<text outline='double' name='start3' top='205' left='59' width='342' height='84'/>
|
||||
<pict name='tag3-1' type='item' size='small' num='0' top='268' left='110'/>
|
||||
<pict name='tag3-2' type='item' size='small' num='0' top='268' left='134'/>
|
||||
<pict name='tag3-3' type='item' size='small' num='0' top='268' left='158'/>
|
||||
<pict name='tag3-4' type='item' size='small' num='0' top='268' left='182'/>
|
||||
<pict name='tag3-5' type='item' size='small' num='0' top='268' left='206'/>
|
||||
</page>
|
||||
</stack>
|
||||
|
||||
|
@@ -1756,6 +1756,7 @@ class cChooseScenario {
|
||||
cDialog me{*ResMgr::dialogs.get("pick-scenario")};
|
||||
std::vector<scen_header_type> scen_headers;
|
||||
void put_scen_info() {
|
||||
me.setTooltipControl("tooltip");
|
||||
std::ostringstream sout;
|
||||
static const char *difficulty[] = {"Low","Medium","High","Very High"};
|
||||
auto& stk = dynamic_cast<cStack&>(me["list"]);
|
||||
@@ -1784,10 +1785,32 @@ class cChooseScenario {
|
||||
);
|
||||
me["desc" + n].setText(description);
|
||||
me["start" + n].show();
|
||||
|
||||
int j = 1;
|
||||
for(auto pair : header.meta_flags){
|
||||
cPict& flagPic = dynamic_cast<cPict&>(me["tag" + n + "-" + std::to_string(j)]);
|
||||
if(pair.first == "compatibility"){
|
||||
if(pair.second == "good"){
|
||||
flagPic.setPict(71); // flowers
|
||||
flagPic.setTooltipText("OpenBoE is known to be compatible with this scenario!");
|
||||
}
|
||||
}
|
||||
flagPic.recalcRect();
|
||||
++j;
|
||||
}
|
||||
for(; j <= 5; ++j){
|
||||
me["tag" + n + "-" + std::to_string(j)].hide();
|
||||
}
|
||||
|
||||
} else {
|
||||
me["pic" + n].hide();
|
||||
me["desc" + n].setText("");
|
||||
me["start" + n].hide();
|
||||
me["tag" + n + "-1"].hide();
|
||||
me["tag" + n + "-2"].hide();
|
||||
me["tag" + n + "-3"].hide();
|
||||
me["tag" + n + "-4"].hide();
|
||||
me["tag" + n + "-5"].hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -427,6 +427,7 @@ std::vector<scen_header_type> build_scen_headers() {
|
||||
// This is only called at startup, when bringing headers of active scenarios.
|
||||
bool load_scenario_header(fs::path file,scen_header_type& scen_head){
|
||||
bool file_ok = false;
|
||||
scen_head.meta_flags.clear();
|
||||
|
||||
std::string fname = file.filename().string();
|
||||
int dot = fname.find_first_of('.');
|
||||
@@ -495,6 +496,21 @@ bool load_scenario_header(fs::path file,scen_header_type& scen_head){
|
||||
std::copy(temp_scenario.format.ver, temp_scenario.format.ver + 3, scen_head.ver);
|
||||
std::copy(temp_scenario.format.prog_make_ver, temp_scenario.format.prog_make_ver + 3, scen_head.prog_make_ver);
|
||||
|
||||
if(fs::exists(file.parent_path() / "meta.xml")){
|
||||
ticpp::Document meta_doc;
|
||||
meta_doc.LoadFile((file.parent_path() / "meta.xml").string());
|
||||
|
||||
// Look for flags in the meta
|
||||
Element* next_child = meta_doc.FirstChildElement()->FirstChildElement(false);
|
||||
while(next_child){
|
||||
if(next_child->Value() == "flags"){
|
||||
scen_head.meta_flags = info_from_action(*next_child);
|
||||
break;
|
||||
}
|
||||
next_child = next_child->NextSiblingElement(false);
|
||||
}
|
||||
}
|
||||
|
||||
fname = fname.substr(0,dot);
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
|
||||
|
@@ -26,6 +26,7 @@ struct scen_header_type{
|
||||
eContentRating rating;
|
||||
int difficulty, ver[3], prog_make_ver[3];
|
||||
std::string name, teaser1, teaser2, file;
|
||||
std::map<std::string, std::string> meta_flags;
|
||||
};
|
||||
|
||||
extern std::map<std::string, int> startup_button_indices;
|
||||
|
Reference in New Issue
Block a user