1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Add more game window title options

This commit is contained in:
Megamouse 2020-02-20 03:55:25 +01:00
parent dd85e733d3
commit 0dd417e5f2
7 changed files with 93 additions and 32 deletions

View File

@ -75,9 +75,8 @@ bool utils::has_clwb()
return g_value;
}
std::string utils::get_system_info()
std::string utils::get_cpu_brand()
{
std::string result;
std::string brand;
if (get_cpuid(0x80000000, 0)[0] >= 0x80000004)
@ -101,18 +100,16 @@ std::string utils::get_system_info()
brand.erase(brand.begin() + found);
}
#ifdef _WIN32
::SYSTEM_INFO sysInfo;
::GetNativeSystemInfo(&sysInfo);
::MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(memInfo);
::GlobalMemoryStatusEx(&memInfo);
const u32 num_proc = sysInfo.dwNumberOfProcessors;
const u64 mem_total = memInfo.ullTotalPhys;
#else
const u32 num_proc = ::sysconf(_SC_NPROCESSORS_ONLN);
const u64 mem_total = ::sysconf(_SC_PHYS_PAGES) * ::sysconf(_SC_PAGE_SIZE);
#endif
return brand;
}
std::string utils::get_system_info()
{
std::string result;
const std::string brand = get_cpu_brand();
const u64 mem_total = get_total_memory();
const u32 num_proc = get_thread_count();
fmt::append(result, "%s | %d Threads | %.2f GiB RAM", brand, num_proc, mem_total / (1024.0f * 1024 * 1024));
@ -242,3 +239,26 @@ ullong utils::get_tsc_freq()
return 0;
#endif
}
u64 utils::get_total_memory()
{
#ifdef _WIN32
::MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(memInfo);
::GlobalMemoryStatusEx(&memInfo);
return memInfo.ullTotalPhys;
#else
return ::sysconf(_SC_PHYS_PAGES) * ::sysconf(_SC_PAGE_SIZE);
#endif
}
u32 utils::get_thread_count()
{
#ifdef _WIN32
::SYSTEM_INFO sysInfo;
::GetNativeSystemInfo(&sysInfo);
return sysInfo.dwNumberOfProcessors;
#else
return ::sysconf(_SC_NPROCESSORS_ONLN);
#endif
}

View File

@ -47,6 +47,8 @@ namespace utils
bool has_clwb();
std::string get_cpu_brand();
std::string get_system_info();
std::string get_firmware_version();
@ -54,4 +56,8 @@ namespace utils
std::string get_OS_version();
ullong get_tsc_freq();
u64 get_total_memory();
u32 get_thread_count();
}

View File

@ -1,27 +1,12 @@
#include "stdafx.h"
#include "title.h"
#include "rpcs3_version.h"
#include "Utilities/sysinfo.h"
namespace rpcs3
{
std::string get_formatted_title(const title_format_data& title_data)
{
// Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
std::string version = rpcs3::get_version().to_string();
const auto last_minus = version.find_last_of('-');
// Add branch and commit hash to version on frame unless it's master.
if (rpcs3::get_branch() != "master"sv && rpcs3::get_branch() != "HEAD"sv)
{
version = version.substr(0, ~last_minus ? last_minus + 9 : last_minus);
version += '-';
version += rpcs3::get_branch();
}
else
{
version = version.substr(0, last_minus);
}
// Parse title format string
std::string title_string;
@ -71,6 +56,7 @@ namespace rpcs3
}
case 'V':
{
static const std::string version = rpcs3::get_version_and_branch();
title_string += version;
break;
}
@ -79,6 +65,27 @@ namespace rpcs3
fmt::append(title_string, "%.2f", title_data.fps);
break;
}
case 'G':
{
title_string += title_data.vulkan_adapter;
break;
}
case 'C':
{
static const std::string brand = utils::get_cpu_brand();
title_string += brand;
break;
}
case 'c':
{
fmt::append(title_string, "%d", utils::get_thread_count());
break;
}
case 'M':
{
fmt::append(title_string, "%.2f", utils::get_total_memory() / (1024.0f * 1024 * 1024));
break;
}
default:
{
title_string += '%';

View File

@ -10,6 +10,7 @@ namespace rpcs3
std::string title;
std::string title_id;
std::string renderer;
std::string vulkan_adapter;
double fps = .0;
};

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "rpcs3_version.h"
#include "git-version.h"
#include "Utilities/StrUtil.h"
@ -26,4 +26,25 @@ namespace rpcs3
static constexpr utils::version version{ 0, 0, 8, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
return version;
}
std::string get_version_and_branch()
{
// Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
std::string version = rpcs3::get_version().to_string();
const auto last_minus = version.find_last_of('-');
// Add branch and commit hash to version on frame unless it's master.
if (rpcs3::get_branch() != "master"sv && rpcs3::get_branch() != "HEAD"sv)
{
version = version.substr(0, ~last_minus ? last_minus + 9 : last_minus);
version += '-';
version += rpcs3::get_branch();
}
else
{
version = version.substr(0, last_minus);
}
return version;
}
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <cstdint>
#include <Utilities/version.h>
@ -8,4 +8,5 @@ namespace rpcs3
std::string_view get_branch();
std::pair<std::string, std::string> get_commit_and_hash();
const utils::version& get_version();
std::string get_version_and_branch();
}

View File

@ -1304,6 +1304,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
rpcs3::title_format_data title_data;
title_data.format = sstr(new_format);
title_data.renderer = xemu_settings->GetSetting(emu_settings::Renderer);
title_data.vulkan_adapter = xemu_settings->GetSetting(emu_settings::VulkanAdapter);
title_data.fps = 60.;
if (game)
@ -1326,6 +1327,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
const std::vector<std::pair<const QString, const QString>> window_title_glossary =
{
{ "%G", tr("GPU Model") },
{ "%C", tr("CPU Model") },
{ "%c", tr("Thread Count") },
{ "%M", tr("System Memory") },
{ "%F", tr("Framerate") },
{ "%R", tr("Renderer") },
{ "%T", tr("Title") },