UI / Cmdline:

* Fullscreen mode should be remembered/applied properly now.
 * implemented --fullscreen and --windowed options
 * Made the --help popup a lot prettier

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3249 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-06-21 04:04:32 +00:00
parent 7c8170d582
commit 7461f83414
16 changed files with 215 additions and 36 deletions

View File

@ -72,6 +72,7 @@ public:
pxStaticText& SetMinHeight( int height );
pxStaticText& SetHeight( int lines );
pxStaticText& Align( wxAlignment align );
pxStaticText& Bold();
pxStaticText& WrapAt( int width );

View File

@ -621,13 +621,15 @@ protected:
class pxTextWrapperBase
{
protected:
bool m_eol;
int m_linecount;
bool m_eol;
int m_linecount;
wxString m_indent;
public:
virtual ~pxTextWrapperBase() throw() { }
pxTextWrapperBase()
pxTextWrapperBase( const wxString& indent=wxEmptyString )
: m_indent( indent )
{
m_eol = false;
m_linecount = 0;
@ -664,10 +666,13 @@ class pxTextWrapper : public pxTextWrapperBase
typedef pxTextWrapperBase _parent;
protected:
wxString m_text;
wxString m_text;
public:
pxTextWrapper() : pxTextWrapperBase() { }
pxTextWrapper( const wxString& wrapPrefix=wxEmptyString )
: pxTextWrapperBase( wrapPrefix )
{ }
virtual ~pxTextWrapper() throw() { }
const wxString& GetResult() const
@ -679,8 +684,8 @@ public:
pxTextWrapper& Wrap( const wxWindow* win, const wxString& text, int widthMax );
protected:
virtual void OnOutputLine(const wxString& line);
virtual void OnNewLine();
void OnOutputLine(const wxString& line);
void OnNewLine();
};
// --------------------------------------------------------------------------------------

View File

@ -85,6 +85,12 @@ pxStaticText& pxStaticText::SetHeight( int lines )
return *this;
}
pxStaticText& pxStaticText::Align( wxAlignment align )
{
m_align = align;
return *this;
}
pxStaticText& pxStaticText::Bold()
{
wxFont bold( GetFont() );

View File

@ -264,7 +264,7 @@ wxSizerFlags pxSizerFlags::Checkbox()
}
// --------------------------------------------------------------------------------------
// pxTextWrapper / pxTextWrapperBase Implementations
// pxTextWrapper / pxTextWrapperBase (mplementations)
// --------------------------------------------------------------------------------------
pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString& text, int widthMax )
@ -272,6 +272,8 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
if( text.IsEmpty() ) return *this;
const wxChar *lastSpace = NULL;
bool wasWrapped = false;
wxString line;
line.Alloc( text.Length()+12 );
@ -283,12 +285,17 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
OnNewLine();
lastSpace = NULL;
line.clear();
lineStart = p;
if(wasWrapped)
line = m_indent;
else
line.clear();
}
if ( *p == L'\n' || *p == L'\0' )
{
wasWrapped = false;
DoOutputLine(line);
if ( *p == L'\0' )
@ -296,7 +303,7 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
}
else // not EOL
{
if ( *p == L' ' )
if ( *p == L' ' || *p == L',' || *p == L'/' )
lastSpace = p;
line += *p;
@ -308,6 +315,8 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
if ( width > widthMax )
{
wasWrapped = true;
// remove the last word from this line
line.erase(lastSpace - lineStart, p + 1 - lineStart);
DoOutputLine(line);
@ -366,7 +375,7 @@ void pxTextWrapper::OnNewLine()
}
// --------------------------------------------------------------------------------------
// ScopedBusyCursor Implementations
// ScopedBusyCursor (implementations)
// --------------------------------------------------------------------------------------
std::stack<BusyCursorType> ScopedBusyCursor::m_cursorStack;

View File

@ -391,6 +391,12 @@ public:
}
};
enum GsWindowMode_t
{
GsWinMode_Unspecified = 0,
GsWinMode_Windowed,
GsWinMode_Fullscreen,
};
class CommandlineOverrides
{
@ -406,11 +412,14 @@ public:
bool UseGamefix[GamefixId_COUNT];
bool ApplyCustomGamefixes;
GsWindowMode_t GsWindowMode;
public:
CommandlineOverrides()
{
DisableSpeedhacks = false;
ApplyCustomGamefixes = false;
GsWindowMode = GsWinMode_Unspecified;
}
// Returns TRUE if either speedhacks or gamefixes are being overridden.
@ -433,6 +442,23 @@ public:
}
};
// --------------------------------------------------------------------------------------
// Pcsx2AppTraits
// --------------------------------------------------------------------------------------
// Overrides and customizes some default wxWidgets behaviors. This class is instanized by
// calls to Pcsx2App::CreateTraits(), which is called from wxWidgets as-needed. wxWidgets
// does cache an instance of the traits, so the object construction need not be trivial
// (translation: it can be complicated-ish -- it won't affect performance).
//
class Pcsx2AppTraits : public wxGUIAppTraits
{
typedef wxGUIAppTraits _parent;
public:
virtual ~Pcsx2AppTraits() {}
wxMessageOutput* CreateMessageOutput();
};
// =====================================================================================================
// Pcsx2App - main wxApp class
// =====================================================================================================
@ -624,6 +650,7 @@ public:
// --------------------------------------------------------------------------
// Overrides of wxApp virtuals:
// --------------------------------------------------------------------------
wxAppTraits* CreateTraits();
bool OnInit();
int OnExit();
void CleanUp();

