From f35518d527d9eebe876ecf7bd8baca4032959418 Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Wed, 24 Jul 2024 00:12:53 -0600 Subject: [PATCH] sdl window: Added game title (serial, title and app_ver) --- src/emulator.cpp | 14 +++++++++----- src/sdl_window.cpp | 7 ++++--- src/sdl_window.h | 5 ++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 47ac57ac..7985e9e2 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -51,9 +51,6 @@ Emulator::Emulator() { memory = Core::Memory::Instance(); controller = Common::Singleton::Instance(); linker = Common::Singleton::Instance(); - window = std::make_unique(WindowWidth, WindowHeight, controller); - - g_window = window.get(); } Emulator::~Emulator() { @@ -68,6 +65,8 @@ void Emulator::Run(const std::filesystem::path& file) { // Loading param.sfo file if exists std::string id; + std::string title; + std::string app_version; std::filesystem::path sce_sys_folder = file.parent_path() / "sce_sys"; if (std::filesystem::is_directory(sce_sys_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { @@ -75,10 +74,10 @@ void Emulator::Run(const std::filesystem::path& file) { auto* param_sfo = Common::Singleton::Instance(); param_sfo->open(sce_sys_folder.string() + "/param.sfo", {}); id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); - std::string title(param_sfo->GetString("TITLE")); + title = param_sfo->GetString("TITLE"); LOG_INFO(Loader, "Game id: {} Title: {}", id, title); u32 fw_version = param_sfo->GetInteger("SYSTEM_VER"); - std::string app_version = param_sfo->GetString("APP_VER"); + app_version = param_sfo->GetString("APP_VER"); LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version); } else if (entry.path().filename() == "pic0.png" || entry.path().filename() == "pic1.png") { @@ -92,6 +91,11 @@ void Emulator::Run(const std::filesystem::path& file) { } } } + std::string game_title = id + " - " + title + " <" + app_version + ">"; + window = + std::make_unique(WindowWidth, WindowHeight, controller, game_title); + + g_window = window.get(); const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir) / id; if (!std::filesystem::exists(mount_data_dir)) { diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index c4fcbcfa..c0e9afdd 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -18,14 +18,15 @@ namespace Frontend { -WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_) - : width{width_}, height{height_}, controller{controller_} { +WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_, + std::string game_title_) + : width{width_}, height{height_}, controller{controller_}, game_title{game_title_} { if (SDL_Init(SDL_INIT_VIDEO) < 0) { UNREACHABLE_MSG("Failed to initialize SDL video subsystem: {}", SDL_GetError()); } SDL_InitSubSystem(SDL_INIT_AUDIO); - const std::string title = "shadPS4 v" + std::string(Common::VERSION); + const std::string title = "shadPS4 v" + std::string(Common::VERSION) + " | " + game_title; SDL_PropertiesID props = SDL_CreateProperties(); SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str()); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED); diff --git a/src/sdl_window.h b/src/sdl_window.h index 6e14fbd0..688a4407 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -3,6 +3,7 @@ #pragma once +#include #include "common/types.h" struct SDL_Window; @@ -40,7 +41,8 @@ struct WindowSystemInfo { class WindowSDL { public: - explicit WindowSDL(s32 width, s32 height, Input::GameController* controller); + explicit WindowSDL(s32 width, s32 height, Input::GameController* controller, + std::string game_title); ~WindowSDL(); s32 getWidth() const { @@ -68,6 +70,7 @@ private: private: s32 width; s32 height; + std::string game_title; Input::GameController* controller; WindowSystemInfo window_info{}; SDL_Window* window{};