* Console now uses a fixed-width font by default
 * Core PCSX2 memory structures (VTLB and Recompilers) are allocated on startup.
 * Added some more gui/ini/startup mess.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1539 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-07-18 03:11:51 +00:00
parent 0f33c59509
commit 6e894deb67
25 changed files with 447 additions and 764 deletions

View File

@ -1,251 +0,0 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "SafeArray.h"
#include "AsciiString.h"
using namespace Threading;
namespace AsciiStringAllocator
{
struct PrivateHandle
{
AsciiStringAllocatorHandle* PublicHandle;
};
static const uint UnitLength = 256;
static const uint UnitLengthMask = UnitLength-1;
static const uint AllocationCleanupThreshold = 256;
static const uint InitialBufferLength = 0x100000; // 1MB!
static const AsciiStringAllocatorHandle* PublicHandleAllocated = (AsciiStringAllocatorHandle*)1;
static uint m_release_counter( 0 );
static SafeArray<PrivateHandle> m_PrivateHandles( InitialBufferLength / UnitLength );
static SafeArray<char> m_StringBuffer( InitialBufferLength );
static int m_NextPrivateHandle;
static int m_NextBufferIndex;
static MutexLock m_Lock;
static char* GetPtr( const AsciiStringAllocatorHandle& handle )
{
return &m_StringBuffer[ m_PrivateHandles[ handle.Index ] ];
}
static void DoCompact()
{
if( m_release_counter < AllocationCleanupThreshold ) return;
ScopedLock locker( m_Lock );
int handlecount = m_PrivateHandles.GetLength();
int writepos = 0;
for( int readpos=0; readpos<handlecount; readpos++ )
{
PrivateHandle& curhandle = m_PrivateHandles[readpos];
if( curhandle.PublicHandle != NULL )
{
int cwpos = writepos;
writepos++;
if( cwpos == readpos ) continue;
if( curhandle.PublicHandle != PublicHandleAllocated )
curhandle.PublicHandle->Index = cwpos;
// todo: replace this with a hardcoded XMM inline copy of 256 bytes. :)
memcpy_fast(
m_StringBuffer.GetPtr(cwpos*UnitLength),
m_StringBuffer.GetPtr(readpos*UnitLength),
UnitLength
);
}
}
}
void New( AsciiStringAllocatorHandle& dest, int length )
{
int numblocks = (length / UnitLength)+1;
length = numblocks * UnitLength;
ScopedLock locker( m_Lock );
AsciiStringAllocatorHandle retval( m_NextPrivateHandle, length );
m_PrivateHandles[m_NextPrivateHandle++].PublicHandle = &dest;
for( int p=numblocks-1; p; --p, ++m_NextPrivateHandle )
m_PrivateHandles[m_NextPrivateHandle].PublicHandle = PublicHandleAllocated;
m_StringBuffer.MakeRoomFor( m_NextPrivateHandle * UnitLength );
return retval;
}
bool Grow( AsciiStringAllocatorHandle& dest )
{
ScopedLock locker( m_lock );
if( m_PrivateHandles[m_NextPrivateHandle].PublicHandle == NULL )
{
m_PrivateHandles[m_NextPrivateHandle].PublicHandle = PublicHandleAllocated;
return true;
}
return false;
}
// releases the block without clearing the handle structure information
// and without doing a block compact check.
static int _release( AsciiStringAllocatorHandle& handle )
{
const int numblocks = handle.Length / UnitLength;
const int endblock = handle.Index + numblocks;
ScopedLock locker( m_Lock );
for( int i=handle.Index; i<endblock; i++ )
m_PrivateHandles[i].PublicHandle = NULL;
// Rewind the NextPrivateHandle if we haven't allocated anything else
// since this allocation was made.
if( endblock == m_NextPrivateHandle )
m_NextPrivateHandle = handle.Index;
return numblocks;
}
void Release( AsciiStringAllocatorHandle& handle )
{
handle.Index = -1;
handle.Length = 0;
m_release_counter += _release( handle );
if( m_release_counter >= AllocationCleanupThreshold )
DoCleanup();
}
// Allocates a new handle and copies the old string contents to the new reserve.
void Reallocate( AsciiStringAllocatorHandle& handle, int newsize )
{
int newblocks = (newsize / UnitLength)+1;
newsize = newblocks * UnitLength;
ScopedLock locker( m_Lock );
_release( handle );
m_StringBuffer.MakeRoomFor( m_NextPrivateHandle + newblocks );
if( m_NextPrivateHandle != handle.Index )
{
memcpy_fast(
m_StringBuffer.GetPtr( m_NextPrivateHandle ),
m_StringBuffer(handle.Index),
handle.Length
);
handle.Index = m_NextPrivateHandle;
}
handle.Length = newsize;
}
};
AsciiStringAllocatorHandle::GetPtr() const
{
return AsciiStringAllocator::GetPtr( *this );
}
//////////////////////////////////////////////////////////////////////////////////////////
//
AsciiString::AsciiString( int length_reserve )
{
AsciiStringAllocator::New( m_MemoryHandle, len )
}
const wxCharBuffer AsciiString::mb_str() const
{
// use wxCharBuffer here for sake of safety, since parallel string operations could
// result in the pointer to this string becoming invalid.
ScopedLock locker( AsciiStringAllocator::m_Lock );
return wxCharBuffer( AsciiStringAllocator::GetPtr( m_MemoryHandle ) );
}
AsciiStringLock::operator char*()
{
return m_buffer;
}
char& AsciiStringLock::operator[]( int idx )
{
return m_buffer[idx];
}
char AsciiStringLock::GetCharAt( int idx ) const
{
return m_buffer[idx];
}
char* AsciiStringLock::GetPtr()
{
return m_buffer;
}
AsciiStringLock::AsciiStringLock( AsciiString& str ) :
m_string( str )
{
m_string.Lock();
}
AsciiStringLock::~AsciiStringLock()
{
m_string.Unlock();
}
AsciiStringLock::operator char*()
{
AsciiStringAllocator::GetPtr( m_handle );
}
AsciiString AsciiString::operator+( const AsciiString& right )
{
int len = GetLength() + right.GetLength();
AsciiString dest( len+1 );
char* lockptr = m_MemoryHandle.GetPtr();
memcpy_fast( lockptr, GetBufferPtr(), GetLength() );
memcpy_fast( lockptr+GetLength(), right.GetBufferPtr(), right.GetLength() );
lockptr[dest.GetLength()] = 0;
}
AsciiString& AsciiString::Append( const AsciiString& src )
{
int needlen = src.GetLength() + GetLength()+1;
if( needlen >= m_MemoryHandle.Length )
{
// The new string is too large -- looks like we're going to need to allocate
// a larger block. We try and use Grow first, if the appending string is very
// short (it sometimes saves the need to copy the block to a new location)
if( src.GetLength() >= AsciiStringAllocator::UnitLength || !AsciiStringAllocator::Grow( m_MemoryHandle ) )
AsciiStringAllocator::Reallocate( m_MemoryHandle, needlen );
}
char* lockptr = m_MemoryHandle.GetPtr();
memcpy_fast( lockptr+GetLength(), src.GetBufferPtr(), src.GetLength() );
lockptr[GetLength()] = 0;
}

