diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChannelSidePanel.cpp | 10 | ||||
-rw-r--r-- | src/ChannelTopPanel.cpp | 2 | ||||
-rw-r--r-- | src/Chatbar.cpp | 8 | ||||
-rw-r--r-- | src/MessageBoard.cpp | 6 | ||||
-rw-r--r-- | src/UsersSidePanel.cpp | 9 | ||||
-rw-r--r-- | src/main.cpp | 2 |
6 files changed, 20 insertions, 17 deletions
diff --git a/src/ChannelSidePanel.cpp b/src/ChannelSidePanel.cpp index 524e504..49407cc 100644 --- a/src/ChannelSidePanel.cpp +++ b/src/ChannelSidePanel.cpp @@ -13,7 +13,8 @@ using namespace std; namespace dchat { - vector<Channel*> channels; + static vector<Channel*> channels; + static sf::Vector2f position; const float WIDTH = 300.0f; const unsigned int FONT_SIZE = 20; const float PADDING_BOTTOM = 10.0f; @@ -45,7 +46,7 @@ namespace dchat auto mousePos = sf::Mouse::getPosition(window); - sf::Vector2f position(10.0f, posY); + position.y = posY; for(Channel *channel : channels) { sf::FloatRect box(0.0f, position.y, getWidth(), channelBoxHeight); @@ -84,4 +85,9 @@ namespace dchat { return floor(WIDTH * Settings::getScaling()); } + + float ChannelSidePanel::getHeight() + { + return position.y; + } } diff --git a/src/ChannelTopPanel.cpp b/src/ChannelTopPanel.cpp index 9d4869e..ec02651 100644 --- a/src/ChannelTopPanel.cpp +++ b/src/ChannelTopPanel.cpp @@ -51,7 +51,7 @@ namespace dchat window.draw(rect); sf::Vector2f bottomLinePos(floor(ChannelSidePanel::getWidth() + PADDING_SIDE * Settings::getScaling()), getHeight() - BOTTOM_LINE_HEIGHT); - sf::Vector2f bottomLineSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), BOTTOM_LINE_HEIGHT); + sf::Vector2f bottomLineSize(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), BOTTOM_LINE_HEIGHT); LineColor lineColor; lineColor.sideColor = lineSideColor; diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp index a3e1d0f..6a459cc 100644 --- a/src/Chatbar.cpp +++ b/src/Chatbar.cpp @@ -197,13 +197,13 @@ namespace dchat text.setCharacterSize(FONT_SIZE * Settings::getScaling()); const float fontHeight = text.getFont()->getLineSpacing(text.getCharacterSize()); - sf::RectangleShape lineShape(sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - LINE_PADDING_SIDE * Settings::getScaling() * 2.0f), LINE_HEIGHT)); + sf::RectangleShape lineShape(sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - LINE_PADDING_SIDE * Settings::getScaling() * 2.0f), LINE_HEIGHT)); lineShape.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10)); lineShape.setPosition(ChannelSidePanel::getWidth() + LINE_PADDING_SIDE * Settings::getScaling(), floor(windowSize.y - getHeight())); window.draw(lineShape); - sf::Vector2f inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f)); - sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(getHeight() - LINE_HEIGHT)); + sf::Vector2f inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f)); + sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth()), floor(getHeight() - LINE_HEIGHT)); background.setSize(backgroundSize); background.setPosition(ChannelSidePanel::getWidth(), floor(windowSize.y - backgroundSize.y)); window.draw(background); @@ -229,7 +229,7 @@ namespace dchat auto windowSize = window.getSize(); const float fontSize = FONT_SIZE * Settings::getScaling(); const float fontHeight = ResourceCache::getFont("fonts/Nunito-Regular.ttf")->getLineSpacing(fontSize); - return { floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f) }; + return { floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f) }; } float Chatbar::getHeight() diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp index 2c89be3..4366d9b 100644 --- a/src/MessageBoard.cpp +++ b/src/MessageBoard.cpp @@ -385,8 +385,8 @@ namespace dchat void MessageBoard::draw(sf::RenderWindow &window, Cache &cache) { auto windowSize = window.getSize(); - backgroundSizeWithoutPadding = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight())); - backgroundSize = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight() - PADDING_TOP)); + backgroundSizeWithoutPadding = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth()), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight())); + backgroundSize = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight() - PADDING_TOP)); backgroundPos = sf::Vector2f(ChannelSidePanel::getWidth(), ChannelTopPanel::getHeight()); //if(backgroundSize != staticContentTexture.getSize()) @@ -459,7 +459,7 @@ namespace dchat scrollbar.maxScroll = totalHeight; scrollbar.width = 10.0f * Settings::getScaling(); scrollbar.maxHeight = (float)backgroundSize.y; - scrollbar.position.x = windowSize.x - UsersSidePanel::getWidth() - scrollbar.width; + scrollbar.position.x = windowSize.x - scrollbar.width; scrollbar.position.y = backgroundPos.y; scrollbar.draw(window); scroll = scrollbar.getScrollingForContent(); diff --git a/src/UsersSidePanel.cpp b/src/UsersSidePanel.cpp index b1f7843..7d7970f 100644 --- a/src/UsersSidePanel.cpp +++ b/src/UsersSidePanel.cpp @@ -1,5 +1,6 @@ #include "../include/UsersSidePanel.hpp" #include "../include/ChannelTopPanel.hpp" +#include "../include/ChannelSidePanel.hpp" #include "../include/ResourceCache.hpp" #include "../include/Settings.hpp" #include "../include/Channel.hpp" @@ -74,18 +75,14 @@ namespace dchat void UsersSidePanel::draw(sf::RenderWindow &window, Cache &cache) { - float posY = ChannelTopPanel::getHeight(); auto windowSize = window.getSize(); - sf::RectangleShape rect(sf::Vector2f(getWidth(), windowSize.y - ChannelTopPanel::getHeight())); - rect.setFillColor(ColorScheme::getBackgroundColor()); - rect.setPosition(windowSize.x - getWidth(), posY); - window.draw(rect); // TODO: Remove this? + float posY = std::min((windowSize.y - ChannelTopPanel::getHeight()) * 0.5f, ChannelSidePanel::getHeight()); Channel *currentChannel = Channel::getCurrent(); if(!currentChannel) return; const sf::Font *font = ResourceCache::getFont("fonts/Nunito-Regular.ttf"); - sf::Vector2f position(rect.getPosition().x + 10.0f, posY); + sf::Vector2f position(10.0f, posY); const float textHeight = font->getLineSpacing(FONT_SIZE * Settings::getScaling()); diff --git a/src/main.cpp b/src/main.cpp index 77b1d5c..15c02ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -353,7 +353,7 @@ int main(int argc, char **argv) } } }; - database = odhtdb::Database::connect("83.252.53.188", 27130, Cache::getDchatDir(), callbackFuncs).get(); + database = odhtdb::Database::connect("127.0.0.1", 27130, Cache::getDchatDir(), callbackFuncs).get(); auto addSystemMessage = [&lastFocusedTimer](const std::string &msg, bool plainText = true) { |