1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
/*
* ImageLocator.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "ImageLocator.h"
#include "../gui/CGuiHandler.h"
#include "IScreenHandler.h"
#include "../../lib/json/JsonNode.h"
SharedImageLocator::SharedImageLocator(const JsonNode & config, EImageBlitMode mode)
: defFrame(config["defFrame"].Integer())
, defGroup(config["defGroup"].Integer())
, layer(mode)
{
if(!config["file"].isNull())
image = ImagePath::fromJson(config["file"]);
if(!config["defFile"].isNull())
defFile = AnimationPath::fromJson(config["defFile"]);
}
SharedImageLocator::SharedImageLocator(const ImagePath & path, EImageBlitMode mode)
: image(path)
, layer(mode)
{
}
SharedImageLocator::SharedImageLocator(const AnimationPath & path, int frame, int group, EImageBlitMode mode)
: defFile(path)
, defFrame(frame)
, defGroup(group)
, layer(mode)
{
}
ImageLocator::ImageLocator(const JsonNode & config, EImageBlitMode mode)
: SharedImageLocator(config, mode)
, verticalFlip(config["verticalFlip"].Bool())
, horizontalFlip(config["horizontalFlip"].Bool())
{
}
bool SharedImageLocator::operator < (const SharedImageLocator & other) const
{
if(image != other.image)
return image < other.image;
if(defFile != other.defFile)
return defFile < other.defFile;
if(defGroup != other.defGroup)
return defGroup < other.defGroup;
if(defFrame != other.defFrame)
return defFrame < other.defFrame;
if(layer != other.layer)
return layer < other.layer;
return false;
}
bool ImageLocator::empty() const
{
return !image.has_value() && !defFile.has_value();
}
|