View File

@ -1,84 +0,0 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
class AsciiStringAllocatorHandle
{
public:
const int Index;
const int Length;
public:
AsciiStringAllocatorHandle( int handle, int len ) :
Index( handle ),
Length( len )
{
}
char* GetPtr() const;
void Lock();
void Unlock();
};
class AsciiString
{
protected:
AsciiStringAllocatorHandle m_MemoryHandle;
int m_Length;
public:
AsciiString();
AsciiString( AsciiString& copycat );
AsciiString( const char* src );
AsciiString( const char* src, int length );
AsciiString( const char* src, int startpos, int length );
AsciiString( int length_reserve );
const char* mb_str() const;
char mb_str_unsafe();
int GetLength() const
{
return m_Length;
}
AsciiString operator+( const AsciiString& right );
AsciiString& Append( const AsciiString& src );
void Lock();
void Unlock();
};
class AsciiStringLock
{
protected:
AsciiString& m_string;
char* m_buffer;
public:
AsciiStringLock( const AsciiStringAllocatorHandle& handle );
~AsciiStringLock();
char* GetPtr();
char GetCharAt( int idx ) const;
operator char*();
char& operator[]( int idx );
const char& operator[]( int idx ) const { return GetCharAt( idx ); }
};

View File

@ -22,13 +22,6 @@
#include <signal.h>
#include "Common.h"
extern void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
extern void __fastcall InstallLinuxExceptionHandler();
extern void __fastcall ReleaseLinuxExceptionHandler();
#define PCSX2_MEM_PROTECT_BEGIN() InstallLinuxExceptionHandler()
#define PCSX2_MEM_PROTECT_END() ReleaseLinuxExceptionHandler()
extern void SignalExit(int sig);
static const uptr m_pagemask = getpagesize()-1;

View File

@ -173,6 +173,7 @@ namespace PathDefs
namespace FilenameDefs
{
extern wxFileName GetConfig();
extern wxFileName GetUsermodeConfig();
extern const wxFileName& Memcard( int slot );
};

View File

@ -30,97 +30,48 @@
#include "R5900Exceptions.h"
using namespace std;
using namespace Console;
// disable all session overrides by default...
SessionOverrideFlags g_Session = {false};
bool sysInitialized = false;
// I can't believe I had to make my own version of trim. C++'s STL is totally whack.
// And I still had to fix it too. I found three samples of trim online and *all* three
// were buggy. People really need to learn to code before they start posting trim
// functions in their blogs. (air)
static void trim( string& line )
{
if ( line.empty() )
return;
int string_size = line.length();
int beginning_of_string = 0;
int end_of_string = string_size - 1;
bool encountered_characters = false;
// find the start of characters in the string
while ( (beginning_of_string < string_size) && (!encountered_characters) )
{
if ( (line[ beginning_of_string ] != ' ') && (line[ beginning_of_string ] != '\t') )
encountered_characters = true;
else
++beginning_of_string;
}
// test if no characters were found in the string
if ( beginning_of_string == string_size )
return;
encountered_characters = false;
// find the character in the string
while ( (end_of_string > beginning_of_string) && (!encountered_characters) )
{
// if a space or tab was found then ignore it
if ( (line[ end_of_string ] != ' ') && (line[ end_of_string ] != '\t') )
encountered_characters = true;
else
--end_of_string;
}
// return the original string with all whitespace removed from its beginning and end
// + 1 at the end to add the space for the string delimiter
//line.substr( beginning_of_string, end_of_string - beginning_of_string + 1 );
line.erase( end_of_string+1, string_size );
line.erase( 0, beginning_of_string );
}
//////////////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------
// This function should be called once during program execution.
//
void SysDetect()
{
using namespace Console;
if( sysInitialized ) return;
sysInitialized = true;
Notice("PCSX2 " PCSX2_VERSION " - compiled on " __DATE__ );
Notice("Savestate version: %x", params g_SaveVersion);
// fixme: This line is here for the purpose of creating external ASM code. Yah. >_<
DevCon::Notice( "EE pc offset: 0x%x, IOP pc offset: 0x%x", params (u32)&cpuRegs.pc - (u32)&cpuRegs, (u32)&psxRegs.pc - (u32)&psxRegs );
cpudetectInit();
string family( cpuinfo.x86Fam );
trim( family );
SetColor( Console::Color_White );
SetColor( Color_Black );
WriteLn( "x86Init:" );
WriteLn(
"\tCPU vendor name = %s\n"
"\tFamilyID = %x\n"
"\tx86Family = %s\n"
"\tCPU speed = %d.%03d Ghz\n"
"\tCores = %d physical [%d logical]\n"
"\tx86PType = %s\n"
"\tx86Flags = %8.8x %8.8x\n"
"\tx86EFlags = %8.8x\n", params
cpuinfo.x86ID, cpuinfo.x86StepID, family.c_str(),
WriteLn( wxsFormat(
L"\tCPU vendor name = %s\n"
L"\tFamilyID = %x\n"
L"\tx86Family = %s\n"
L"\tCPU speed = %d.%03d Ghz\n"
L"\tCores = %d physical [%d logical]\n"
L"\tx86PType = %s\n"
L"\tx86Flags = %8.8x %8.8x\n"
L"\tx86EFlags = %8.8x\n",
wxString::FromAscii( cpuinfo.x86ID ).c_str(), cpuinfo.x86StepID,
wxString::FromAscii( cpuinfo.x86Fam ).Trim().Trim(false).c_str(),
cpuinfo.cpuspeed / 1000, cpuinfo.cpuspeed%1000,
cpuinfo.PhysicalCores, cpuinfo.LogicalCores,
cpuinfo.x86Type, cpuinfo.x86Flags, cpuinfo.x86Flags2,
wxString::FromAscii( cpuinfo.x86Type ).c_str(),
cpuinfo.x86Flags, cpuinfo.x86Flags2,
cpuinfo.x86EFlags
);
) );
WriteLn( "Features:" );
WriteLn(
@ -493,3 +444,24 @@ u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller)
}
return Mem;
}
// Ensures existence of necessary folders, and performs error handling if the
// folders fail to create.
static void InitFolderStructure()
{
}
// Returns FALSE if the core/recompiler memory allocations failed.
bool SysInit()
{
PCSX2_MEM_PROTECT_BEGIN();
SysDetect();
if( !SysAllocateMem() )
return false; // critical memory allocation failure;
SysAllocateDynarecs();
PCSX2_MEM_PROTECT_END();
return true;
}

