wxgui: various cleanups.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1536 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-07-17 05:45:34 +00:00
parent ccdb5d84b9
commit 3a5c1d180b
5 changed files with 31 additions and 76 deletions

View File

@ -62,6 +62,7 @@ protected:
wxTextCtrl& m_TextCtrl;
ColorArray m_ColorTable;
Console::Colors m_curcolor;
volatile long m_msgcounter; // used to track queued messages and throttle load placed on the gui message pump
public:
// ctor & dtor

View File

@ -117,6 +117,7 @@ ConsoleLogFrame::ConsoleLogFrame(MainEmuFrame *parent, const wxString& title) :
wxTE_MULTILINE | wxHSCROLL | wxTE_READONLY | wxTE_RICH2 ) )
, m_ColorTable()
, m_curcolor( Color_Black )
, m_msgcounter( 0 )
{
m_TextCtrl.SetBackgroundColour( wxColor( 238, 240, 248 ) ); //wxColor( 48, 48, 64 ) );
@ -299,11 +300,12 @@ void ConsoleLogFrame::Write( const wxString& text )
m_TextCtrl.AppendText( text );
// cap at 256k for now:
// cap at 256k for now...
// fixme - 256k runs well on win32 but appears to be very sluggish on linux. Might
// need platform dependent defaults here. - air
if( m_TextCtrl.GetLastPosition() > 0x40000 )
{
m_TextCtrl.AppendText( L"************************ REMOVING BUFFER CRAP *****************\n" );
m_TextCtrl.Remove( 0, 0x8000 );
m_TextCtrl.Remove( 0, 0x10000 );
}
}
@ -320,8 +322,6 @@ void ConsoleLogFrame::Newline()
Write( L"\n" );
}
static volatile long counter = 0;
// ------------------------------------------------------------------------
// Deadlock protection: High volume logs will over-tax our message pump and cause the
// GUI to become inaccessible. The cool solution would be a threaded log window, but wx
@ -331,9 +331,9 @@ static volatile long counter = 0;
// catch up.
void ConsoleLogFrame::CountMessage()
{
_InterlockedIncrement( &counter );
_InterlockedIncrement( &m_msgcounter );
if( counter > 0x10 ) // 0x10 -- arbitrary value that seems to work well on my C2Q 3.2ghz
if( m_msgcounter > 0x10 ) // 0x10 -- arbitrary value that seems to work well on my C2Q 3.2ghz
{
if( !wxThread::IsMain() )
{
@ -341,8 +341,8 @@ void ConsoleLogFrame::CountMessage()
// pthreads semaphores instead of Sleep, but I haven't been able to conjure up
// such an alternative yet.
while( counter > 1 ) { Sleep(1); }
Sleep(1); // give the main thread more time to catch up. :|
while( m_msgcounter > 1 ) { Sleep(1); }
Sleep(0); // give the main thread more time to catch up. :|
}
}
@ -350,7 +350,7 @@ void ConsoleLogFrame::CountMessage()
void ConsoleLogFrame::DoMessage()
{
int cur = _InterlockedDecrement( &counter );
int cur = _InterlockedDecrement( &m_msgcounter );
if( m_TextCtrl.IsFrozen() )
{
if( cur <= 1 && wxThread::IsMain() )

View File

@ -28,18 +28,6 @@
using namespace Dialogs;
// ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeLanguagesMenu() const
{
wxMenu* menuLangs = new wxMenu();
// TODO : Index languages out of the resources and Langs folder.
menuLangs->Append(Menu_Language_Start, _T("English"), wxEmptyString, wxITEM_RADIO);
return menuLangs;
}
// ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeStatesMenu()
{
@ -136,27 +124,25 @@ void MainEmuFrame::OnCloseWindow(wxCloseEvent& evt)
void MainEmuFrame::OnMoveAround( wxMoveEvent& evt )
{
// Uncomment this when going logger stress testing (and them move the window around)
// ... makes for a good test of the message pump's responsiveness.
//Console::Notice( "Mess o' crashiness? It can't be!" );
// 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 );
Console::Status( "Mess o' crashiness? It can't be!" );
if( lastpos == evt.GetPosition() ) return;
lastpos = evt.GetPosition();
if( g_Conf->ConLogBox.AutoDock )
{
g_Conf->ConLogBox.DisplayPosition = GetRect().GetTopRight();
//if( ConsoleLogFrame* frame = wxGetApp().GetProgramLog() )
// frame->DockedMove();
wxCommandEvent conevt( wxEVT_DockConsole );
wxGetApp().ProgramLog_PostEvent( conevt );
}
//Console::Error( "XWindows Messages Suck: %d, %d", params GetPosition().x, GetPosition().y );
g_Conf->MainGuiPosition = evt.GetPosition();
//evt.Skip();
@ -191,10 +177,6 @@ void MainEmuFrame::ConnectMenus()
ConnectMenu( Menu_State_LoadOther, Menu_LoadStateOther_Click );
ConnectMenu( Menu_State_SaveOther, Menu_SaveStateOther_Click );
ConnectMenu( Menu_Config_Gamefixes, Menu_Gamefixes_Click );
ConnectMenu( Menu_Config_SpeedHacks,Menu_Speedhacks_Click );
ConnectMenu( Menu_Debug_Open, Menu_Debug_Open_Click );
ConnectMenu( Menu_Debug_MemoryDump, Menu_Debug_MemoryDump_Click );
ConnectMenu( Menu_Debug_Logging, Menu_Debug_Logging_Click );
@ -312,7 +294,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, int id, const wxString& title, cons
// ------------------------------------------------------------------------
m_menuConfig.Append(Menu_Config_Settings, _("Settings..."), wxEmptyString);
m_menuConfig.Append(Menu_Config_Settings, _("Core Settings..."), wxEmptyString);
m_menuConfig.AppendSeparator();
// Query installed "tertiary" plugins for name and menu options.
@ -322,14 +304,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, int id, const wxString& title, cons
m_menuConfig.Append(Menu_Config_FireWire, _("Firewire"), wxEmptyString);
m_menuConfig.AppendSeparator();
m_menuConfig.Append(Menu_SelectPlugins, _("Plugin Selector..."), wxEmptyString);
m_menuConfig.AppendSeparator();
m_menuConfig.Append(Menu_Config_Memcards, _("Memcards"), _T("Memory card file locations and options"));
m_menuConfig.Append(Menu_Config_Gamefixes, _("Gamefixes"), _T("God of War and TriAce fixes are found here"));
m_menuConfig.Append(Menu_Config_SpeedHacks, _("Speed Hacks"), _T("Options to make Pcsx2 emulate faster, but less accurately"));
m_menuConfig.Append(Menu_Config_Patches, _("Patches"), wxEmptyString);
//m_menuConfig.Append(Menu_Config_Advanced, _("Advanced"), _T("Cpu, Fpu, and Recompiler options."), wxITEM_NORMAL);
// ------------------------------------------------------------------------
@ -351,16 +326,12 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, int id, const wxString& title, cons
// Ref will want this re-added eventually.
//m_menuMisc.Append(47, _T("Print CDVD Info..."), wxEmptyString, wxITEM_CHECK);
m_menuMisc.Append(Menu_Languages, _T("Languages"), MakeLanguagesMenu(), wxEmptyString);
m_menuMisc.AppendSeparator();
m_menuMisc.Append(Menu_About, _T("About..."), wxEmptyString);
m_menuMisc.Append(Menu_Website, _T("Pcsx2 Website..."), _T("Opens your web-browser!"));
m_menuMisc.Append(Menu_About, _T("About..."), wxEmptyString, wxITEM_NORMAL);
m_menuMisc.Append(Menu_Website, _T("Pcsx2 Website..."), _T("Opens your web-browser!"), wxITEM_NORMAL);
m_menuDebug.Append(Menu_Debug_Open, _T("Open Debug Window..."), wxEmptyString, wxITEM_NORMAL);
m_menuDebug.Append(Menu_Debug_MemoryDump, _T("Memory Dump..."), wxEmptyString, wxITEM_NORMAL);
m_menuDebug.Append(Menu_Debug_Logging, _T("Logging..."), wxEmptyString, wxITEM_NORMAL);
m_menuDebug.Append(Menu_Debug_Open, _T("Open Debug Window..."), wxEmptyString);
m_menuDebug.Append(Menu_Debug_MemoryDump, _T("Memory Dump..."), wxEmptyString);
m_menuDebug.Append(Menu_Debug_Logging, _T("Logging..."), wxEmptyString);
m_MenuItem_Console.Check( g_Conf->ConLogBox.Visible );
@ -417,16 +388,6 @@ void MainEmuFrame::Menu_Reset_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Gamefixes_Click( wxCommandEvent& event )
{
//GameFixesDialog( this, wxID_ANY ).ShowModal();
}
void MainEmuFrame::Menu_Speedhacks_Click( wxCommandEvent& event )
{
//SpeedHacksDialog( this, wxID_ANY ).ShowModal();
}
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)
{
}

View File

@ -66,16 +66,11 @@ protected:
Menu_State_Save01, // first of many save slots
// Config Subsection
Menu_SelectPlugins = 100,
Menu_Config_Settings = 100,
Menu_Config_CDVD,
Menu_Config_DEV9,
Menu_Config_USB,
Menu_Config_FireWire,
Menu_Config_Settings,
Menu_Config_Memcards,
Menu_Config_SpeedHacks,
Menu_Config_Gamefixes,
Menu_Config_Patches,
// Video Subsection
@ -170,9 +165,6 @@ protected:
void Menu_Resume_Click(wxCommandEvent &event);
void Menu_Reset_Click(wxCommandEvent &event);
void Menu_Gamefixes_Click( wxCommandEvent& event );
void Menu_Speedhacks_Click( wxCommandEvent& event );
void Menu_Debug_Open_Click(wxCommandEvent &event);
void Menu_Debug_MemoryDump_Click(wxCommandEvent &event);
void Menu_Debug_Logging_Click(wxCommandEvent &event);

View File

@ -101,9 +101,7 @@ void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
parser.AddOption( wxEmptyString, L"cdvd", L"uses filename as the CDVD plugin for this session only." );
parser.AddOption( wxEmptyString, L"gs", L"uses filename as the GS plugin for this session only." );
parser.AddOption( wxEmptyString, L"spu", L"uses filename as the SPU2 plugin for this session only." );
parser.AddOption( wxEmptyString, L"pad", L"uses filename as *both* PAD plugins for this session only." );
parser.AddOption( wxEmptyString, L"pad1", L"uses filename as the PAD1 plugin for this session only." );
parser.AddOption( wxEmptyString, L"pad2", L"uses filename as the PAD2 plugin for this session only." );
parser.AddOption( wxEmptyString, L"pad", L"uses filename as the PAD plugin for this session only." );
parser.AddOption( wxEmptyString, L"dev9", L"uses filename as the DEV9 plugin for this session only." );
parser.AddOption( wxEmptyString, L"usb", L"uses filename as the USB plugin for this session only." );
@ -129,7 +127,7 @@ bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser)
//////////////////////////////////////////////////////////////////////////////////////////
// ConsoleThreadTest -- useful class for unit testing the thread safety and general performance
// of the console logger.
#if 0
//
class ConsoleTestThread : public Thread
{
int Callback()
@ -138,12 +136,14 @@ class ConsoleTestThread : public Thread
while( true )
{
// Two lines, both formatted, and varied colors. This makes for a fairly realistic
// worst case scenario (without being entirely unrealistic).
Console::WriteLn( wxsFormat( L"This is a threaded logging test. Something bad could happen... %d", ++numtrack ) );
Console::Status( wxsFormat( L"Testing high stress loads %s", L"(multi-color)" ) );
Sleep( 0 );
}
}
};
#endif
// ------------------------------------------------------------------------
bool Pcsx2App::OnInit()
@ -182,7 +182,7 @@ bool Pcsx2App::OnInit()
g_Conf->Apply();
m_ProgramLogBox = new ConsoleLogFrame( NULL, L"PCSX2 Program Log" );
m_Ps2ConLogBox = m_ProgramLogBox;
m_Ps2ConLogBox = m_ProgramLogBox; // just use a single logger for now.
//m_Ps2ConLogBox = new ConsoleLogFrame( NULL, L"PS2 Console Log" );
m_MainFrame = new MainEmuFrame( NULL, wxID_ANY, wxEmptyString );
@ -190,6 +190,7 @@ bool Pcsx2App::OnInit()
SetExitOnFrameDelete( true );
m_MainFrame->Show();
// Logger Stress Test: See ConsoleTestThread defined above for details
//ConsoleTestThread* woo = new ConsoleTestThread();
//woo->Start();