aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Message.hpp23
-rw-r--r--include/MessageBoard.hpp32
-rw-r--r--include/MessagePart.hpp38
-rw-r--r--include/ResourceCache.hpp13
-rw-r--r--include/Settings.hpp10
-rw-r--r--include/User.hpp22
6 files changed, 138 insertions, 0 deletions
diff --git a/include/Message.hpp b/include/Message.hpp
new file mode 100644
index 0000000..c037eb3
--- /dev/null
+++ b/include/Message.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "MessagePart.hpp"
+#include "User.hpp"
+#include <string>
+#include <vector>
+
+namespace dchat
+{
+ class Message
+ {
+ public:
+ Message(User *user);
+ virtual ~Message();
+
+ void addText(const std::string &text);
+ std::vector<MessagePart*>& getParts();
+
+ const User *user;
+ private:
+ std::vector<MessagePart*> messageParts;
+ };
+}
diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp
new file mode 100644
index 0000000..f399761
--- /dev/null
+++ b/include/MessageBoard.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "Message.hpp"
+#include <SFML/Graphics/RenderTexture.hpp>
+#include <SFML/Graphics/RenderWindow.hpp>
+#include <SFML/Window/Event.hpp>
+#include <stdexcept>
+
+namespace dchat
+{
+ class MessageBoard
+ {
+ public:
+ MessageBoard(const sf::Vector2u &size);
+ ~MessageBoard();
+
+ void updateStaticContentTexture(const sf::Vector2u &newSize);
+ void addMessage(Message *message);
+
+ void processEvent(const sf::Event &event);
+ void draw(sf::RenderWindow &window);
+ private:
+ sf::RenderTexture staticContentTexture;
+ bool useStaticContentTexture;
+ bool dirty;
+ bool selectingText;
+ bool leftMouseButtonPressed;
+ sf::Vector2f mousePos;
+ sf::Vector2f selectingTextStart;
+ std::vector<Message*> messages;
+ };
+}
diff --git a/include/MessagePart.hpp b/include/MessagePart.hpp
new file mode 100644
index 0000000..e50852a
--- /dev/null
+++ b/include/MessagePart.hpp
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <SFML/Graphics/Text.hpp>
+#include <SFML/System/Vector2.hpp>
+#include <string>
+
+namespace dchat
+{
+ class MessagePart
+ {
+ public:
+ enum class Type
+ {
+ TEXT
+ };
+
+ MessagePart(Type _type) : type(_type) {}
+ virtual ~MessagePart(){}
+
+ static float getSizeScaled();
+ virtual sf::Vector2f getPosition() const = 0;
+ virtual sf::Vector2f getSize() const = 0;
+
+ const Type type;
+ };
+
+ class MessagePartText : public MessagePart
+ {
+ public:
+ MessagePartText(const std::string &text);
+
+ static float getFontSizeScaled();
+ virtual sf::Vector2f getPosition() const override;
+ virtual sf::Vector2f getSize() const override;
+
+ sf::Text text;
+ };
+}
diff --git a/include/ResourceCache.hpp b/include/ResourceCache.hpp
new file mode 100644
index 0000000..d35eb8f
--- /dev/null
+++ b/include/ResourceCache.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <SFML/Graphics/Font.hpp>
+#include <string>
+
+namespace dchat
+{
+ class ResourceCache
+ {
+ public:
+ static const sf::Font& getFont(const std::string &filepath);
+ };
+}
diff --git a/include/Settings.hpp b/include/Settings.hpp
new file mode 100644
index 0000000..ab757ec
--- /dev/null
+++ b/include/Settings.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace dchat
+{
+ class Settings
+ {
+ public:
+ static float getScaling();
+ };
+}
diff --git a/include/User.hpp b/include/User.hpp
new file mode 100644
index 0000000..2a8f46b
--- /dev/null
+++ b/include/User.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <string>
+
+namespace dchat
+{
+ class User
+ {
+ public:
+ virtual ~User(){}
+ virtual const std::string& getName() const = 0;
+ };
+
+ class OfflineUser : public User
+ {
+ public:
+ OfflineUser(const std::string &name);
+ virtual const std::string& getName() const override;
+
+ std::string name;
+ };
+}