View File

@ -623,6 +623,7 @@ AppConfig::GSWindowOptions::GSWindowOptions()
WindowSize = wxSize( 640, 480 );
WindowPos = wxDefaultPosition;
IsMaximized = false;
IsFullscreen = false;
}
void AppConfig::GSWindowOptions::SanityCheck()
@ -657,6 +658,8 @@ void AppConfig::GSWindowOptions::LoadSave( IniInterface& ini )
IniEntry( WindowSize );
IniEntry( WindowPos );
IniEntry( IsMaximized );
IniEntry( IsFullscreen );
static const wxChar* AspectRatioNames[] =
{

View File

@ -147,6 +147,7 @@ public:
{
// Closes the GS/Video port on escape (good for fullscreen activity)
bool CloseOnEsc;
bool DefaultToFullscreen;
bool AlwaysHideMouse;
bool DisableResizeBorders;
@ -157,6 +158,7 @@ public:
wxSize WindowSize;
wxPoint WindowPos;
bool IsMaximized;
bool IsFullscreen;
GSWindowOptions();

View File

@ -282,8 +282,7 @@ void Pcsx2App::AllocateCoreStuffs()
g_Conf->EmuOptions.Recompiler.EnableIOP = false;
}
if( !m_CoreAllocs->IsRecAvailable_MicroVU0() )
{
if( !m_CoreAllocs->IsRecAvailable_MicroVU0() ) {
scrollableTextArea->AppendText( L"* microVU0\n\n" );
g_Conf->EmuOptions.Recompiler.UseMicroVU0 = false;
g_Conf->EmuOptions.Recompiler.EnableVU0 = g_Conf->EmuOptions.Recompiler.EnableVU0 && m_CoreAllocs->IsRecAvailable_SuperVU0();
@ -347,7 +346,9 @@ void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
parser.AddParam( _("IsoFile"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL );
parser.AddSwitch( L"h", L"help", _("displays this list of command line options"), wxCMD_LINE_OPTION_HELP );
parser.AddSwitch( wxEmptyString,L"console", _("forces the program log/console to be visible") );
parser.AddSwitch( wxEmptyString,L"console", _("forces the program log/console to be visible"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"fullscreen", _("use fullscreen GS mode") );
parser.AddSwitch( wxEmptyString,L"windowed", _("use windowed GS mode") );
parser.AddSwitch( wxEmptyString,L"nogui", _("disables display of the gui while running games") );
parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING );
@ -381,13 +382,13 @@ bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser )
{
wxString dest;
if( parser.Found( L"cfgpath", &dest ) && !dest.IsEmpty() )
if (parser.Found( L"cfgpath", &dest ) && !dest.IsEmpty())
{
Console.Warning( L"Config path override: " + dest );
Overrides.SettingsFolder = dest;
}
if( parser.Found( L"cfg", &dest ) && !dest.IsEmpty() )
if (parser.Found( L"cfg", &dest ) && !dest.IsEmpty())
{
Console.Warning( L"Config file override: " + dest );
Overrides.SettingsFile = dest;
@ -395,6 +396,9 @@ bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser )
Overrides.DisableSpeedhacks = parser.Found(L"nohacks");
if (parser.Found(L"fullscreen")) Overrides.GsWindowMode = GsWinMode_Fullscreen;
if (parser.Found(L"windowed")) Overrides.GsWindowMode = GsWinMode_Windowed;
const PluginInfo* pi = tbl_PluginInfo; do
{
if( !parser.Found( pi->GetShortname().Lower(), &dest ) ) continue;

View File

@ -265,6 +265,75 @@ void Pcsx2App::PadKeyDispatch( const keyEvent& ev )
}
}
// --------------------------------------------------------------------------------------
// Pcsx2AppTraits (implementations)
// --------------------------------------------------------------------------------------
class pxMessageOutputMessageBox : public wxMessageOutput
{
public:
pxMessageOutputMessageBox() { }
virtual void Printf(const wxChar* format, ...);
};
void pxMessageOutputMessageBox::Printf(const wxChar* format, ...)
{
using namespace pxSizerFlags;
va_list args;
va_start(args, format);
wxString out;
out.PrintfV(format, args);
va_end(args);
int pos = out.Find( L"[IsoFile]" );
if(pos == wxNOT_FOUND)
{
Msgbox::Alert( out ); return;
}
pos += 9; // strlen of [IsoFile]
wxDialogWithHelpers popup( NULL, _("PCSX2 Commandline Options") );
popup.SetMinWidth( 640 );
popup += popup.Heading(out.Mid(0, pos));
//popup += ;
//popup += popup.Text(out.Mid(pos, out.Length())).Align( wxALIGN_LEFT ) | pxExpand.Border(wxALL, StdPadding*3);
wxTextCtrl* traceArea = new wxTextCtrl(
&popup, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_READONLY | wxTE_MULTILINE | wxTE_RICH2 | wxHSCROLL
);
traceArea->SetDefaultStyle( wxTextAttr( wxNullColour, wxNullColour, pxGetFixedFont() ) );
traceArea->SetFont( pxGetFixedFont() );
int fonty = traceArea->GetCharHeight();
traceArea->SetMinSize( wxSize( traceArea->GetMinWidth(), (fonty+1)*18 ) );
traceArea->WriteText( pxTextWrapper(wxString(L' ', 18)).Wrap(traceArea, out.Mid(pos, out.Length()), 600).GetResult() );
traceArea->SetInsertionPoint( 0 );
traceArea->ShowPosition( 0 );
popup += traceArea | pxExpand.Border(wxALL, StdPadding*3);
pxIssueConfirmation(popup, MsgButtons().Close() );
}
wxMessageOutput* Pcsx2AppTraits::CreateMessageOutput()
{
#ifdef __UNIX__
return _parent::CreateMessageOutput();
#else
return new pxMessageOutputMessageBox;
#endif
}
// --------------------------------------------------------------------------------------
// FramerateManager (implementations)
// --------------------------------------------------------------------------------------
void FramerateManager::Reset()
{
//memzero( m_fpsqueue );
@ -302,6 +371,10 @@ double FramerateManager::GetFramerate() const
return (double)GetTickFrequency() / (double)ticks_per_frame;
}
// ----------------------------------------------------------------------------
// Pcsx2App Event Handlers
// ----------------------------------------------------------------------------
// LogicalVsync - Event received from the AppCoreThread (EEcore) for each vsync,
// roughly 50/60 times a second when frame limiting is enabled, and up to 10,000
// times a second if not (ok, not quite, but you get the idea... I hope.)
@ -332,10 +405,6 @@ void Pcsx2App::LogicalVsync()
}
}
// ----------------------------------------------------------------------------
// Pcsx2App Event Handlers
// ----------------------------------------------------------------------------
HashTools::HashMap<int, const GlobalCommandDescriptor*> GlobalAccels( 0, 0xffffffff );
void Pcsx2App::OnEmuKeyDown( wxKeyEvent& evt )
@ -512,6 +581,11 @@ void Pcsx2App::ClearPendingSave()
}
}
wxAppTraits* Pcsx2App::CreateTraits()
{
return new Pcsx2AppTraits;
}
// This method generates debug assertions if the MainFrame handle is NULL (typically
// indicating that PCSX2 is running in NoGUI mode, or that the main frame has been
// closed). In most cases you'll want to use HasMainFrame() to test for thread
@ -672,13 +746,26 @@ void AppLoadSettings()
void AppSaveSettings()
{
if( wxGetApp().Rpc_TryInvokeAsync(AppSaveSettings) ) return;
// If multiple SaveSettings messages are requested, we want to ignore most of them.
// Saving settings once when the GUI is idle should be fine. :)
static u32 isPosted = false;
if( !wxThread::IsMain() )
{
if( AtomicExchange(isPosted, true) )
wxGetApp().PostIdleMethod( AppSaveSettings );
return;
}
if( !wxFile::Exists( g_Conf->CurrentIso ) )
g_Conf->CurrentIso.clear();
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
AtomicExchange( isPosted, false );
AppIniSaver saver;
g_Conf->LoadSave( saver );
sApp.DispatchEvent( saver );

View File

@ -475,7 +475,7 @@ void ConsoleLogFrame::OnDockedMove( wxCommandEvent& event )
void ConsoleLogFrame::OnMoveAround( wxMoveEvent& evt )
{
if( IsBeingDeleted() || IsIconized() ) return;
if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return;
// Docking check! If the window position is within some amount
// of the main window, enable docking.

View File

@ -42,8 +42,7 @@ Dialogs::AssertionDialog::AssertionDialog( const wxString& text, const wxString&
traceArea->SetDefaultStyle( wxTextAttr( wxNullColour, wxNullColour, pxGetFixedFont() ) );
traceArea->SetFont( pxGetFixedFont() );
int fonty;
traceArea->GetTextExtent( L"blaH yeah", NULL, &fonty );
int fonty = traceArea->GetCharHeight();
traceArea->WriteText( stacktrace );
traceArea->SetMinSize( wxSize( traceArea->GetMinWidth(), (fonty+1)*18 ) );

View File

@ -245,7 +245,6 @@ GSFrame::GSFrame(wxWindow* parent, const wxString& title)
, m_timer_UpdateTitle( this )
{
SetIcons( wxGetApp().GetIconBundle() );
SetClientSize( g_Conf->GSWindow.WindowSize );
SetBackgroundColour( *wxBLACK );
@ -281,6 +280,22 @@ void GSFrame::OnCloseWindow(wxCloseEvent& evt)
evt.Skip(); // and close it.
}
bool GSFrame::ShowFullScreen(bool show, long style)
{
if( show != IsFullScreen() )
Console.WriteLn( Color_StrongMagenta, "(gsFrame) Switching to %s mode...", show ? "Fullscreen" : "Windowed" );
_parent::ShowFullScreen( show );
if( g_Conf->GSWindow.IsFullscreen != show )
{
g_Conf->GSWindow.IsFullscreen = show;
AppSaveSettings();
return true;
}
return false;
}
wxStaticText* GSFrame::GetLabel_OutputDisabled() const
{
@ -308,7 +323,7 @@ bool GSFrame::Show( bool shown )
{
GSPanel* gsPanel = GetViewport();
if( gsPanel == NULL || gsPanel->IsBeingDeleted() )
if( !gsPanel || gsPanel->IsBeingDeleted() )
{
gsPanel = new GSPanel( this );
m_id_gspanel = gsPanel->GetId();
@ -321,6 +336,22 @@ bool GSFrame::Show( bool shown )
if( wxStaticText* label = GetLabel_OutputDisabled() )
label->Show( EmuConfig.GS.DisableOutput );
switch( wxGetApp().Overrides.GsWindowMode )
{
case GsWinMode_Windowed:
g_Conf->GSWindow.IsFullscreen = false;
break;
case GsWinMode_Fullscreen:
g_Conf->GSWindow.IsFullscreen = true;
break;
case GsWinMode_Unspecified:
g_Conf->GSWindow.IsFullscreen = g_Conf->GSWindow.DefaultToFullscreen;
break;
}
ShowFullScreen( g_Conf->GSWindow.IsFullscreen );
m_timer_UpdateTitle.Start( TitleBarUpdateMs );
}
else
@ -404,9 +435,11 @@ void GSFrame::OnMove( wxMoveEvent& evt )
evt.Skip();
g_Conf->GSWindow.IsMaximized = IsMaximized();
// evt.GetPosition() returns the client area position, not the window frame position.
if( !IsFullScreen() && !IsMaximized() && IsVisible() )
g_Conf->GSWindow.WindowPos = GetScreenPosition();
if( !g_Conf->GSWindow.IsMaximized && !IsFullScreen() && !IsIconized() && IsVisible() )
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

View File

@ -32,7 +32,8 @@ extern LimiterModeType g_LimiterMode;
// --------------------------------------------------------------------------------------
// GSPanel
// --------------------------------------------------------------------------------------
class GSPanel : public wxWindow, public EventListener_AppStatus
class GSPanel : public wxWindow
, public EventListener_AppStatus
{
typedef wxWindow _parent;
@ -71,9 +72,9 @@ protected:
// --------------------------------------------------------------------------------------
// GSFrame
// --------------------------------------------------------------------------------------
class GSFrame : public wxFrame,
public EventListener_AppStatus,
public EventListener_CoreThread
class GSFrame : public wxFrame
, public EventListener_AppStatus
, public EventListener_CoreThread
{
typedef wxFrame _parent;
@ -95,6 +96,8 @@ public:
bool Show( bool shown=true );
wxStaticText* GetLabel_OutputDisabled() const;
bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
protected:
void OnCloseWindow( wxCloseEvent& evt );
void OnMove( wxMoveEvent& evt );

View File

@ -216,8 +216,8 @@ namespace Implementations
void FullscreenToggle()
{
g_Conf->GSWindow.DefaultToFullscreen = !g_Conf->GSWindow.DefaultToFullscreen;
sGSFrame.ShowFullScreen( g_Conf->GSWindow.DefaultToFullscreen );
if( GSFrame* gsframe = wxGetApp().GetGsFramePtr() )
gsframe->ShowFullScreen( !gsframe->IsFullScreen() );
}
}

View File

@ -107,7 +107,7 @@ void MainEmuFrame::OnCloseWindow(wxCloseEvent& evt)
void MainEmuFrame::OnMoveAround( wxMoveEvent& evt )
{
if( IsBeingDeleted() || IsIconized() ) return;
if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return;
// Uncomment this when doing logger stress testing (and then move the window around
// while the logger spams itself)

View File

@ -268,8 +268,8 @@ struct V_ReverbBuffers
s32 IIR_SRC_A0;
s32 IIR_SRC_A1;
s32 IIR_SRC_B1;
s32 IIR_SRC_B0;
s32 IIR_SRC_B1;
s32 IIR_DEST_A0;
s32 IIR_DEST_A1;
s32 IIR_DEST_B0;