From 9d4879215bb7b3b89122a930f86248cc405536a1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 13 Sep 2020 17:47:51 +0200 Subject: Add description to mangadex search result, add youtube timestamp --- src/Body.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/Body.cpp') diff --git a/src/Body.cpp b/src/Body.cpp index 0297072..b4ab917 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -173,11 +173,16 @@ namespace QuickMedia { if(body_item->dirty) { body_item->dirty = false; if(body_item->title_text) - body_item->title_text->setString(body_item->title); + body_item->title_text->setString(body_item->get_title()); else - body_item->title_text = std::make_unique(body_item->title, font, 14, size.x - 50 - image_padding_x * 2.0f); + body_item->title_text = std::make_unique(body_item->get_title(), bold_font, 16, size.x - 50 - image_padding_x * 2.0f); //body_item->title_text->updateGeometry(); // TODO: Call this to make getHeight work on first frame (called below) } + + if(!body_item->get_description().empty() && !body_item->description_text) { + body_item->description_text = std::make_unique(body_item->get_description(), font, 14, size.x - 50 - image_padding_x * 2.0f); + body_item->description_text->updateGeometry(); + } } // Find the starting row that can be drawn to make selected row visible as well @@ -191,6 +196,9 @@ namespace QuickMedia { if(!item->author.empty()) { item_height += author_text.getCharacterSize() + 2.0f; } + if(item->description_text) { + item_height += item->description_text->getHeight(); + } if(draw_thumbnails && !item->thumbnail_url.empty()) { auto &item_thumbnail = item_thumbnail_textures[item->thumbnail_url]; item_thumbnail.referenced = false; @@ -234,6 +242,9 @@ namespace QuickMedia { if(!item->author.empty()) { item_height += author_text.getCharacterSize() + 2.0f; } + if(item->description_text) { + item_height += item->description_text->getHeight(); + } if(draw_thumbnails && !item->thumbnail_url.empty()) { float image_height = image_max_height; if(item_thumbnail.texture && item_thumbnail.texture->getNativeHandle() != 0) { @@ -318,13 +329,19 @@ namespace QuickMedia { //title_text.setString(item->title); //title_text.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y)); //window.draw(title_text); - item->title_text->setString(item->title); item->title_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - 4.0f)); item->title_text->setMaxWidth(size.x - text_offset_x - image_padding_x * 2.0f); item->title_text->draw(window); - // TODO: Do the same for non-manga content - const Json::Value &item_progress = content_progress[item->title]; + if(item->description_text) { + item->description_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - 4.0f + item->title_text->getHeight())); + item->description_text->setMaxWidth(size.x - text_offset_x - image_padding_x * 2.0f); + item->description_text->draw(window); + } + + // TODO: Do the same for non-manga content. + // TODO: Cache this instead of hash access every item every frame. + const Json::Value &item_progress = content_progress[item->get_title()]; if(item_progress.isObject()) { const Json::Value ¤t_json = item_progress["current"]; const Json::Value &total_json = item_progress["total"]; @@ -366,7 +383,9 @@ namespace QuickMedia { } for(auto &item : items) { - item->visible = string_find_case_insensitive(item->title, text); + item->visible = string_find_case_insensitive(item->get_title(), text); + if(!item->visible && !item->get_description().empty()) + item->visible = string_find_case_insensitive(item->get_description(), text); } } -- cgit v1.2.3