aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-04-28 11:52:04 +0200
committerdec05eba <dec05eba@protonmail.com>2018-04-28 11:53:18 +0200
commit3b03f87070d91f63f0dc3c7152723727781dcccf (patch)
tree7b06163f34248d1e632c032cfaf306787675e585 /include
parentb0bfb8b8d1479502bd5adf17e6a1b94ec00c63ca (diff)
Add commands, users side panel, improve image download
start using odhtdb
Diffstat (limited to 'include')
-rw-r--r--include/Cache.hpp1
-rw-r--r--include/Channel.hpp2
-rw-r--r--include/ChannelSidePanel.hpp12
-rw-r--r--include/Chatbar.hpp6
-rw-r--r--include/Command.hpp17
-rw-r--r--include/MessageBoard.hpp2
-rw-r--r--include/StringView.hpp10
-rw-r--r--include/UsersSidePanel.hpp15
-rw-r--r--include/env.hpp14
9 files changed, 58 insertions, 21 deletions
diff --git a/include/Cache.hpp b/include/Cache.hpp
index 0314e7e..d78324c 100644
--- a/include/Cache.hpp
+++ b/include/Cache.hpp
@@ -61,6 +61,7 @@ namespace dchat
std::thread downloadWaitThread;
std::vector<ImageDownloadInfo> imageDownloadProcesses;
+ std::vector<ImageDownloadInfo> imageDownloadProcessesQueue;
std::mutex imageDownloadMutex;
};
}
diff --git a/include/Channel.hpp b/include/Channel.hpp
index 4d1f528..4bdb4b5 100644
--- a/include/Channel.hpp
+++ b/include/Channel.hpp
@@ -18,7 +18,7 @@ namespace dchat
const std::string& getName() const;
void processEvent(const sf::Event &event);
- void draw(sf::RenderWindow &window, const sf::Vector2f &position, Cache &cache);
+ void draw(sf::RenderWindow &window, Cache &cache);
private:
MessageBoard messageBoard;
Chatbar chatbar;
diff --git a/include/ChannelSidePanel.hpp b/include/ChannelSidePanel.hpp
index 8331787..c1ed5d6 100644
--- a/include/ChannelSidePanel.hpp
+++ b/include/ChannelSidePanel.hpp
@@ -1,6 +1,5 @@
#pragma once
-#include <vector>
#include <SFML/Graphics/RenderWindow.hpp>
namespace dchat
@@ -10,13 +9,8 @@ namespace dchat
class ChannelSidePanel
{
public:
- ChannelSidePanel(float width);
- void addChannel(Channel *channel);
-
- void draw(sf::RenderWindow &window);
-
- float width;
- private:
- std::vector<Channel*> channels;
+ static void addChannel(Channel *channel);
+ static void draw(sf::RenderWindow &window);
+ static float getWidth();
};
}
diff --git a/include/Chatbar.hpp b/include/Chatbar.hpp
index c98db48..a9871f6 100644
--- a/include/Chatbar.hpp
+++ b/include/Chatbar.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "StringView.hpp"
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
@@ -16,6 +17,7 @@ namespace dchat
Chatbar();
void addChar(sf::Uint32 codePoint);
+ void addString(const std::string &strToAdd);
const sf::String& getString() const;
void removePreviousChar();
void removeNextChar();
@@ -27,7 +29,9 @@ namespace dchat
bool isFocused() const;
void processEvent(const sf::Event &event, Channel *channel);
- void draw(sf::RenderWindow &window, const sf::Vector2f &position);
+ void draw(sf::RenderWindow &window);
+ private:
+ void processChatCommand(const StringView &cmd);
private:
sf::Text text;
sf::RectangleShape background;
diff --git a/include/Command.hpp b/include/Command.hpp
new file mode 100644
index 0000000..fe8a947
--- /dev/null
+++ b/include/Command.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <vector>
+#include <string>
+#include <functional>
+
+namespace dchat
+{
+ using CommandHandlerFunc = std::function<void(const std::vector<std::string> &args)>;
+
+ class Command
+ {
+ public:
+ static bool add(const std::string &cmd, CommandHandlerFunc handlerFunc);
+ static bool call(const std::string &cmd, const std::vector<std::string> &args);
+ };
+}
diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp
index 523fb16..ca1405f 100644
--- a/include/MessageBoard.hpp
+++ b/include/MessageBoard.hpp
@@ -20,7 +20,7 @@ namespace dchat
void addMessage(Message *message);
void processEvent(const sf::Event &event);
- void draw(sf::RenderWindow &window, const sf::Vector2f &position, Cache &cache);
+ void draw(sf::RenderWindow &window, Cache &cache);
private:
sf::RenderTexture staticContentTexture;
bool dirty;
diff --git a/include/StringView.hpp b/include/StringView.hpp
index 9eea387..45d0f5b 100644
--- a/include/StringView.hpp
+++ b/include/StringView.hpp
@@ -52,6 +52,16 @@ namespace dchat
return memcmp(data, other.data, size * sizeof(CharType)) == 0;
}
+ bool operator == (const BasicStringView<CharType> &other) const
+ {
+ return equals(other);
+ }
+
+ bool operator != (const BasicStringView<CharType> &other) const
+ {
+ return !equals(other);
+ }
+
CharType operator [] (usize index) const
{
assert(index < size);
diff --git a/include/UsersSidePanel.hpp b/include/UsersSidePanel.hpp
new file mode 100644
index 0000000..aebdb34
--- /dev/null
+++ b/include/UsersSidePanel.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "User.hpp"
+#include <SFML/Graphics/RenderWindow.hpp>
+
+namespace dchat
+{
+ class UsersSidePanel
+ {
+ public:
+ static void addUser(User *user);
+ static void draw(sf::RenderWindow &window);
+ static float getWidth();
+ };
+}
diff --git a/include/env.hpp b/include/env.hpp
index e0a5b03..abaedd8 100644
--- a/include/env.hpp
+++ b/include/env.hpp
@@ -8,9 +8,9 @@
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN64)
- #define OS_ENV_64BIT
+ #define SYS_ENV_64BIT
#else
- #define OS_ENV_32BIT
+ #define SYS_ENV_32BIT
#endif
#define OS_FAMILY OS_FAMILY_WINDOWS
#define OS_TYPE OS_TYPE_WINDOWS
@@ -40,13 +40,13 @@
#if defined(__GNUC__)
#if defined(__x86_64__) || defined(__pc64__)
- #define OS_ENV_64BIT
+ #define SYS_ENV_64BIT
#else
- #define OS_ENV_32BIT
+ #define SYS_ENV_32BIT
#endif
#endif
-#if !defined(OS_ENV_32BIT) && !defined(OS_ENV_64BIT)
+#if !defined(SYS_ENV_32BIT) && !defined(SYS_ENV_64BIT)
#error "System is not detected as either 32-bit or 64-bit"
#endif
@@ -57,7 +57,3 @@
#if !defined(OS_TYPE)
#error "System not supported. Only Windows and linux systems supported right now"
#endif
-
-#if !defined(DEBUG) && !defined(NDEBUG)
-#define DEBUG
-#endif