aboutsummaryrefslogtreecommitdiff
path: root/include/MessageBoard.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/MessageBoard.hpp')
-rw-r--r--include/MessageBoard.hpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp
index 1d1f523..c1eecb0 100644
--- a/include/MessageBoard.hpp
+++ b/include/MessageBoard.hpp
@@ -1,9 +1,8 @@
#pragma once
-#include "Message.hpp"
#include "types.hpp"
-#include "../include/Cache.hpp"
-#include "../include/Scrollbar.hpp"
+#include "Message.hpp"
+#include "Scrollbar.hpp"
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>
@@ -11,37 +10,41 @@
#include <odhtdb/Signature.hpp>
#include <stdexcept>
#include <mutex>
+#include <memory>
namespace dchat
{
- class Channel;
+ class Room;
+ struct RoomMessage;
+ class Cache;
+ class User;
class MessageBoard
{
- friend class Channel;
public:
- MessageBoard(Channel *channel);
+ MessageBoard(std::shared_ptr<Room> room);
~MessageBoard();
- void processEvent(const sf::Event &event, Cache &cache);
- void draw(sf::RenderWindow &window, Cache &cache);
-
- Message* getLatestMessage();
- const std::vector<Message*>& getMessages() const;
+ void processEvent(const sf::Event &event, Cache *cache);
+ void draw(sf::RenderWindow &window, Cache *cache);
+
+ bool addMessage(Message *message);
+ void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser);
+
+ void addOfflineUserMessage(std::string msg, bool plainText);
+ void addSystemUserMessage(std::string msg, bool plainText);
private:
usize findPositionToInsertMessageByTimestamp(Message *message);
void updateStaticContentTexture(const sf::Vector2u &newSize);
- bool addMessage(Message *message, const odhtdb::Hash &id);
- void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser);
- void drawDefault(sf::RenderWindow &window, Cache &cache);
- void drawSimple(sf::RenderWindow &window, Cache &cache);
+ void drawDefault(sf::RenderWindow &window, Cache *cache);
+ void drawSimple(sf::RenderWindow &window, Cache *cache);
private:
- Channel *channel;
+ std::shared_ptr<Room> room;
bool dirty;
- std::vector<Message*> messages;
odhtdb::MapHash<Message*> messageIdMap;
+ std::vector<Message*> messages;
double scroll;
double scrollSpeed;
double totalHeight;
@@ -54,5 +57,8 @@ namespace dchat
usize visibleMessageStartIndex;
usize visibleMessageEndIndex;
Scrollbar scrollbar;
+
+ std::shared_ptr<User> offlineUser;
+ std::shared_ptr<User> systemUser;
};
}