aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core/spritesheet.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-20 13:12:19 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-20 14:26:44 +0000
commit16905976c82c57fdc98a8988392354597f166a12 (patch)
tree8e8c677a793f10bdc93594c071f46721a1880f1e /yage/core/spritesheet.cpp
parent335a259da22a1775fad3f3b83cc31cbcf7d1afcc (diff)
downloadYAGE-16905976c82c57fdc98a8988392354597f166a12.tar.gz
YAGE-16905976c82c57fdc98a8988392354597f166a12.zip
improving compilation speed
Diffstat (limited to 'yage/core/spritesheet.cpp')
-rw-r--r--yage/core/spritesheet.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/yage/core/spritesheet.cpp b/yage/core/spritesheet.cpp
index e18d7fe8..f61b668a 100644
--- a/yage/core/spritesheet.cpp
+++ b/yage/core/spritesheet.cpp
@@ -6,27 +6,26 @@
* ----------------------------------------------------------------------------
*/
-/** @file
- */
+/// @file
#include "spritesheet.h"
+#include <rapidjson/document.h>
+#include <yage/core/imageloader.h>
+
#include <cassert>
#include <fstream>
#include <sstream>
#include <stdexcept>
-#include <rapidjson/document.h>
-#include <yage/core/imageloader.h>
-
-using namespace std;
-using namespace rapidjson;
-using namespace yage::details;
+using rapidjson::Document;
+using yage::details::Coordinate;
+using yage::details::SpriteMap;
namespace yage
{
-SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
+SpriteSheet::SpriteSheet(std::string pngFileName, std::string jsonFileName)
{
int jsonWidth, jsonHeight;
fileLocations_ =
@@ -34,23 +33,23 @@ SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
texture_ = ImageLoader::loadPng(pngFileName);
if (texture_.width != jsonWidth)
- throw runtime_error("JSON width does not match texture width");
+ throw std::runtime_error("JSON width does not match texture width");
if (texture_.height != jsonHeight)
- throw runtime_error("JSON height does not match texture height");
+ throw std::runtime_error("JSON height does not match texture height");
}
-string SpriteSheet::fileContent(string jsonFileName) const
+std::string SpriteSheet::fileContent(std::string jsonFileName) const
{
- ifstream inputFile(jsonFileName);
+ std::ifstream inputFile(jsonFileName);
- stringstream stream;
+ std::stringstream stream;
stream << inputFile.rdbuf();
return stream.str();
}
SpriteMap SpriteSheet::parseJson(int &width, int &height,
- string jsonContent) const
+ std::string jsonContent) const
{
SpriteMap spriteMap;
Document jsonAtlas;
@@ -62,7 +61,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
for (auto &texture : jsonAtlas["sprites"].GetObject()) {
Coordinate coord;
for (auto &value : texture.value.GetObject()) {
- string keyName{value.value.GetString()};
+ std::string keyName{value.value.GetString()};
int keyValue{value.value.GetInt()};
if (keyName == "x") {
coord.x = keyValue;
@@ -73,7 +72,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
} else if (keyName == "height") {
coord.height = keyValue;
} else {
- throw runtime_error("JSON key incorrect: " + keyName);
+ throw std::runtime_error("JSON key incorrect: " + keyName);
}
}
spriteMap[texture.name.GetString()] = coord;