mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-08-11 01:45:34 +02:00
properly update ingame_overlay, thanks to debugzxcv
This commit is contained in:
parent
ac12cecc2e
commit
f84346e5e2
4 changed files with 35 additions and 28 deletions
|
@ -71,8 +71,8 @@ struct Overlay_Achievement
|
||||||
bool hidden{};
|
bool hidden{};
|
||||||
bool achieved{};
|
bool achieved{};
|
||||||
uint32 unlock_time{};
|
uint32 unlock_time{};
|
||||||
std::weak_ptr<uint64_t> icon{};
|
InGameOverlay::RendererResource_t* icon{} = nullptr;
|
||||||
std::weak_ptr<uint64_t> icon_gray{};
|
InGameOverlay::RendererResource_t* icon_gray{} = nullptr;
|
||||||
int icon_handle = Settings::UNLOADED_IMAGE_HANDLE;
|
int icon_handle = Settings::UNLOADED_IMAGE_HANDLE;
|
||||||
int icon_gray_handle = Settings::UNLOADED_IMAGE_HANDLE;
|
int icon_gray_handle = Settings::UNLOADED_IMAGE_HANDLE;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ static constexpr int base_notif_window_id = 0 * max_window_id;
|
||||||
static constexpr int base_friend_window_id = 1 * max_window_id;
|
static constexpr int base_friend_window_id = 1 * max_window_id;
|
||||||
static constexpr int base_friend_item_id = 2 * max_window_id;
|
static constexpr int base_friend_item_id = 2 * max_window_id;
|
||||||
|
|
||||||
static const std::set<InGameOverlay::ToggleKey> overlay_toggle_keys = {
|
static InGameOverlay::ToggleKey overlay_toggle_keys[] = {
|
||||||
InGameOverlay::ToggleKey::SHIFT, InGameOverlay::ToggleKey::TAB
|
InGameOverlay::ToggleKey::SHIFT, InGameOverlay::ToggleKey::TAB
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ bool Steam_Overlay::renderer_hook_proc()
|
||||||
PRINT_DEBUG("renderer hook was null!");
|
PRINT_DEBUG("renderer hook was null!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PRINT_DEBUG("got renderer hook %p for '%s'", _renderer, _renderer->GetLibraryName().c_str());
|
PRINT_DEBUG("got renderer hook %p for '%s'", _renderer, _renderer->GetLibraryName());
|
||||||
|
|
||||||
// note: make sure to load all relevant strings before creating the font(s), otherwise some glyphs ranges will be missing
|
// note: make sure to load all relevant strings before creating the font(s), otherwise some glyphs ranges will be missing
|
||||||
load_achievements_data();
|
load_achievements_data();
|
||||||
|
@ -218,7 +218,7 @@ bool Steam_Overlay::renderer_hook_proc()
|
||||||
overlay_state_hook(state == InGameOverlay::OverlayHookState::Ready || state == InGameOverlay::OverlayHookState::Reset);
|
overlay_state_hook(state == InGameOverlay::OverlayHookState::Ready || state == InGameOverlay::OverlayHookState::Reset);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool started = _renderer->StartHook(overlay_toggle_callback, overlay_toggle_keys, &fonts_atlas);
|
bool started = _renderer->StartHook(overlay_toggle_callback, overlay_toggle_keys, 2, &fonts_atlas);
|
||||||
PRINT_DEBUG("started renderer hook (result=%i)", (int)started);
|
PRINT_DEBUG("started renderer hook (result=%i)", (int)started);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -361,7 +361,12 @@ void Steam_Overlay::load_achievements_data()
|
||||||
ach.progress = (uint32)pnMinProgress;
|
ach.progress = (uint32)pnMinProgress;
|
||||||
ach.max_progress = (uint32)pnMaxProgress;
|
ach.max_progress = (uint32)pnMaxProgress;
|
||||||
}
|
}
|
||||||
|
if (ach.icon == nullptr) {
|
||||||
|
ach.icon = _renderer->CreateResource();
|
||||||
|
}
|
||||||
|
if (ach.icon_gray == nullptr) {
|
||||||
|
ach.icon_gray = _renderer->CreateResource();
|
||||||
|
}
|
||||||
achievements.emplace_back(ach);
|
achievements.emplace_back(ach);
|
||||||
|
|
||||||
if (!setup_overlay_called) return;
|
if (!setup_overlay_called) return;
|
||||||
|
@ -1057,13 +1062,13 @@ void Steam_Overlay::build_notifications(float width, float height)
|
||||||
auto &icon_rsrc = (notification_type)it->type == notification_type::achievement
|
auto &icon_rsrc = (notification_type)it->type == notification_type::achievement
|
||||||
? ach.icon
|
? ach.icon
|
||||||
: ach.icon_gray;
|
: ach.icon_gray;
|
||||||
if (!icon_rsrc.expired() && ImGui::BeginTable("imgui_table", 2)) {
|
if (icon_rsrc->GetResourceId() != 0 && ImGui::BeginTable("imgui_table", 2)) {
|
||||||
ImGui::TableSetupColumn("imgui_table_image", ImGuiTableColumnFlags_WidthFixed, settings->overlay_appearance.icon_size);
|
ImGui::TableSetupColumn("imgui_table_image", ImGuiTableColumnFlags_WidthFixed, settings->overlay_appearance.icon_size);
|
||||||
ImGui::TableSetupColumn("imgui_table_text");
|
ImGui::TableSetupColumn("imgui_table_text");
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size);
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::Image((ImTextureID)*icon_rsrc.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));
|
ImGui::Image(icon_rsrc->GetResourceId(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::TextWrapped("%s", it->message.c_str());
|
ImGui::TextWrapped("%s", it->message.c_str());
|
||||||
|
@ -1208,7 +1213,7 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved, b
|
||||||
if (!settings->overlay_upload_achs_icons_to_gpu) return false; // don't upload anything to the GPU
|
if (!settings->overlay_upload_achs_icons_to_gpu) return false; // don't upload anything to the GPU
|
||||||
|
|
||||||
auto &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
|
auto &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
|
||||||
if (!icon_rsrc.expired()) return true;
|
if (icon_rsrc->GetResourceId() != 0) return true;
|
||||||
|
|
||||||
// icons needs to be loaded, but we're not allowed
|
// icons needs to be loaded, but we're not allowed
|
||||||
if (!upload_new_icon_to_gpu) return false;
|
if (!upload_new_icon_to_gpu) return false;
|
||||||
|
@ -1220,11 +1225,10 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved, b
|
||||||
auto image_info = settings->get_image(icon_handle);
|
auto image_info = settings->get_image(icon_handle);
|
||||||
if (image_info) {
|
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);
|
||||||
icon_rsrc = _renderer->CreateImageResource(
|
icon_rsrc->SetAutoLoad(InGameOverlay::ResourceAutoLoad_t::OnUse);
|
||||||
(void*)image_info->data.c_str(),
|
icon_rsrc->AttachResource((void*)image_info->data.c_str(), icon_size, icon_size);
|
||||||
icon_size, icon_size);
|
|
||||||
|
|
||||||
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->GetResourceId() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !icon_rsrc.expired();
|
return !icon_rsrc.expired();
|
||||||
|
@ -1325,7 +1329,7 @@ uint32 Steam_Overlay::apply_global_style_color()
|
||||||
void Steam_Overlay::render_main_window()
|
void Steam_Overlay::render_main_window()
|
||||||
{
|
{
|
||||||
char tmp[TRANSLATION_BUFFER_SIZE]{};
|
char tmp[TRANSLATION_BUFFER_SIZE]{};
|
||||||
snprintf(tmp, sizeof(tmp), translationRenderer[current_language], (_renderer == nullptr ? "Unknown" : _renderer->GetLibraryName().c_str()));
|
snprintf(tmp, sizeof(tmp), translationRenderer[current_language], (_renderer == nullptr ? "Unknown" : _renderer->GetLibraryName()));
|
||||||
std::string windowTitle{};
|
std::string windowTitle{};
|
||||||
// Note: don't translate this, project and author names are nouns, they must be kept intact for proper referral
|
// Note: don't translate this, project and author names are nouns, they must be kept intact for proper referral
|
||||||
// think of it as translating "Protobuf - Google"
|
// think of it as translating "Protobuf - Google"
|
||||||
|
@ -1432,7 +1436,7 @@ void Steam_Overlay::render_main_window()
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
bool could_create_ach_table_entry = false;
|
bool could_create_ach_table_entry = false;
|
||||||
if (!x.icon.expired() || !x.icon_gray.expired()) {
|
if (x.icon->GetResourceId() != 0 || x.icon_gray->GetResourceId() != 0) {
|
||||||
if (ImGui::BeginTable(x.title.c_str(), 2)) {
|
if (ImGui::BeginTable(x.title.c_str(), 2)) {
|
||||||
could_create_ach_table_entry = true;
|
could_create_ach_table_entry = true;
|
||||||
|
|
||||||
|
@ -1442,9 +1446,9 @@ void Steam_Overlay::render_main_window()
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
auto &icon_rsrc = achieved ? x.icon : x.icon_gray;
|
auto &icon_rsrc = achieved ? x.icon : x.icon_gray;
|
||||||
if (!icon_rsrc.expired()) {
|
if (icon_rsrc->GetResourceId() != 0) {
|
||||||
ImGui::Image(
|
ImGui::Image(
|
||||||
(ImTextureID)*icon_rsrc.lock().get(),
|
icon_rsrc->GetResourceId(),
|
||||||
ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)
|
ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1667,14 +1671,12 @@ void Steam_Overlay::UnSetupOverlay()
|
||||||
|
|
||||||
PRINT_DEBUG("releasing any images resources");
|
PRINT_DEBUG("releasing any images resources");
|
||||||
for (auto &ach : achievements) {
|
for (auto &ach : achievements) {
|
||||||
if (!ach.icon.expired()) {
|
if (ach.icon->GetResourceId() != 0) {
|
||||||
_renderer->ReleaseImageResource(ach.icon);
|
ach.icon->Unload();
|
||||||
ach.icon.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ach.icon_gray.expired()) {
|
if (ach.icon_gray->GetResourceId() != 0) {
|
||||||
_renderer->ReleaseImageResource(ach.icon_gray);
|
ach.icon_gray->Unload();
|
||||||
ach.icon_gray.reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -697,6 +697,7 @@ if _OPTIONS["build-ingame_overlay"] or _OPTIONS["all-build"] then
|
||||||
'INGAMEOVERLAY_USE_SYSTEM_LIBRARIES=OFF',
|
'INGAMEOVERLAY_USE_SYSTEM_LIBRARIES=OFF',
|
||||||
'INGAMEOVERLAY_USE_SPDLOG=OFF',
|
'INGAMEOVERLAY_USE_SPDLOG=OFF',
|
||||||
'INGAMEOVERLAY_BUILD_TESTS=OFF',
|
'INGAMEOVERLAY_BUILD_TESTS=OFF',
|
||||||
|
'INGAMEOVERLAY_DYNAMIC_RUNTIME=OFF',
|
||||||
}
|
}
|
||||||
-- fix missing standard include/header file for gcc/clang
|
-- fix missing standard include/header file for gcc/clang
|
||||||
local ingame_overlay_fixes = {}
|
local ingame_overlay_fixes = {}
|
||||||
|
@ -713,19 +714,23 @@ if _OPTIONS["build-ingame_overlay"] or _OPTIONS["all-build"] then
|
||||||
|
|
||||||
if _OPTIONS["32-build"] then
|
if _OPTIONS["32-build"] then
|
||||||
cmake_build('ingame_overlay/deps/System', true, {
|
cmake_build('ingame_overlay/deps/System', true, {
|
||||||
'BUILD_SYSTEMLIB_TESTS=OFF',
|
'SYSTEM_BUILD_TESTS=OFF',
|
||||||
|
'SYSTEM_DYNAMIC_RUNTIME=OFF',
|
||||||
}, nil, ingame_overlay_fixes)
|
}, nil, ingame_overlay_fixes)
|
||||||
cmake_build('ingame_overlay/deps/mini_detour', true, {
|
cmake_build('ingame_overlay/deps/mini_detour', true, {
|
||||||
'BUILD_MINIDETOUR_TESTS=OFF',
|
'MINIDETOUR_BUILD_TESTS=OFF',
|
||||||
|
'MINIDETOUR_DYNAMIC_RUNTIME=OFF',
|
||||||
})
|
})
|
||||||
cmake_build('ingame_overlay', true, ingame_overlay_common_defs, nil, ingame_overlay_fixes)
|
cmake_build('ingame_overlay', true, ingame_overlay_common_defs, nil, ingame_overlay_fixes)
|
||||||
end
|
end
|
||||||
if _OPTIONS["64-build"] then
|
if _OPTIONS["64-build"] then
|
||||||
cmake_build('ingame_overlay/deps/System', false, {
|
cmake_build('ingame_overlay/deps/System', false, {
|
||||||
'BUILD_SYSTEMLIB_TESTS=OFF',
|
'SYSTEM_BUILD_TESTS=OFF',
|
||||||
|
'SYSTEM_DYNAMIC_RUNTIME=OFF',
|
||||||
}, nil, ingame_overlay_fixes)
|
}, nil, ingame_overlay_fixes)
|
||||||
cmake_build('ingame_overlay/deps/mini_detour', false, {
|
cmake_build('ingame_overlay/deps/mini_detour', false, {
|
||||||
'BUILD_MINIDETOUR_TESTS=OFF',
|
'MINIDETOUR_BUILD_TESTS=OFF',
|
||||||
|
'MINIDETOUR_DYNAMIC_RUNTIME=OFF',
|
||||||
})
|
})
|
||||||
cmake_build('ingame_overlay', false, ingame_overlay_common_defs, nil, ingame_overlay_fixes)
|
cmake_build('ingame_overlay', false, ingame_overlay_common_defs, nil, ingame_overlay_fixes)
|
||||||
end
|
end
|
||||||
|
|
2
third-party/deps/common
vendored
2
third-party/deps/common
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 371c6fee3c63b8ebb4075bd31d421ea94c56dbcc
|
Subproject commit f43f9bdf19da89d110e5090169517530b42ac260
|
Loading…
Add table
Reference in a new issue