View File

@ -24,6 +24,7 @@
#include "Utilities/Threading.h" // to use threading stuff, include the Threading namespace in your file.
#include "Misc.h"
extern bool SysInit();
extern void SysDetect(); // Detects cpu type and fills cpuInfo structs.
extern void SysReset(); // Resets the various PS2 cpus, sub-systems, and recompilers.
extern void SysUpdate(); // Called on VBlank (to update i.e. pads)
@ -50,9 +51,29 @@ extern void SysExecute();
// The allocated block has code execution privileges.
// Returns NULL on allocation failure.
extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnamed");
extern void vSyncDebugStuff( uint frame );
#ifdef __LINUX__
extern void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
extern void __fastcall InstallLinuxExceptionHandler();
extern void __fastcall ReleaseLinuxExceptionHandler();
static void NTFS_CompressFile( const wxString& file, bool compressStatus=true ) {}
# define PCSX2_MEM_PROTECT_BEGIN() InstallLinuxExceptionHandler()
# define PCSX2_MEM_PROTECT_END() ReleaseLinuxExceptionHandler()
#elif defined( _WIN32 )
extern int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps);
extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );
# define PCSX2_MEM_PROTECT_BEGIN() __try {
# define PCSX2_MEM_PROTECT_END() } __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
#else
# error PCSX2 - Unsupported operating system platform.
#endif
//////////////////////////////////////////////////////////////////////////////////////////
// Different types of message boxes that the emulator can employ from the friendly confines

View File

