mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-27 05:04:01 +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 name{};
|
||||||
std::string title{};
|
std::string title{};
|
||||||
std::string description{};
|
std::string description{};
|
||||||
std::string icon_name{};
|
int icon_handle = 0;
|
||||||
std::string icon_gray_name{};
|
int icon_gray_handle = 0;
|
||||||
uint32 progress{};
|
uint32 progress{};
|
||||||
uint32 max_progress{};
|
uint32 max_progress{};
|
||||||
bool hidden{};
|
bool hidden{};
|
||||||
|
@ -356,8 +356,8 @@ void Steam_Overlay::load_achievements_data()
|
|||||||
ach.unlock_time = 0;
|
ach.unlock_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true);
|
ach.icon_handle = steamUserStats->get_achievement_icon_handle(ach.name, true);
|
||||||
ach.icon_gray_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false);
|
ach.icon_gray_handle = steamUserStats->get_achievement_icon_handle(ach.name, false);
|
||||||
|
|
||||||
float pnMinProgress = 0, pnMaxProgress = 0;
|
float pnMinProgress = 0, pnMaxProgress = 0;
|
||||||
if (steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress)) {
|
if (steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress)) {
|
||||||
@ -1285,29 +1285,24 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved)
|
|||||||
if (!_renderer) return false;
|
if (!_renderer) return false;
|
||||||
|
|
||||||
std::weak_ptr<uint64_t> &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
|
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;
|
uint8_t &load_trials = achieved ? ach.icon_load_trials : ach.icon_gray_load_trials;
|
||||||
|
|
||||||
if (!icon_rsrc.expired()) return true;
|
if (!icon_rsrc.expired()) return true;
|
||||||
|
|
||||||
if (load_trials && icon_name.size()) {
|
if (load_trials) {
|
||||||
--load_trials;
|
--load_trials;
|
||||||
std::string file_path(Local_Storage::get_game_settings_path() + icon_name);
|
auto image_info = settings->get_image(icon_handle);
|
||||||
unsigned int file_size = file_size_(file_path);
|
if (image_info) {
|
||||||
|
|
||||||
int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
|
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(
|
icon_rsrc = _renderer->CreateImageResource(
|
||||||
(void*)img.c_str(),
|
(void*)image_info->data.c_str(),
|
||||||
icon_size, icon_size);
|
icon_size, icon_size);
|
||||||
|
|
||||||
if (!icon_rsrc.expired()) load_trials = Overlay_Achievement::ICON_LOAD_MAX_TRIALS;
|
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());
|
PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)!icon_rsrc.expired());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return !icon_rsrc.expired();
|
return !icon_rsrc.expired();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user