diff --git a/source/Game.cpp b/source/Game.cpp index 470dd6c..9aca64a 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -244,7 +244,7 @@ Game::render() { /** * Returns current FPS as string. */ -sf::String +String Game::getFps() { return str((mElapsed != 0) ? 1000.0f / mElapsed : 0.0f, 2); } diff --git a/source/Game.h b/source/Game.h index 155e503..5c7e971 100644 --- a/source/Game.h +++ b/source/Game.h @@ -19,6 +19,7 @@ #include "TileManager.h" #include "sprite/Player.h" #include "util/Collection.h" +#include "util/String.h" class Player; class Collection; @@ -46,7 +47,7 @@ private: void mouseUp(const sf::Event& event); void generate(); - sf::String getFps(); + String getFps(); sf::Vector2 convertCoordinates(int x, int y); // Private variables. diff --git a/source/TileManager.cpp b/source/TileManager.cpp index 14a14bc..1a64e64 100755 --- a/source/TileManager.cpp +++ b/source/TileManager.cpp @@ -9,9 +9,10 @@ #include +#include "abstract/Sprite.h" #include "util/Loader.h" #include "util/ResourceManager.h" -#include "abstract/Sprite.h" +#include "util/String.h" const Vector2i TileManager::TILE_SIZE = Vector2i(100, 100); @@ -45,7 +46,7 @@ TileManager::Tile::Tile(Type type, const TilePosition& position, b2World& world) */ std::shared_ptr TileManager::Tile::getTexture(Type type) { - sf::String filename; + String filename; switch (type) { case Type::FLOOR: filename = "floor.png"; diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index 29b0d6c..af8e951 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -17,7 +17,7 @@ std::vector Character::mCharacterInstances = std::vector /** * Saves pointer to this instance in static var for think(). */ -Character::Character(const Instances& instances, const sf::String& texturePath, +Character::Character(const Instances& instances, const String& texturePath, const PhysicalData& data, int health) : Sprite(texturePath, data), mMaxHealth(health), diff --git a/source/abstract/Character.h b/source/abstract/Character.h index b0aa530..0c6ceca 100644 --- a/source/abstract/Character.h +++ b/source/abstract/Character.h @@ -12,6 +12,7 @@ #include "Sprite.h" #include "../Instances.h" +#include "../util/String.h" class Instances; class Sprite; @@ -22,7 +23,7 @@ class Sprite; class Character : public Sprite { // Public functions. public: - Character(const Instances& instances, const sf::String& texturePath, + Character(const Instances& instances, const String& texturePath, const PhysicalData& data, int health); virtual ~Character() = 0; diff --git a/source/abstract/Sprite.cpp b/source/abstract/Sprite.cpp index 65e367b..de8e5ce 100644 --- a/source/abstract/Sprite.cpp +++ b/source/abstract/Sprite.cpp @@ -8,7 +8,6 @@ #include "Sprite.h" #include "../util/Loader.h" -#include "../util/String.h" #include "../util/ResourceManager.h" /** @@ -16,7 +15,7 @@ * * @param texturePath Relative path to the texture file in the resource folder. */ -Sprite::Sprite(const sf::String& texturePath, const PhysicalData& data) : +Sprite::Sprite(const String& texturePath, const PhysicalData& data) : Physical(data), mTexture(ResourceManager::i().acquire(Loader::i().fromFile(texturePath))), mSize(data.size) { diff --git a/source/abstract/Sprite.h b/source/abstract/Sprite.h index 8a8b486..c0b8f7d 100644 --- a/source/abstract/Sprite.h +++ b/source/abstract/Sprite.h @@ -14,6 +14,7 @@ #include "Physical.h" #include "../util/Vector.h" +#include "../util/String.h" class Physical; @@ -25,7 +26,7 @@ class Physical; class Sprite : public sf::Drawable, public Physical { // Public functions. public: - Sprite(const sf::String& texturePath, const PhysicalData& data); + Sprite(const String& texturePath, const PhysicalData& data); Sprite(const std::shared_ptr& texture, const PhysicalData& data); virtual ~Sprite() = 0; diff --git a/source/sprite/Player.cpp b/source/sprite/Player.cpp index 0b64f41..2c95098 100644 --- a/source/sprite/Player.cpp +++ b/source/sprite/Player.cpp @@ -11,6 +11,7 @@ #include "../util/Vector.h" #include "../items/Weapon.h" +#include "../util/String.h" const float Player::SPEED = 100.0f; const Vector2i Player::SIZE = Vector2i(50, 50); diff --git a/source/util/String.h b/source/util/String.h index add34c3..ac1f136 100644 --- a/source/util/String.h +++ b/source/util/String.h @@ -12,10 +12,10 @@ #ifndef DG_STRING_H_ #define DG_STRING_H_ -#include #include +#include -#include +typedef std::string String; /** * Converts any value to a string. @@ -24,7 +24,7 @@ * @return val converted to string. */ template -sf::String +String str(T val) { std::stringstream out; out << val; @@ -39,7 +39,7 @@ str(T val) { * @return val converted to string. */ template -sf::String +String str(T val, int digits) { std::stringstream out; out.precision(digits);