1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

- Rewrote Kingdom Overview window - all should be stable now

- New classes for GUI - lists and tabs
- finishing work on Json config in animations
This commit is contained in:
Ivan Savenko 2011-07-22 16:22:22 +00:00
parent f5874540b3
commit 35a528e062
9 changed files with 1940 additions and 1116 deletions

168
Sprites/PortraitsLarge.json Normal file
View File

@ -0,0 +1,168 @@
{
"images" :
[
{ "frame" : 0, "file" : "HPL000KN.bmp"},
{ "frame" : 1, "file" : "HPL001KN.bmp"},
{ "frame" : 2, "file" : "HPL002KN.bmp"},
{ "frame" : 3, "file" : "HPL003KN.bmp"},
{ "frame" : 4, "file" : "HPL004KN.bmp"},
{ "frame" : 5, "file" : "HPL005KN.bmp"},
{ "frame" : 6, "file" : "HPL006KN.bmp"},
{ "frame" : 7, "file" : "HPL007KN.bmp"},
{ "frame" : 8, "file" : "HPL008CL.bmp"},
{ "frame" : 9, "file" : "HPL009CL.bmp"},
{ "frame" : 10, "file" : "HPL010CL.bmp"},
{ "frame" : 11, "file" : "HPL011CL.bmp"},
{ "frame" : 12, "file" : "HPL012CL.bmp"},
{ "frame" : 13, "file" : "HPL013CL.bmp"},
{ "frame" : 14, "file" : "HPL014CL.bmp"},
{ "frame" : 15, "file" : "HPL015CL.bmp"},
{ "frame" : 16, "file" : "HPL016RN.bmp"},
{ "frame" : 17, "file" : "HPL017RN.bmp"},
{ "frame" : 18, "file" : "HPL018RN.bmp"},
{ "frame" : 19, "file" : "HPL019RN.bmp"},
{ "frame" : 20, "file" : "HPL020RN.bmp"},
{ "frame" : 21, "file" : "HPL021RN.bmp"},
{ "frame" : 22, "file" : "HPL022RN.bmp"},
{ "frame" : 23, "file" : "HPL023RN.bmp"},
{ "frame" : 24, "file" : "HPL024DR.bmp"},
{ "frame" : 25, "file" : "HPL025DR.bmp"},
{ "frame" : 26, "file" : "HPL026DR.bmp"},
{ "frame" : 27, "file" : "HPL027DR.bmp"},
{ "frame" : 28, "file" : "HPL028DR.bmp"},
{ "frame" : 29, "file" : "HPL029DR.bmp"},
{ "frame" : 30, "file" : "HPL030DR.bmp"},
{ "frame" : 31, "file" : "HPL031DR.bmp"},
{ "frame" : 32, "file" : "HPL032AL.bmp"},
{ "frame" : 33, "file" : "HPL033AL.bmp"},
{ "frame" : 34, "file" : "HPL034AL.bmp"},
{ "frame" : 35, "file" : "HPL035AL.bmp"},
{ "frame" : 36, "file" : "HPL036AL.bmp"},
{ "frame" : 37, "file" : "HPL037AL.bmp"},
{ "frame" : 38, "file" : "HPL038AL.bmp"},
{ "frame" : 39, "file" : "HPL039AL.bmp"},
{ "frame" : 40, "file" : "HPL040WZ.bmp"},
{ "frame" : 41, "file" : "HPL041WZ.bmp"},
{ "frame" : 42, "file" : "HPL042WZ.bmp"},
{ "frame" : 43, "file" : "HPL043WZ.bmp"},
{ "frame" : 44, "file" : "HPL044WZ.bmp"},
{ "frame" : 45, "file" : "HPL045WZ.bmp"},
{ "frame" : 46, "file" : "HPL046WZ.bmp"},
{ "frame" : 47, "file" : "HPL047WZ.bmp"},
{ "frame" : 48, "file" : "HPL048HR.bmp"},
{ "frame" : 49, "file" : "HPL049HR.bmp"},
{ "frame" : 50, "file" : "HPL050HR.bmp"},
{ "frame" : 51, "file" : "HPL051HR.bmp"},
{ "frame" : 52, "file" : "HPL052HR.bmp"},
{ "frame" : 53, "file" : "HPL053HR.bmp"},
{ "frame" : 54, "file" : "HPL054HR.bmp"},
{ "frame" : 55, "file" : "HPL055HR.bmp"},
{ "frame" : 56, "file" : "HPL056DM.bmp"},
{ "frame" : 57, "file" : "HPL057DM.bmp"},
{ "frame" : 58, "file" : "HPL058DM.bmp"},
{ "frame" : 59, "file" : "HPL059DM.bmp"},
{ "frame" : 60, "file" : "HPL060DM.bmp"},
{ "frame" : 61, "file" : "HPL061DM.bmp"},
{ "frame" : 62, "file" : "HPL062DM.bmp"},
{ "frame" : 63, "file" : "HPL063DM.bmp"},
{ "frame" : 64, "file" : "HPL064DK.bmp"},
{ "frame" : 65, "file" : "HPL065DK.bmp"},
{ "frame" : 66, "file" : "HPL066DK.bmp"},
{ "frame" : 67, "file" : "HPL067DK.bmp"},
{ "frame" : 68, "file" : "HPL068DK.bmp"},
{ "frame" : 69, "file" : "HPL069DK.bmp"},
{ "frame" : 70, "file" : "HPL070DK.bmp"},
{ "frame" : 71, "file" : "HPL071DK.bmp"},
{ "frame" : 72, "file" : "HPL072NC.bmp"},
{ "frame" : 73, "file" : "HPL073NC.bmp"},
{ "frame" : 74, "file" : "HPL074NC.bmp"},
{ "frame" : 75, "file" : "HPL075NC.bmp"},
{ "frame" : 76, "file" : "HPL076NC.bmp"},
{ "frame" : 77, "file" : "HPL077NC.bmp"},
{ "frame" : 78, "file" : "HPL078NC.bmp"},
{ "frame" : 79, "file" : "HPL079NC.bmp"},
{ "frame" : 80, "file" : "HPL080OV.bmp"},
{ "frame" : 81, "file" : "HPL081OV.bmp"},
{ "frame" : 82, "file" : "HPL082OV.bmp"},
{ "frame" : 83, "file" : "HPL083OV.bmp"},
{ "frame" : 84, "file" : "HPL084OV.bmp"},
{ "frame" : 85, "file" : "HPL085OV.bmp"},
{ "frame" : 86, "file" : "HPL086OV.bmp"},
{ "frame" : 87, "file" : "HPL087OV.bmp"},
{ "frame" : 88, "file" : "HPL088WL.bmp"},
{ "frame" : 89, "file" : "HPL089WL.bmp"},
{ "frame" : 90, "file" : "HPL090WL.bmp"},
{ "frame" : 91, "file" : "HPL091WL.bmp"},
{ "frame" : 92, "file" : "HPL092WL.bmp"},
{ "frame" : 93, "file" : "HPL093WL.bmp"},
{ "frame" : 94, "file" : "HPL094WL.bmp"},
{ "frame" : 95, "file" : "HPL095WL.bmp"},
{ "frame" : 96, "file" : "HPL096BR.bmp"},
{ "frame" : 97, "file" : "HPL097BR.bmp"},
{ "frame" : 98, "file" : "HPL098BR.bmp"},
{ "frame" : 99, "file" : "HPL099BR.bmp"},
{ "frame" : 100, "file" : "HPL100BR.bmp"},
{ "frame" : 101, "file" : "HPL101BR.bmp"},
{ "frame" : 102, "file" : "HPL102BR.bmp"},
{ "frame" : 103, "file" : "HPL103BR.bmp"},
{ "frame" : 104, "file" : "HPL104BM.bmp"},
{ "frame" : 105, "file" : "HPL105BM.bmp"},
{ "frame" : 106, "file" : "HPL106BM.bmp"},
{ "frame" : 107, "file" : "HPL107BM.bmp"},
{ "frame" : 108, "file" : "HPL108BM.bmp"},
{ "frame" : 109, "file" : "HPL109BM.bmp"},
{ "frame" : 110, "file" : "HPL110BM.bmp"},
{ "frame" : 111, "file" : "HPL111BM.bmp"},
{ "frame" : 112, "file" : "HPL112BS.bmp"},
{ "frame" : 113, "file" : "HPL113BS.bmp"},
{ "frame" : 114, "file" : "HPL114BS.bmp"},
{ "frame" : 115, "file" : "HPL115BS.bmp"},
{ "frame" : 116, "file" : "HPL116BS.bmp"},
{ "frame" : 117, "file" : "HPL117BS.bmp"},
{ "frame" : 118, "file" : "HPL118BS.bmp"},
{ "frame" : 119, "file" : "HPL119BS.bmp"},
{ "frame" : 120, "file" : "HPL120WH.bmp"},
{ "frame" : 121, "file" : "HPL121WH.bmp"},
{ "frame" : 122, "file" : "HPL122WH.bmp"},
{ "frame" : 123, "file" : "HPL123WH.bmp"},
{ "frame" : 124, "file" : "HPL124WH.bmp"},
{ "frame" : 125, "file" : "HPL125WH.bmp"},
{ "frame" : 126, "file" : "HPL126WH.bmp"},
{ "frame" : 127, "file" : "HPL127WH.bmp"},
{ "frame" : 128, "file" : "HPL000PL.bmp"},
{ "frame" : 129, "file" : "HPL001PL.bmp"},
{ "frame" : 130, "file" : "HPL002PL.bmp"},
{ "frame" : 131, "file" : "HPL003PL.bmp"},
{ "frame" : 132, "file" : "HPL004PL.bmp"},
{ "frame" : 133, "file" : "HPL005PL.bmp"},
{ "frame" : 134, "file" : "HPL006PL.bmp"},
{ "frame" : 135, "file" : "HPL007PL.bmp"},
{ "frame" : 136, "file" : "HPL000EL.bmp"},
{ "frame" : 137, "file" : "HPL001EL.bmp"},
{ "frame" : 138, "file" : "HPL002EL.bmp"},
{ "frame" : 139, "file" : "HPL003EL.bmp"},
{ "frame" : 140, "file" : "HPL004EL.bmp"},
{ "frame" : 141, "file" : "HPL005EL.bmp"},
{ "frame" : 142, "file" : "HPL006EL.bmp"},
{ "frame" : 143, "file" : "HPL007EL.bmp"},
{ "frame" : 144, "file" : "HPL130KN.bmp"},
{ "frame" : 145, "file" : "HPL000SH.bmp"},
{ "frame" : 146, "file" : "HPL128QC.bmp"},
{ "frame" : 147, "file" : "HPL003SH.bmp"},
{ "frame" : 148, "file" : "HPL004SH.bmp"},
{ "frame" : 149, "file" : "HPL005SH.bmp"},
{ "frame" : 150, "file" : "HPL006SH.bmp"},
{ "frame" : 151, "file" : "HPL007SH.bmp"},
{ "frame" : 152, "file" : "HPL009SH.bmp"},
{ "frame" : 153, "file" : "HPL008SH.bmp"},
{ "frame" : 154, "file" : "HPL001SH.bmp"},
{ "frame" : 155, "file" : "HPL131DM.bmp"},
{ "frame" : 156, "file" : "HPL129MK.bmp"},
{ "frame" : 157, "file" : "HPL002SH.bmp"},
{ "frame" : 158, "file" : "HPL132Wl.bmp"},
{ "frame" : 159, "file" : "HPL133Nc.bmp"},
{ "frame" : 160, "file" : "HPL134Nc.bmp"},
{ "frame" : 161, "file" : "HPL135Wi.bmp"},
{ "frame" : 162, "file" : "HPL136Wi.bmp"}
]
}

