Permalink
Browse files

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.
  • Loading branch information...
1 parent d42759c commit da57014eb8e5a5a2236a6c91d1a8ee67fe489ec9 @FlatOutPS2 FlatOutPS2 committed with turtleli Jan 6, 2017
@@ -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;
@@ -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);
@@ -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;
}
@@ -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:
@@ -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:
@@ -78,5 +78,7 @@ enum {
IDC_LINEAR_PRESENT,
IDC_AUTO_FLUSH,
IDC_UNSCALE_POINT_LINE,
+ IDC_OSD_LOG,
+ IDC_OSD_MONITOR,
};
#endif
@@ -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();
@@ -818,3 +822,115 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
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;
+}
@@ -64,6 +64,20 @@ class GSHacksDlg : public GSDialog
}
};
+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 @@ class GSSettingsDlg : public GSDialog
// Shade Boost
GSShaderDlg ShaderDlg;
GSHacksDlg HacksDlg;
+ GSOSDDlg OSDDlg;
public:
GSSettingsDlg();
@@ -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";
Oops, something went wrong.

0 comments on commit da57014

Please sign in to comment.