Permalink
Browse files

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}
  • Loading branch information...
1 parent 4e22dc4 commit 9b988ee12d09e1b05e08b7264bdbe7fab15c1fc6 @avih avih committed Oct 8, 2015
Showing with 65 additions and 14 deletions.
  1. +29 −0 pcsx2/gui/AppConfig.cpp
  2. +16 −0 pcsx2/gui/AppConfig.h
  3. +20 −14 pcsx2/gui/FrameForGS.cpp
@@ -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
@@ -241,6 +241,21 @@ class AppConfig
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 @@ class AppConfig
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
@@ -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,23 +565,23 @@ 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;
}
}
FastFormatUnicode cpuUsage;
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);
-
- 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 omodef = (smode2 & 2) ? templates.OutputFrame : templates.OutputField;
+ wxString omodei = (smode2 & 1) ? templates.OutputInterlaced : templates.OutputProgressive;
+
+ 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 )

5 comments on commit 9b988ee

@karasuhebi
Contributor

Why VFPS and not VPS or Hz? According to HyNES, which is the only other emulator I can find that mentions the term, "VFPS means virtual FPS, or frames that are being rendered, but not necessarily displayed". So it seems that the usage here is incorrect.

@karasuhebi
Contributor

Is there a way to make it so I can use spaces in the limiter string? Right now if I have LimiterTurbo= (Turbo) the space won't show up in the title bar. Obviously I could just add the space in the TitleTemplate string but then the space will always be there, even when the limiter is on normal.</.s>

EDIT: Never mind. I figured it out. I have to use quotes around the string value. So in the end it should look like this: LimiterTurbo=" (Turbo)".

Fun little factoid: This new template system seems to support UTF-8. Check out the infinity symbol in my title bar :D

@willkuer
Contributor

That's nice.

Now we need a gui element for that :P

@karasuhebi
Contributor

hint hint @turtleli ;P

@tsunami2311

possible of added a line so we can see what f7 does? there is no display for those settings

Please sign in to comment.