@ -154,6 +154,11 @@ namespace FilenameDefs
return wxGetApp().GetAppName() + L".ini";
}
wxFileName GetUsermodeConfig()
{
return L"usermode.ini";
}
const wxFileName& Memcard( int slot )
{
@ -292,6 +297,18 @@ void AppConfig::LoadSave( IniInterface& ini )
//
void AppConfig::Apply()
{
// Ensure existence of necessary documents folders. Plugins and other parts
// of PCSX2 rely on them.
g_Conf->Folders.MemoryCards.Mkdir();
g_Conf->Folders.Savestates.Mkdir();
g_Conf->Folders.Snapshots.Mkdir();
// Update the compression attribute on the Memcards folder.
// Memcards generally compress very well via NTFS compression.
NTFS_CompressFile( g_Conf->Folders.MemoryCards.ToString(), g_Conf->MemoryCards.EnableNTFS );
if( !i18n_SetLanguage( LanguageId ) )
{
if( !i18n_SetLanguage( wxLANGUAGE_DEFAULT ) )
@ -306,7 +323,7 @@ void AppConfig::Apply()
wxConfigBase* cfg = wxConfigBase::Get( false );
wxASSERT( cfg != NULL );
if( g_RecentIsoList != NULL )
g_RecentIsoList->Save( *cfg );
safe_delete( g_RecentIsoList );

View File

@ -89,15 +89,18 @@ static bool OpenLogFile(wxFile& file, wxString& filename, wxWindow *parent)
ConsoleLogFrame::ColorArray::ColorArray() :
m_table( 8 )
{
wxFont fixed( 8, wxMODERN, wxNORMAL, wxNORMAL );
wxFont fixedB( 8, wxMODERN, wxNORMAL, wxBOLD );
// Standard R, G, B format:
new (&m_table[Color_Black]) wxTextAttr( wxColor( 0, 0, 0 ) );
new (&m_table[Color_Red]) wxTextAttr( wxColor( 128, 0, 0 ) );
new (&m_table[Color_Green]) wxTextAttr( wxColor( 0, 128, 0 ) );
new (&m_table[Color_Blue]) wxTextAttr( wxColor( 0, 0, 128 ) );
new (&m_table[Color_Yellow]) wxTextAttr( wxColor( 180, 180, 0 ) );
new (&m_table[Color_Cyan]) wxTextAttr( wxColor( 0, 160, 160 ) );
new (&m_table[Color_Magenta]) wxTextAttr( wxColor( 160, 0, 160 ) );
new (&m_table[Color_White]) wxTextAttr( wxColor( 160, 160, 160 ) );
new (&m_table[Color_Black]) wxTextAttr( wxColor( 0, 0, 0 ), wxNullColour, fixed );
new (&m_table[Color_Red]) wxTextAttr( wxColor( 128, 0, 0 ), wxNullColour, fixedB );
new (&m_table[Color_Green]) wxTextAttr( wxColor( 0, 128, 0 ), wxNullColour, fixed );
new (&m_table[Color_Blue]) wxTextAttr( wxColor( 0, 0, 128 ), wxNullColour, fixed );
new (&m_table[Color_Yellow]) wxTextAttr( wxColor( 160, 160, 0 ), wxNullColour, fixedB );
new (&m_table[Color_Cyan]) wxTextAttr( wxColor( 0, 140, 140 ), wxNullColour, fixed );
new (&m_table[Color_Magenta]) wxTextAttr( wxColor( 160, 0, 160 ), wxNullColour, fixed );
new (&m_table[Color_White]) wxTextAttr( wxColor( 128, 128, 128 ), wxNullColour, fixed );
}
// ------------------------------------------------------------------------
@ -110,16 +113,18 @@ void ConsoleLogFrame::ColorArray::SetFont( const wxFont& font )
m_table[i].SetFont( font );
}
static const Console::Colors DefaultConsoleColor = Color_White;
// ------------------------------------------------------------------------
ConsoleLogFrame::ConsoleLogFrame(MainEmuFrame *parent, const wxString& title) :
wxFrame(parent, wxID_ANY, title)
, m_TextCtrl( *new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxHSCROLL | wxTE_READONLY | wxTE_RICH2 ) )
, m_ColorTable()
, m_curcolor( Color_Black )
, m_curcolor( DefaultConsoleColor )
, m_msgcounter( 0 )
{
m_TextCtrl.SetBackgroundColour( wxColor( 238, 240, 248 ) ); //wxColor( 48, 48, 64 ) );
m_TextCtrl.SetBackgroundColour( wxColor( 230, 235, 242 ) );
// create menu
wxMenuBar *pMenuBar = new wxMenuBar;
@ -156,10 +161,10 @@ ConsoleLogFrame::ConsoleLogFrame(MainEmuFrame *parent, const wxString& title) :
Connect( wxEVT_MOVE, wxMoveEventHandler(ConsoleLogFrame::OnMoveAround) );
Connect( wxEVT_SIZE, wxSizeEventHandler(ConsoleLogFrame::OnResize) );
Connect( wxEVT_LOG_Write, wxCommandEventHandler(ConsoleLogFrame::OnWrite) );
Connect( wxEVT_LOG_Newline, wxCommandEventHandler(ConsoleLogFrame::OnNewline) );
Connect( wxEVT_SetTitleText, wxCommandEventHandler(ConsoleLogFrame::OnSetTitle) );
Connect( wxEVT_DockConsole, wxCommandEventHandler(ConsoleLogFrame::OnDockedMove) );
Connect( wxEVT_LOG_Write, wxCommandEventHandler(ConsoleLogFrame::OnWrite) );
Connect( wxEVT_LOG_Newline, wxCommandEventHandler(ConsoleLogFrame::OnNewline) );
Connect( wxEVT_SetTitleText,wxCommandEventHandler(ConsoleLogFrame::OnSetTitle) );
Connect( wxEVT_DockConsole, wxCommandEventHandler(ConsoleLogFrame::OnDockedMove) );
}
ConsoleLogFrame::~ConsoleLogFrame() { }
@ -257,8 +262,8 @@ void ConsoleLogFrame::SetColor( Colors color )
void ConsoleLogFrame::ClearColor()
{
m_curcolor = Color_Black;
m_TextCtrl.SetDefaultStyle( m_ColorTable.Default() );
if( DefaultConsoleColor != m_curcolor )
m_TextCtrl.SetDefaultStyle( m_ColorTable[m_curcolor=DefaultConsoleColor] );
}
void ConsoleLogFrame::OnWrite( wxCommandEvent& event )
@ -368,7 +373,7 @@ void ConsoleLogFrame::DoMessage()
namespace Console
{
// thread-local console color storage.
__threadlocal Colors th_CurrentColor = Color_Black;
__threadlocal Colors th_CurrentColor = DefaultConsoleColor;
void __fastcall SetTitle( const wxString& title )
{
@ -384,7 +389,7 @@ namespace Console
void ClearColor()
{
th_CurrentColor = Color_Black;
th_CurrentColor = DefaultConsoleColor;
}
bool Newline()

View File

@ -72,17 +72,26 @@ bool Dialogs::ConfigurationDialog::ApplySettings()
{
AppConfig confcopy( *g_Conf );
int pagecount = m_listbook.GetPageCount();
for( int i=0; i<pagecount; ++i )
try
{
BaseApplicableConfigPanel* panel = (BaseApplicableConfigPanel*)m_listbook.GetPage(i);
if( !panel->Apply( confcopy ) ) return false;
int pagecount = m_listbook.GetPageCount();
for( int i=0; i<pagecount; ++i )
{
BaseApplicableConfigPanel* panel = (BaseApplicableConfigPanel*)m_listbook.GetPage(i);
panel->Apply( confcopy );
}
*g_Conf = confcopy;
g_Conf->Apply();
g_Conf->Save();
}
catch( Exception::CannotApplySettings& ex )
{
wxMessageBox( ex.DisplayMessage(), _("Cannot apply settings...") );
// TODO : Automatically switch focus to the panel that failed.
return false;
}
*g_Conf = confcopy;
g_Conf->Apply();
g_Conf->Save();
return true;
}

View File

@ -22,6 +22,7 @@
#include <wx/image.h>
#include "wxHelpers.h"
#include "Panels/ConfigurationPanels.h"
namespace Dialogs
{
@ -38,8 +39,14 @@ namespace Dialogs
class PickUserModeDialog : public wxDialogWithHelpers
{
protected:
Panels::UsermodeSelectionPanel* m_panel_usersel;
public:
PickUserModeDialog( wxWindow* parent, int id=wxID_ANY );
protected:
void OnOk_Click( wxCommandEvent& evt );
};
}

View File

@ -17,20 +17,75 @@
*/
#include "PrecompiledHeader.h"
#include "ModalPopups.h"
#include <wx/stdpaths.h>
using namespace wxHelpers;
Panels::UsermodeSelectionPanel::UsermodeSelectionPanel( wxWindow* parent ) :
BaseApplicableConfigPanel( parent )
, m_radio_user( NULL )
, m_radio_cwd( NULL )
{
wxStaticBoxSizer& s_boxer = *new wxStaticBoxSizer( wxVERTICAL, this, _( "Usermode Selection" ) );
AddStaticText( s_boxer,
L"Please select your preferred default location for PCSX2 user-level documents below "
L"(includes memory cards, screenshots, settings, and savestates). "
L"These folder locations can be overridden at any time using the Core Settings panel.",
480, wxALIGN_CENTRE );
m_radio_user = &AddRadioButton( s_boxer, _("User Documents (recommended)"), _("Location: ") + wxStandardPaths::Get().GetDocumentsDir() );
m_radio_cwd = &AddRadioButton( s_boxer, _("Current working folder (intended for developer use only)"), _("Location: ") + wxGetCwd() );
s_boxer.AddSpacer( 4 );
SetSizerAndFit( &s_boxer );
}
void Panels::UsermodeSelectionPanel::Apply( AppConfig& conf )
{
if( !m_radio_cwd->GetValue() && !m_radio_user->GetValue() )
throw Exception::CannotApplySettings( wxLt( "You must select one of the available user modes before proceeding." ) );
conf.UseAdminMode = m_radio_cwd->GetValue();
}
Dialogs::PickUserModeDialog::PickUserModeDialog( wxWindow* parent, int id ) :
wxDialogWithHelpers( parent, id, _("PCSX2 Select User Mode"), false )
wxDialogWithHelpers( parent, id, _("PCSX2 First Time configuration"), false )
, m_panel_usersel( new Panels::UsermodeSelectionPanel( this ) )
{
wxBoxSizer& s_main = *new wxBoxSizer( wxVERTICAL );
AddStaticText( s_main, _("PCSX2 is starting from a new or unknown working directory and needs to be configured."), 400 );
AddStaticText( s_main, _("Current Working Directory: ") + wxGetCwd(), 480 );
AddStaticText( s_main, _("PCSX2 is starting from a new or unknown folder and needs to be configured."),
0, wxALIGN_CENTRE );
s_main.AddSpacer( 8 );
s_main.Add( m_panel_usersel, SizerFlags::StdGroupie() );
//new wxListCt
AddOkCancel( s_main );
SetSizerAndFit( &s_main );
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PickUserModeDialog::OnOk_Click ) );
}
void Dialogs::PickUserModeDialog::OnOk_Click( wxCommandEvent& evt )
{
AppConfig confcopy( *g_Conf );
try
{
m_panel_usersel->Apply( confcopy );
*g_Conf = confcopy;
g_Conf->Apply();
g_Conf->Save();
Close();
evt.Skip();
}
catch( Exception::CannotApplySettings& ex )
{
wxMessageBox( ex.DisplayMessage() + L"\n" + _("You may press Cancel to close the program."), _("Cannot apply settings...") );
}
}

View File

@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hopeb that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@ -18,16 +18,10 @@
#include "PrecompiledHeader.h"
#include "MainFrame.h"
#include "Dialogs/LogOptionsDialog.h"
#include "Dialogs/ModalPopups.h"
#include "Resources/EmbeddedImage.h"
#include "Resources/AppIcon.h"
#include "Dialogs/ConfigurationDialog.h"
using namespace Dialogs;
// ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeStatesMenu()
{
@ -339,82 +333,3 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainEmuFrame::OnCloseWindow) );
}
void MainEmuFrame::Menu_ConfigSettings_Click(wxCommandEvent &event)
{
Dialogs::ConfigurationDialog( this ).ShowModal();
}
void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event)
{
wxFileDialog ctrl( this, _("Run PS2 Iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString,
L"Iso Image (*.iso)|*.iso|(*.mdf)|*.mdf|Nero Image (*.nrg)|*.nrg", wxFD_FILE_MUST_EXIST );
ctrl.ShowModal();
Console::WriteLn( L"Test Iso Open: " + ctrl.GetFilename() );
}
void MainEmuFrame::Menu_RunWithoutDisc_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event)
{
//Console::Status( "%d", params event.GetId() - g_RecentIsoList->GetBaseId() );
//Console::WriteLn( Color_Magenta, g_RecentIsoList->GetHistoryFile( event.GetId() - g_RecentIsoList->GetBaseId() ) );
}
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_LoadStateOther_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_SaveStateOther_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Exit_Click(wxCommandEvent &event)
{
Close();
}
void MainEmuFrame::Menu_Suspend_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Resume_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Reset_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_MemoryDump_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_Logging_Click(wxCommandEvent &event)
{
LogOptionsDialog( this, wxID_ANY ).ShowModal();
}
void MainEmuFrame::Menu_ShowConsole(wxCommandEvent &event)
{
// Use messages to relay open/close commands (thread-safe)
g_Conf->ConLogBox.Visible = event.IsChecked();
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, g_Conf->ConLogBox.Visible ? wxID_OPEN : wxID_CLOSE );
wxGetApp().ProgramLog_PostEvent( evt );
}
void MainEmuFrame::Menu_ShowAboutBox(wxCommandEvent &event)
{
AboutBoxDialog( this, wxID_ANY ).ShowModal();
}

