Added String typedef to std::string for easier changing.
This commit is contained in:
parent
4981af6438
commit
9ff5edbcd5
9 changed files with 17 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<float> convertCoordinates(int x, int y);
|
||||
|
||||
// Private variables.
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
|
||||
#include <Thor/Resources.hpp>
|
||||
|
||||
#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<sf::Texture>
|
||||
TileManager::Tile::getTexture(Type type) {
|
||||
sf::String filename;
|
||||
String filename;
|
||||
switch (type) {
|
||||
case Type::FLOOR:
|
||||
filename = "floor.png";
|
||||
|
|
|
@ -17,7 +17,7 @@ std::vector<Character*> Character::mCharacterInstances = std::vector<Character*>
|
|||
/**
|
||||
* 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),
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<sf::Texture>(texturePath))),
|
||||
mSize(data.size) {
|
||||
|
|
|
@ -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<sf::Texture>& texture, const PhysicalData& data);
|
||||
virtual ~Sprite() = 0;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#ifndef DG_STRING_H_
|
||||
#define DG_STRING_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <SFML/System.hpp>
|
||||
typedef std::string String;
|
||||
|
||||
/**
|
||||
* Converts any value to a string.
|
||||
|
@ -24,7 +24,7 @@
|
|||
* @return val converted to string.
|
||||
*/
|
||||
template <typename T>
|
||||
sf::String
|
||||
String
|
||||
str(T val) {
|
||||
std::stringstream out;
|
||||
out << val;
|
||||
|
@ -39,7 +39,7 @@ str(T val) {
|
|||
* @return val converted to string.
|
||||
*/
|
||||
template <typename T>
|
||||
sf::String
|
||||
String
|
||||
str(T val, int digits) {
|
||||
std::stringstream out;
|
||||
out.precision(digits);
|
||||
|
|
Reference in a new issue