mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
in the overlay, use the achievement icon handle directly instead of the icon filepath to load the icon resource
This commit is contained in:
parent
4e5aa8085e
commit
f581a892eb
@ -69,8 +69,8 @@ struct Overlay_Achievement
|
||||
std::string name{};
|
||||
std::string title{};
|
||||
std::string description{};
|
||||
std::string icon_name{};
|
||||
std::string icon_gray_name{};
|
||||
int icon_handle = 0;
|
||||
int icon_gray_handle = 0;
|
||||
uint32 progress{};
|
||||
uint32 max_progress{};
|
||||
bool hidden{};
|
||||
|
@ -356,8 +356,8 @@ void Steam_Overlay::load_achievements_data()
|
||||
ach.unlock_time = 0;
|
||||
}
|
||||
|
||||
ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true);
|
||||
ach.icon_gray_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false);
|
||||
ach.icon_handle = steamUserStats->get_achievement_icon_handle(ach.name, true);
|
||||
ach.icon_gray_handle = steamUserStats->get_achievement_icon_handle(ach.name, false);
|
||||
|
||||
float pnMinProgress = 0, pnMaxProgress = 0;
|
||||
if (steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress)) {
|
||||
@ -1285,27 +1285,22 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved)
|
||||
if (!_renderer) return false;
|
||||
|
||||
std::weak_ptr<uint64_t> &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
|
||||
const std::string &icon_name = achieved ? ach.icon_name : ach.icon_gray_name;
|
||||
const int icon_handle = achieved ? ach.icon_handle : ach.icon_gray_handle;
|
||||
uint8_t &load_trials = achieved ? ach.icon_load_trials : ach.icon_gray_load_trials;
|
||||
|
||||
if (!icon_rsrc.expired()) return true;
|
||||
|
||||
if (load_trials && icon_name.size()) {
|
||||
if (load_trials) {
|
||||
--load_trials;
|
||||
std::string file_path(Local_Storage::get_game_settings_path() + icon_name);
|
||||
unsigned int file_size = file_size_(file_path);
|
||||
|
||||
int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
|
||||
if (file_size) {
|
||||
std::string img(Local_Storage::load_image_resized(file_path, "", icon_size));
|
||||
if (img.size()) {
|
||||
icon_rsrc = _renderer->CreateImageResource(
|
||||
(void*)img.c_str(),
|
||||
icon_size, icon_size);
|
||||
|
||||
if (!icon_rsrc.expired()) load_trials = Overlay_Achievement::ICON_LOAD_MAX_TRIALS;
|
||||
PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)!icon_rsrc.expired());
|
||||
}
|
||||
auto image_info = settings->get_image(icon_handle);
|
||||
if (image_info) {
|
||||
int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
|
||||
icon_rsrc = _renderer->CreateImageResource(
|
||||
(void*)image_info->data.c_str(),
|
||||
icon_size, icon_size);
|
||||
|
||||
if (!icon_rsrc.expired()) load_trials = Overlay_Achievement::ICON_LOAD_MAX_TRIALS;
|
||||
PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)!icon_rsrc.expired());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user