View File

@ -0,0 +1,112 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "MainFrame.h"
#include "Dialogs/ModalPopups.h"
#include "Dialogs/ConfigurationDialog.h"
#include "Dialogs/LogOptionsDialog.h"
using namespace Dialogs;
void MainEmuFrame::Menu_ConfigSettings_Click(wxCommandEvent &event)
{
Dialogs::ConfigurationDialog( this ).ShowModal();
}
static const wxChar* isoFilterTypes =
L"Iso Image (*.iso)|*.iso|Bin Image|(*.bin)|MDF Image (*.mdf)|*.mdf|Nero Image (*.nrg)|*.nrg";
void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event)
{
Console::Status( L"Default Folder: " + g_Conf->Folders.RunIso.ToString() );
wxFileDialog ctrl( this, _("Run PS2 Iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString,
isoFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( ctrl.ShowModal() == wxID_CANCEL ) return;
g_Conf->Folders.RunIso = ctrl.GetPath();
}
void MainEmuFrame::Menu_RunWithoutDisc_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event)
{
//Console::Status( "%d", params event.GetId() - g_RecentIsoList->GetBaseId() );
//Console::WriteLn( Color_Magenta, g_RecentIsoList->GetHistoryFile( event.GetId() - g_RecentIsoList->GetBaseId() ) );
}
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_LoadStateOther_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_SaveStateOther_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Exit_Click(wxCommandEvent &event)
{
Close();
}
void MainEmuFrame::Menu_Suspend_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Resume_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Reset_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_MemoryDump_Click(wxCommandEvent &event)
{
}
void MainEmuFrame::Menu_Debug_Logging_Click(wxCommandEvent &event)
{
LogOptionsDialog( this, wxID_ANY ).ShowModal();
}
void MainEmuFrame::Menu_ShowConsole(wxCommandEvent &event)
{
// Use messages to relay open/close commands (thread-safe)
g_Conf->ConLogBox.Visible = event.IsChecked();
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, g_Conf->ConLogBox.Visible ? wxID_OPEN : wxID_CLOSE );
wxGetApp().ProgramLog_PostEvent( evt );
}
void MainEmuFrame::Menu_ShowAboutBox(wxCommandEvent &event)
{
AboutBoxDialog( this, wxID_ANY ).ShowModal();
}

View File

