aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-11 22:34:42 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-11 22:34:42 +0200
commitf1063e25a55aec5a8f7b294d0392dd31d5bf9813 (patch)
treef529b443ef1aab8404638f375e461af540e75cec /src
parenta627a1fedd8d8a727d881f7e6c9e03c731dcfafd (diff)
4chan: show the replied to messages when navigating replies
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp1
-rw-r--r--src/QuickMedia.cpp18
-rw-r--r--src/plugins/Fourchan.cpp1
3 files changed, 15 insertions, 5 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index c186b9c..9ea2e01 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -72,6 +72,7 @@ namespace QuickMedia {
timestamp_text = std::make_unique<sf::Text>(*other.timestamp_text);
else
timestamp_text = nullptr;
+ replies_to = other.replies_to;
replies = other.replies;
post_number = other.post_number;
userdata = other.userdata;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f1f983e..ddeacab 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3278,11 +3278,14 @@ namespace QuickMedia {
}
BodyItem *selected_item = thread_body->get_selected();
- if(event.key.code == sf::Keyboard::Enter && selected_item && (comment_navigation_stack.empty() || thread_body->get_selected_item() != comment_navigation_stack.top()) && !selected_item->replies.empty()) {
+ if(event.key.code == sf::Keyboard::Enter && selected_item && (comment_navigation_stack.empty() || thread_body->get_selected_item() != comment_navigation_stack.top()) && (!selected_item->replies_to.empty() || !selected_item->replies.empty())) {
for(auto &body_item : thread_body->items) {
body_item->visible = false;
}
selected_item->visible = true;
+ for(size_t reply_to_index : selected_item->replies_to) {
+ thread_body->items[reply_to_index]->visible = true;
+ }
for(size_t reply_index : selected_item->replies) {
thread_body->items[reply_index]->visible = true;
}
@@ -3308,6 +3311,9 @@ namespace QuickMedia {
thread_body->set_selected_item(previous_selected);
selected_item = thread_body->items[comment_navigation_stack.top()].get();
selected_item->visible = true;
+ for(size_t reply_to_index : selected_item->replies_to) {
+ thread_body->items[reply_to_index]->visible = true;
+ }
for(size_t reply_index : selected_item->replies) {
thread_body->items[reply_index]->visible = true;
}
@@ -3493,10 +3499,9 @@ namespace QuickMedia {
// TODO: Show "Posting..." when posting comment
} else if(navigation_stage == NavigationStage::VIEWING_ATTACHED_IMAGE) {
// TODO: Use image instead of data with string. texture->loadFromMemory creates a temporary image anyways that parses the string.
- std::string image_data;
if(downloading_image && load_image_future.ready()) {
downloading_image = false;
- image_data = load_image_future.get();
+ std::string image_data = load_image_future.get();
sf::Image attached_image;
if(load_image_from_memory(attached_image, image_data.data(), image_data.size()) && attached_image_texture->loadFromImage(attached_image)) {
@@ -3512,7 +3517,6 @@ namespace QuickMedia {
}
}
- // TODO: Show a white image with the text "Downloading..." while the image is downloading and loading
if(attached_image_texture->getNativeHandle() != 0) {
auto content_size = window_size;
sf::Vector2u texture_size = attached_image_texture->getSize();
@@ -3527,12 +3531,16 @@ namespace QuickMedia {
window.draw(attached_image_sprite);
} else {
sf::RectangleShape rect(sf::Vector2f(640.0f, 480.0f));
- rect.setFillColor(sf::Color::White);
+ rect.setFillColor(sf::Color(52, 58, 70));
auto content_size = window_size;
auto rect_size = clamp_to_size(rect.getSize(), content_size);
rect.setSize(rect_size);
rect.setPosition(std::floor(content_size.x * 0.5f - rect_size.x * 0.5f), std::floor(content_size.y * 0.5f - rect_size.y * 0.5f));
window.draw(rect);
+
+ load_sprite.setPosition(window_size.x * 0.5f, window_size.y * 0.5f);
+ load_sprite.setRotation(load_sprite_timer.getElapsedTime().asSeconds() * 400.0);
+ window.draw(load_sprite);
}
} else if(navigation_stage == NavigationStage::REPLYING) {
window.draw(comment_input_shade);
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 34cb8bf..2b31e70 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -307,6 +307,7 @@ namespace QuickMedia {
// TODO: Link this quote to a 4chan archive that still has the quoted comment (if available)
comment_text += "(dead)";
} else {
+ result_items[body_item_index]->replies_to.push_back(it->second);
result_items[it->second]->replies.push_back(body_item_index);
}
break;