GS window title: use a template system to satisfy everyone

This allows to choose which items appear at the title and at which order, as
well as the text and some of the textual values (at PCSX2_ui.ini).

The template's variables (include % if relevant but not the surrounding text):
${slot}, ${limiter}, ${speed}, ${vfps}, ${cpuusage}, ${omodef}, ${omodei}, ${gsdx}

The system treats the GSdx info as a single unit, as well as the CPU usage info.
The UI section (at the CPU usage section) is only visible in devel/debug builds.

The current template values which also demonstrate all the configurable values:
[UiTemplates]
LimiterUnlimited=-unlimited
LimiterTurbo=-turbo
LimiterSlowmo=-slowmo
LimiterNormal=
OutputFrame=frame
OutputField=field
OutputProgressive=p
OutputInterlaced=i
TitleTemplate=Slot: ${slot} | Speed${limiter}: ${speed} (${vfps}) | ${cpuusage} | ${omodef}-${omodei} | ${gsdx}

The previous longer template values:
[UiTemplates]
LimiterUnlimited=None
LimiterTurbo=Turbo
LimiterSlowmo=Slomo
LimiterNormal=Normal
OutputFrame=Frame
OutputField=Field
OutputProgressive=Progressive
OutputInterlaced=Interlaced
TitleTemplate=${gsdx} | Limiter: ${limiter} | ${omodei} (${omodef}) | Speed: ${speed} (${vfps}) | ${cpuusage} | State: ${slot}
This commit is contained in:
Avi Halachmi (:avih) 2015-10-08 05:48:16 +03:00
parent 4e22dc4987
commit 9b988ee12d
3 changed files with 64 additions and 13 deletions

View File

@ -686,6 +686,7 @@ void AppConfig::LoadSave( IniInterface& ini )
BaseFilenames .LoadSave( ini );
GSWindow .LoadSave( ini );
Framerate .LoadSave( ini );
Templates .LoadSave( ini );
ini.Flush();
}
@ -928,6 +929,34 @@ void AppConfig::FramerateOptions::LoadSave( IniInterface& ini )
IniEntry( SkipOnTurbo );
}
AppConfig::UiTemplateOptions::UiTemplateOptions()
{
LimiterUnlimited = L"-unlimited";
LimiterTurbo = L"-turbo";
LimiterSlowmo = L"-slowmo";
LimiterNormal = L"";
OutputFrame = L"frame";
OutputField = L"field";
OutputProgressive = L"p";
OutputInterlaced = L"i";
TitleTemplate = L"Slot: ${slot} | Speed${limiter}: ${speed} (${vfps}) | ${cpuusage} | ${omodef}-${omodei} | ${gsdx}";
}
void AppConfig::UiTemplateOptions::LoadSave(IniInterface& ini)
{
ScopedIniGroup path(ini, L"UiTemplates");
IniEntry(LimiterUnlimited);
IniEntry(LimiterTurbo);
IniEntry(LimiterSlowmo);
IniEntry(LimiterNormal);
IniEntry(OutputFrame);
IniEntry(OutputField);
IniEntry(OutputProgressive);
IniEntry(OutputInterlaced);
IniEntry(TitleTemplate);
}
int AppConfig::GetMaxPresetIndex()
{
return 5;

View File

@ -241,6 +241,21 @@ public:
void SanityCheck();
};
struct UiTemplateOptions {
UiTemplateOptions();
void LoadSave(IniInterface& conf);
wxString LimiterUnlimited;
wxString LimiterTurbo;
wxString LimiterSlowmo;
wxString LimiterNormal;
wxString OutputFrame;
wxString OutputField;
wxString OutputProgressive;
wxString OutputInterlaced;
wxString TitleTemplate;
};
public:
wxPoint MainGuiPosition;
@ -311,6 +326,7 @@ public:
FilenameOptions BaseFilenames;
GSWindowOptions GSWindow;
FramerateOptions Framerate;
UiTemplateOptions Templates;
// PCSX2-core emulation options, which are passed to the emu core prior to initiating
// an emulation session. Note these are the options saved into the GUI ini file and

View File

@ -555,6 +555,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
// an intermediate white screen appears too which leads to a very annoying flickering.
if (IsFullScreen()) return;
#endif
AppConfig::UiTemplateOptions& templates = g_Conf->Templates;
double fps = wxGetApp().FpsManager.GetFramerate();
// The "not PAL" case covers both Region_NTSC and Region_NTSC_PROGRESSIVE
@ -564,15 +565,15 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
gsDest[0] = 0; // No need to set whole array to NULL.
GSgetTitleInfo2( gsDest, sizeof(gsDest) );
const wxChar* limiterStr = L"-unlimited";
const wxChar* limiterStr = templates.LimiterUnlimited;
if( g_Conf->EmuOptions.GS.FrameLimitEnable )
{
switch( g_LimiterMode )
{
case Limit_Nominal: limiterStr = L""; break;
case Limit_Turbo: limiterStr = L"-turbo"; break;
case Limit_Slomo: limiterStr = L"-slowmo"; break;
case Limit_Nominal: limiterStr = templates.LimiterNormal; break;
case Limit_Turbo: limiterStr = templates.LimiterTurbo; break;
case Limit_Slomo: limiterStr = templates.LimiterSlowmo; break;
}
}
@ -580,7 +581,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
if (m_CpuUsage.IsImplemented()) {
m_CpuUsage.UpdateStats();
cpuUsage.Write(L" | EE: %3d%%", m_CpuUsage.GetEEcorePct());
cpuUsage.Write(L"EE: %3d%%", m_CpuUsage.GetEEcorePct());
cpuUsage.Write(L" | GS: %3d%%", m_CpuUsage.GetGsPct());
if (THREAD_VU1)
@ -590,15 +591,20 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
}
const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2);
wxString omodef = (smode2 & 2) ? templates.OutputFrame : templates.OutputField;
wxString omodei = (smode2 & 1) ? templates.OutputInterlaced : templates.OutputProgressive;
SetTitle( pxsFmt( L"Slot %d | Speed%ls: %3d%% (%.02f)%ls | %ls-%ls | %s",
States_GetCurrentSlot(),
limiterStr, lround(per), fps,
cpuUsage.c_str(),
(smode2 & 2) ? L"frame" : L"field",
(smode2 & 1) ? L"i" : L"p",
WX_STR(fromUTF8(gsDest)))
);
wxString title = templates.TitleTemplate;
title.Replace(L"${slot}", pxsFmt(L"%d", States_GetCurrentSlot()));
title.Replace(L"${limiter}", limiterStr);
title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(per)));
title.Replace(L"${vfps}", pxsFmt(L"%.02f", fps));
title.Replace(L"${cpuusage}", cpuUsage);
title.Replace(L"${omodef}", omodef);
title.Replace(L"${omodei}", omodei);
title.Replace(L"${gsdx}", fromUTF8(gsDest));
SetTitle(title);
}
void GSFrame::OnActivate( wxActivateEvent& evt )