From 4edb6c87c101d3fbc42bdc591b4965b451149a20 Mon Sep 17 00:00:00 2001 From: offtkp Date: Fri, 3 May 2024 02:10:17 +0300 Subject: [PATCH] Format everything --- src/retro_achievements.cpp | 340 ++++++++++++++++++++----------------- 1 file changed, 182 insertions(+), 158 deletions(-) diff --git a/src/retro_achievements.cpp b/src/retro_achievements.cpp index fc7f92d3a..8dcd2828c 100644 --- a/src/retro_achievements.cpp +++ b/src/retro_achievements.cpp @@ -18,24 +18,24 @@ ImFont* se_get_mono_font(); ra_config_t* se_get_ra_config(); } +#include "https.hpp" #include "IconsForkAwesome.h" #include "rc_client.h" -#include "sokol_time.h" -#include "https.hpp" #include "rc_consoles.h" #include "sb_types.h" +#include "sokol_time.h" #include +#include #include #include -#include -#include #include #include #include #include #include #include +#include #include #include @@ -109,17 +109,17 @@ struct ra_challenge_indicator_t struct ra_progress_indicator_t { atlas_tile_t* tile = nullptr; - std::string title {}; - std::string measured_progress {}; + std::string title{}; + std::string measured_progress{}; bool show = false; }; struct ra_notification_t { atlas_tile_t* tile = nullptr; - std::string title {}; - std::string submessage {}; - std::string submessage2 {}; + std::string title{}; + std::string submessage{}; + std::string submessage2{}; uint32_t time = 0; }; @@ -175,14 +175,16 @@ struct ra_state_t bool pending_login = false; - // Game state is a shared_ptr. This is because there's a lot of asynchronous http requests referring to it - // so every time we need to create such a request, we make a copy of the shared_ptr and pass it to the callback. - // The data will then go to that state. This way, if before the callback is called the state is destroyed, the data will - // go to a valid place before the game state is destroyed after the last reference to it is gone. - // Having a single state that exists for the entirety of the programs lifetime doesn't work. Imagine you load a game, - // an http request is fired to download the games image, you then load a different game, another http request is fired and finishes earlier, - // when the first request finishes, the game icon will be that of the old game. For this reason, multiple states need to exist and a global - // state solution is not viable. + // Game state is a shared_ptr. This is because there's a lot of asynchronous http requests + // referring to it so every time we need to create such a request, we make a copy of the + // shared_ptr and pass it to the callback. The data will then go to that state. This way, if + // before the callback is called the state is destroyed, the data will go to a valid place + // before the game state is destroyed after the last reference to it is gone. Having a single + // state that exists for the entirety of the programs lifetime doesn't work. Imagine you load a + // game, an http request is fired to download the games image, you then load a different game, + // another http request is fired and finishes earlier, when the first request finishes, the game + // icon will be that of the old game. For this reason, multiple states need to exist and a + // global state solution is not viable. ra_game_state_ptr game_state; void download(ra_game_state_ptr game_state, const std::string& url, @@ -286,7 +288,8 @@ namespace game_state->notifications.push_back(notification); } - ra_achievement_t* retro_achievements_move_bucket(ra_game_state_ptr game_state, uint32_t id, uint8_t bucket_id) + ra_achievement_t* retro_achievements_move_bucket(ra_game_state_ptr game_state, uint32_t id, + uint8_t bucket_id) { // We need to move the achievement from one bucket to another // Unfortunately we don't know which bucket the achievement is in @@ -295,8 +298,7 @@ namespace ra_achievement_t* achievement_ptr = nullptr; for (int i = 0; i < game_state->achievement_list.buckets.size(); i++) { - ra_bucket_t* bucket = - &game_state->achievement_list.buckets[i]; + ra_bucket_t* bucket = &game_state->achievement_list.buckets[i]; for (int j = 0; j < bucket->achievements.size(); j++) { if (bucket->achievements[j]->id == id) @@ -310,8 +312,7 @@ namespace bool bucket_found = false; for (int k = 0; k < game_state->achievement_list.buckets.size(); k++) { - if (game_state->achievement_list.buckets[k].bucket_id == - bucket_id) + if (game_state->achievement_list.buckets[k].bucket_id == bucket_id) { game_state->achievement_list.buckets[k].achievements.push_back( std::move(achievement)); @@ -355,8 +356,7 @@ namespace bucket.achievements.push_back(std::move(achievement)); game_state->achievement_list.buckets.emplace( - game_state->achievement_list.buckets.begin(), - std::move(bucket)); + game_state->achievement_list.buckets.begin(), std::move(bucket)); } break; } @@ -396,9 +396,11 @@ namespace uint8_t bucket = rc_achievement->bucket; std::unique_lock lock(game_state->mutex); ra_state->download(game_state, url, [game_state, notification, url, id, bucket]() { - ra_achievement_t* achievement = retro_achievements_move_bucket(game_state, id, bucket); + ra_achievement_t* achievement = + retro_achievements_move_bucket(game_state, id, bucket); - if (achievement) { + if (achievement) + { achievement->tile = &game_state->image_cache[url]; notification->tile = achievement->tile; game_state->notifications.push_back(*notification); @@ -407,7 +409,8 @@ namespace } } - void retro_achievements_progress_indicator_updated(ra_game_state_ptr game_state, + void + retro_achievements_progress_indicator_updated(ra_game_state_ptr game_state, const rc_client_achievement_t* rc_achievement) { game_state->progress_indicator.title = std::string("Progress: ") + rc_achievement->title; @@ -415,7 +418,8 @@ namespace std::string url; url.resize(256); - if (rc_client_achievement_get_image_url(rc_achievement, RC_CLIENT_ACHIEVEMENT_STATE_ACTIVE, &url[0], url.size()) == RC_OK) + if (rc_client_achievement_get_image_url(rc_achievement, RC_CLIENT_ACHIEVEMENT_STATE_ACTIVE, + &url[0], url.size()) == RC_OK) { std::unique_lock lock(game_state->mutex); ra_state->download(game_state, url, [game_state, url]() { @@ -424,7 +428,8 @@ namespace } } - std::string category_to_icon(uint8_t id) { + std::string category_to_icon(uint8_t id) + { switch (id) { case RC_CLIENT_ACHIEVEMENT_BUCKET_LOCKED: @@ -516,70 +521,82 @@ namespace retro_achievements_achievement_triggered(game_state, event->achievement); break; } - case RC_CLIENT_EVENT_LEADERBOARD_STARTED: { + case RC_CLIENT_EVENT_LEADERBOARD_STARTED: + { ra_game_state_ptr game_state = ra_state->game_state; - + std::unique_lock lock(game_state->mutex); ra_notification_t notification; - notification.title = std::string("Leaderboard attempt started: ") + event->leaderboard->title; + notification.title = + std::string("Leaderboard attempt started: ") + event->leaderboard->title; notification.submessage = event->leaderboard->description; notification.tile = game_state->game_image; game_state->notifications.push_back(notification); break; } - case RC_CLIENT_EVENT_LEADERBOARD_FAILED: { + case RC_CLIENT_EVENT_LEADERBOARD_FAILED: + { ra_game_state_ptr game_state = ra_state->game_state; - + std::unique_lock lock(game_state->mutex); ra_notification_t notification; - notification.title = std::string("Leaderboard attempt failed: ") + event->leaderboard->title; + notification.title = + std::string("Leaderboard attempt failed: ") + event->leaderboard->title; notification.submessage = event->leaderboard->description; notification.tile = game_state->game_image; game_state->notifications.push_back(notification); break; } - case RC_CLIENT_EVENT_LEADERBOARD_SUBMITTED: { + case RC_CLIENT_EVENT_LEADERBOARD_SUBMITTED: + { ra_game_state_ptr game_state = ra_state->game_state; std::unique_lock lock(game_state->mutex); ra_notification_t notification; notification.title = "Leaderboard attempt submitted!"; - notification.submessage = std::string(event->leaderboard->tracker_value) + " for " + event->leaderboard->title; + notification.submessage = std::string(event->leaderboard->tracker_value) + " for " + + event->leaderboard->title; notification.tile = game_state->game_image; game_state->notifications.push_back(notification); break; } case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_UPDATE: - case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_SHOW: { + case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_SHOW: + { ra_game_state_ptr game_state = ra_state->game_state; std::unique_lock lock(game_state->mutex); ra_leaderboard_tracker_t tracker; - memcpy(tracker.display, event->leaderboard_tracker->display, sizeof(tracker.display)); + memcpy(tracker.display, event->leaderboard_tracker->display, + sizeof(tracker.display)); game_state->leaderboard_trackers[event->leaderboard_tracker->id] = tracker; break; } - case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE: { + case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE: + { ra_game_state_ptr game_state = ra_state->game_state; std::unique_lock lock(game_state->mutex); game_state->leaderboard_trackers.erase(event->leaderboard_tracker->id); break; } - case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW: { + case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW: + { ra_game_state_ptr game_state = ra_state->game_state; std::unique_lock lock(game_state->mutex); uint32_t id = event->achievement->id; - retro_achievements_move_bucket(game_state, event->achievement->id, event->achievement->bucket); + retro_achievements_move_bucket(game_state, event->achievement->id, + event->achievement->bucket); ra_challenge_indicator_t indicator; game_state->challenges[id] = indicator; lock.unlock(); std::string url; url.resize(256); - if (rc_client_achievement_get_image_url( - event->achievement, RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED, &url[0], url.size()) == RC_OK) + if (rc_client_achievement_get_image_url(event->achievement, + RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED, + &url[0], url.size()) == RC_OK) { std::unique_lock lock(game_state->mutex); ra_state->download(game_state, url, [game_state, url, id]() { @@ -588,42 +605,49 @@ namespace } break; } - case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_HIDE: { + case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_HIDE: + { ra_game_state_ptr game_state = ra_state->game_state; std::unique_lock lock(game_state->mutex); - retro_achievements_move_bucket(game_state, event->achievement->id, RC_CLIENT_ACHIEVEMENT_BUCKET_LOCKED); + retro_achievements_move_bucket(game_state, event->achievement->id, + RC_CLIENT_ACHIEVEMENT_BUCKET_LOCKED); game_state->challenges.erase(event->achievement->id); break; } - case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_SHOW: { + case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_SHOW: + { ra_game_state_ptr game_state = ra_state->game_state; game_state->progress_indicator.show = true; - retro_achievements_progress_indicator_updated(game_state, - event->achievement); + retro_achievements_progress_indicator_updated(game_state, event->achievement); } - case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_UPDATE: { + case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_UPDATE: + { retro_achievements_progress_indicator_updated(ra_state->game_state, - event->achievement); + event->achievement); break; } - case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_HIDE: { + case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_HIDE: + { ra_game_state_ptr game_state = ra_state->game_state; game_state->progress_indicator.show = false; break; } - case RC_CLIENT_EVENT_GAME_COMPLETED: { + case RC_CLIENT_EVENT_GAME_COMPLETED: + { ra_game_state_ptr game_state = ra_state->game_state; - + std::unique_lock lock(game_state->mutex); - std::string completed = rc_client_get_hardcore_enabled(ra_state->rc_client) - ? "Mastered" : "Completed"; + std::string completed = + rc_client_get_hardcore_enabled(ra_state->rc_client) ? "Mastered" : "Completed"; const rc_client_game_t* game = rc_client_get_game_info(ra_state->rc_client); rc_client_user_game_summary_t summary; rc_client_get_user_game_summary(ra_state->rc_client, &summary); ra_notification_t notification; notification.title = completed + " " + game->title + "!"; - notification.submessage = std::string("All ") + std::to_string(summary.num_core_achievements) + " achievements unlocked"; + notification.submessage = std::string("All ") + + std::to_string(summary.num_core_achievements) + + " achievements unlocked"; notification.tile = game_state->game_image; game_state->notifications.push_back(notification); break; @@ -699,9 +723,9 @@ namespace std::unique_lock lock(ra_state->game_state->mutex); for (int i = 0; i < ra_state->game_state->achievement_list.buckets.size(); i++) { - ra_bucket_t* bucket = - &ra_state->game_state->achievement_list.buckets[i]; - std::string label = category_to_icon(bucket->bucket_id) + " " + se_localize_and_cache(bucket->label.c_str()); + ra_bucket_t* bucket = &ra_state->game_state->achievement_list.buckets[i]; + std::string label = category_to_icon(bucket->bucket_id) + " " + + se_localize_and_cache(bucket->label.c_str()); se_text(label.c_str()); for (int j = 0; j < bucket->achievements.size(); j++) { @@ -717,14 +741,15 @@ namespace const auto& achievement = bucket->achievements[j]; se_boxed_image_dual_label(achievement->title.c_str(), - achievement->description.c_str(), ICON_FK_SPINNER, - image, 0, uv0, uv1); + achievement->description.c_str(), ICON_FK_SPINNER, image, + 0, uv0, uv1); } } } } // namespace -void ra_achievement_list_t::initialize(ra_game_state_ptr game_state, rc_client_achievement_list_t* list) +void ra_achievement_list_t::initialize(ra_game_state_ptr game_state, + rc_client_achievement_list_t* list) { std::unique_lock lock(game_state->mutex); @@ -928,9 +953,11 @@ void ra_state_t::handle_downloaded(ra_game_state_ptr game_state, const std::stri void ra_state_t::rebuild_achievement_list(ra_game_state_ptr game_state) { game_state->achievement_list.initialize( - game_state, rc_client_create_achievement_list( - rc_client, RC_CLIENT_ACHIEVEMENT_CATEGORY_CORE, // TODO: option for _AND_UNOFFICIAL achievements? - RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS)); + game_state, + rc_client_create_achievement_list( + rc_client, + RC_CLIENT_ACHIEVEMENT_CATEGORY_CORE, // TODO: option for _AND_UNOFFICIAL achievements? + RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS)); } ra_game_state_t::~ra_game_state_t() @@ -1041,7 +1068,7 @@ void retro_achievements_load_game() return; // the old one will be destroyed when the last reference is gone - ra_state->game_state.reset(new ra_game_state_t()); + ra_state->game_state.reset(new ra_game_state_t()); // We need to create a shared_ptr*, so we can pass it to the C api. ra_game_state_ptr* game_state = new ra_game_state_ptr(ra_state->game_state); @@ -1146,24 +1173,15 @@ void retro_achievements_update_atlases() if (atlas->image.id == SG_INVALID_ID) { sg_image_desc desc = {0}; - desc.type = SG_IMAGETYPE_2D, - desc.render_target = false, - desc.width = atlas->pixel_stride, - desc.height = atlas->pixel_stride, - desc.num_slices = 1, - desc.num_mipmaps = 1, - desc.usage = SG_USAGE_DYNAMIC, - desc.pixel_format = SG_PIXELFORMAT_RGBA8, - desc.sample_count = 1, - desc.min_filter = SG_FILTER_LINEAR, - desc.mag_filter = SG_FILTER_LINEAR, - desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE, - desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE, + desc.type = SG_IMAGETYPE_2D, desc.render_target = false, + desc.width = atlas->pixel_stride, desc.height = atlas->pixel_stride, + desc.num_slices = 1, desc.num_mipmaps = 1, desc.usage = SG_USAGE_DYNAMIC, + desc.pixel_format = SG_PIXELFORMAT_RGBA8, desc.sample_count = 1, + desc.min_filter = SG_FILTER_LINEAR, desc.mag_filter = SG_FILTER_LINEAR, + desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE, desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE, desc.wrap_w = SG_WRAP_CLAMP_TO_EDGE, - desc.border_color = SG_BORDERCOLOR_TRANSPARENT_BLACK, - desc.max_anisotropy = 1, - desc.min_lod = 0.0f, - desc.max_lod = 1e9f, + desc.border_color = SG_BORDERCOLOR_TRANSPARENT_BLACK, desc.max_anisotropy = 1, + desc.min_lod = 0.0f, desc.max_lod = 1e9f, atlas->image = sg_make_image(&desc); @@ -1260,14 +1278,18 @@ void retro_achievements_draw_panel(int win_w) se_text(settings.c_str()); ra_config_t* config = se_get_ra_config(); - if (igCheckbox(se_localize_and_cache("Enable Hardcore Mode"), &config->hardcore_mode)) { + if (igCheckbox(se_localize_and_cache("Enable Hardcore Mode"), &config->hardcore_mode)) + { rc_client_set_hardcore_enabled(ra_state->rc_client, se_get_ra_config()->hardcore_mode); } - + igCheckbox(se_localize_and_cache("Enable Notifications"), &config->draw_notifications); - igCheckbox(se_localize_and_cache("Enable Progress Indicators"), &config->draw_progress_indicators); - igCheckbox(se_localize_and_cache("Enable Leaderboard Trackers"), &config->draw_leaderboard_trackers); - igCheckbox(se_localize_and_cache("Enable Challenge Indicators"), &config->draw_challenge_indicators); + igCheckbox(se_localize_and_cache("Enable Progress Indicators"), + &config->draw_progress_indicators); + igCheckbox(se_localize_and_cache("Enable Leaderboard Trackers"), + &config->draw_leaderboard_trackers); + igCheckbox(se_localize_and_cache("Enable Challenge Indicators"), + &config->draw_challenge_indicators); retro_achievements_draw_achievements(); } @@ -1325,31 +1347,32 @@ void retro_achievements_draw_notifications(float left, float top) float image_width = 64; float image_height = 64; - float placard_width = padding + 350 + padding; // notifications that have the same width are more appealing + float placard_width = + padding + 350 + padding; // notifications that have the same width are more appealing float wrap_width = placard_width - padding * 2 - image_width; float title_height = 0, submessage_height = 0, submessage2_height = 0; ImVec2 out; ImFont* font = igGetFont(); - ImFont_CalcTextSizeA(&out, font, 22.0f, std::numeric_limits::max(), wrap_width, notification.title.c_str(), NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 22.0f, std::numeric_limits::max(), wrap_width, + notification.title.c_str(), NULL, NULL); title_height = out.y; float placard_height = padding + title_height + padding; if (!notification.submessage.empty()) { - ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, notification.submessage.c_str(), NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, + notification.submessage.c_str(), NULL, NULL); submessage_height = out.y; placard_height += submessage_height + padding; } if (!notification.submessage2.empty()) { - ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, notification.submessage2.c_str(), NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, + notification.submessage2.c_str(), NULL, NULL); submessage2_height = out.y; placard_height += submessage2_height + padding; } @@ -1358,9 +1381,10 @@ void retro_achievements_draw_notifications(float left, float top) ImVec2{x + placard_width, y + placard_height}, 0x515151 | ALPHA(180), 8.0f, ImDrawCornerFlags_All); - ImDrawList_AddRect(igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)}, - ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)}, - 0x000000 | ALPHA(180), 8.0f, ImDrawCornerFlags_All, 2.0f); + ImDrawList_AddRect( + igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)}, + ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)}, + 0x000000 | ALPHA(180), 8.0f, ImDrawCornerFlags_All, 2.0f); if (notification.tile && notification.tile->atlas_id != SG_INVALID_ID) { @@ -1374,24 +1398,24 @@ void retro_achievements_draw_notifications(float left, float top) } else { - ImDrawList_AddRectFilled( - igGetWindowDrawList(), ImVec2{x + 15, y + 15}, - ImVec2{x + padding + image_width, y + padding + image_height}, - 0x242424 | ALPHA(255), 8.0f, ImDrawCornerFlags_All); + ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x + 15, y + 15}, + ImVec2{x + padding + image_width, y + padding + image_height}, + 0x242424 | ALPHA(255), 8.0f, ImDrawCornerFlags_All); } ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 22.0f, ImVec2{x + image_width + padding * 2, y + padding}, 0xffffff | ALPHA(255), notification.title.c_str(), NULL, wrap_width, NULL); - ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f, - ImVec2{x + image_width + padding * 2, y + padding + title_height + padding}, - 0x00aaaa | ALPHA(255), notification.submessage.c_str(), NULL, - wrap_width, NULL); - ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f, - ImVec2{x + image_width + padding * 2, y + padding + title_height + padding + submessage_height + padding}, - 0xaaaa00 | ALPHA(255), notification.submessage2.c_str(), NULL, - wrap_width, NULL); + ImDrawList_AddTextFontPtr( + igGetWindowDrawList(), igGetFont(), 18.0f, + ImVec2{x + image_width + padding * 2, y + padding + title_height + padding}, + 0x00aaaa | ALPHA(255), notification.submessage.c_str(), NULL, wrap_width, NULL); + ImDrawList_AddTextFontPtr( + igGetWindowDrawList(), igGetFont(), 18.0f, + ImVec2{x + image_width + padding * 2, + y + padding + title_height + padding + submessage_height + padding}, + 0xaaaa00 | ALPHA(255), notification.submessage2.c_str(), NULL, wrap_width, NULL); y += placard_height + padding; } @@ -1423,50 +1447,50 @@ void retro_achievements_draw_progress_indicator(float right, float top) ImVec2 out; ImFont* font = igGetFont(); - ImFont_CalcTextSizeA(&out, font, 22.0f, std::numeric_limits::max(), wrap_width, indicator.measured_progress.c_str(), NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 22.0f, std::numeric_limits::max(), wrap_width, + indicator.measured_progress.c_str(), NULL, NULL); float title_height = out.y; - ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, indicator.measured_progress.c_str(), NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 18.0f, std::numeric_limits::max(), wrap_width, + indicator.measured_progress.c_str(), NULL, NULL); float progress_height = out.y; - float placard_height = std::max(padding + title_height + padding + progress_height + padding, padding + image_height + padding); + float placard_height = std::max(padding + title_height + padding + progress_height + padding, + padding + image_height + padding); ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x, y}, - ImVec2{x + placard_width, y + placard_height}, - 0x80515151, 8.0f, ImDrawCornerFlags_All); + ImVec2{x + placard_width, y + placard_height}, 0x80515151, 8.0f, + ImDrawCornerFlags_All); - ImDrawList_AddRect(igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)}, - ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)}, - 0x80000000, 8.0f, ImDrawCornerFlags_All, 2.0f); + ImDrawList_AddRect( + igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)}, + ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)}, 0x80000000, + 8.0f, ImDrawCornerFlags_All, 2.0f); if (indicator.tile && indicator.tile->atlas_id != SG_INVALID_ID) { ImVec2 uv0 = {indicator.tile->x1, indicator.tile->y1}; ImVec2 uv1 = {indicator.tile->x2, indicator.tile->y2}; - ImDrawList_AddImageRounded( - igGetWindowDrawList(), (ImTextureID)(intptr_t)indicator.tile->atlas_id, - ImVec2{x + padding, y + padding}, - ImVec2{x + padding + image_width, y + padding + image_height}, uv0, uv1, - 0x80ffffff, 8.0f, ImDrawCornerFlags_All); + ImDrawList_AddImageRounded(igGetWindowDrawList(), + (ImTextureID)(intptr_t)indicator.tile->atlas_id, + ImVec2{x + padding, y + padding}, + ImVec2{x + padding + image_width, y + padding + image_height}, + uv0, uv1, 0x80ffffff, 8.0f, ImDrawCornerFlags_All); } else { - ImDrawList_AddRectFilled( - igGetWindowDrawList(), ImVec2{x + 15, y + 15}, - ImVec2{x + padding + image_width, y + padding + image_height}, - 0x80242424, 8.0f, ImDrawCornerFlags_All); + ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x + 15, y + 15}, + ImVec2{x + padding + image_width, y + padding + image_height}, + 0x80242424, 8.0f, ImDrawCornerFlags_All); } ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 22.0f, - ImVec2{x + padding + image_width + padding, y + padding}, - 0xffffffff, indicator.title.c_str(), NULL, - wrap_width, NULL); - - ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f, - ImVec2{x + padding + image_width + padding, y + placard_height - padding - progress_height}, - 0xff00aaaa, indicator.measured_progress.c_str(), NULL, - wrap_width, NULL); + ImVec2{x + padding + image_width + padding, y + padding}, 0xffffffff, + indicator.title.c_str(), NULL, wrap_width, NULL); + + ImDrawList_AddTextFontPtr( + igGetWindowDrawList(), igGetFont(), 18.0f, + ImVec2{x + padding + image_width + padding, y + placard_height - padding - progress_height}, + 0xff00aaaa, indicator.measured_progress.c_str(), NULL, wrap_width, NULL); } void retro_achievements_draw_leaderboard_trackers(float left, float bottom) @@ -1498,19 +1522,19 @@ void retro_achievements_draw_leaderboard_trackers(float left, float bottom) igPushFont(font); for (auto& tracker : game_state->leaderboard_trackers) { - ImFont_CalcTextSizeA(&out, font, 12.0f, std::numeric_limits::max(), 0, tracker.second.display, NULL, - NULL); + ImFont_CalcTextSizeA(&out, font, 12.0f, std::numeric_limits::max(), 0, + tracker.second.display, NULL, NULL); float max_text_width = out.x; - ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x, y}, - ImVec2{x + max_text_width + padding * 2, y + text_height + padding * 2}, - 0x80515151, 0, 0); - - ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 12.0f, - ImVec2{x + padding, y + padding}, - 0xffffffff, tracker.second.display, NULL, - std::numeric_limits::max(), NULL); - + ImDrawList_AddRectFilled( + igGetWindowDrawList(), ImVec2{x, y}, + ImVec2{x + max_text_width + padding * 2, y + text_height + padding * 2}, 0x80515151, 0, + 0); + + ImDrawList_AddTextFontPtr( + igGetWindowDrawList(), igGetFont(), 12.0f, ImVec2{x + padding, y + padding}, 0xffffffff, + tracker.second.display, NULL, std::numeric_limits::max(), NULL); + if (i++ % 3 != 2) { x += max_text_width + padding * 3; @@ -1546,16 +1570,17 @@ void retro_achievements_draw_challenge_indicators(float right, float bottom) float y = bottom - 32 * 3 - padding * 2; int i = 0; - for (const auto& item : game_state->challenges) { + for (const auto& item : game_state->challenges) + { const ra_challenge_indicator_t& challenge = item.second; - if (challenge.tile && challenge.tile->atlas_id != SG_INVALID_ID) { - ImDrawList_AddImage( - igGetWindowDrawList(), (ImTextureID)(intptr_t)challenge.tile->atlas_id, - ImVec2{x, y}, - ImVec2{x + 32, y + 32}, ImVec2{challenge.tile->x1, challenge.tile->y1}, - ImVec2{challenge.tile->x2, challenge.tile->y2}, - 0x80ffffff); + if (challenge.tile && challenge.tile->atlas_id != SG_INVALID_ID) + { + ImDrawList_AddImage(igGetWindowDrawList(), + (ImTextureID)(intptr_t)challenge.tile->atlas_id, ImVec2{x, y}, + ImVec2{x + 32, y + 32}, + ImVec2{challenge.tile->x1, challenge.tile->y1}, + ImVec2{challenge.tile->x2, challenge.tile->y2}, 0x80ffffff); } if (i++ % 3 != 2) @@ -1571,5 +1596,4 @@ void retro_achievements_draw_challenge_indicators(float right, float bottom) if (i == 9) break; // show up to 9 trackers } - } \ No newline at end of file