aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text.cpp21
-rw-r--r--src/main.cpp18
2 files changed, 28 insertions, 11 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index 2292a4e..025cb92 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -31,6 +31,7 @@ namespace dchat
dirtyCaret(false),
plainText(false),
editable(false),
+ visible(true),
caretMoveDirection(CaretMoveDirection::NONE),
caretIndex(0)
{
@@ -49,6 +50,7 @@ namespace dchat
dirtyCaret(false),
plainText(_plainText),
editable(false),
+ visible(true),
caretMoveDirection(CaretMoveDirection::NONE),
lineSpacing(0.0f),
caretIndex(0)
@@ -906,21 +908,24 @@ namespace dchat
//sf::FloatRect textRect(pos.x, pos.y, maxWidth, )
//colRect.contains()
//if(pos.x + maxWidth <= 0.0f || pos.x >= maxWidth || pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return;
- if(pos.y + getHeight() <= 0.0f || pos.y >= target.getSize().y) return false;
- /*
- if(editable)
+ if(pos.y + getHeight() <= 0.0f || pos.y >= target.getSize().y)
{
- sf::RectangleShape editBox(sf::Vector2f(std::max(maxWidth, boundingBox.width), boundingBox.height));
- editBox.setPosition(pos.x, pos.y - floor(vspace));
- editBox.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10));
- target.draw(editBox);
+ if(!editable && visible && lastSeenTimer.getElapsedTime().asMilliseconds() > 3000)
+ {
+ visible = false;
+ vertices.resize(0);
+ }
+ return false;
}
- */
+ if(!visible)
+ updateGeometry();
states.transform.translate(pos);
states.texture = &font->getTexture(characterSize);
target.draw(vertices, states);
+ lastSeenTimer.restart();
+ visible = true;
pos.y -= floor(vspace);
for(TextElement &textElement : textElements)
diff --git a/src/main.cpp b/src/main.cpp
index 4440315..cf916e2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -117,11 +117,11 @@ int main(int argc, char **argv)
boost::filesystem::current_path(parentPath); // Ensures loading of resources works no matter which path we run this executable from
*/
- const int FRAMERATE_FOCUSED = 200;
- const int FRAMERATE_NOT_FOCUSED = 30;
+ const sf::Int64 FRAMERATE_FOCUSED = 144;
+ const sf::Int64 FRAMERATE_NOT_FOCUSED = 10;
XInitThreads();
- sf::RenderWindow window(sf::VideoMode(1920, 1080), "dchat");
+ sf::RenderWindow window(sf::VideoMode(1280, 768), "dchat");
window.setVerticalSyncEnabled(false);
window.setFramerateLimit(FRAMERATE_FOCUSED);
@@ -659,8 +659,12 @@ int main(int argc, char **argv)
Channel::getCurrent()->addLocalMessage(msg, Channel::getCurrent()->getSystemUser());
});
+ sf::Clock lastFocusedTimer;
+ sf::Clock frameTimer;
+
while (window.isOpen())
{
+ frameTimer.restart();
Channel *currentChannel = Channel::getCurrent();
sf::Event event;
@@ -702,8 +706,16 @@ int main(int argc, char **argv)
GlobalContextMenu::processEvent(event);
currentChannel->processEvent(event, cache);
}
+
+ lastFocusedTimer.restart();
}
+ if(lastFocusedTimer.getElapsedTime().asMilliseconds() > 3000)
+ {
+ this_thread::sleep_for(chrono::seconds(1));
+ continue;
+ }
+
window.clear(ColorScheme::getBackgroundColor());
ChannelSidePanel::draw(window);
currentChannel->draw(window, cache);