GSdx OSD: Add Windows UI and new option

Adds Windows UI and option to limit the amount of log messages on the
screen at the same time/in the buffer.
This commit is contained in:
FlatOutPS2 2017-01-06 16:40:31 +01:00 committed by Jonathan Li
parent d42759c641
commit da57014eb8
11 changed files with 234 additions and 32 deletions

View File

@ -589,19 +589,35 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
{
double fps = wxGetApp().FpsManager.GetFramerate();
OSDmonitor(Color_StrongGreen, "EE:", std::to_string(m_CpuUsage.GetEEcorePct()).c_str());
OSDmonitor(Color_StrongGreen, "GS:", std::to_string(m_CpuUsage.GetGsPct()).c_str());
OSDmonitor(Color_StrongGreen, "UI:", std::to_string(m_CpuUsage.GetGuiPct()).c_str());
FastFormatUnicode cpuUsage;
if (m_CpuUsage.IsImplemented()) {
m_CpuUsage.UpdateStats();
if (!IsFullScreen()) {
cpuUsage.Write(L"EE: %3d%%", m_CpuUsage.GetEEcorePct());
cpuUsage.Write(L" | GS: %3d%%", m_CpuUsage.GetGsPct());
if (THREAD_VU1)
cpuUsage.Write(L" | VU: %3d%%", m_CpuUsage.GetVUPct());
pxNonReleaseCode(cpuUsage.Write(L" | UI: %3d%%", m_CpuUsage.GetGuiPct()));
}
if (THREAD_VU1)
OSDmonitor(Color_StrongGreen, "VU:", std::to_string(m_CpuUsage.GetVUPct()).c_str());
OSDmonitor(Color_StrongGreen, "EE:", std::to_string(m_CpuUsage.GetEEcorePct()).c_str());
OSDmonitor(Color_StrongGreen, "GS:", std::to_string(m_CpuUsage.GetGsPct()).c_str());
pxNonReleaseCode(OSDmonitor(Color_StrongGreen, "UI:", std::to_string(m_CpuUsage.GetGuiPct()).c_str()));
}
std::ostringstream out;
out << std::fixed << std::setprecision(2) << fps;
OSDmonitor(Color_StrongGreen, "FPS:", out.str());
#ifdef __linux__
// Important Linux note: When the title is set in fullscreen the window is redrawn. Unfortunately
// an intermediate white screen appears too which leads to a very annoying flickering.
if (IsFullScreen()) return;
#endif
AppConfig::UiTemplateOptions& templates = g_Conf->Templates;
@ -623,19 +639,6 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
}
}
FastFormatUnicode cpuUsage;
if (m_CpuUsage.IsImplemented()) {
m_CpuUsage.UpdateStats();
cpuUsage.Write(L"EE: %3d%%", m_CpuUsage.GetEEcorePct());
cpuUsage.Write(L" | GS: %3d%%", m_CpuUsage.GetGsPct());
if (THREAD_VU1)
cpuUsage.Write(L" | VU: %3d%%", m_CpuUsage.GetVUPct());
pxNonReleaseCode(cpuUsage.Write(L" | UI: %3d%%", m_CpuUsage.GetGuiPct()));
}
const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2);
wxString omodef = (smode2 & 2) ? templates.OutputFrame : templates.OutputField;
wxString omodei = (smode2 & 1) ? templates.OutputInterlaced : templates.OutputProgressive;

View File

@ -463,6 +463,9 @@ void populate_osd_table(GtkWidget* osd_table)
GtkWidget* monitor_check = CreateCheckBox("Enable Monitor", "osd_monitor_enabled");
GtkWidget* indicator_check = CreateCheckBox("Enable Indicator", "osd_indicator_enabled");
AddTooltip(log_check, IDC_OSD_LOG);
AddTooltip(monitor_check, IDC_OSD_MONITOR);
InsertWidgetInTable(osd_table , fontname_label , fontname_file);
InsertWidgetInTable(osd_table , fontsize_label , fontsize_text);
InsertWidgetInTable(osd_table , transparency_label , transparency_slide);

View File