168
Sprites/PortraitsSmall.json Normal file
View File

@ -0,0 +1,168 @@
{
"images" :
[
{ "frame" : 0, "file" : "HPS000KN.bmp"},
{ "frame" : 1, "file" : "HPS001KN.bmp"},
{ "frame" : 2, "file" : "HPS002KN.bmp"},
{ "frame" : 3, "file" : "HPS003KN.bmp"},
{ "frame" : 4, "file" : "HPS004KN.bmp"},
{ "frame" : 5, "file" : "HPS005KN.bmp"},
{ "frame" : 6, "file" : "HPS006KN.bmp"},
{ "frame" : 7, "file" : "HPS007KN.bmp"},
{ "frame" : 8, "file" : "HPS008CL.bmp"},
{ "frame" : 9, "file" : "HPS009CL.bmp"},
{ "frame" : 10, "file" : "HPS010CL.bmp"},
{ "frame" : 11, "file" : "HPS011CL.bmp"},
{ "frame" : 12, "file" : "HPS012CL.bmp"},
{ "frame" : 13, "file" : "HPS013CL.bmp"},
{ "frame" : 14, "file" : "HPS014CL.bmp"},
{ "frame" : 15, "file" : "HPS015CL.bmp"},
{ "frame" : 16, "file" : "HPS016RN.bmp"},
{ "frame" : 17, "file" : "HPS017RN.bmp"},
{ "frame" : 18, "file" : "HPS018RN.bmp"},
{ "frame" : 19, "file" : "HPS019RN.bmp"},
{ "frame" : 20, "file" : "HPS020RN.bmp"},
{ "frame" : 21, "file" : "HPS021RN.bmp"},
{ "frame" : 22, "file" : "HPS022RN.bmp"},
{ "frame" : 23, "file" : "HPS023RN.bmp"},
{ "frame" : 24, "file" : "HPS024DR.bmp"},
{ "frame" : 25, "file" : "HPS025DR.bmp"},
{ "frame" : 26, "file" : "HPS026DR.bmp"},
{ "frame" : 27, "file" : "HPS027DR.bmp"},
{ "frame" : 28, "file" : "HPS028DR.bmp"},
{ "frame" : 29, "file" : "HPS029DR.bmp"},
{ "frame" : 30, "file" : "HPS030DR.bmp"},
{ "frame" : 31, "file" : "HPS031DR.bmp"},
{ "frame" : 32, "file" : "HPS032AL.bmp"},
{ "frame" : 33, "file" : "HPS033AL.bmp"},
{ "frame" : 34, "file" : "HPS034AL.bmp"},
{ "frame" : 35, "file" : "HPS035AL.bmp"},
{ "frame" : 36, "file" : "HPS036AL.bmp"},
{ "frame" : 37, "file" : "HPS037AL.bmp"},
{ "frame" : 38, "file" : "HPS038AL.bmp"},
{ "frame" : 39, "file" : "HPS039AL.bmp"},
{ "frame" : 40, "file" : "HPS040WZ.bmp"},
{ "frame" : 41, "file" : "HPS041WZ.bmp"},
{ "frame" : 42, "file" : "HPS042WZ.bmp"},
{ "frame" : 43, "file" : "HPS043WZ.bmp"},
{ "frame" : 44, "file" : "HPS044WZ.bmp"},
{ "frame" : 45, "file" : "HPS045WZ.bmp"},
{ "frame" : 46, "file" : "HPS046WZ.bmp"},
{ "frame" : 47, "file" : "HPS047WZ.bmp"},
{ "frame" : 48, "file" : "HPS048HR.bmp"},
{ "frame" : 49, "file" : "HPS049HR.bmp"},
{ "frame" : 50, "file" : "HPS050HR.bmp"},
{ "frame" : 51, "file" : "HPS051HR.bmp"},
{ "frame" : 52, "file" : "HPS052HR.bmp"},
{ "frame" : 53, "file" : "HPS053HR.bmp"},
{ "frame" : 54, "file" : "HPS054HR.bmp"},
{ "frame" : 55, "file" : "HPS055HR.bmp"},
{ "frame" : 56, "file" : "HPS056DM.bmp"},
{ "frame" : 57, "file" : "HPS057DM.bmp"},
{ "frame" : 58, "file" : "HPS058DM.bmp"},
{ "frame" : 59, "file" : "HPS059DM.bmp"},
{ "frame" : 60, "file" : "HPS060DM.bmp"},
{ "frame" : 61, "file" : "HPS061DM.bmp"},
{ "frame" : 62, "file" : "HPS062DM.bmp"},
{ "frame" : 63, "file" : "HPS063DM.bmp"},
{ "frame" : 64, "file" : "HPS064DK.bmp"},
{ "frame" : 65, "file" : "HPS065DK.bmp"},
{ "frame" : 66, "file" : "HPS066DK.bmp"},
{ "frame" : 67, "file" : "HPS067DK.bmp"},
{ "frame" : 68, "file" : "HPS068DK.bmp"},
{ "frame" : 69, "file" : "HPS069DK.bmp"},
{ "frame" : 70, "file" : "HPS070DK.bmp"},
{ "frame" : 71, "file" : "HPS071DK.bmp"},
{ "frame" : 72, "file" : "HPS072NC.bmp"},
{ "frame" : 73, "file" : "HPS073NC.bmp"},
{ "frame" : 74, "file" : "HPS074NC.bmp"},
{ "frame" : 75, "file" : "HPS075NC.bmp"},
{ "frame" : 76, "file" : "HPS076NC.bmp"},
{ "frame" : 77, "file" : "HPS077NC.bmp"},
{ "frame" : 78, "file" : "HPS078NC.bmp"},
{ "frame" : 79, "file" : "HPS079NC.bmp"},
{ "frame" : 80, "file" : "HPS080OV.bmp"},
{ "frame" : 81, "file" : "HPS081OV.bmp"},
{ "frame" : 82, "file" : "HPS082OV.bmp"},
{ "frame" : 83, "file" : "HPS083OV.bmp"},
{ "frame" : 84, "file" : "HPS084OV.bmp"},
{ "frame" : 85, "file" : "HPS085OV.bmp"},
{ "frame" : 86, "file" : "HPS086OV.bmp"},
{ "frame" : 87, "file" : "HPS087OV.bmp"},
{ "frame" : 88, "file" : "HPS088WL.bmp"},
{ "frame" : 89, "file" : "HPS089WL.bmp"},
{ "frame" : 90, "file" : "HPS090WL.bmp"},
{ "frame" : 91, "file" : "HPS091WL.bmp"},
{ "frame" : 92, "file" : "HPS092WL.bmp"},
{ "frame" : 93, "file" : "HPS093WL.bmp"},
{ "frame" : 94, "file" : "HPS094WL.bmp"},
{ "frame" : 95, "file" : "HPS095WL.bmp"},
{ "frame" : 96, "file" : "HPS096BR.bmp"},
{ "frame" : 97, "file" : "HPS097BR.bmp"},
{ "frame" : 98, "file" : "HPS098BR.bmp"},
{ "frame" : 99, "file" : "HPS099BR.bmp"},
{ "frame" : 100, "file" : "HPS100BR.bmp"},
{ "frame" : 101, "file" : "HPS101BR.bmp"},
{ "frame" : 102, "file" : "HPS102BR.bmp"},
{ "frame" : 103, "file" : "HPS103BR.bmp"},
{ "frame" : 104, "file" : "HPS104BM.bmp"},
{ "frame" : 105, "file" : "HPS105BM.bmp"},
{ "frame" : 106, "file" : "HPS106BM.bmp"},
{ "frame" : 107, "file" : "HPS107BM.bmp"},
{ "frame" : 108, "file" : "HPS108BM.bmp"},
{ "frame" : 109, "file" : "HPS109BM.bmp"},
{ "frame" : 110, "file" : "HPS110BM.bmp"},
{ "frame" : 111, "file" : "HPS111BM.bmp"},
{ "frame" : 112, "file" : "HPS112BS.bmp"},
{ "frame" : 113, "file" : "HPS113BS.bmp"},
{ "frame" : 114, "file" : "HPS114BS.bmp"},
{ "frame" : 115, "file" : "HPS115BS.bmp"},
{ "frame" : 116, "file" : "HPS116BS.bmp"},
{ "frame" : 117, "file" : "HPS117BS.bmp"},
{ "frame" : 118, "file" : "HPS118BS.bmp"},
{ "frame" : 119, "file" : "HPS119BS.bmp"},
{ "frame" : 120, "file" : "HPS120WH.bmp"},
{ "frame" : 121, "file" : "HPS121WH.bmp"},
{ "frame" : 122, "file" : "HPS122WH.bmp"},
{ "frame" : 123, "file" : "HPS123WH.bmp"},
{ "frame" : 124, "file" : "HPS124WH.bmp"},
{ "frame" : 125, "file" : "HPS125WH.bmp"},
{ "frame" : 126, "file" : "HPS126WH.bmp"},
{ "frame" : 127, "file" : "HPS127WH.bmp"},
{ "frame" : 128, "file" : "HPS000PL.bmp"},
{ "frame" : 129, "file" : "HPS001PL.bmp"},
{ "frame" : 130, "file" : "HPS002PL.bmp"},
{ "frame" : 131, "file" : "HPS003PL.bmp"},
{ "frame" : 132, "file" : "HPS004PL.bmp"},
{ "frame" : 133, "file" : "HPS005PL.bmp"},
{ "frame" : 134, "file" : "HPS006PL.bmp"},
{ "frame" : 135, "file" : "HPS007PL.bmp"},
{ "frame" : 136, "file" : "HPS000EL.bmp"},
{ "frame" : 137, "file" : "HPS001EL.bmp"},
{ "frame" : 138, "file" : "HPS002EL.bmp"},
{ "frame" : 139, "file" : "HPS003EL.bmp"},
{ "frame" : 140, "file" : "HPS004EL.bmp"},
{ "frame" : 141, "file" : "HPS005EL.bmp"},
{ "frame" : 142, "file" : "HPS006EL.bmp"},
{ "frame" : 143, "file" : "HPS007EL.bmp"},
{ "frame" : 144, "file" : "HPS130KN.bmp"},
{ "frame" : 145, "file" : "HPS000SH.bmp"},
{ "frame" : 146, "file" : "HPS128QC.bmp"},
{ "frame" : 147, "file" : "HPS003SH.bmp"},
{ "frame" : 148, "file" : "HPS004SH.bmp"},
{ "frame" : 149, "file" : "HPS005SH.bmp"},
{ "frame" : 150, "file" : "HPS006SH.bmp"},
{ "frame" : 151, "file" : "HPS007SH.bmp"},
{ "frame" : 152, "file" : "HPS009SH.bmp"},
{ "frame" : 153, "file" : "HPS008SH.bmp"},
{ "frame" : 154, "file" : "HPS001SH.bmp"},
{ "frame" : 155, "file" : "HPS131DM.bmp"},
{ "frame" : 156, "file" : "HPS129MK.bmp"},
{ "frame" : 157, "file" : "HPS002SH.bmp"},
{ "frame" : 158, "file" : "HPS132Wl.bmp"},
{ "frame" : 159, "file" : "HPS133Nc.bmp"},
{ "frame" : 160, "file" : "HPS134Nc.bmp"},
{ "frame" : 161, "file" : "HPS135Wi.bmp"},
{ "frame" : 162, "file" : "HPS136Wi.bmp"}
]
}