@ -31,6 +31,28 @@
#include "Utilities/SafeArray.h"
#include "Utilities/Threading.h"
namespace Exception
{
// --------------------------------------------------------------------------
// Exception used to perform an abort of Apply/Ok action on settings panels.
// When thrown, the user recieves a popup message containing the information
// specified in the exception message, and is returned to the settings dialog
// to correct the invalid input fields.
//
class CannotApplySettings : public BaseException
{
public:
virtual ~CannotApplySettings() throw() {}
CannotApplySettings( const CannotApplySettings& src ) : BaseException( src ) {}
explicit CannotApplySettings( const char* msg=wxLt("Cannot apply new settings, one of the settings is invalid.") ) :
BaseException( msg ) {}
explicit CannotApplySettings( const wxString& msg_eng, const wxString& msg_xlt ) :
BaseException( msg_eng, msg_xlt ) { }
};
}
namespace Panels
{
//////////////////////////////////////////////////////////////////////////////////////////
@ -46,17 +68,33 @@ namespace Panels
// This method attempts to assign the settings for the panel into the given
// configuration structure (which is typically a copy of g_Conf). If validation
// of form contents fails, the function returns false.
virtual bool Apply( AppConfig& conf )=0;
// of form contents fails, the function should throw Exception::CannotApplySettings.
// If no exceptions are thrown, then the operation is assumed a success. :)
virtual void Apply( AppConfig& conf )=0;
};
//////////////////////////////////////////////////////////////////////////////////////////
//
class UsermodeSelectionPanel : public BaseApplicableConfigPanel
{
protected:
wxRadioButton* m_radio_user;
wxRadioButton* m_radio_cwd;
public:
virtual ~UsermodeSelectionPanel() { }
UsermodeSelectionPanel( wxWindow* parent );
void Apply( AppConfig& conf );
};
//////////////////////////////////////////////////////////////////////////////////////////
//
class SpeedHacksPanel : public BaseApplicableConfigPanel
{
public:
SpeedHacksPanel(wxWindow& parent);
bool Apply( AppConfig& conf );
void Apply( AppConfig& conf );
protected:
void IOPCycleDouble_Click(wxCommandEvent &event);
@ -71,7 +109,7 @@ namespace Panels
{
public:
GameFixesPanel(wxWindow& parent);
bool Apply( AppConfig& conf );
void Apply( AppConfig& conf );
void FPUCompareHack_Click(wxCommandEvent &event);
void FPUMultHack_Click(wxCommandEvent &event);
@ -127,7 +165,7 @@ namespace Panels
public:
PathsPanel(wxWindow& parent);
bool Apply( AppConfig& conf );
void Apply( AppConfig& conf );
};
//////////////////////////////////////////////////////////////////////////////////////////
@ -219,7 +257,7 @@ namespace Panels
virtual void OnProgress( wxCommandEvent& evt );
virtual void OnEnumComplete( wxCommandEvent& evt );
bool Apply( AppConfig& conf );
void Apply( AppConfig& conf );
protected:
void DoRefresh();

View File

@ -52,9 +52,8 @@ Panels::GameFixesPanel::GameFixesPanel( wxWindow& parent ) :
Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( GameFixesPanel::GodWar_Click ) );
}
bool Panels::GameFixesPanel::Apply( AppConfig& conf )
void Panels::GameFixesPanel::Apply( AppConfig& conf )
{
return true;
}
void Panels::GameFixesPanel::FPUCompareHack_Click(wxCommandEvent &event)

View File

@ -114,20 +114,8 @@ Panels::PathsPanel::AdvancedPanel::AdvancedPanel( wxWindow& parent, int id ) :
AddDirPicker( advanced, g_Conf->Folders.Settings, PathDefs::GetSettings,
_("Settings:"), _("Select a folder for PCSX2 settings/inis"), Msg_Tooltips_SettingsPath );
wxStaticBoxSizer& s_diag = *new wxStaticBoxSizer( wxVERTICAL, this, _("Default folder mode") );
AddStaticText( s_diag,
L"This setting only affects folders which are set to use the default folder configurations for your "
L"operating system. Any folders which are configured manually will override this option. ",
400, wxALIGN_CENTRE );
AddRadioButton( s_diag, _("Use to your Documents folder"), _("Location: ") + wxStandardPaths::Get().GetDocumentsDir() );
AddRadioButton( s_diag, _("Use the current working folder"), _("Location: ") + wxGetCwd() );
s_diag.AddSpacer( 4 );
advanced.AddSpacer( 4 );
advanced.Add( &s_diag, SizerFlags::StdGroupie() );
advanced.Add( new UsermodeSelectionPanel( this ), SizerFlags::StdGroupie() );
s_main.Add( &advanced, SizerFlags::StdGroupie() );
s_main.AddSpacer( 5 );
@ -150,7 +138,6 @@ Panels::PathsPanel::PathsPanel( wxWindow& parent ) :
SetSizerAndFit( &s_main );
}
bool Panels::PathsPanel::Apply( AppConfig& conf )
void Panels::PathsPanel::Apply( AppConfig& conf )
{
return true;
}

View File

@ -251,7 +251,7 @@ Panels::PluginSelectorPanel::~PluginSelectorPanel()
safe_delete( m_EnumeratorThread );
}
bool Panels::PluginSelectorPanel::Apply( AppConfig& conf )
void Panels::PluginSelectorPanel::Apply( AppConfig& conf )
{
for( int i=0; i<NumPluginTypes; ++i )
{
@ -262,8 +262,6 @@ bool Panels::PluginSelectorPanel::Apply( AppConfig& conf )
relative.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
conf.BaseFilenames.Plugins[tbl_PluginInfo[i].id] = relative.GetFullPath();
}
return true;
}
void Panels::PluginSelectorPanel::DoRefresh()

View File

@ -77,9 +77,8 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow& parent ) :
Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SpeedHacksPanel::IdleLoopFF_Click ) );
}
bool Panels::SpeedHacksPanel::Apply( AppConfig& conf )
void Panels::SpeedHacksPanel::Apply( AppConfig& conf )
{
return true;
}
void Panels::SpeedHacksPanel::IOPCycleDouble_Click(wxCommandEvent &event)

View File

