aboutsummaryrefslogtreecommitdiffstats
path: root/yage/base/spritesheet.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-09-21 01:25:22 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-09-21 01:25:22 +0100
commitb29349d400674f4f2b84a5ee88cdea0b9e84638e (patch)
tree52ab2fc5ba5bb43bf33dfc682a9ba27fe436487d /yage/base/spritesheet.cpp
parent56d623f4a978f212a52348b46af1a354d6d23ee6 (diff)
downloadYAGE-b29349d400674f4f2b84a5ee88cdea0b9e84638e.tar.gz
YAGE-b29349d400674f4f2b84a5ee88cdea0b9e84638e.zip
Added parser
Diffstat (limited to 'yage/base/spritesheet.cpp')
-rw-r--r--yage/base/spritesheet.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/yage/base/spritesheet.cpp b/yage/base/spritesheet.cpp
index ed4055ab..748cdb5c 100644
--- a/yage/base/spritesheet.cpp
+++ b/yage/base/spritesheet.cpp
@@ -62,16 +62,20 @@ bool SpriteSheetHandler::Key(const char *str, rapidjson::SizeType length, bool)
bool SpriteSheetHandler::StartObject()
{
- if(depth_ == 2) {
- map_[current_key_] = Coordinate();
+ depth_++;
+
+ if(depth_ == 3) {
+ current_image_ = current_key_;
}
- depth_++;
return true;
}
bool SpriteSheetHandler::EndObject(rapidjson::SizeType)
{
+ if(depth_ == 3) {
+ map_[current_image_] = coord_;
+ }
depth_--;
return true;
}
@@ -86,12 +90,29 @@ bool SpriteSheetHandler::EndArray(rapidjson::SizeType)
return true;
}
+SpriteMap SpriteSheetHandler::spriteMap() const
+{
+ return map_;
+}
+
bool SpriteSheetHandler::handleNumber(int i)
{
if(current_key_ == "width") {
if(depth_ == 1) {
-
+ image_width_ = i;
+ } else {
+ coord_.width = i;
+ }
+ } else if(current_key_ == "height") {
+ if(depth_ == 1) {
+ image_height_ = i;
+ } else {
+ coord_.height = i;
}
+ } else if(current_key_ == "x") {
+ coord_.x = i;
+ } else if(current_key_ == "y") {
+ coord_.y = i;
}
return true;
}