aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Channel.cpp2
-rw-r--r--src/MessageBoard.cpp53
-rw-r--r--src/Text.cpp8
3 files changed, 32 insertions, 31 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp
index 185c544..2426981 100644
--- a/src/Channel.cpp
+++ b/src/Channel.cpp
@@ -19,7 +19,7 @@ namespace dchat
localUser(_localUser ? _localUser : new OfflineUser("You"))
{
addUserLocally(localUser);
- localUser->avatarUrl = "https://archive.lainchan.jp/diy/thumb/1445879602710.png";
+ localUser->avatarUrl = "https://discordemoji.com/assets/emoji/HanekawaSmug.gif";
addLocalMessage(u8"[emoji](https://discordemoji.com/assets/emoji/PepeDab.gif) deaf [emoji](https://discordemoji.com/assets/emoji/COGGERS.gif)", &systemUser);
addLocalMessage(u8"[emoji](https://discordemoji.com/assets/emoji/PepeDab.gif)[emoji](https://discordemoji.com/assets/emoji/COGGERS.gif)", &systemUser);
diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp
index 5e101aa..c56419d 100644
--- a/src/MessageBoard.cpp
+++ b/src/MessageBoard.cpp
@@ -124,38 +124,39 @@ namespace dchat
timestamp.setPosition(sf::Vector2f(floor(position.x + (AVATAR_DIAMETER + AVATAR_PADDING_SIDE) * Settings::getScaling() + usernameText.getLocalBounds().width + USERNAME_TIMESTAMP_SIDE_PADDING * Settings::getScaling()), floor(position.y + 2.0f * Settings::getScaling() + usernameTextHeight * 0.5f - timestampTextHeight * 0.5f)));
window.draw(timestamp);
}
- }
-
- // Max avatar size = 1mb
- const ContentByUrlResult avatarResult = cache.getContentByUrl(message->user->avatarUrl, 1024 * 1024);
- if(avatarResult.type == ContentByUrlResult::Type::CACHED)
- {
- sf::Shader *circleShader = ResourceCache::getShader("shaders/circleMask.glsl", sf::Shader::Fragment);
- circleShader->setUniform("texture", sf::Shader::CurrentTexture);
- if(avatarResult.cachedType == ContentByUrlResult::CachedType::TEXTURE)
+ // Max avatar size = 1mb
+ const ContentByUrlResult avatarResult = cache.getContentByUrl(message->user->avatarUrl, 1024 * 1024);
+ if(avatarResult.type == ContentByUrlResult::Type::CACHED)
{
- // TODO: Store this sprite somewhere, might not be efficient to create a new sprite object every frame
- sf::Sprite sprite(*avatarResult.texture);
- auto textureSize = avatarResult.texture->getSize();
- sprite.setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
- sprite.setScale(sf::Vector2f(AVATAR_DIAMETER * Settings::getScaling() / (float)textureSize.x, AVATAR_DIAMETER * Settings::getScaling() / (float)textureSize.y));
- window.draw(sprite, circleShader);
+ sf::Shader *circleShader = ResourceCache::getShader("shaders/circleMask.glsl", sf::Shader::Fragment);
+ circleShader->setUniform("texture", sf::Shader::CurrentTexture);
+
+ if(avatarResult.cachedType == ContentByUrlResult::CachedType::TEXTURE)
+ {
+ // TODO: Store this sprite somewhere, might not be efficient to create a new sprite object every frame
+ sf::Sprite sprite(*avatarResult.texture);
+ auto textureSize = avatarResult.texture->getSize();
+ sprite.setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
+ sprite.setScale(sf::Vector2f(AVATAR_DIAMETER * Settings::getScaling() / (float)textureSize.x, AVATAR_DIAMETER * Settings::getScaling() / (float)textureSize.y));
+ window.draw(sprite, circleShader);
+ }
+ else if(avatarResult.cachedType == ContentByUrlResult::CachedType::GIF)
+ {
+ auto gifSize = avatarResult.gif->getSize();
+ avatarResult.gif->setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
+ avatarResult.gif->setScale(sf::Vector2f(AVATAR_DIAMETER * Settings::getScaling() / (float)gifSize.x, AVATAR_DIAMETER * Settings::getScaling() / (float)gifSize.y));
+ avatarResult.gif->draw(window, circleShader);
+ }
}
- else if(avatarResult.cachedType == ContentByUrlResult::CachedType::GIF)
+ else
{
- auto gifSize = avatarResult.gif->getSize();
- avatarResult.gif->setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
- avatarResult.gif->setScale(sf::Vector2f(AVATAR_DIAMETER * Settings::getScaling() / (float)gifSize.x, AVATAR_DIAMETER * Settings::getScaling() / (float)gifSize.y));
- avatarResult.gif->draw(window, circleShader);
+ sf::CircleShape avatarCircle(AVATAR_DIAMETER * 0.5f * Settings::getScaling(), 60 * Settings::getScaling());
+ avatarCircle.setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
+ avatarCircle.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(30, 30, 30));
+ window.draw(avatarCircle);
}
}
- else
- {
- sf::CircleShape avatarCircle(AVATAR_DIAMETER * 0.5f * Settings::getScaling(), 60 * Settings::getScaling());
- avatarCircle.setPosition(sf::Vector2f(floor(position.x), floor(position.y)));
- window.draw(avatarCircle);
- }
position.y += usernameTextHeight + USERNAME_PADDING_BOTTOM * Settings::getScaling();
}
diff --git a/src/Text.cpp b/src/Text.cpp
index 9ea4847..f78c6b7 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -504,7 +504,7 @@ namespace dchat
return textElements[0].text.size == 0 || caretIndex == textElements[0].text.size;
}
- // TODO: This can be optimized by using step algorithm (jump to middle of vertices list and check if it's at next row, if not then divide by 2 again, and do this recursively)
+ // TODO: This can be optimized by using binary search
int Text::getStartOfLine(int startIndex) const
{
assert(!dirty && !dirtyText);
@@ -526,7 +526,7 @@ namespace dchat
return 0;
}
- // TODO: This can be optimized by using step algorithm (jump to middle of vertices list and check if it's at next row, if not then divide by 2 again, and do this recursively)
+ // TODO: This can be optimized by using binary search
int Text::getEndOfLine(int startIndex) const
{
assert(!dirty && !dirtyText);
@@ -548,7 +548,7 @@ namespace dchat
return numVertices / 4;
}
- // TODO: This can be optimized by using step algorithm (jump to middle of vertices list and check if it's at next row, if not then divide by 2 again, and do this recursively)
+ // TODO: This can be optimized by using binary search
int Text::getPreviousLineClosestPosition(int startIndex) const
{
assert(!dirty && !dirtyText);
@@ -582,7 +582,7 @@ namespace dchat
return 0;
}
- // TODO: This can be optimized by using step algorithm (jump to middle of vertices list and check if it's at next row, if not then divide by 2 again, and do this recursively)
+ // TODO: This can be optimized by using binary search
int Text::getNextLineClosestPosition(int startIndex) const
{
assert(!dirty && !dirtyText);