@ -31,6 +31,23 @@ IMPLEMENT_APP(Pcsx2App)
AppConfig* g_Conf = NULL;
wxFileHistory* g_RecentIsoList = NULL;
namespace Exception
{
// --------------------------------------------------------------------------
// Exception used to perfom an "errorless" termination of the app during OnInit
// procedures. This happens when a user cancels out of startup prompts/wizards.
//
class StartupAborted : public BaseException
{
public:
virtual ~StartupAborted() throw() {}
StartupAborted( const StartupAborted& src ) : BaseException( src ) {}
explicit StartupAborted( const wxString& msg_eng=L"Startup initialization was aborted by the user." ) :
BaseException( msg_eng, msg_eng ) { } // english messages only for this exception.
};
}
Pcsx2App::Pcsx2App() :
m_ProgramLogBox( NULL )
, m_Ps2ConLogBox( NULL )
@ -51,22 +68,38 @@ wxFileConfig* OpenConfig( const wxString& filename )
void Pcsx2App::ReadUserModeSettings()
{
wxString configfile( Path::Combine( wxGetCwd(), L"usermode.ini" ) );
wxFileName usermodefile( FilenameDefs::GetUsermodeConfig() );
usermodefile.SetPath( wxGetCwd() );
if( !wxFile::Exists( configfile ) )
wxFileConfig* conf_usermode = OpenConfig( usermodefile.GetFullPath() );
if( !wxFile::Exists( usermodefile.GetFullPath() ) )
{
Dialogs::PickUserModeDialog( m_MainFrame ).ShowModal();
// first time startup, so give the user the choice of user mode:
if( Dialogs::PickUserModeDialog( NULL ).ShowModal() == wxID_CANCEL )
throw Exception::StartupAborted( L"Startup aborted: User cancelled Usermode selection." );
// Save user's new settings
if( conf_usermode != NULL )
{
IniSaver saver( *conf_usermode );
g_Conf->LoadSaveUserMode( saver );
}
}
else
{
// usermode.ini exists -- assume Documents mode, unless the ini explicitly
// specifies otherwise.
g_Conf->UseAdminMode = false;
if( conf_usermode != NULL )
{
IniLoader loader( *conf_usermode );
g_Conf->LoadSaveUserMode( loader );
}
}
wxFileConfig* conf_usermode = OpenConfig( Path::Combine( wxGetCwd(), L"usermode.ini" ) );
// Ensure proper scoping (IniLoader gets closed prior to delete)
{
IniLoader loader( *conf_usermode );
g_Conf->LoadSaveUserMode( loader );
}
delete conf_usermode;
safe_delete( conf_usermode );
}
// ------------------------------------------------------------------------
@ -75,6 +108,8 @@ void Pcsx2App::ReadUserModeSettings()
//
bool Pcsx2App::TryOpenConfigCwd()
{
ReadUserModeSettings();
wxDirName inipath_cwd( (wxDirName)wxGetCwd() + PathDefs::Base::Settings() );
if( !inipath_cwd.IsReadable() ) return false;
@ -167,23 +202,34 @@ bool Pcsx2App::OnInit()
//
// Conveniently this dual mode setup applies equally well to most modern Linux distros.
if( !TryOpenConfigCwd() )
try
{
PathDefs::GetDocuments().Mkdir();
PathDefs::GetSettings().Mkdir();
if( !TryOpenConfigCwd() )
{
PathDefs::GetDocuments().Mkdir();
PathDefs::GetSettings().Mkdir();
// Allow wx to use our config, and enforces auto-cleanup as well
wxString confile( Path::Combine( PathDefs::GetSettings(), FilenameDefs::GetConfig() ) );
wxConfigBase::Set( OpenConfig( confile ) );
wxConfigBase::Get()->SetRecordDefaults();
// Allow wx to use our config, and enforces auto-cleanup as well
wxString confile( Path::Combine( PathDefs::GetSettings(), FilenameDefs::GetConfig() ) );
wxConfigBase::Set( OpenConfig( confile ) );
wxConfigBase::Get()->SetRecordDefaults();
}
g_Conf->Load();
g_Conf->Apply();
g_Conf->Folders.Logs.Mkdir();
m_ProgramLogBox = new ConsoleLogFrame( NULL, L"PCSX2 Program Log" );
m_Ps2ConLogBox = m_ProgramLogBox; // just use a single logger for now.
m_ProgramLogBox->Hide();
//m_Ps2ConLogBox = new ConsoleLogFrame( NULL, L"PS2 Console Log" );
SysInit();
}
g_Conf->Load();
g_Conf->Apply();
m_ProgramLogBox = new ConsoleLogFrame( NULL, L"PCSX2 Program Log" );
m_Ps2ConLogBox = m_ProgramLogBox; // just use a single logger for now.
//m_Ps2ConLogBox = new ConsoleLogFrame( NULL, L"PS2 Console Log" );
catch( Exception::StartupAborted& )
{
return false;
}
m_MainFrame = new MainEmuFrame( NULL, L"PCSX2" );
SetTopWindow( m_MainFrame );

View File

@ -175,9 +175,9 @@ wxCheckBox& wxDialogWithHelpers::AddCheckBox( wxSizer& sizer, const wxString& la
return wxHelpers::AddCheckBoxTo( this, sizer, label, id );
}
wxStaticText& wxDialogWithHelpers::AddStaticText(wxSizer& sizer, const wxString& label, int size )
wxStaticText& wxDialogWithHelpers::AddStaticText(wxSizer& sizer, const wxString& label, int size, int alignFlags )
{
return wxHelpers::AddStaticTextTo( this, sizer, label, size );
return wxHelpers::AddStaticTextTo( this, sizer, label, size, alignFlags );
}
void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )

View File

@ -33,7 +33,7 @@ public:
protected:
wxCheckBox& AddCheckBox( wxSizer& sizer, const wxString& label, wxWindowID id=wxID_ANY );
wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int size=0 );
wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int size=0, int alignFlags=wxALIGN_LEFT );
void AddOkCancel( wxSizer& sizer, bool hasApply=false );
};

View File

@ -1966,6 +1966,10 @@
RelativePath="..\..\gui\MainFrame.h"
>
</File>
<File
RelativePath="..\..\gui\MainMenuClicks.cpp"
>
</File>
<File
RelativePath="..\..\gui\wxHelpers.cpp"
>
@ -2138,6 +2142,10 @@
RelativePath="..\WinCompressNTFS.cpp"
>
</File>
<File
RelativePath="..\WinSysExec.cpp"
>
</File>
<Filter
Name="ISO"
>

View File