View File

@ -945,31 +945,53 @@ void CAnimation::init(CDefFile * file)
if (spriteh->haveFile(name, FILE_TEXT))
{
std::string configFile = spriteh->getTextFile(name);
const JsonNode &config(configFile);
JsonMap::const_iterator rootEntry = config.Struct().find("sequences");
if (rootEntry != config.Struct().end())
const JsonNode config(configFile);
std::string basepath;
if (!config["basepath"].isNull())
basepath = config["basepath"].String();
if (!config["sequences"].isNull())
{
//TODO: Process sequences group
const JsonVector &groups = config["sequences"].Vector();
for (JsonVector::const_iterator groupsIter = groups.begin(); groupsIter!=groups.end(); ++groupsIter)
{
JsonNode group = *groupsIter;
size_t groupID = group["group"].Float();//TODO: string-to-value conversion
source[groupID].clear();
const JsonVector &frames = group["frames"].Vector();
for (JsonVector::const_iterator framesIter = frames.begin(); framesIter!=frames.end(); ++framesIter)
{
const JsonNode &frame = *framesIter;
source[groupID].push_back(frame);
std::string filename = frame["file"].String();
source[groupID].back()["file"].String() = basepath + filename;
}
}
}
rootEntry = config.Struct().find("images");
if (rootEntry != config.Struct().end())
if (!config["images"].isNull())
{
JsonVector vector = rootEntry->second.Vector();
const JsonVector &vector = config["images"].Vector();
for (JsonVector::const_iterator it = vector.begin(); it!=vector.end(); ++it)
{
JsonMap::const_iterator entry = it->Struct().find("group");
const JsonNode &node = *it;
size_t group=0;
if (entry != it->Struct().end())
group = entry->second.Float();
if (!node["group"].isNull())
group = node["group"].Float();
size_t frame = node["frame"].Float();
size_t frame = it->Struct().find("frame")->second.Float();
if (source[group].size() <= frame)
source[group].resize(frame+1);
source[group][frame] = *it;
source[group][frame] = node;
std::string filename = node["file"].String();
source[group][frame]["file"].String() = basepath + filename;
}
}
}
@ -1026,7 +1048,7 @@ void CAnimation::setCustom(std::string filename, size_t frame, size_t group)
{
if (source[group].size() <= frame)
source[group].resize(frame+1);
source[group][frame] = filename;
source[group][frame]["file"].String() = filename;
//FIXME: update image if already loaded
}

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,20 @@
#ifndef __CKINGDOMINTERFACE_H__
#define __CKINGDOMINTERFACE_H__
#pragma once
#include "../global.h"
#include <list>
#include "GUIBase.h"
#include "GUIClasses.h"
#include "CMusicBase.h"
class AdventureMapButton;
class CAnimImage;
class CHighlightableButtonsGroup;
class CResDataBar;
class CStatusBar;
class CSlider;
class CMinorResDataBar;
class HoverableArea;
class MoraleLuckBox;
class CTownInfo;
class CCreaInfo;
class HeroSlots;
/*
* CKingdomInterface.h, part of VCMI engine
@ -25,123 +26,386 @@ class MoraleLuckBox;
*
*/
/// Huge class responsible for viewing and handling kingdom view, where you can see all your towns, flagged mines and heroes
class CKingdomInterface : public CGarrisonHolder
class CKingdHeroList;
class CKingdTownList;
class IInfoBoxData;
/*
* Several classes to display basically any data.
* Main part - class InfoBox which controls how data will be formatted\positioned
* InfoBox have image and 0-2 labels
* In constructor it should receive object that implements IInfoBoxData interface
*
* interface IInfoBoxData defines way to get data for use in InfoBox
* have several implementations:
* InfoBoxHeroData - to display one of fields from hero (e.g. absolute value of primary skills)
* InfoBoxCustomHeroData - to display one of hero fields without hero (e.g. bonuses from objects)
* InfoBoxTownData - data from town
* InfoBoxCustom - user-defined data
*/
/// Displays one of object propertries with image and optional labels
class InfoBox : public CIntObject
{
class CTownItem : public CWindowWithGarrison
{
class CCreaPlace: public LRClickableAreaWTextComp
{
public:
const CGTownInstance * town;
CCreaPlace(); //c-tor
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void activate();
void deactivate();
};
public:
const CGTownInstance * town;
CKingdomInterface * parent;
int numb;//position on screen (1..size)
HoverableArea *incomeArea;//hoverable text for town hall, fort, income
CHeroArea * garrHero, *visitHero;//portraits of heroes
LRClickableAreaOpenTown *hallArea, *fortArea, * townImage;//town image
std::vector < HoverableArea * > creaGrowth;
std::vector < CCreaPlace * > creaCount;
void setTown(const CGTownInstance * newTown);//change town and update info
void showAll(SDL_Surface * to);
void activate();
void deactivate();
CTownItem (int num, CKingdomInterface * Owner);//c-tor
~CTownItem();//d-tor
};
class CHeroItem : public CWindowWithGarrison
{
class CArtPlace: public LRClickableAreaWTextComp
{
public:
CHeroItem * parent;
CArtPlace(CHeroItem * owner, const Rect &r = Rect(0, 0, 44, 44)); //c-tor
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void activate();
void deactivate();
};
public:
const CGHeroInstance * hero;
CKingdomInterface * parent;
int artGroup,numb;//current art group (0 = equiped, 1 = misc, 2 = backpack)
int backpackPos;//first visible artifact in backpack
AdventureMapButton * artLeft, * artRight;//buttons for backpack
CHeroArea * portrait;
LRClickableAreaWText * experience;
MoraleLuckBox * morale, * luck;
LRClickableAreaWText * spellPoints;
LRClickableAreaWText * speciality;
std::vector<LRClickableAreaWTextComp *> primarySkills;
std::vector<LRClickableAreaWTextComp *> secondarySkills;
std::vector<CArtPlace *> artifacts;
std::vector<CArtPlace *> backpack;
CHighlightableButtonsGroup * artButtons;
void setHero(const CGHeroInstance * newHero);//change hero and update info
void scrollArts(int move);//moving backpack, receiving distance
void onArtChange(int newstate);//changes artgroup
void showAll(SDL_Surface * to);
void activate();
void deactivate();
CHeroItem (int num, CKingdomInterface * Owner);//c-tor
~CHeroItem();//d-tor
};
public:
//common data
int state;//1 = towns showed, 2 = heroes;
SDL_Surface * bg;//background
CStatusBar * statusbar;//statusbar
CResDataBar *resdatabar;//resources
int size,PicCount;
enum InfoPos
{
POS_UP_DOWN, POS_DOWN, POS_RIGHT, POS_INSIDE, POS_CORNER, POS_NONE
};
enum InfoSize
{
SIZE_TINY, SIZE_SMALL, SIZE_MEDIUM, SIZE_BIG, SIZE_HUGE
};
//buttons
AdventureMapButton *exit;//exit button
AdventureMapButton *toTowns;//town button
AdventureMapButton *toHeroes;//hero button
CDefEssential * title; //title bar
private:
InfoSize size;
InfoPos infoPos;
IInfoBoxData *data;
//hero/town lists
CSlider * slider;//slider
bool showHarrisoned;//show harrisoned hero in heroes list or not, disabled by default
int heroPos,townPos;//position of lists
std::vector<CHeroItem *> heroes;//heroes list
std::vector<CTownItem *> towns;//towns list
CDefEssential * slots, *fort, *hall;
CLabel * value;
CLabel * name;
CAnimImage * image;
HoverableArea *hover;
//objects list
int objSize, objPos;
CDefEssential *objPics;
std::map<int,std::pair<int, const std::string*> > objList; //dwelling ID, count, hover text
std::vector <HoverableArea* > ObjList;//list of dwellings
AdventureMapButton* ObjUp, *ObjDown, *ObjTop, *ObjBottom;//buttons for dwellings list
public:
InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data);
~InfoBox();
//income pics
std::vector<HoverableArea*> incomes;//mines + incomes
std::vector<int> incomesVal;//values to print
CDefEssential * mines;
void clickRight(tribool down, bool previousState);
void clickLeft(tribool down, bool previousState);
CKingdomInterface(); //c-tor
~CKingdomInterface(); //d-tor
void updateGarrisons();//garrison updater
void moveObjectList(int newPos);
void recreateHeroList(int pos);//recreating heroes list (on slider move)
void recreateTownList(int pos);//same for town list
void listToTowns();//changing list to town view
void listToHeroes();//changing list to heroes view
void sliderMoved(int newpos);//when we move a slider...
void show(SDL_Surface * to);
void showAll(SDL_Surface * to);
void close();
void activate();
void deactivate();
//Update object if data may have changed
//void update();
};
#endif // __CCASTLEINTERFACE_H__
class IInfoBoxData
{
public:
enum InfoType
{
HERO_PRIMARY_SKILL, HERO_MANA, HERO_EXPERIENCE, HERO_SPECIAL, HERO_SECONDARY_SKILL,
//TODO: Luck? Morale? Artifact?
ARMY_SLOT,//TODO
TOWN_GROWTH, TOWN_AVAILABLE, TOWN_BUILDING,//TODO
CUSTOM
};
protected:
InfoType type;
IInfoBoxData(InfoType Type);
public:
//methods that generate values for displaying
virtual std::string getValueText()=0;
virtual std::string getNameText()=0;
virtual std::string getImageName(InfoBox::InfoSize size)=0;
virtual std::string getHoverText()=0;
virtual size_t getImageIndex()=0;
//TODO: replace with something better
virtual bool prepareMessage(std::string &text, SComponent **comp)=0;
};
class InfoBoxAbstractHeroData : public IInfoBoxData
{
protected:
virtual int getSubID()=0;
virtual si64 getValue()=0;
public:
InfoBoxAbstractHeroData(InfoType Type);
std::string getValueText();
std::string getNameText();
std::string getImageName(InfoBox::InfoSize size);
std::string getHoverText();
size_t getImageIndex();
bool prepareMessage(std::string &text, SComponent **comp);
};
class InfoBoxHeroData : public InfoBoxAbstractHeroData
{
const CGHeroInstance * hero;
int index;//index of data in hero (0-7 for sec. skill, 0-3 for pr. skill)
int getSubID();
si64 getValue();
public:
InfoBoxHeroData(InfoType Type, const CGHeroInstance *Hero, int Index=0);
//To get a bit different texts for hero window
std::string getHoverText();
std::string getValueText();
bool prepareMessage(std::string &text, SComponent **comp);
};
class InfoBoxCustomHeroData : public InfoBoxAbstractHeroData
{
int subID;//subID of data (0=attack...)
si64 value;//actual value of data, 64-bit to fit experience and negative values
int getSubID();
si64 getValue();
public:
InfoBoxCustomHeroData(InfoType Type, int subID, si64 value);
};
class InfoBoxCustom : public IInfoBoxData
{
public:
std::string valueText;
std::string nameText;
std::string imageName;
std::string hoverText;
size_t imageIndex;
InfoBoxCustom(std::string ValueText, std::string NameText, std::string ImageName, size_t ImageIndex, std::string HoverText="");
std::string getValueText();
std::string getNameText();
std::string getImageName(InfoBox::InfoSize size);
std::string getHoverText();
size_t getImageIndex();
bool prepareMessage(std::string &text, SComponent **comp);
};
//TODO!!!
class InfoBoxTownData : public IInfoBoxData
{
const CGTownInstance * town;
int index;//index of data in town
int value;//actual value of data
public:
InfoBoxTownData(InfoType Type, const CGTownInstance * Town, int Index);
InfoBoxTownData(InfoType Type, int SubID, int Value);
std::string getValueText();
std::string getNameText();
std::string getImageName(InfoBox::InfoSize size);
std::string getHoverText();
size_t getImageIndex();
};
////////////////////////////////////////////////////////////////////////////////
/// Interface used in CTabbedInt and CListBox
class IGuiObjectListManager
{
public:
//Create object for specified position, may return NULL if no object is needed at this position
//NOTE: position may be greater then size (empty rows in ListBox)
virtual CIntObject * getObject(size_t position)=0;
//Called when object needs to be removed
virtual void removeObject(CIntObject * object)
{
delete object;
};
virtual ~IGuiObjectListManager(){};
};
/// Used as base for Tabs and List classes
class CObjectList : public CIntObject
{
IGuiObjectListManager *manager;
protected:
//Internal methods for safe creation of items (Children capturing and activation/deactivation if needed)
void deleteItem(CIntObject* item);
CIntObject* createItem(size_t index);
public:
CObjectList(IGuiObjectListManager *Manager);
~CObjectList();
};
/// Window element with multiple tabs
class CTabbedInt : public CObjectList
{
private:
CIntObject * activeTab;
size_t activeID;
public:
//Manager - object which implements this interface, will be destroyed by TabbedInt
//Pos - position of object, all tabs will be moved here
//ActiveID - ID of initially active tab
CTabbedInt(IGuiObjectListManager *Manager, Point position=Point(), size_t ActiveID=0);
void setActive(size_t which);
//recreate active tab
void reset();
//return currently active item
CIntObject * getItem();
};
/// List of IntObjects with optional slider
class CListBox : public CObjectList
{
private:
std::list< CIntObject* > items;
size_t first;
size_t totalSize;
Point itemOffset;
CSlider * slider;
void updatePositions();
public:
//Manager - object which implements this interface, will be destroyed by ListBox
//Pos - position of first item
//ItemOffset - distance between items in the list
//VisibleSize - maximal number of displayable at once items
//TotalSize
//Slider - slider style, bit field: 1 = present(disabled), 2=horisontal(vertical), 4=blue(brown)
//SliderPos - position of slider, if present
CListBox(IGuiObjectListManager *Manager, Point Pos, Point ItemOffset, size_t VisibleSize,
size_t TotalSize, size_t InitialPos=0, int Slider=0, Rect SliderPos=Rect() );
//recreate all visible items
void reset();
//return currently active items
std::list< CIntObject * > getItems();
//scroll list
void moveToPos(size_t which);
void moveToNext();
void moveToPrev();
};
////////////////////////////////////////////////////////////////////////////////
/// Class which holds all parts of kingdom overview window
class CKingdomInterface : public CGarrisonHolder, public CArtifactHolder
{
private:
CListBox * dwellingsList;
CTabbedInt * tabArea;
CPicture * background;
//Main buttons
AdventureMapButton *btnTowns;
AdventureMapButton *btnHeroes;
AdventureMapButton *btnExit;
//Buttons for scrolling dwellings list
AdventureMapButton *dwellUp, *dwellDown;
AdventureMapButton *dwellTop, *dwellBottom;
InfoBox * minesBox[7];
HoverableArea * incomeArea;
CLabel * incomeAmount;
CGStatusBar * statusbar;
CResDataBar *resdatabar;
void activateTab(size_t which);
//Internal functions used during construction
void generateButtons();
void generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects);
void generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects);
public:
CKingdomInterface();
void townChanged(const CGTownInstance *town);
void updateGarrisons();
void artifactRemoved(const ArtifactLocation &artLoc);
void artifactMoved(const ArtifactLocation &artLoc, const ArtifactLocation &destLoc);
void artifactDisassembled(const ArtifactLocation &artLoc);
void artifactAssembled(const ArtifactLocation &artLoc);
};
/// List item with town
class CTownItem : public CGarrisonHolder
{
CAnimImage *background;
CAnimImage *picture;
CLabel *name;
CLabel *income;
CGarrisonInt *garr;
LRClickableAreaOpenTown *townArea;
HeroSlots *heroes;
CTownInfo *hall, *fort;
std::vector<CCreaInfo*> available;
std::vector<CCreaInfo*> growth;
public:
const CGTownInstance * town;
CTownItem(const CGTownInstance* town);
void updateGarrisons();
void update();
};
/// List item with hero
class CHeroItem : public CWindowWithGarrison
{
const CGHeroInstance * hero;
CAnimImage *background;
CAnimImage *portrait;
CLabel *name;
CHeroArea *heroArea;
CLabel *artsText;
CTabbedInt *artsTabs;
CHighlightableButtonsGroup *artButtons;
std::vector<InfoBox*> heroInfo;
MoraleLuckBox * morale, * luck;
void onArtChange(int tabIndex);
public:
CArtifactsOfHero *heroArts;
CHeroItem(const CGHeroInstance* hero, CArtifactsOfHero::SCommonPart * artsCommonPart);
};
/// Tab with all hero-specific data
class CKingdHeroList : public CGarrisonHolder, public CWindowWithArtifacts
{
private:
std::vector<CHeroItem*> heroItems;
CListBox * heroes;
CPicture * title;
CLabel * heroLabel;
CLabel * skillsLabel;
public:
CKingdHeroList(size_t maxSize);
void updateGarrisons();
};
/// Tab with all town-specific data
class CKingdTownList : public CGarrisonHolder
{
private:
std::vector<CTownItem*> townItems;
CListBox * towns;
CPicture * title;
CLabel * townLabel;
CLabel * garrHeroLabel;
CLabel * visitHeroLabel;
public:
CKingdTownList(size_t maxSize);
void townChanged(const CGTownInstance *town);
void updateGarrisons();
};