@ -55,15 +55,15 @@ void GSOsdManager::LoadSize() {
GSOsdManager::GSOsdManager() : m_atlas_h(0)
, m_atlas_w(0)
, m_max_width(0)
, m_onscreen_messages(0)
, m_texture_dirty(true)
{
m_log_enabled = theApp.GetConfigB("osd_log_enabled");
m_log_speed = theApp.GetConfigI("osd_log_speed");
m_log_speed = m_log_speed < 2 ? 2 : m_log_speed > 10 ? 10 : m_log_speed;
m_log_speed = std::max(2, std::min(theApp.GetConfigI("osd_log_speed"), 10));
m_monitor_enabled = theApp.GetConfigB("osd_monitor_enabled");
m_indicator_enabled = theApp.GetConfigB("osd_indicator_enabled");
m_osd_transparency = theApp.GetConfigI("osd_transparency");
m_osd_transparency = m_osd_transparency < 0 ? 0 : m_osd_transparency > 200 ? 200 : m_osd_transparency;
m_osd_transparency = std::max(0, std::min(theApp.GetConfigI("osd_transparency"), 100));
m_max_onscreen_messages = theApp.GetConfigI("osd_max_log_messages");
if (FT_Init_FreeType(&m_library)) {
fprintf(stderr, "Failed to init the freetype library\n");
@ -183,6 +183,7 @@ void GSOsdManager::Log(const char *utf8, uint32 color) {
std::u32string buffer = conv.from_bytes(utf8);
for(auto const &c : buffer) AddGlyph(c);
#endif
m_onscreen_messages++;
m_log.push_back(log_info{color, buffer, std::chrono::system_clock::time_point()});
}
@ -299,7 +300,7 @@ size_t GSOsdManager::Size() {
elapsed = std::chrono::seconds(0);
} else {
elapsed = std::chrono::system_clock::now() - it->OnScreen;
if(elapsed > std::chrono::seconds(m_log_speed)) {
if(elapsed > std::chrono::seconds(m_log_speed) || m_onscreen_messages > m_max_onscreen_messages) {
continue;
}
}
@ -346,7 +347,7 @@ float GSOsdManager::StringSize(const std::u32string msg) {
size_t GSOsdManager::GeneratePrimitives(GSVertexPT1* dst, size_t count) {
size_t drawn = 0;
float transparency = 1.0f - m_osd_transparency / 200.0f;
float transparency = 1.0f - m_osd_transparency / 100.0f;
if(m_log_enabled) {
float offset = 0;
@ -361,7 +362,8 @@ size_t GSOsdManager::GeneratePrimitives(GSVertexPT1* dst, size_t count) {
it->OnScreen = std::chrono::system_clock::now();
std::chrono::duration<float> elapsed = std::chrono::system_clock::now() - it->OnScreen;
if(elapsed > std::chrono::seconds(m_log_speed)) {
if(elapsed > std::chrono::seconds(m_log_speed) || m_onscreen_messages > m_max_onscreen_messages) {
m_onscreen_messages--;
it = m_log.erase(it);
continue;
}

View File

@ -54,8 +54,7 @@ class GSOsdManager {
uint32 m_atlas_h;
uint32 m_atlas_w;
int32 m_max_width;
void compute_glyph_size();
int32 m_onscreen_messages;
struct log_info {
uint32 color;
@ -84,6 +83,7 @@ class GSOsdManager {
bool m_monitor_enabled;
bool m_indicator_enabled;
int m_osd_transparency;
int m_max_onscreen_messages;
public:

View File

@ -90,6 +90,10 @@ const char* dialog_message(int ID, bool* updateText) {
return "Offset for the ST/UV texture coordinates. Fixes some odd texture issues and might fix some post processing alignment too.\n\n"
" 0500 0500, fixes Persona 3 minimap, helps Haunting Ground.\n"
" 0000 1000, fixes Xenosaga hair edges (DX10+ Issue)";
case IDC_OSD_LOG:
return "Prints log messages from the Function keys onscreen.";
case IDC_OSD_MONITOR:
return "Continuously prints the FPS and the EE, GS and VU(if the MTVU speedhack is enabled) percentages onscreen.";
case IDC_PALTEX:
return "When checked 4/8 bits texture will be send to the GPU with a palette. GPU will be in charge of the conversion.\n\n"
"When unchecked the CPU will convert directly the texture to 32 bits.\n\n"
@ -135,6 +139,10 @@ const char* dialog_message(int ID, bool* updateText) {
return "Makes textures partially or fully transparent as required by emulation. May cause unusual slowdowns for some games.";
case IDC_LOGZ:
return "Treat depth as logarithmic instead of linear. Recommended setting is on unless it causes graphical glitches.";
case IDC_OSD_MAX_LOG_EDIT:
case IDC_OSD_MAX_LOG:
return "Sets the maximum number of log messages on the screen or in the buffer at the same time.\n\n"
"The maximum number of messages visible on the screen at the same time also depends on the character size.";
#endif
#ifdef __linux__
case IDC_LINEAR_PRESENT:

View File

@ -78,5 +78,7 @@ enum {
IDC_LINEAR_PRESENT,
IDC_AUTO_FLUSH,
IDC_UNSCALE_POINT_LINE,
IDC_OSD_LOG,
IDC_OSD_MONITOR,
};
#endif

View File

@ -249,6 +249,10 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
if (code == BN_CLICKED)
ShaderDlg.DoModal();
break;
case IDC_OSDBUTTON:
if (code == BN_CLICKED)
OSDDlg.DoModal();
break;
case IDC_HACKSBUTTON:
if (code == BN_CLICKED)
HacksDlg.DoModal();
@ -816,5 +820,117 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
default: return false;
}
return true;
}
// OSD Configuration Dialog
GSOSDDlg::GSOSDDlg() :
GSDialog(IDD_OSD)
{}
void GSOSDDlg::OnInit()
{
// OSD Indicator is greyed out because it's currently an empty shell.
EnableWindow(GetDlgItem(m_hWnd, IDC_OSD_INDICATOR), false);
CheckDlgButton(m_hWnd, IDC_OSD_LOG, theApp.GetConfigB("osd_log_enabled"));
CheckDlgButton(m_hWnd, IDC_OSD_MONITOR, theApp.GetConfigB("osd_monitor_enabled"));
CheckDlgButton(m_hWnd, IDC_OSD_INDICATOR, theApp.GetConfigB("osd_indicator_enabled"));
m_transparency = theApp.GetConfigI("osd_transparency");
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_TRANSPARENCY_SLIDER), TBM_SETRANGE, TRUE, MAKELONG(0, 100));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SIZE), UDM_SETRANGE, 0, MAKELPARAM(100, 1));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SIZE), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfigI("osd_fontsize"), 0));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SPEED), UDM_SETRANGE, 0, MAKELPARAM(10, 2));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SPEED), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfigI("osd_log_speed"), 0));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_MAX_LOG), UDM_SETRANGE, 0, MAKELPARAM(20, 1));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_MAX_LOG), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfigI("osd_max_log_messages"), 0));
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_FONT_EDIT), WM_SETTEXT, 0, (LPARAM)theApp.GetConfigS("osd_fontname").c_str());
AddTooltip(IDC_OSD_MAX_LOG);
AddTooltip(IDC_OSD_MAX_LOG_EDIT);
AddTooltip(IDC_OSD_MONITOR);
UpdateControls();
}
void GSOSDDlg::UpdateControls()
{
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_TRANSPARENCY_SLIDER), TBM_SETPOS, TRUE, m_transparency);
char text[8] = { 0 };
sprintf(text, "%d", m_transparency);
SetDlgItemText(m_hWnd, IDC_OSD_TRANSPARENCY_TEXT, text);
}
bool GSOSDDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_HSCROLL:
{
if ((HWND)lParam == GetDlgItem(m_hWnd, IDC_OSD_TRANSPARENCY_SLIDER))
{
char text[8] = { 0 };
m_transparency = SendMessage(GetDlgItem(m_hWnd, IDC_OSD_TRANSPARENCY_SLIDER), TBM_GETPOS, 0, 0);
sprintf(text, "%d", m_transparency);
SetDlgItemText(m_hWnd, IDC_OSD_TRANSPARENCY_TEXT, text);
}
} break;
case WM_COMMAND:
{
int id = LOWORD(wParam);
switch (id)
{
case IDOK:
{
INT_PTR data;
theApp.SetConfig("osd_fontsize", (int)SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SIZE), UDM_GETPOS, 0, 0));
theApp.SetConfig("osd_log_speed", (int)SendMessage(GetDlgItem(m_hWnd, IDC_OSD_SPEED), UDM_GETPOS, 0, 0));
theApp.SetConfig("osd_max_log_messages", (int)SendMessage(GetDlgItem(m_hWnd, IDC_OSD_MAX_LOG), UDM_GETPOS, 0, 0));
theApp.SetConfig("osd_log_enabled", (int)IsDlgButtonChecked(m_hWnd, IDC_OSD_LOG));
theApp.SetConfig("osd_monitor_enabled", (int)IsDlgButtonChecked(m_hWnd, IDC_OSD_MONITOR));
theApp.SetConfig("osd_indicator_enabled", (int)IsDlgButtonChecked(m_hWnd, IDC_OSD_INDICATOR));
theApp.SetConfig("osd_transparency", m_transparency);
// OSD Font
int length = ((int)SendMessage(GetDlgItem(m_hWnd, IDC_OSD_FONT_EDIT), WM_GETTEXTLENGTH, 0, 0)) + 1;
std::unique_ptr<char[]> buffer(new char[length]);
SendMessage(GetDlgItem(m_hWnd, IDC_OSD_FONT_EDIT), WM_GETTEXT, (WPARAM)length, (LPARAM)buffer.get());
theApp.SetConfig("osd_fontname", buffer.get());
EndDialog(m_hWnd, id);
} break;
case IDC_OSD_FONT_BUTTON:
if (HIWORD(wParam) == BN_CLICKED)
OpenFileDialog(IDC_OSD_FONT_EDIT, "Select External Font");
break;
case IDCANCEL:
{
EndDialog(m_hWnd, IDCANCEL);
} break;
}
} break;
case WM_CLOSE:EndDialog(m_hWnd, IDCANCEL); break;
default: return false;
}
return true;
}

