From 64c12f5a7a8122fe80c32e613c1caef17f8437f8 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sun, 29 Nov 2009 22:50:55 +0000 Subject: [PATCH] Video/GS Window and Panel Options (partly!) implemented: * Aspect ratio and mouse cursor hiding features should be mostly functional. * Mouse cursor by default hides after 1.75 seconds of inactivity, when in the area of the GS window. Can be forced to always hidden in the control panel. Unlike the liilypad hack, this one won't hide the mouse in the main window or title bars. (and it should work for Linux too!!) * GS window position and size should be remembered between sessions. Console Logger window z-order is now "bound" to the main window. When clicking either window to bring it to focus, the other window follows (implemented for Win32 only, since wxWidgets doesn't have a cross-platform implementation of the necessary SetWindowPos call). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2275 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/pxStaticText.h | 3 +- common/src/Utilities/pxStaticText.cpp | 4 +- pcsx2/gui/App.h | 3 + pcsx2/gui/AppConfig.cpp | 74 +++++- pcsx2/gui/AppConfig.h | 45 +++- pcsx2/gui/AppMain.cpp | 2 +- pcsx2/gui/ConsoleLogger.cpp | 14 ++ pcsx2/gui/ConsoleLogger.h | 1 + pcsx2/gui/FrameForGS.cpp | 158 +++++++++++- pcsx2/gui/MainFrame.cpp | 18 +- pcsx2/gui/MainFrame.h | 39 ++- pcsx2/gui/Panels/ConfigurationPanels.h | 4 +- pcsx2/gui/Panels/VideoPanel.cpp | 280 ++++++++++++--------- pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 12 + 14 files changed, 504 insertions(+), 153 deletions(-) diff --git a/common/include/Utilities/pxStaticText.h b/common/include/Utilities/pxStaticText.h index 1de97faf26..df79a30b5c 100644 --- a/common/include/Utilities/pxStaticText.h +++ b/common/include/Utilities/pxStaticText.h @@ -90,7 +90,8 @@ extern void operator+=( wxSizer& target, pxStaticText& src ); template<> inline void operator+=( wxSizer& target, const pxWindowAndFlags& src ) { - target.Add( src.window, src.flags ); + src.window->AddTo( target, src.flags ); + //target.Add( src.window, src.flags ); } // -------------------------------------------------------------------------------------- diff --git a/common/src/Utilities/pxStaticText.cpp b/common/src/Utilities/pxStaticText.cpp index ecdac11c7a..d52f1d7fd7 100644 --- a/common/src/Utilities/pxStaticText.cpp +++ b/common/src/Utilities/pxStaticText.cpp @@ -63,13 +63,13 @@ pxStaticText& pxStaticText::SetToolTip( const wxString& tip ) void pxStaticText::AddTo( wxSizer& sizer, wxSizerFlags flags ) { - sizer.Add( this, flags.Align( m_alignflags ) ); + sizer.Add( this, flags.Align( m_alignflags | (flags.GetFlags() & wxALIGN_MASK) ) ); _setLabel(); } void pxStaticText::InsertAt( wxSizer& sizer, int position, wxSizerFlags flags ) { - sizer.Insert( position, this, flags.Align( m_alignflags ) ); + sizer.Insert( position, this, flags.Align( m_alignflags | (flags.GetFlags() & wxALIGN_MASK) ) ); _setLabel(); } diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index b32271333d..05ce3453bf 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -568,6 +568,9 @@ DECLARE_APP(Pcsx2App) #define sApp \ if( Pcsx2App* __app_ = (Pcsx2App*)wxApp::GetInstance() ) (*__app_) +#define sLogFrame \ + if( ConsoleLogFrame* __conframe_ = wxGetApp().GetProgramLog() ) (*__conframe_) + #define sMainFrame \ if( MainEmuFrame* __frame_ = GetMainFramePtr() ) (*__frame_) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 32e62d6433..9134c0fecb 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -318,7 +318,6 @@ AppConfig::AppConfig() Toolbar_ShowLabels = true; McdEnableNTFS = true; - CloseGSonEsc = true; EnableSpeedHacks = false; CdvdSource = CDVDsrc_Iso; @@ -388,7 +387,6 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini ) IniEntry( CurrentIso ); IniEntry( CurrentELF ); - IniEntry( CloseGSonEsc ); IniEntry( EnableSpeedHacks ); ini.EnumEntry( L"CdvdSource", CdvdSource, CDVD_SourceLabels, defaults.CdvdSource ); @@ -408,6 +406,7 @@ void AppConfig::LoadSave( IniInterface& ini ) BaseFilenames.LoadSave( ini ); EmuOptions.LoadSave( ini ); + GSWindow.LoadSave( ini ); ini.Flush(); } @@ -447,12 +446,12 @@ void AppConfig::FolderOptions::ApplyDefaults() // ------------------------------------------------------------------------ AppConfig::FolderOptions::FolderOptions() : bitset( 0xffffffff ) -, Plugins( PathDefs::GetPlugins() ) -, Bios( PathDefs::GetBios() ) -, Snapshots( PathDefs::GetSnapshots() ) -, Savestates( PathDefs::GetSavestates() ) -, MemoryCards( PathDefs::GetMemoryCards() ) -, Logs( PathDefs::GetLogs() ) +, Plugins ( PathDefs::GetPlugins() ) +, Bios ( PathDefs::GetBios() ) +, Snapshots ( PathDefs::GetSnapshots() ) +, Savestates ( PathDefs::GetSavestates() ) +, MemoryCards ( PathDefs::GetMemoryCards() ) +, Logs ( PathDefs::GetLogs() ) , RunIso( PathDefs::GetDocuments() ) // raw default is always the Documents folder. , RunELF( PathDefs::GetDocuments() ) // raw default is always the Documents folder. @@ -518,6 +517,65 @@ void AppConfig::FilenameOptions::LoadSave( IniInterface& ini ) ini.Entry( L"BIOS", Bios, pc ); } +// ------------------------------------------------------------------------ +AppConfig::GSOptions::GSOptions() +{ + CloseOnEsc = true; + DefaultToFullscreen = false; + AlwaysHideMouse = false; + DisableResizeBorders = false; + + AspectRatio = AspectRatio_4_3; + + WindowSize = wxSize( 640, 480 ); + WindowPos = wxDefaultPosition; + IsMaximized = false; +} + +void AppConfig::GSOptions::SanityCheck() +{ + // Ensure Conformation of various options... + + WindowSize.x = std::max( WindowSize.x, 8 ); + WindowSize.x = std::min( WindowSize.x, wxGetDisplayArea().GetWidth()-16 ); + + WindowSize.y = std::max( WindowSize.y, 8 ); + WindowSize.y = std::min( WindowSize.y, wxGetDisplayArea().GetHeight()-48 ); + + if( !wxGetDisplayArea().Contains( wxRect( WindowPos, WindowSize ) ) ) + WindowPos = wxDefaultPosition; + + + if( (uint)AspectRatio >= (uint)AspectRatio_MaxCount ) + AspectRatio = AspectRatio_4_3; +} + +void AppConfig::GSOptions::LoadSave( IniInterface& ini ) +{ + IniScopedGroup path( ini, L"GSWindow" ); + + GSOptions defaults; + + IniEntry( CloseOnEsc ); + IniEntry( DefaultToFullscreen ); + IniEntry( AlwaysHideMouse ); + IniEntry( DisableResizeBorders ); + + IniEntry( WindowSize ); + IniEntry( WindowPos ); + + static const wxChar* AspectRatioNames[] = + { + L"Stretch", + L"4:3", + L"16:9", + }; + + ini.EnumEntry( L"AspectRatio", AspectRatio, AspectRatioNames, defaults.AspectRatio ); + + DisableResizeBorders = false; +} + wxFileConfig* OpenFileConfig( const wxString& filename ) { return new wxFileConfig( wxEmptyString, wxEmptyString, filename, wxEmptyString, wxCONFIG_USE_RELATIVE_PATH ); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 98abd08caf..a498c1f80f 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -29,10 +29,18 @@ extern bool UseDefaultSettingsFolder; // when TRUE, pcsx2 derives the settings wxDirName GetSettingsFolder(); wxString GetSettingsFilename(); -////////////////////////////////////////////////////////////////////////////////////////// -// Pcsx2 Application Configuration. -// -// +enum AspectRatioType +{ + AspectRatio_Stretch, + AspectRatio_4_3, + AspectRatio_16_9, + AspectRatio_MaxCount +}; + +// ===================================================================================================== +// Pcsx2 Application Configuration. +// ===================================================================================================== + class AppConfig { public: @@ -109,6 +117,29 @@ public: bool Enabled; // memory card enabled (if false, memcard will not show up in-game) }; + // ------------------------------------------------------------------------ + // The GS window receives much love from the land of Options and Settings. + // + struct GSOptions + { + // Closes the GS/Video port on escape (good for fullscreen activity) + bool CloseOnEsc; + bool DefaultToFullscreen; + bool AlwaysHideMouse; + bool DisableResizeBorders; + + AspectRatioType AspectRatio; + + wxSize WindowSize; + wxPoint WindowPos; + bool IsMaximized; + + GSOptions(); + + void LoadSave( IniInterface& conf ); + void SanityCheck(); + }; + public: wxPoint MainGuiPosition; @@ -139,9 +170,6 @@ public: // enables automatic ntfs compression of memory cards (Win32 only) bool McdEnableNTFS; - // Closes the GS/Video port on escape (good for fullscreen activity) - bool CloseGSonEsc; - // Master toggle for enabling or disabling all speedhacks in one fail-free swoop. // (the toggle is applied when a new EmuConfig is sent through AppCoreThread::ApplySettings) bool EnableSpeedHacks; @@ -155,7 +183,8 @@ public: ConsoleLogOptions Ps2ConBox; FolderOptions Folders; FilenameOptions BaseFilenames; - + GSOptions GSWindow; + // 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 // which are shown as options in the gui preferences, but *not* necessarily the options diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index a33a4ce52f..c082abb7f2 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -467,7 +467,7 @@ void Pcsx2App::OpenGsFrame() m_gsFrame = new GSFrame( m_MainFrame, L"PCSX2" ); m_gsFrame->SetFocus(); - pDsp = (uptr)m_gsFrame->GetHandle(); + pDsp = (uptr)m_gsFrame->GetWindow()->GetHandle(); m_gsFrame->Show(); // The "in the main window" quickie hack... diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 3a45a0556c..66cf9b5360 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -326,6 +326,7 @@ ConsoleLogFrame::ConsoleLogFrame( MainEmuFrame *parent, const wxString& title, A Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(ConsoleLogFrame::OnCloseWindow) ); Connect( wxEVT_MOVE, wxMoveEventHandler(ConsoleLogFrame::OnMoveAround) ); Connect( wxEVT_SIZE, wxSizeEventHandler(ConsoleLogFrame::OnResize) ); + Connect( wxEVT_ACTIVATE, wxActivateEventHandler(ConsoleLogFrame::OnActivate) ); Connect( wxEVT_SetTitleText, wxCommandEventHandler(ConsoleLogFrame::OnSetTitle) ); Connect( wxEVT_DockConsole, wxCommandEventHandler(ConsoleLogFrame::OnDockedMove) ); @@ -473,6 +474,19 @@ void ConsoleLogFrame::OnResize( wxSizeEvent& evt ) evt.Skip(); } +void ConsoleLogFrame::OnActivate( wxActivateEvent& evt ) +{ + // Special implementation to "connect" the console log window with the main frame + // window. When one is clicked, the other is assured to be brought to the foreground + // with it. (wxWidgets appears to have no equivalent to this) +#ifdef __WXMSW__ + if( MainEmuFrame* mainframe = GetMainFramePtr() ) + SetWindowPos( (HWND)mainframe->GetHWND(), (HWND)GetHWND(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE ); +#endif + + evt.Skip(); +} + void ConsoleLogFrame::OnCloseWindow(wxCloseEvent& event) { if( event.CanVeto() ) diff --git a/pcsx2/gui/ConsoleLogger.h b/pcsx2/gui/ConsoleLogger.h index 1dbe11a7c7..5e8a827539 100644 --- a/pcsx2/gui/ConsoleLogger.h +++ b/pcsx2/gui/ConsoleLogger.h @@ -273,5 +273,6 @@ protected: void OnMoveAround( wxMoveEvent& evt ); void OnResize( wxSizeEvent& evt ); + void OnActivate( wxActivateEvent& evt ); }; diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index a3f9486c5f..7cf8ba7919 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -42,16 +42,136 @@ void GSFrame::InitDefaultAccelerators() m_Accels.Map( AAC( WXK_F12 ), "Sys_RecordingToggle" ); } -GSFrame::GSFrame(wxWindow* parent, const wxString& title): - wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxSize( 640, 480 ), wxDEFAULT_FRAME_STYLE ) +GSPanel::GSPanel( wxWindow* parent ) + : wxWindow() + , m_Listener_SettingsApplied( wxGetApp().Source_SettingsApplied(), EventListener ( this, OnSettingsApplied ) ) + , m_HideMouseTimer( this ) + +{ + m_CursorShown = true; + + if ( !wxWindow::Create(parent, wxID_ANY) ) + throw Exception::RuntimeError( "GSPanel constructor esplode!!" ); + + if( g_Conf->GSWindow.AlwaysHideMouse ) + { + SetCursor( wxCursor(wxCURSOR_BLANK) ); + m_CursorShown = false; + } + + Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler (GSPanel::OnCloseWindow) ); + Connect( wxEVT_SIZE, wxSizeEventHandler (GSPanel::OnResize) ); + + Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_MOTION, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(GSPanel::OnShowMouse) ); + Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(GSPanel::OnShowMouse) ); + + Connect(m_HideMouseTimer.GetId(), wxEVT_TIMER, wxTimerEventHandler(GSPanel::OnHideMouseTimeout) ); +} + +void GSPanel::DoShowMouse() +{ + if( g_Conf->GSWindow.AlwaysHideMouse ) return; + + if( !m_CursorShown ) + { + SetCursor( wxCursor( wxCURSOR_DEFAULT ) ); + m_CursorShown = true; + } + m_HideMouseTimer.Start( 1750, true ); +} + +void GSPanel::DoResize() +{ + if( GetParent() == NULL ) return; + wxSize client = GetParent()->GetClientSize(); + wxSize viewport = client; + + switch( g_Conf->GSWindow.AspectRatio ) + { + case AspectRatio_Stretch: + // just default to matching client size. + break; + + case AspectRatio_4_3: + if( client.x/4 <= client.y/3 ) + viewport.y = (int)(client.x * (3.0/4.0)); + else + viewport.x = (int)(client.y * (4.0/3.0)); + break; + + case AspectRatio_16_9: + if( client.x/16 <= client.y/9 ) + viewport.y = (int)(client.x * (9.0/16.0)); + else + viewport.x = (int)(client.y * (9.0/16.0)); + break; + } + + SetSize( viewport ); + CenterOnParent(); +} + +void GSPanel::OnResize(wxSizeEvent& event) +{ + DoResize(); + //Console.Error( "Size? %d x %d", GetSize().x, GetSize().y ); + //event. +} + +void GSPanel::OnCloseWindow(wxCloseEvent& evt) +{ + wxGetApp().OnGsFrameClosed(); + evt.Skip(); // and close it. +} + +void GSPanel::OnShowMouse( wxMouseEvent& evt ) +{ + evt.Skip(); + DoShowMouse(); +} + +void GSPanel::OnHideMouseTimeout( wxTimerEvent& evt ) +{ + SetCursor( wxCursor( wxCURSOR_BLANK ) ); + m_CursorShown = false; +} + + +void __evt_fastcall GSPanel::OnSettingsApplied( void* obj, int& evt ) +{ + if( obj == NULL ) return; + GSPanel* panel = (GSPanel*)obj; + + panel->DoResize(); + panel->DoShowMouse(); +} + +GSFrame::GSFrame(wxWindow* parent, const wxString& title) + : wxFrame(parent, wxID_ANY, title, + g_Conf->GSWindow.WindowPos, wxSize( 640, 480 ), + (g_Conf->GSWindow.DisableResizeBorders ? 0 : wxRESIZE_BORDER) | wxCAPTION | wxCLIP_CHILDREN | + wxSYSTEM_MENU | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX + ) { SetIcons( wxGetApp().GetIconBundle() ); InitDefaultAccelerators(); - //new wxStaticText( "" ); - Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(GSFrame::OnCloseWindow) ); - Connect( wxEVT_KEY_DOWN, wxKeyEventHandler(GSFrame::OnKeyDown) ); + SetClientSize( g_Conf->GSWindow.WindowSize ); + + m_gspanel = new GSPanel( this ); + + //Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler (GSFrame::OnCloseWindow) ); + Connect( wxEVT_MOVE, wxMoveEventHandler (GSFrame::OnMove) ); + Connect( wxEVT_SIZE, wxSizeEventHandler (GSFrame::OnResize) ); + Connect( wxEVT_KEY_DOWN, wxKeyEventHandler (GSFrame::OnKeyDown) ); } GSFrame::~GSFrame() throw() @@ -59,10 +179,32 @@ GSFrame::~GSFrame() throw() CoreThread.Suspend(); // Just in case...! } -void GSFrame::OnCloseWindow(wxCloseEvent& evt) +wxWindow* GSFrame::GetWindow() { - wxGetApp().OnGsFrameClosed(); - evt.Skip(); // and close it. + return m_gspanel; +} + +void GSFrame::OnMove( wxMoveEvent& evt ) +{ + // evt.GetPosition() returns the client area position, not the window frame position. + g_Conf->GSWindow.WindowPos = GetScreenPosition(); + + // wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions + // like selecting or deselecting a window, which muck up docking logic. We filter them + // out using 'lastpos' here. :) + + static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord ); + if( lastpos == evt.GetPosition() ) return; + lastpos = evt.GetPosition(); +} + +void GSFrame::OnResize( wxSizeEvent& evt ) +{ + g_Conf->GSWindow.WindowSize = GetClientSize(); + m_gspanel->DoResize(); + + // if we skip, the panel is auto-sized to fit our window anyway, which we do not want! + //evt.Skip(); } void GSFrame::OnKeyDown( wxKeyEvent& evt ) diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 09933ef447..06d4caeed1 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -22,6 +22,10 @@ #include +#ifdef __WXMSW__ +# include // needed for SetWindowPos (OnActivate) +#endif + #if _MSC_VER # include "svnrev.h" #endif @@ -439,6 +443,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) ConnectMenus(); Connect( wxEVT_MOVE, wxMoveEventHandler (MainEmuFrame::OnMoveAround) ); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainEmuFrame::OnCloseWindow) ); + Connect( wxEVT_ACTIVATE, wxActivateEventHandler(MainEmuFrame::OnActivate) ); SetDropTarget( new IsoDropTarget( this ) ); } @@ -448,10 +453,17 @@ MainEmuFrame::~MainEmuFrame() throw() m_menuCDVD.Remove( MenuId_IsoSelector ); } -// This should be called whenever major changes to the ini configs have occurred, -// or when the recent file count mismatches the max filecount. -void MainEmuFrame::ReloadRecentLists() +void MainEmuFrame::OnActivate( wxActivateEvent& evt ) { + // Special implementation to "connect" the console log window with the main frame + // window. When one is clicked, the other is assured to be brought to the foreground + // with it. (wxWidgets appears to have no equivalent to this) +#ifdef __WXMSW__ + if( ConsoleLogFrame* logframe = wxGetApp().GetProgramLog() ) + SetWindowPos( (HWND)logframe->GetHWND(), (HWND)GetHWND(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE ); +#endif + + evt.Skip(); } void MainEmuFrame::ApplyCoreStatus() diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index e46f4cf9a3..457005211d 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -21,21 +21,52 @@ #include "App.h" +// -------------------------------------------------------------------------------------- +// GSPanel +// -------------------------------------------------------------------------------------- +class GSPanel : public wxWindow +{ +protected: + EventListenerBinding m_Listener_SettingsApplied; + wxTimer m_HideMouseTimer; + bool m_CursorShown; + +public: + GSPanel( wxWindow* parent ); + virtual ~GSPanel() throw() { } + + void DoResize(); + void DoShowMouse(); + +protected: + static void __evt_fastcall OnSettingsApplied( void* obj, int& evt ); + + void OnCloseWindow( wxCloseEvent& evt ); + void OnResize(wxSizeEvent& event); + void OnShowMouse( wxMouseEvent& evt ); + void OnHideMouseTimeout( wxTimerEvent& evt ); +}; + // -------------------------------------------------------------------------------------- // GSFrame // -------------------------------------------------------------------------------------- class GSFrame : public wxFrame { protected: - AcceleratorDictionary m_Accels; + AcceleratorDictionary m_Accels; + + GSPanel* m_gspanel; public: GSFrame(wxWindow* parent, const wxString& title); virtual ~GSFrame() throw(); + wxWindow* GetWindow(); + protected: void InitDefaultAccelerators(); - void OnCloseWindow( wxCloseEvent& evt ); + void OnMove( wxMoveEvent& evt ); + void OnResize( wxSizeEvent& evt ); void OnKeyDown( wxKeyEvent& evt ); }; @@ -136,7 +167,6 @@ public: bool IsPaused() const { return GetMenuBar()->IsChecked( MenuId_Sys_SuspendResume ); } void UpdateIsoSrcSelection(); - void ReloadRecentLists(); protected: static void __evt_fastcall OnCoreThreadStatusChanged( void* obj, wxCommandEvent& evt ); @@ -152,8 +182,9 @@ protected: void InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf ); - void OnCloseWindow(wxCloseEvent& evt); + void OnCloseWindow( wxCloseEvent& evt ); void OnMoveAround( wxMoveEvent& evt ); + void OnActivate( wxActivateEvent& evt ); void Menu_ConfigSettings_Click(wxCommandEvent &event); void Menu_SelectBios_Click(wxCommandEvent &event); diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 47c542585d..c63a413b40 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -184,11 +184,13 @@ namespace Panels class GSWindowSettingsPanel : public BaseApplicableConfigPanel { protected: + wxComboBox* m_combo_AspectRatio; + pxCheckBox* m_check_CloseGS; pxCheckBox* m_check_SizeLock; - pxCheckBox* m_check_AspectLock; pxCheckBox* m_check_VsyncEnable; pxCheckBox* m_check_Fullscreen; + pxCheckBox* m_check_HideMouse; wxTextCtrl* m_text_WindowWidth; wxTextCtrl* m_text_WindowHeight; diff --git a/pcsx2/gui/Panels/VideoPanel.cpp b/pcsx2/gui/Panels/VideoPanel.cpp index eeb6f08486..b5fd64c83d 100644 --- a/pcsx2/gui/Panels/VideoPanel.cpp +++ b/pcsx2/gui/Panels/VideoPanel.cpp @@ -145,6 +145,169 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent ) OnSettingsChanged(); } +// -------------------------------------------------------------------------------------- +// GSWindowSetting Implementation +// -------------------------------------------------------------------------------------- + +Panels::GSWindowSettingsPanel::GSWindowSettingsPanel( wxWindow* parent ) + : BaseApplicableConfigPanel( parent ) +{ + const wxString aspect_ratio_labels[] = + { + _("Fit to Window/Screen"), + _("Standard (4:3)"), + _("Widescreen (16:9)") + }; + + m_combo_AspectRatio = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, + ArraySize(aspect_ratio_labels), aspect_ratio_labels, wxCB_READONLY ); + + m_text_WindowWidth = CreateNumericalTextCtrl( this, 5 ); + m_text_WindowHeight = CreateNumericalTextCtrl( this, 5 ); + + m_check_SizeLock = new pxCheckBox( this, _("Disable window resize border") ); + m_check_HideMouse = new pxCheckBox( this, _("Always hide mouse cursor") ); + m_check_CloseGS = new pxCheckBox( this, _("Hide window on suspend") ); + m_check_Fullscreen = new pxCheckBox( this, _("Default to Fullscreen") ); + m_check_VsyncEnable = new pxCheckBox( this, _("Vsync Enable") ); + + m_check_VsyncEnable->SetToolTip( pxE( ".Tooltips:Video:Vsync", + L"Vsync eliminates screen tearing but typically has a big performance hit. " + L"It usually only applies to fullscreen mode, and may not work with all GS plugins." + ) ); + + m_check_HideMouse->SetToolTip( pxE( ".Tooltips:Video:HideMouse", + L"Check this to force the mouse cursor invisible inside the GS window; useful if using " + L"the mouse as a primary control device for gaming. By default the mouse auto-hides after " + L"3 seconds of inactivity." + ) ); + + m_check_Fullscreen->SetToolTip( pxE( ".Tooltips:Video:Fullscreen", + L"Enables automatic mode switch to fullscreen when starting or resuming emulation. " + L"You can still toggle fullscreen display at any time using alt-enter." + ) ); + + m_check_CloseGS->SetToolTip( pxE( ".Tooltips:Video:HideGS", + L"Completely closes the often large and bulky GS window when pressing " + L"ESC or suspending the emulator." + ) ); + + // ---------------------------------------------------------------------------- + // Layout and Positioning + + wxBoxSizer& s_customsize( *new wxBoxSizer( wxHORIZONTAL ) ); + s_customsize += m_text_WindowWidth; + s_customsize += Text( L"x" ); + s_customsize += m_text_WindowHeight; + + wxFlexGridSizer& s_AspectRatio( *new wxFlexGridSizer( 2, StdPadding, StdPadding ) ); + //s_AspectRatio.AddGrowableCol( 0 ); + s_AspectRatio.AddGrowableCol( 1 ); + + s_AspectRatio += Text(_("Aspect Ratio:")) | pxMiddle; + s_AspectRatio += m_combo_AspectRatio | pxExpand; + s_AspectRatio += Text(_("Custom Window Size:")) | pxMiddle; + s_AspectRatio += s_customsize | pxAlignRight; + + *this += s_AspectRatio | StdExpand(); + *this += m_check_SizeLock; + *this += new wxStaticLine( this ) | StdExpand(); + + *this += m_check_Fullscreen; + *this += m_check_VsyncEnable; + *this += m_check_HideMouse; + *this += m_check_CloseGS; + + OnSettingsChanged(); +} + +// -------------------------------------------------------------------------------------- +// VideoPanel Implementation +// -------------------------------------------------------------------------------------- + +Panels::VideoPanel::VideoPanel( wxWindow* parent ) : + BaseApplicableConfigPanel( parent ) +{ + wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL ); + wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL ); + left->SetIdealWidth( (left->GetIdealWidth()-12) / 2 ); + right->SetIdealWidth( (right->GetIdealWidth()-12) / 2 ); + + m_check_SynchronousGS = new pxCheckBox( left, _("Synchronized MTGS"), + _("For troubleshooting potential bugs in the MTGS only, as it is potentially very slow.") + ); + + m_check_SynchronousGS->SetToolTip(_("Enable this if you think the MTGS is causing crashes or graphical errors.")); + + GSWindowSettingsPanel* winpan = new GSWindowSettingsPanel( left ); + winpan->AddFrame(_("Display/Window")); + + FramelimiterPanel* fpan = new FramelimiterPanel( right ); + fpan->AddFrame(_("Framelimiter")); + + wxFlexGridSizer* s_table = new wxFlexGridSizer( 2 ); + s_table->AddGrowableCol( 0 ); + s_table->AddGrowableCol( 1 ); + + *left += winpan | pxExpand; + *right += fpan | pxExpand; + + *left += 5; + *left += m_check_SynchronousGS; + + *s_table += left | StdExpand(); + *s_table += right | StdExpand(); + + *this += s_table | pxExpand; + + m_check_SynchronousGS->SetValue( g_Conf->EmuOptions.Video.SynchronousMTGS ); +} + +void Panels::VideoPanel::Apply() +{ + g_Conf->EmuOptions.Video.SynchronousMTGS = m_check_SynchronousGS->GetValue(); +} + +void Panels::GSWindowSettingsPanel::OnSettingsChanged() +{ + const AppConfig::GSOptions& conf( g_Conf->GSWindow ); + + m_check_CloseGS ->SetValue( conf.CloseOnEsc ); + m_check_Fullscreen ->SetValue( conf.DefaultToFullscreen ); + m_check_HideMouse ->SetValue( conf.AlwaysHideMouse ); + m_check_SizeLock ->SetValue( conf.DisableResizeBorders ); + + m_combo_AspectRatio ->SetSelection( (int)conf.AspectRatio ); + + m_text_WindowWidth ->SetValue( wxsFormat( L"%d", conf.WindowSize.GetWidth() ) ); + m_text_WindowHeight ->SetValue( wxsFormat( L"%d", conf.WindowSize.GetHeight() ) ); + +} + +void Panels::GSWindowSettingsPanel::Apply() +{ + AppConfig::GSOptions& gsopt( g_Conf->GSWindow ); + + gsopt.CloseOnEsc = m_check_CloseGS ->GetValue(); + gsopt.DefaultToFullscreen = m_check_Fullscreen->GetValue(); + gsopt.AlwaysHideMouse = m_check_HideMouse ->GetValue(); + gsopt.DisableResizeBorders = m_check_SizeLock ->GetValue(); + + gsopt.AspectRatio = (AspectRatioType)m_combo_AspectRatio->GetSelection(); + + long xr, yr; + + if( !m_text_WindowWidth->GetValue().ToLong( &xr ) || !m_text_WindowHeight->GetValue().ToLong( &yr ) ) + throw Exception::CannotApplySettings( this, + L"User submitted non-numeric window size parameters!", + _("Invalid window dimensions specified: Size cannot contain non-numeric digits! >_<") + ); + + gsopt.WindowSize.x = xr; + gsopt.WindowSize.y = yr; +} + + void Panels::FramelimiterPanel::OnSettingsChanged() { const Pcsx2Config::VideoOptions& conf( g_Conf->EmuOptions.Video ); @@ -158,120 +321,3 @@ void Panels::FramelimiterPanel::Apply() // TODO : Apply options from checkboxes (once video config struct is is implemented) } - -// -------------------------------------------------------------------------------------- -// GSWindowSetting Implementation -// -------------------------------------------------------------------------------------- - -Panels::GSWindowSettingsPanel::GSWindowSettingsPanel( wxWindow* parent ) - : BaseApplicableConfigPanel( parent ) -{ - m_text_WindowWidth = CreateNumericalTextCtrl( this, 5 ); - m_text_WindowHeight = CreateNumericalTextCtrl( this, 5 ); - - m_check_CloseGS = new pxCheckBox( this, _("Hide GS window") ); - - m_check_AspectLock = new pxCheckBox( this, _("Lock Aspect Ratio") ); - - m_check_SizeLock = new pxCheckBox( this, _("Lock Size"), - pxE( ".Tooltips:Video:LockSize", - L"Disables the resize border for the GS window." - ) - ); - - m_check_VsyncEnable = new pxCheckBox( this, _("Wait for Vsync"), - pxE( ".Tooltips:Video:Vsync", - L"This reduces screen/refresh tearing but typically has a big performance hit. " - L"It may not work in windowed modes, and may not be supported by all GS plugins." - ) - ); - - m_check_Fullscreen = new pxCheckBox( this, _("Force Fullscreen at Startup"), - pxE( ".Panels:Video:Fullscreen", - L"Enables automatic modeswitch to fullscreen when starting or resuming emulation." - ) - ); - - m_check_CloseGS->SetToolTip( pxE( ".Tooltips:Video:HideGS", - L"Completely closes the often large and bulky GS window when pressing " - L"ESC or suspending the emulator. Might prevent memory leaks too, if you use DX10." - ) ); - - // ---------------------------------------------------------------------------- - // Layout and Positioning - - wxBoxSizer& s_customsize( *new wxBoxSizer( wxHORIZONTAL ) ); - s_customsize += m_text_WindowWidth; - s_customsize += Text(L"x" ); - s_customsize += m_text_WindowHeight; - - //wxFlexGridSizer& s_winsize( *new wxFlexGridSizer( 2 ) ); - //s_winsize.AddGrowableCol( 0 ); - - wxStaticBoxSizer& s_winsize( *new wxStaticBoxSizer( wxVERTICAL, this, _("Custom Window Size:") ) ); - s_winsize += s_customsize | StdSpace().Border( wxLEFT | wxRIGHT | wxBOTTOM); - - *this += s_winsize | StdSpace(); - - *this += m_check_SizeLock; - *this += m_check_AspectLock; - *this += m_check_Fullscreen; - *this += m_check_CloseGS; - *this += m_check_VsyncEnable; - - m_text_WindowWidth ->SetValue( L"640" ); - m_text_WindowHeight ->SetValue( L"480" ); - m_check_CloseGS ->SetValue( g_Conf->CloseGSonEsc ); - -} - -void Panels::GSWindowSettingsPanel::Apply() -{ -} - -// -------------------------------------------------------------------------------------- -// VideoPanel Implementation -// -------------------------------------------------------------------------------------- - -Panels::VideoPanel::VideoPanel( wxWindow* parent ) : - BaseApplicableConfigPanel( parent ) -{ - m_check_SynchronousGS = new pxCheckBox( this, _("Force Synchronized MTGS"), - _("For troubleshooting possible bugs in the MTGS. Enabling this option will be a big slowdown.") - ); - - wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL ); - wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL ); - left->SetIdealWidth( (left->GetIdealWidth()-16) / 2 ); - right->SetIdealWidth( (right->GetIdealWidth()-16) / 2 ); - - GSWindowSettingsPanel* winpan = new GSWindowSettingsPanel( left ); - winpan->AddFrame(_("Display/Window")); - - FramelimiterPanel* fpan = new FramelimiterPanel( right ); - fpan->AddFrame(_("Framelimiter")); - - wxFlexGridSizer* s_table = new wxFlexGridSizer( 2 ); - - *left += winpan | pxExpand; - *right += fpan | pxExpand; - - *s_table += left | StdExpand(); - *s_table += right | StdExpand(); - - *this += Heading(L"This panel is not implemented yet.\nIT DOES NOT WORK. AT ALL."); - *this += m_check_SynchronousGS; - *this += s_table; - - // TODO: - // Framelimiting / Frameskipping / Vsync - // GS Window Options ( incl. Fullscreen ) - // MTGS Forced Synchronization - - m_check_SynchronousGS->SetValue( g_Conf->EmuOptions.Video.SynchronousMTGS ); -} - -void Panels::VideoPanel::Apply() -{ - g_Conf->EmuOptions.Video.SynchronousMTGS = m_check_SynchronousGS->GetValue(); -} diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index 9569efc296..5020ae25ff 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -2299,6 +2299,18 @@ RelativePath=".\..\resource.h" > + + + + +