View File

@ -4,6 +4,7 @@
#include "../CCallback.h"
#include "CCastleInterface.h"
#include "CCursorHandler.h"
#include "CKingdomInterface.h"
#include "CGameInfo.h"
#include "CHeroWindow.h"
#include "CMessage.h"
@ -488,6 +489,15 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
c->garr->recreateSlots();
c->heroes->update();
}
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
{
CKingdomInterface *ki = dynamic_cast<CKingdomInterface*>(isa);
if (ki)
{
ki->townChanged(town);
ki->updateGarrisons();
}
}
GH.totalRedraw();
}
void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
@ -1032,11 +1042,18 @@ void CPlayerInterface::heroArtifactSetChanged(const CGHeroInstance*hero)
void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
{
boost::unique_lock<boost::recursive_mutex> un(*pim);
if(castleInt && town->ID == TOWNI_TYPE)
if(const CGTownInstance * townObj = dynamic_cast<const CGTownInstance*>(town))
{
CFortScreen *fs = dynamic_cast<CFortScreen*>(GH.topInt());
if(fs)
fs->creaturesChanged();
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
{
CKingdomInterface *ki = dynamic_cast<CKingdomInterface*>(isa);
if (ki && townObj)
ki->townChanged(townObj);
}
}
else if(GH.listInt.size() && (town->ID == 17 || town->ID == 20 || town->ID == 106)) //external dwelling
{

View File

@ -5409,10 +5409,13 @@ void CArtifactsOfHero::updateParentWindow()
void CArtifactsOfHero::safeRedraw()
{
if(parent)
parent->redraw();
else
redraw();
if (active)
{
if(parent)
parent->redraw();
else
redraw();
}
}
void CArtifactsOfHero::realizeCurrentTransaction()

View File

@ -5,6 +5,8 @@
#include <fstream>
#include <sstream>
const JsonNode JsonNode::nullNode;
JsonNode::JsonNode(JsonType Type):
type(DATA_NULL)
{
@ -76,6 +78,11 @@ void JsonNode::setType(JsonType Type)
}
}
bool JsonNode::isNull() const
{
return type == DATA_NULL;
}
bool & JsonNode::Bool()
{
setType(DATA_BOOL);
@ -137,6 +144,19 @@ const JsonMap & JsonNode::Struct() const
return *data.Struct;
}
JsonNode & JsonNode::operator[](std::string child)
{
return Struct()[child];
}
const JsonNode & JsonNode::operator[](std::string child) const
{
JsonMap::const_iterator it = Struct().find(child);
if (it != Struct().end())
return it->second;
return nullNode;
}
////////////////////////////////////////////////////////////////////////////////
//Helper to write content of map/vector

View File

@ -41,7 +41,7 @@ public:
//Create empty node
JsonNode(JsonType Type = DATA_NULL);
//Create tree from Json-formatted input
JsonNode(std::string input);
explicit JsonNode(std::string input);
//Copy c-tor
JsonNode(const JsonNode &copy);
@ -54,6 +54,8 @@ public:
void setType(JsonType Type);
JsonType getType() const;
bool isNull() const;
//non-const acessors, node will change type on type mismatch
bool & Bool();
int & Int();
@ -72,6 +74,13 @@ public:
//formatted output of this node in JSON format
void write(std::ostream &out, std::string prefix="") const;
//operator [], for structs only - get child node by name
JsonNode & operator[](std::string child);
const JsonNode & operator[](std::string child) const;
//error value for const operator[]
static const JsonNode nullNode;
};
std::ostream & operator<<(std::ostream &out, const JsonNode &node);