@ -19,10 +19,6 @@
#pragma once
#include "Utilities/RedtapeWindows.h" // our "safe" include of windows (sets version and undefs uselessness)
#include <commctrl.h>
#include <windowsx.h>
#include <tchar.h>
#include "System.h"
#include "HostGui.h"
@ -36,18 +32,7 @@ int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps);
#define PCSX2_MEM_PROTECT_BEGIN() __try {
#define PCSX2_MEM_PROTECT_END() } __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
// --->> Ini Configuration [ini.c]
extern char g_WorkingFolder[g_MaxPath];
extern const char* g_CustomConfigFile;
bool LoadConfig();
void SaveConfig();
// <<--- END Ini Configuration [ini.c]
// --->> Patch Browser Stuff (in the event we ever use it
// --->> Patch Browser Stuff (in the event we ever use it)
void ListPatches (HWND hW);
int ReadPatch (HWND hW, char fileName[1024]);
@ -56,114 +41,13 @@ BOOL Save_Patch_Proc( char * filename );
// <<--- END Patch Browser
struct AppData
{
HWND hWnd; // Main window handle
HINSTANCE hInstance; // Application instance
HMENU hMenu; // Main window menu
};
class IniFile
{
protected:
wxString m_filename;
wxString m_section;
public:
virtual ~IniFile();
IniFile();
void SetCurrentSection( const wxString& newsection );
virtual void Entry( const wxString& var, wxString& value, const wxString& defvalue=wxString() )=0;
virtual void Entry( const wxString& var, char (&value)[g_MaxPath], const wxString& defvalue=wxString() )=0;
virtual void Entry( const wxString& var, int& value, const int defvalue=0 )=0;
virtual void Entry( const wxString& var, uint& value, const uint defvalue=0 )=0;
virtual void Entry( const wxString& var, bool& value, const bool defvalue=0 )=0;
virtual void EnumEntry( const wxString& var, int& value, const char* const* enumArray, const int defvalue=0 )=0;
void DoConfig( PcsxConfig& Conf );
void MemcardSettings( PcsxConfig& Conf );
};
class IniFileLoader : public IniFile
{
protected:
SafeArray<char> m_workspace;
public:
virtual ~IniFileLoader();
IniFileLoader();
void Entry( const wxString& var, wxString& value, const wxString& defvalue=wxString() );
void Entry( const wxString& var, char (&value)[g_MaxPath], const wxString& defvalue=wxString() );
void Entry( const wxString& var, int& value, const int defvalue=0 );
void Entry( const wxString& var, uint& value, const uint defvalue=0 );
void Entry( const wxString& var, bool& value, const bool defvalue=false );
void EnumEntry( const wxString& var, int& value, const char* const* enumArray, const int defvalue=0 );
};
class IniFileSaver : public IniFile
{
public:
virtual ~IniFileSaver();
IniFileSaver();
void Entry( const wxString& var, const wxString& value, const wxString& defvalue=wxString() );
void Entry( const wxString& var, wxString& value, const wxString& defvalue=wxString() );
void Entry( const wxString& var, char (&value)[g_MaxPath], const wxString& defvalue=wxString() );
void Entry( const wxString& var, int& value, const int defvalue=0 );
void Entry( const wxString& var, uint& value, const uint defvalue=0 );
void Entry( const wxString& var, bool& value, const bool defvalue=false );
void EnumEntry( const wxString& var, int& value, const char* const* enumArray, const int defvalue=0 );
};
extern LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
extern void CreateMainWindow();
extern void RunGui();
extern bool HostGuiInit();
extern BOOL Pcsx2Configure(HWND hWnd);
extern void InitLanguages();
extern char *GetLanguageNext();
extern void CloseLanguages();
extern void ChangeLanguage(char *lang);
extern void WinClose();
extern void ExecuteCpu();
extern void OnStates_LoadOther();
extern void OnStates_SaveOther();
extern int ParseCommandLine( int tokenCount, TCHAR *const *const tokens );
extern BOOL CALLBACK PatchBDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK CpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK AdvancedOptionsProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
//extern BOOL CALLBACK HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
extern AppData gApp;
extern HWND hStatusWnd;
extern PcsxConfig winConfig; // local storage of the configuration options.
extern bool nDisableSC; // screensaver
extern unsigned int langsMax;
extern SafeArray<u8>* g_RecoveryState;
extern SafeArray<u8>* g_gsRecoveryState;
extern const char* g_pRunGSState;
extern int g_SaveGSStream;
// Throws an exception based on the value returned from GetLastError.
// Performs an option return value success/fail check on hresult.
extern void StreamException_ThrowLastError( const wxString& streamname, HANDLE result=INVALID_HANDLE_VALUE );
// Throws an exception based on the given error code (usually taken from ANSI C's errno)
extern void StreamException_ThrowFromErrno( const wxString& streamname, errno_t errcode );
extern bool StreamException_LogFromErrno( const wxString& streamname, const wxChar* action, errno_t result );
extern bool StreamException_LogLastError( const wxString& streamname, const wxChar* action, HANDLE result=INVALID_HANDLE_VALUE );
// Sets the NTFS compression flag for a directory or file. This function does not operate
// recursively. Set compressStatus to false to decompress compressed files (and do nothing
// to already decompressed files).
extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );

View File

@ -19,6 +19,7 @@
#include "Win32.h"
// Translates an Errno code into an exception.
// Throws an exception based on the given error code (usually taken from ANSI C's errno)
void StreamException_ThrowFromErrno( const wxString& streamname, errno_t errcode )
{
if( errcode == 0 ) return;
@ -53,6 +54,8 @@ void StreamException_ThrowFromErrno( const wxString& streamname, errno_t errcode
}
}
// Throws an exception based on the value returned from GetLastError.
// Performs an option return value success/fail check on hresult.
void StreamException_ThrowLastError( const wxString& streamname, HANDLE result )
{
if( result != INVALID_HANDLE_VALUE ) return;
@ -118,7 +121,13 @@ bool StreamException_LogLastError( const wxString& streamname, const wxChar* act
return false;
}
// Exceptions thrown: None. Errors are logged to console. Failures are considered non-critical
// Sets the NTFS compression flag for a directory or file. This function does not operate
// recursively. Set compressStatus to false to decompress compressed files (and do nothing
// to already decompressed files).
//
// Exceptions thrown: None.
// (Errors are logged to console. Failures are considered non-critical)
//
void NTFS_CompressFile( const wxString& file, bool compressStatus )
{
bool isFile = !wxDirExists( file );

View File

@ -16,30 +16,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "Win32.h"
#include <winnt.h>
#include "Common.h"
#include "VUmicro.h"
#include "iR5900.h"
// temporary hack to keep this code compiling.
//static const char* _( const char* src ) { return src; }
static bool sinit = false;
bool nDisableSC = false; // screensaver
// This instance is not modified by command line overrides so
// that command line plugins and stuff won't be saved into the
// user's conf file accidentally.
PcsxConfig winConfig; // local storage of the configuration options.
HWND hStatusWnd = NULL;
AppData gApp;
const char* g_pRunGSState = NULL;
int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps )
{
@ -61,45 +43,6 @@ int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps )
return EXCEPTION_CONTINUE_EXECUTION;
}
static void CreateDirs()
{
Path::CreateDirectory(MEMCARDS_DIR);
Path::CreateDirectory(SSTATES_DIR);
Path::CreateDirectory(SNAPSHOTS_DIR);
}
/*
bool HostGuiInit()
{
if( sinit ) return true;
sinit = true;
CreateDirs();
// Set the compression attribute on the Memcards folder.
// Memcards generally compress very well via NTFS compression.
NTFS_CompressFile( MEMCARDS_DIR, Config.McdEnableNTFS );
#ifdef OLD_TESTBUILD_STUFF
if( IsDevBuild && emuLog == NULL && g_TestRun.plogname != NULL )
emuLog = fopen(g_TestRun.plogname, "w");
#endif
if( emuLog == NULL )
emuLog = fopen(LOGS_DIR "\\emuLog.txt","w");
PCSX2_MEM_PROTECT_BEGIN();
SysDetect();
if( !SysAllocateMem() )
return false; // critical memory allocation failure;
SysAllocateDynarecs();
PCSX2_MEM_PROTECT_END();
return true;
}
*/
namespace HostSys
{
void *Mmap(uptr base, u32 size)