diff --git a/src/common/Settings.cpp b/src/common/Settings.cpp index 55d720b81..086fbe305 100644 --- a/src/common/Settings.cpp +++ b/src/common/Settings.cpp @@ -117,8 +117,11 @@ static struct { static const char* section_overlay = "overlay"; static struct { + const char* build_hash = "Build Hash"; const char* FPS = "FPS"; const char* hle_lle_stats = "HLE/LLE Stats"; + const char* title_name = "Title Name"; + const char* file_name = "File Name"; } sect_overlay_keys; static const char* section_audio = "audio"; @@ -547,8 +550,11 @@ bool Settings::LoadConfig() // ==== Overlay Begin ========= + m_overlay.build_hash = m_si.GetBoolValue(section_overlay, sect_overlay_keys.build_hash, false); m_overlay.fps = m_si.GetBoolValue(section_overlay, sect_overlay_keys.FPS, false); m_overlay.hle_lle_stats = m_si.GetBoolValue(section_overlay, sect_overlay_keys.hle_lle_stats, false); + m_overlay.title_name = m_si.GetBoolValue(section_overlay, sect_overlay_keys.title_name, false); + m_overlay.file_name = m_si.GetBoolValue(section_overlay, sect_overlay_keys.file_name, false); // ==== Overlay End =========== @@ -735,8 +741,11 @@ bool Settings::Save(std::string file_path) // ==== Overlay Begin ======= + m_si.SetBoolValue(section_overlay, sect_overlay_keys.build_hash, m_overlay.build_hash, nullptr, true); m_si.SetBoolValue(section_overlay, sect_overlay_keys.FPS, m_overlay.fps, nullptr, true); m_si.SetBoolValue(section_overlay, sect_overlay_keys.hle_lle_stats, m_overlay.hle_lle_stats, nullptr, true); + m_si.SetBoolValue(section_overlay, sect_overlay_keys.title_name, m_overlay.title_name, nullptr, true); + m_si.SetBoolValue(section_overlay, sect_overlay_keys.file_name, m_overlay.file_name, nullptr, true); // ==== Overlay End ========= diff --git a/src/common/xbe/Xbe.cpp b/src/common/xbe/Xbe.cpp index 31e0343c2..9e1e11323 100644 --- a/src/common/xbe/Xbe.cpp +++ b/src/common/xbe/Xbe.cpp @@ -41,8 +41,6 @@ #include "common/AddressRanges.h" #include "common/xbox/Types.hpp" -namespace fs = std::filesystem; - #ifdef CXBXR_EMU extern "C" void CxbxKrnlPrintUEM(ULONG); #endif @@ -58,12 +56,11 @@ Xbe::Xbe(const char *x_szFilename, bool bFromGUI) FILE *XbeFile = fopen(x_szFilename, "rb"); - // verify Xbe file was opened successfully - if(XbeFile == 0) - { - using namespace fs; // limit its scope inside here + std::string XbeName = std::filesystem::path(x_szFilename).filename().string(); // recover the xbe name + + // verify Xbe file was opened successfully + if(XbeFile == 0) { - std::string XbeName = path(x_szFilename).filename().string(); // recover the xbe name // NOTE: the check for the existence of the child window is necessary because the user could have previously loaded the dashboard, // removed/changed the path and attempt to load it again from the recent list, which will crash CxbxInitWindow below // Note that GetHwnd(), CxbxKrnl_hEmuParent and HalReturnToFirmware are all not suitable here for various reasons @@ -96,7 +93,7 @@ Xbe::Xbe(const char *x_szFilename, bool bFromGUI) SetFatalError(std::string("Could not open the Xbe file ") + XbeName); return; } - } + } printf("OK\n"); @@ -111,6 +108,14 @@ Xbe::Xbe(const char *x_szFilename, bool bFromGUI) *(++c) = '\0'; } + printf("OK\n"); + + // remember the Xbe file name + { + printf("Xbe::Xbe: Storing Xbe File Name..."); + strncpy(m_szFileName, XbeName.c_str(), ARRAY_SIZE(m_szFileName) * sizeof(char)); + } + printf("OK\n"); // read Xbe image header diff --git a/src/common/xbe/Xbe.h b/src/common/xbe/Xbe.h index bc19eabc1..81d8dfe3e 100644 --- a/src/common/xbe/Xbe.h +++ b/src/common/xbe/Xbe.h @@ -258,6 +258,9 @@ class Xbe : public Error // Xbe original path char m_szPath[MAX_PATH]; + // Xbe original file name + char m_szFileName[MAX_PATH]; + // Xbe ascii title, translated from certificate title char m_szAsciiTitle[41]; diff --git a/src/core/common/imgui/settings.h b/src/core/common/imgui/settings.h index 9b9e56682..32b3ae891 100644 --- a/src/core/common/imgui/settings.h +++ b/src/core/common/imgui/settings.h @@ -27,8 +27,11 @@ // Intended to store as permanent settings typedef struct { + bool build_hash; bool fps; bool hle_lle_stats; + bool title_name; + bool file_name; } overlay_settings; // Intended for EmuShared only below diff --git a/src/core/common/imgui/ui.cpp b/src/core/common/imgui/ui.cpp index ac1d02fde..cca59231a 100644 --- a/src/core/common/imgui/ui.cpp +++ b/src/core/common/imgui/ui.cpp @@ -120,8 +120,11 @@ void ImGuiUI::DrawMenu() if (ImGui::BeginMenu("Settings")) { if (ImGui::BeginMenu("Overlay")) { bool bChanged = false; + bChanged |= ImGui::MenuItem("Show Build Hash", NULL, &m_settings.build_hash); bChanged |= ImGui::MenuItem("Show FPS", NULL, &m_settings.fps); bChanged |= ImGui::MenuItem("Show HLE/LLE Stats", NULL, &m_settings.hle_lle_stats); + bChanged |= ImGui::MenuItem("Show Title Name", NULL, &m_settings.title_name); + bChanged |= ImGui::MenuItem("Show File Name", NULL, &m_settings.file_name); if (bChanged) { g_EmuShared->SetOverlaySettings(&m_settings); ipc_send_gui_update(IPC_UPDATE_GUI::OVERLAY, 1); @@ -139,14 +142,18 @@ void ImGuiUI::DrawMenu() void ImGuiUI::DrawWidgets() { - if (m_settings.fps || m_settings.hle_lle_stats) { + + if (m_settings.fps + || m_settings.hle_lle_stats + ||m_settings.title_name + || m_settings.file_name) { ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - (IMGUI_MIN_DIST_SIDE/* * m_backbuffer_scale*/), IMGUI_MIN_DIST_TOP/* * m_backbuffer_scale*/), ImGuiCond_Always, ImVec2(1.0f, 0.0f)); ImGui::SetNextWindowSize(ImVec2(200.0f/* * m_backbuffer_scale*/, 0.0f)); ImGui::SetNextWindowBgAlpha(0.5f); - if (ImGui::Begin("overlay_stats", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoNav | + if (ImGui::Begin("overlay_stats_topright", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) { @@ -180,8 +187,36 @@ void ImGuiUI::DrawWidgets() - ImGui::GetScrollX() - 2 * ImGui::GetStyle().ItemSpacing.x); ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), flagString.c_str()); } - ImGui::End(); + + if (m_settings.title_name) { + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Title: %.41s", CxbxKrnl_Xbe->m_szAsciiTitle); + } + + if (m_settings.file_name) { + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "File: %.260s", CxbxKrnl_Xbe->m_szFileName); + } + } + ImGui::End(); + } + + if (m_settings.build_hash) { + + ImGui::SetNextWindowPos(ImVec2(IMGUI_MIN_DIST_SIDE, ImGui::GetIO().DisplaySize.y - IMGUI_MIN_DIST_SIDE/* * m_backbuffer_scale*/), + ImGuiCond_Always, ImVec2(0.0f, 1.0f)); + + //ImGui::SetNextWindowSize(ImVec2(200.0f/* * m_backbuffer_scale*/, 0.0f)); + ImGui::SetNextWindowBgAlpha(0.5f); + if (ImGui::Begin("overlay_stats_bottom", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) { + + if (m_settings.build_hash) { + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Build: %s", GetGitVersionStr()); + } + + } + ImGui::End(); } ImGuiWindowFlags input_handler = m_is_focus ? ImGuiWindowFlags_None : ImGuiWindowFlags_NoInputs; diff --git a/src/core/common/imgui/video.cpp b/src/core/common/imgui/video.cpp index 8cad468d5..de2a90cb9 100644 --- a/src/core/common/imgui/video.cpp +++ b/src/core/common/imgui/video.cpp @@ -50,8 +50,8 @@ void ImGuiVideo::DrawWidgets(bool is_focus, ImGuiWindowFlags input_handler) if (ImGui::CollapsingHeader("Vertex Buffer Cache", ImGuiTreeNodeFlags_DefaultOpen)) { VertexBufferConverter.DrawCacheStats(); } - ImGui::End(); } + ImGui::End(); } // Render the lightgun laser