View File

@ -64,6 +64,20 @@ public:
}
};
class GSOSDDlg : public GSDialog
{
int m_transparency;
void UpdateControls();
protected:
void OnInit();
bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
public:
GSOSDDlg();
};
class GSSettingsDlg : public GSDialog
{
@ -91,6 +105,7 @@ protected:
// Shade Boost
GSShaderDlg ShaderDlg;
GSHacksDlg HacksDlg;
GSOSDDlg OSDDlg;
public:
GSSettingsDlg();

View File

@ -322,7 +322,8 @@ void GSdxApp::Init()
m_default_configuration["osd_log_enabled"] = "1";
m_default_configuration["osd_log_speed"] = "6";
m_default_configuration["osd_monitor_enabled"] = "0";
m_default_configuration["osd_transparency"] = "50";
m_default_configuration["osd_transparency"] = "25";
m_default_configuration["osd_max_log_messages"] = "3";
m_default_configuration["override_geometry_shader"] = "-1";
m_default_configuration["override_GL_ARB_clear_texture"] = "-1";
m_default_configuration["override_GL_ARB_draw_buffers_blend"] = "-1";

View File

@ -177,6 +177,33 @@ BEGIN
GROUPBOX "External Shader Settings",IDC_STATIC,6,138,236,88,BS_CENTER
END
IDD_OSD DIALOGEX 0, 0, 191, 229
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "OSD Configuration"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,42,209,50,14
DEFPUSHBUTTON "Cancel",IDCANCEL,99,209,50,14
CONTROL "Enable Log",IDC_OSD_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,6,54,10
CONTROL "Enable Monitor",IDC_OSD_MONITOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,22,90,10
CONTROL "Enable Indicator",IDC_OSD_INDICATOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,38,90,10
LTEXT "Character size:",IDC_STATIC,15,57,120,8
EDITTEXT IDC_OSD_SIZE_EDIT,15,68,58,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_OSD_SIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,15,69,11,14
LTEXT "Scrolling speed:",IDC_STATIC,15,90,120,8
EDITTEXT IDC_OSD_SPEED_EDIT,15,101,58,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "", IDC_OSD_SPEED,"msctls_updown32", UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,15,102,11,14
LTEXT "Maximum number of onscreen messages:",IDC_STATIC,15,121,150,8
EDITTEXT IDC_OSD_MAX_LOG_EDIT,15,132,58,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "", IDC_OSD_MAX_LOG,"msctls_updown32", UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,15,133,11,14
LTEXT "Transparency:",IDC_STATIC,15,151,50,8
CONTROL "",IDC_OSD_TRANSPARENCY_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,15,163,115,15
RTEXT "100",IDC_OSD_TRANSPARENCY_TEXT,130,167,15,8
LTEXT "Font:",IDC_STATIC,15,180,75,8
PUSHBUTTON "Browse",IDC_OSD_FONT_BUTTON,140,188,36,14
EDITTEXT IDC_OSD_FONT_EDIT,15,188,115,14,ES_AUTOHSCROLL
END
IDD_CAPTURE DIALOGEX 0, 0, 279, 71
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Capture settings"
@ -222,7 +249,7 @@ BEGIN
CONTROL "Windowed",IDC_WINDOWED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,129,157,49,10
END
IDD_CONFIG DIALOGEX 0, 0, 243, 389
IDD_CONFIG DIALOGEX 0, 0, 243, 405
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "GSdx Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@ -272,9 +299,11 @@ BEGIN
EDITTEXT IDC_SWTHREADS_EDIT,198,302,34,13,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_SWTHREADS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,221,301,11,14
PUSHBUTTON "Configure",IDC_SHADEBUTTON,105,339,127,14
LTEXT "Shader Configuration:",IDC_STATIC,11,342,90,14
DEFPUSHBUTTON "OK",IDOK,69,369,50,14
PUSHBUTTON "Cancel",IDCANCEL,125,369,50,14
LTEXT "Shader Configuration:",IDC_STATIC,11,343,90,14
PUSHBUTTON "Configure",IDC_OSDBUTTON,105,356,127,14
LTEXT "OSD Configuration:",IDC_STATIC,11,359,90,14
DEFPUSHBUTTON "OK",IDOK,69,385,50,14
PUSHBUTTON "Cancel",IDCANCEL,125,385,50,14
END
@ -309,6 +338,14 @@ BEGIN
BOTTOMMARGIN, 244
END
IDD_OSD, DIALOG
BEGIN
LEFTMARGIN, 6
RIGHTMARGIN, 242
TOPMARGIN, 7
BOTTOMMARGIN, 244
END
IDD_CAPTURE, DIALOG
BEGIN
VERTGUIDE, 6

View File

@ -107,6 +107,20 @@
#define IDC_LARGE_FB 2103
#define IDC_AUTO_FLUSH 2104
#define IDC_UNSCALE_POINT_LINE 2105
#define IDC_OSD_FONT_EDIT 2106
#define IDC_OSD_FONT_BUTTON 2107
#define IDC_OSD_SPEED 2108
#define IDC_OSD_SPEED_EDIT 2109
#define IDC_OSD_SIZE 2110
#define IDC_OSD_SIZE_EDIT 2111
#define IDC_OSD_TRANSPARENCY_SLIDER 2112
#define IDC_OSD_TRANSPARENCY_TEXT 2113
#define IDC_OSD_LOG 2114
#define IDC_OSD_MONITOR 2115
#define IDC_OSD_INDICATOR 2116
#define IDC_OSDBUTTON 2117
#define IDC_OSD_MAX_LOG 2118
#define IDC_OSD_MAX_LOG_EDIT 2119
#define IDR_CONVERT_FX 10000
#define IDR_TFX_FX 10001
#define IDR_MERGE_FX 10002
@ -117,6 +131,7 @@
#define IDR_SHADEBOOST_FX 10007
#define IDR_TFX_CL 10008
#define IDD_HACKS 10009
#define IDD_OSD 10010
#define IDC_STATIC -1
// Next default values for new objects