From 2f184cc171b7cab25dabea442375c8a914ad0e70 Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Sun, 9 Jun 2024 13:59:21 -0600 Subject: [PATCH] Added game title, serial and version to sdl window. --- src/common/config.h | 1 + src/run.h | 18 ++++++++++-------- src/sdl_window.cpp | 10 +++++++--- src/sdl_window.h | 5 ++++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/common/config.h b/src/common/config.h index 8591ccdc..0a3b4905 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "types.h" namespace Config { diff --git a/src/run.h b/src/run.h index 28c4e57c..9d495d1b 100644 --- a/src/run.h +++ b/src/run.h @@ -36,14 +36,12 @@ public: s32 width = Config::getScreenWidth(); s32 height = Config::getScreenHeight(); - auto* controller = Common::Singleton::Instance(); - Frontend::WindowSDL window{width, height, controller}; - g_window = &window; - auto* mnt = Common::Singleton::Instance(); std::filesystem::path p = std::string(ebootPath); mnt->Mount(p.parent_path(), "/app0"); - + std::string id; + std::string title; + std::string app_version; // Loading param.sfo file if exists std::filesystem::path sce_sys_folder = p.parent_path() / "sce_sys"; if (std::filesystem::is_directory(sce_sys_folder)) { @@ -51,11 +49,11 @@ public: if (entry.path().filename() == "param.sfo") { auto* param_sfo = Common::Singleton::Instance(); param_sfo->open(sce_sys_folder.string() + "/param.sfo", {}); - std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); - std::string title(param_sfo->GetString("TITLE")); + id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); + 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") { @@ -70,6 +68,10 @@ public: } } + auto* controller = Common::Singleton::Instance(); + Frontend::WindowSDL window{width, height, controller, title, id, app_version}; + g_window = &window; + auto linker = Common::Singleton::Instance(); Libraries::InitHLELibs(&linker->GetHLESymbols()); linker->LoadModule(ebootPath); diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 51369c79..878e7164 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -12,15 +12,19 @@ namespace Frontend { -WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_) +WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_, + std::string_view game_title_, std::string_view game_serial_, + std::string_view game_appver_) : width{width_}, height{height_}, controller{controller_} { if (SDL_Init(SDL_INIT_VIDEO) < 0) { UNREACHABLE_MSG("Failed to initialize SDL video subsystem: {}", SDL_GetError()); } - const std::string title = "shadPS4 v" + std::string(Common::VERSION); + const std::string windowTitle = "shadPS4 v" + std::string(Common::VERSION) + " | " + + game_serial_.data() + " - " + game_title_.data() + " (v" + + game_appver_.data() + ")"; SDL_PropertiesID props = SDL_CreateProperties(); - SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str()); + SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, windowTitle.c_str()); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SDL_WINDOWPOS_CENTERED); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, width); diff --git a/src/sdl_window.h b/src/sdl_window.h index 13ee7864..c886e527 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; @@ -39,7 +40,9 @@ 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_view game_title_, std::string_view game_serial_, + std::string_view game_appver_); ~WindowSDL(); s32 getWidth() const {