sdl window: Added game title (serial, title and app_ver)

This commit is contained in:
raziel1000 2024-07-24 00:12:53 -06:00 committed by georgemoralis
parent f29293c9fb
commit f35518d527
3 changed files with 17 additions and 9 deletions

View File

@ -51,9 +51,6 @@ Emulator::Emulator() {
memory = Core::Memory::Instance(); memory = Core::Memory::Instance();
controller = Common::Singleton<Input::GameController>::Instance(); controller = Common::Singleton<Input::GameController>::Instance();
linker = Common::Singleton<Core::Linker>::Instance(); linker = Common::Singleton<Core::Linker>::Instance();
window = std::make_unique<Frontend::WindowSDL>(WindowWidth, WindowHeight, controller);
g_window = window.get();
} }
Emulator::~Emulator() { Emulator::~Emulator() {
@ -68,6 +65,8 @@ void Emulator::Run(const std::filesystem::path& file) {
// Loading param.sfo file if exists // Loading param.sfo file if exists
std::string id; std::string id;
std::string title;
std::string app_version;
std::filesystem::path sce_sys_folder = file.parent_path() / "sce_sys"; std::filesystem::path sce_sys_folder = file.parent_path() / "sce_sys";
if (std::filesystem::is_directory(sce_sys_folder)) { if (std::filesystem::is_directory(sce_sys_folder)) {
for (const auto& entry : std::filesystem::directory_iterator(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<PSF>::Instance(); auto* param_sfo = Common::Singleton<PSF>::Instance();
param_sfo->open(sce_sys_folder.string() + "/param.sfo", {}); param_sfo->open(sce_sys_folder.string() + "/param.sfo", {});
id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); 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); LOG_INFO(Loader, "Game id: {} Title: {}", id, title);
u32 fw_version = param_sfo->GetInteger("SYSTEM_VER"); 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); LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version);
} else if (entry.path().filename() == "pic0.png" || } else if (entry.path().filename() == "pic0.png" ||
entry.path().filename() == "pic1.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<Frontend::WindowSDL>(WindowWidth, WindowHeight, controller, game_title);
g_window = window.get();
const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir) / id; const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir) / id;
if (!std::filesystem::exists(mount_data_dir)) { if (!std::filesystem::exists(mount_data_dir)) {

View File

@ -18,14 +18,15 @@
namespace Frontend { namespace Frontend {
WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_) WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_,
: width{width_}, height{height_}, controller{controller_} { std::string game_title_)
: width{width_}, height{height_}, controller{controller_}, game_title{game_title_} {
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
UNREACHABLE_MSG("Failed to initialize SDL video subsystem: {}", SDL_GetError()); UNREACHABLE_MSG("Failed to initialize SDL video subsystem: {}", SDL_GetError());
} }
SDL_InitSubSystem(SDL_INIT_AUDIO); 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_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, title.c_str());
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED);

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <string>
#include "common/types.h" #include "common/types.h"
struct SDL_Window; struct SDL_Window;
@ -40,7 +41,8 @@ struct WindowSystemInfo {
class WindowSDL { class WindowSDL {
public: public:
explicit WindowSDL(s32 width, s32 height, Input::GameController* controller); explicit WindowSDL(s32 width, s32 height, Input::GameController* controller,
std::string game_title);
~WindowSDL(); ~WindowSDL();
s32 getWidth() const { s32 getWidth() const {
@ -68,6 +70,7 @@ private:
private: private:
s32 width; s32 width;
s32 height; s32 height;
std::string game_title;
Input::GameController* controller; Input::GameController* controller;
WindowSystemInfo window_info{}; WindowSystemInfo window_info{};
SDL_Window* window{}; SDL_Window* window{};