2019-05-16 01:16:19 +02:00
|
|
|
//
|
|
|
|
// Created by trotfunky on 15/05/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SNIPPETS_DRAWINGELEMENT_H
|
|
|
|
#define SNIPPETS_DRAWINGELEMENT_H
|
|
|
|
|
2019-05-16 13:07:29 +02:00
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <ostream>
|
|
|
|
|
2019-05-16 01:16:19 +02:00
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <pugixml.hpp>
|
2019-05-16 13:07:29 +02:00
|
|
|
|
|
|
|
#include "xmlParser.h"
|
2019-05-16 01:16:19 +02:00
|
|
|
|
|
|
|
namespace xmlParser
|
|
|
|
{
|
|
|
|
class DrawingElement
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2019-05-21 12:48:08 +02:00
|
|
|
// TODO : S'arranger pour n'avoir que des constructeurs sensés : pas de constructeur vide/résultat non évident
|
2019-05-16 13:07:29 +02:00
|
|
|
explicit DrawingElement(std::string label = "Test DrawingElement", float x = 0, float y = 1,
|
|
|
|
const sf::Color& = sf::Color::Yellow);
|
|
|
|
|
2019-05-16 01:16:19 +02:00
|
|
|
explicit DrawingElement(const pugi::xml_node&);
|
|
|
|
|
|
|
|
virtual void draw(sf::RenderWindow&) = 0;
|
2019-05-16 13:07:29 +02:00
|
|
|
void draw(sf::RenderWindow&, float referenceX, float referenceY);
|
2019-05-16 01:16:19 +02:00
|
|
|
|
|
|
|
std::string label;
|
|
|
|
|
2019-05-16 13:07:29 +02:00
|
|
|
virtual float getX() const;
|
|
|
|
virtual void setX(float newX);
|
2019-05-16 01:16:19 +02:00
|
|
|
|
2019-05-16 13:07:29 +02:00
|
|
|
virtual float getY() const;
|
|
|
|
virtual void setY(float newY);
|
2019-05-16 01:16:19 +02:00
|
|
|
|
|
|
|
const sf::Color& getColor() const;
|
2019-05-16 13:07:29 +02:00
|
|
|
const std::string getStringColor() const;
|
2019-05-16 01:16:19 +02:00
|
|
|
void setColor(const sf::Color& newColor);
|
|
|
|
void setColor(const std::string& stringColor);
|
|
|
|
|
2019-05-21 12:48:08 +02:00
|
|
|
virtual const std::string toString(int indent) const;
|
2019-05-16 13:07:29 +02:00
|
|
|
|
|
|
|
friend std::ostream& operator<<(std::ostream&,const DrawingElement&);
|
|
|
|
|
2019-05-16 01:16:19 +02:00
|
|
|
protected:
|
2019-05-16 13:07:29 +02:00
|
|
|
float x;
|
|
|
|
float y;
|
2019-05-16 01:16:19 +02:00
|
|
|
|
|
|
|
sf::Color color;
|
|
|
|
|
|
|
|
sf::Shape* shape;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SNIPPETS_DRAWINGELEMENT_H
|