mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
unlock functionality
This commit is contained in:
parent
48231f5f4f
commit
4d8414bd3d
@ -70,7 +70,7 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
||||
}
|
||||
|
||||
for(const JsonNode & node : config[name]["items"].Vector())
|
||||
campButtons.push_back(std::make_shared<CCampaignButton>(node, campaignSet));
|
||||
campButtons.push_back(std::make_shared<CCampaignButton>(node, config, campaignSet));
|
||||
}
|
||||
|
||||
void CCampaignScreen::activate()
|
||||
@ -89,7 +89,7 @@ std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & butt
|
||||
return std::make_shared<CButton>(Point((int)button["x"].Float(), (int)button["y"].Float()), AnimationPath::fromJson(button["name"]), help, [=](){ close();}, EShortcut::GLOBAL_CANCEL);
|
||||
}
|
||||
|
||||
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, std::string campaignSet)
|
||||
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const JsonNode & parentConfig, std::string campaignSet)
|
||||
: campaignSet(campaignSet)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
@ -102,7 +102,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, std::
|
||||
campFile = config["file"].String();
|
||||
video = VideoPath::fromJson(config["video"]);
|
||||
|
||||
status = config["open"].Bool() ? CCampaignScreen::ENABLED : CCampaignScreen::DISABLED;
|
||||
status = CCampaignScreen::ENABLED;
|
||||
|
||||
auto header = CampaignHandler::getHeader(campFile);
|
||||
hoverText = header->getName();
|
||||
@ -110,6 +110,16 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, std::
|
||||
if(persistent["campaign"][campaignSet][header->getFilename()]["completed"].Bool())
|
||||
status = CCampaignScreen::COMPLETED;
|
||||
|
||||
for(const JsonNode & node : parentConfig[campaignSet]["items"].Vector())
|
||||
{
|
||||
for(const JsonNode & requirement : config["requires"].Vector())
|
||||
{
|
||||
if(node["id"].Integer() == requirement.Integer())
|
||||
if(!persistent["campaign"][campaignSet][node["file"].String()]["completed"].Bool())
|
||||
status = CCampaignScreen::DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if(status != CCampaignScreen::DISABLED)
|
||||
{
|
||||
addUsedEvents(LCLICK | HOVER);
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
void hover(bool on) override;
|
||||
|
||||
public:
|
||||
CCampaignButton(const JsonNode & config, std::string campaignSet);
|
||||
CCampaignButton(const JsonNode & config, const JsonNode & parentConfig, std::string campaignSet);
|
||||
void show(Canvas & to) override;
|
||||
};
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
"exitbutton" : {"x": 658, "y": 482, "name":"CMPSCAN" },
|
||||
"items":
|
||||
[
|
||||
{ "x":90, "y":72, "file":"DATA/GOOD1.H3C", "image":"CAMPGD1S", "video":"CGOOD1", "open": true },
|
||||
{ "x":539, "y":72, "file":"DATA/EVIL1.H3C", "image":"CAMPEV1S", "video":"CEVIL1", "open": true },
|
||||
{ "x":43, "y":245, "file":"DATA/GOOD2.H3C", "image":"CAMPGD2S", "video":"CGOOD2", "open": true },
|
||||
{ "x":313, "y":244, "file":"DATA/NEUTRAL1.H3C", "image":"CAMPNEUS", "video":"CNEUTRAL", "open": true },
|
||||
{ "x":586, "y":246, "file":"DATA/EVIL2.H3C", "image":"CAMPEV2S", "video":"CEVIL2", "open": true },
|
||||
{ "x":34, "y":417, "file":"DATA/GOOD3.H3C", "image":"CAMPGD3S", "video":"CGOOD3", "open": true },
|
||||
{ "x":404, "y":414, "file":"DATA/SECRET1.H3C", "image":"CAMPSCTS", "video":"CSECRET", "open": true }
|
||||
{ "id": 1, "x":90, "y":72, "file":"DATA/GOOD1", "image":"CAMPGD1S", "video":"CGOOD1", "requires": [] },
|
||||
{ "id": 2, "x":539, "y":72, "file":"DATA/EVIL1", "image":"CAMPEV1S", "video":"CEVIL1", "requires": [] },
|
||||
{ "id": 3, "x":43, "y":245, "file":"DATA/GOOD2", "image":"CAMPGD2S", "video":"CGOOD2", "requires": [1, 2, 4] },
|
||||
{ "id": 4, "x":313, "y":244, "file":"DATA/NEUTRAL1", "image":"CAMPNEUS", "video":"CNEUTRAL", "requires": [] },
|
||||
{ "id": 5, "x":586, "y":246, "file":"DATA/EVIL2", "image":"CAMPEV2S", "video":"CEVIL2", "requires": [1, 2, 4] },
|
||||
{ "id": 6, "x":34, "y":417, "file":"DATA/GOOD3", "image":"CAMPGD3S", "video":"CGOOD3", "requires": [3, 5] },
|
||||
{ "id": 7, "x":404, "y":414, "file":"DATA/SECRET1", "image":"CAMPSCTS", "video":"CSECRET", "requires": [6] }
|
||||
]
|
||||
},
|
||||
"ab" :
|
||||
@ -25,12 +25,12 @@
|
||||
"exitbutton" : {"x": 658, "y": 482, "name":"CMPSCAN" },
|
||||
"items":
|
||||
[
|
||||
{ "x":90, "y":72, "file":"DATA/AB.H3C", "image":"CAMP1AB7", "video":"C1ab7", "open": true },
|
||||
{ "x":539, "y":72, "file":"DATA/BLOOD.H3C", "image":"CAMP1DB2", "video":"C1db2", "open": true },
|
||||
{ "x":43, "y":245, "file":"DATA/SLAYER.H3C", "image":"CAMP1DS1", "video":"C1ds1", "open": true },
|
||||
{ "x":313, "y":244, "file":"DATA/FESTIVAL.H3C", "image":"CAMP1FL3", "video":"C1fl3", "open": true },
|
||||
{ "x":586, "y":246, "file":"DATA/FIRE.H3C", "image":"CAMP1PF2", "video":"C1pf2", "open": true },
|
||||
{ "x":34, "y":417, "file":"DATA/FOOL.H3C", "image":"CAMP1FW1", "video":"C1fw1", "open": true }
|
||||
{ "id": 1, "x":90, "y":72, "file":"DATA/AB", "image":"CAMP1AB7", "video":"C1ab7", "requires": [] },
|
||||
{ "id": 2, "x":539, "y":72, "file":"DATA/BLOOD", "image":"CAMP1DB2", "video":"C1db2", "requires": [] },
|
||||
{ "id": 3, "x":43, "y":245, "file":"DATA/SLAYER", "image":"CAMP1DS1", "video":"C1ds1", "requires": [] },
|
||||
{ "id": 4, "x":313, "y":244, "file":"DATA/FESTIVAL", "image":"CAMP1FL3", "video":"C1fl3", "requires": [] },
|
||||
{ "id": 5, "x":586, "y":246, "file":"DATA/FIRE", "image":"CAMP1PF2", "video":"C1pf2", "requires": [] },
|
||||
{ "id": 6, "x":34, "y":417, "file":"DATA/FOOL", "image":"CAMP1FW1", "video":"C1fw1", "requires": [1, 2, 3, 4, 5] }
|
||||
]
|
||||
},
|
||||
"sod":
|
||||
@ -39,26 +39,13 @@
|
||||
"exitbutton" : {"x": 658, "y": 482, "name":"CMPSCAN" },
|
||||
"items":
|
||||
[
|
||||
{ "x":90, "y":72, "file":"DATA/GEM.H3C", "image":"CAMPNB1", "video":"NEW", "open": true },
|
||||
{ "x":539, "y":72, "file":"DATA/GELU.H3C", "image":"CAMPEL1", "video":"ELIXIR", "open": true },
|
||||
{ "x":43, "y":245, "file":"DATA/CRAG.H3C", "image":"CAMPHS1", "video":"HACK", "open": true },
|
||||
{ "x":313, "y":244, "file":"DATA/SANDRO.H3C", "image":"CAMPRN1", "video":"RISE", "open": true },
|
||||
{ "x":586, "y":246, "file":"DATA/YOG.H3C", "image":"CAMPBB1", "video":"BIRTH", "open": true },
|
||||
{ "x":34, "y":417, "file":"DATA/FINAL.H3C", "image":"CAMPUA1", "video":"UNHOLY", "open": true },
|
||||
{ "x":404, "y":414, "file":"DATA/SECRET.H3C", "image":"CAMPSP1", "video":"SPECTRE", "open": true }
|
||||
{ "id": 1, "x":90, "y":72, "file":"DATA/GEM", "image":"CAMPNB1", "video":"NEW", "requires": [] },
|
||||
{ "id": 2, "x":539, "y":72, "file":"DATA/GELU", "image":"CAMPEL1", "video":"ELIXIR", "requires": [] },
|
||||
{ "id": 3, "x":43, "y":245, "file":"DATA/CRAG", "image":"CAMPHS1", "video":"HACK", "requires": [] },
|
||||
{ "id": 4, "x":313, "y":244, "file":"DATA/SANDRO", "image":"CAMPRN1", "video":"RISE", "requires": [1, 2, 3, 5] },
|
||||
{ "id": 5, "x":586, "y":246, "file":"DATA/YOG", "image":"CAMPBB1", "video":"BIRTH", "requires": [] },
|
||||
{ "id": 6, "x":34, "y":417, "file":"DATA/FINAL", "image":"CAMPUA1", "video":"UNHOLY", "requires": [4] },
|
||||
{ "id": 7, "x":404, "y":414, "file":"DATA/SECRET", "image":"CAMPSP1", "video":"SPECTRE", "requires": [6] }
|
||||
]
|
||||
}
|
||||
// "wog" :
|
||||
// {
|
||||
// /// wog campaigns, currently has no assigned button in campaign screen and thus unused
|
||||
// "images" : [ {"x": 0, "y": 0, "name":"CAMPZALL"} ],
|
||||
// "exitbutton" : {"x": 658, "y": 482, "name":"CMPSCAN", "hotkey" : 27},
|
||||
// "items":
|
||||
// [
|
||||
// { "x":90, "y":72, "file":"DATA/ZC1.H3C", "image":"CAMPZ01", "open": true},
|
||||
// { "x":539, "y":72, "file":"DATA/ZC2.H3C", "image":"CAMPZ02", "open": true},
|
||||
// { "x":43, "y":245, "file":"DATA/ZC3.H3C", "image":"CAMPZ03", "open": true},
|
||||
// { "x":311, "y":242, "file":"DATA/ZC4.H3C", "image":"CAMPZ04", "open": true}
|
||||
// ]
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user