mirror of https://github.com/PCSX2/pcsx2.git
Added drag&drop for the main window (supports isos and ELFs -- isos are automatically added to the Recent Iso menu), and fixed some minor bugs in managing/updating the recent iso menu.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2122 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
35aac70cd1
commit
b9e372ec75
|
@ -71,7 +71,9 @@ bool tryIsoType(isoFile *iso, u32 size, u32 offset, u32 blockofs)
|
|||
return false;
|
||||
}
|
||||
|
||||
int isoDetect(isoFile *iso) // based on florin's CDVDbin detection code :)
|
||||
// based on florin's CDVDbin detection code :)
|
||||
// Returns 0 if the image is valid/known/supported, or -1 if not (iso->type == ISOTYPE_ILLEGAL).
|
||||
int isoDetect(isoFile *iso)
|
||||
{
|
||||
char buf[32];
|
||||
int len;
|
||||
|
@ -106,11 +108,11 @@ int isoDetect(isoFile *iso) // based on florin's CDVDbin detection code :)
|
|||
iso->blocks = 16;
|
||||
}
|
||||
|
||||
if (tryIsoType(iso, 2048, 0, 24)) return 0; // ISO 2048
|
||||
if (tryIsoType(iso, 2336, 0, 16)) return 0; // RAW 2336
|
||||
if (tryIsoType(iso, 2048, 0, 24)) return 0; // ISO 2048
|
||||
if (tryIsoType(iso, 2336, 0, 16)) return 0; // RAW 2336
|
||||
if (tryIsoType(iso, 2352, 0, 0)) return 0; // RAW 2352
|
||||
if (tryIsoType(iso, 2448, 0, 0)) return 0; // RAWQ 2448
|
||||
if (tryIsoType(iso, 2048, 150 * 2048, 24)) return 0; // NERO ISO 2048
|
||||
if (tryIsoType(iso, 2048, 150 * 2048, 24)) return 0; // NERO ISO 2048
|
||||
if (tryIsoType(iso, 2352, 150 * 2048, 0)) return 0; // NERO RAW 2352
|
||||
if (tryIsoType(iso, 2448, 150 * 2048, 0)) return 0; // NERO RAWQ 2448
|
||||
if (tryIsoType(iso, 2048, -8, 24)) return 0; // ISO 2048
|
||||
|
@ -131,7 +133,7 @@ isoFile *isoOpen(const char *filename)
|
|||
iso = (isoFile*)malloc(sizeof(isoFile));
|
||||
if (iso == NULL) return NULL;
|
||||
|
||||
memset(iso, 0, sizeof(isoFile));
|
||||
memzero( *iso );
|
||||
strcpy(iso->filename, filename);
|
||||
|
||||
iso->handle = _openfile( iso->filename, O_RDONLY);
|
||||
|
|
|
@ -292,6 +292,8 @@
|
|||
<Unit filename="../gui/GlobalCommands.cpp" />
|
||||
<Unit filename="../gui/IniInterface.cpp" />
|
||||
<Unit filename="../gui/IniInterface.h" />
|
||||
<Unit filename="../gui/IsoDropTarget.cpp" />
|
||||
<Unit filename="../gui/IsoDropTarget.h" />
|
||||
<Unit filename="../gui/MainFrame.cpp" />
|
||||
<Unit filename="../gui/MainFrame.h" />
|
||||
<Unit filename="../gui/MainMenuClicks.cpp" />
|
||||
|
@ -309,6 +311,7 @@
|
|||
<Unit filename="../gui/Panels/VideoPanel.cpp" />
|
||||
<Unit filename="../gui/Plugins.cpp" />
|
||||
<Unit filename="../gui/RecentIsoList.cpp" />
|
||||
<Unit filename="../gui/RecentIsoList.h" />
|
||||
<Unit filename="../gui/Resources/AppIcon16.h" />
|
||||
<Unit filename="../gui/Resources/AppIcon16.png">
|
||||
<Option compile="1" />
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "Utilities/EventSource.h"
|
||||
#include "IniInterface.h"
|
||||
|
||||
//class IniInterface;
|
||||
class MainEmuFrame;
|
||||
class GSFrame;
|
||||
class ConsoleLogFrame;
|
||||
|
@ -34,6 +33,8 @@ class AppCoreThread;
|
|||
#include "Utilities/wxGuiTools.h"
|
||||
|
||||
#include "AppConfig.h"
|
||||
#include "RecentIsoList.h"
|
||||
|
||||
#include "System.h"
|
||||
#include "System/SysThreads.h"
|
||||
|
||||
|
@ -261,55 +262,6 @@ public:
|
|||
void Map( const KeyAcceleratorCode& acode, const char *searchfor );
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// RecentIsoList
|
||||
// --------------------------------------------------------------------------------------
|
||||
class RecentIsoList : public wxEvtHandler
|
||||
{
|
||||
protected:
|
||||
struct RecentItem
|
||||
{
|
||||
wxString Filename;
|
||||
wxMenuItem* ItemPtr;
|
||||
|
||||
RecentItem() { ItemPtr = NULL; }
|
||||
|
||||
RecentItem( const wxString& src ) :
|
||||
Filename( src )
|
||||
, ItemPtr( NULL )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<RecentItem> m_Items;
|
||||
|
||||
wxMenu* m_Menu;
|
||||
uint m_MaxLength;
|
||||
int m_cursel;
|
||||
|
||||
wxMenuItem* m_Separator;
|
||||
|
||||
EventListenerBinding<IniInterface> m_Listener_SettingsLoadSave;
|
||||
|
||||
public:
|
||||
RecentIsoList( wxMenu* menu );
|
||||
virtual ~RecentIsoList() throw();
|
||||
|
||||
void RemoveAllFromMenu();
|
||||
void Repopulate();
|
||||
void Add( const wxString& src );
|
||||
|
||||
protected:
|
||||
void InsertIntoMenu( int id );
|
||||
void DoSettingsLoadSave( IniInterface& ini );
|
||||
|
||||
void OnChangedSelection( wxCommandEvent& evt );
|
||||
|
||||
static void __evt_fastcall OnSettingsLoadSave( void* obj, IniInterface& evt );
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// AppImageIds - Config and Toolbar Images and Icons
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
@ -614,7 +566,7 @@ extern void AppSaveSettings();
|
|||
extern void AppApplySettings( const AppConfig* oldconf=NULL, bool saveOnSuccess=false );
|
||||
|
||||
extern bool SysHasValidState();
|
||||
|
||||
extern void SysUpdateIsoSrcFile( const wxString& newIsoFile );
|
||||
extern void SysStatus( const wxString& text );
|
||||
|
||||
extern bool HasMainFrame();
|
||||
|
@ -622,3 +574,4 @@ extern MainEmuFrame& GetMainFrame();
|
|||
extern MainEmuFrame* GetMainFramePtr();
|
||||
|
||||
extern AppCoreThread CoreThread;
|
||||
|
||||
|
|
|
@ -104,6 +104,14 @@ void AppCoreThread::OnResumeReady()
|
|||
{
|
||||
ApplySettings( g_Conf->EmuOptions );
|
||||
|
||||
if( !wxFile::Exists( g_Conf->CurrentIso ) )
|
||||
g_Conf->CurrentIso.Clear();
|
||||
|
||||
sApp.GetRecentIsoList().Add( g_Conf->CurrentIso );
|
||||
CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso );
|
||||
|
||||
AppSaveSettings();
|
||||
|
||||
if( GSopen2 != NULL )
|
||||
wxGetApp().OpenGsFrame();
|
||||
|
||||
|
|
|
@ -274,6 +274,7 @@ bool Pcsx2App::OnInit()
|
|||
AppConfig_OnChangedSettingsFolder();
|
||||
|
||||
m_MainFrame = new MainEmuFrame( NULL, L"PCSX2" );
|
||||
m_MainFrame->PushEventHandler( m_RecentIsoList );
|
||||
|
||||
if( m_ProgramLogBox )
|
||||
{
|
||||
|
|
|
@ -347,6 +347,11 @@ int Pcsx2App::OnExit()
|
|||
if( g_Conf )
|
||||
AppSaveSettings();
|
||||
|
||||
sMainFrame.PopEventHandler( m_RecentIsoList );
|
||||
|
||||
m_RecentIsoList = NULL;
|
||||
m_RecentIsoMenu = NULL;
|
||||
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
|
||||
|
@ -488,6 +493,8 @@ static void _sendmsg_SysExecute()
|
|||
return;
|
||||
}
|
||||
|
||||
AppSaveSettings();
|
||||
|
||||
wxCommandEvent execevt( pxEVT_SysExecute );
|
||||
execevt.SetInt( _sysexec_cdvdsrc_type );
|
||||
wxGetApp().AddPendingEvent( execevt );
|
||||
|
@ -587,6 +594,13 @@ void SysStatus( const wxString& text )
|
|||
sMainFrame.SetStatusText( text );
|
||||
}
|
||||
|
||||
// Applies a new active iso source file
|
||||
void SysUpdateIsoSrcFile( const wxString& newIsoFile )
|
||||
{
|
||||
g_Conf->CurrentIso = newIsoFile;
|
||||
sMainFrame.UpdateIsoSrcSelection();
|
||||
}
|
||||
|
||||
bool HasMainFrame()
|
||||
{
|
||||
return wxTheApp && wxGetApp().HasMainFrame();
|
||||
|
|
|
@ -171,6 +171,12 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const
|
|||
// dialogs because we offer more button types, and we don't want the MSW default behavior
|
||||
// of right-justified buttons.
|
||||
|
||||
if( type.HasCustom() )
|
||||
AddCustomButton( pxID_CUSTOM, type.GetCustomLabel() );
|
||||
|
||||
// Order of wxID_RESET and custom button have been picked fairly arbitrarily, since there's
|
||||
// no standard governing those.
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// GTK+ / Linux inverts OK/CANCEL order -- cancel / no first, OK / Yes later. >_<
|
||||
if( type.HasCancel() )
|
||||
|
@ -195,6 +201,9 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const
|
|||
AddActionButton( wxID_YESTOALL );
|
||||
}
|
||||
|
||||
if( type.HasReset() )
|
||||
AddCustomButton( wxID_RESET, _("Reset") );
|
||||
|
||||
#ifndef __WXGTK__
|
||||
if( type.HasNo() || type.HasCancel() ) // Extra space between Affirm and Cancel Actions
|
||||
m_ButtonSizer.Add(0, 0, 1, wxEXPAND, 0);
|
||||
|
@ -216,8 +225,20 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const
|
|||
CenterOnScreen();
|
||||
}
|
||||
|
||||
void Dialogs::ExtensibleConfirmation::OnActionButtonClicked( wxCommandEvent& evt )
|
||||
{
|
||||
EndModal( evt.GetId() );
|
||||
}
|
||||
|
||||
void Dialogs::ExtensibleConfirmation::AddCustomButton( wxWindowID id, const wxString& label )
|
||||
{
|
||||
m_ButtonSizer.Add( new wxButton( this, id, label ), SizerFlags::StdButton() )->SetProportion( 6 );
|
||||
Connect( id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ExtensibleConfirmation::OnActionButtonClicked ) );
|
||||
}
|
||||
|
||||
void Dialogs::ExtensibleConfirmation::AddActionButton( wxWindowID id )
|
||||
{
|
||||
m_ButtonSizer.Add( new wxButton( this, id ), SizerFlags::StdButton() )->SetProportion( 6 );
|
||||
Connect( id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ExtensibleConfirmation::OnActionButtonClicked ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <wx/image.h>
|
||||
#include <wx/wizard.h>
|
||||
|
||||
static const wxWindowID pxID_CUSTOM = wxID_LOWEST - 1;
|
||||
|
||||
class FirstTimeWizard : public wxWizard
|
||||
{
|
||||
protected:
|
||||
|
@ -77,9 +79,12 @@ protected:
|
|||
m_Apply:1,
|
||||
m_Abort:1,
|
||||
m_Retry:1,
|
||||
m_Ignore:1;
|
||||
m_Ignore:1,
|
||||
m_Reset:1;
|
||||
BITFIELD_END
|
||||
|
||||
wxString m_CustomLabel;
|
||||
|
||||
public:
|
||||
ConfButtons() : bitset( 0 ) { }
|
||||
|
||||
|
@ -93,8 +98,16 @@ public:
|
|||
ConfButtons& Abort() { m_Abort = true; return *this; }
|
||||
ConfButtons& Retry() { m_Retry = true; return *this; }
|
||||
ConfButtons& Ignore() { m_Ignore = true; return *this; }
|
||||
ConfButtons& Reset() { m_Reset = true; return *this; }
|
||||
|
||||
ConfButtons& Custom( const wxString& label)
|
||||
{
|
||||
m_CustomLabel = label;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConfButtons& OKCancel() { m_OK = m_Cancel = true; return *this; }
|
||||
ConfButtons& YesNo() { m_Yes = m_No = true; return *this; }
|
||||
|
||||
bool HasOK() const { return m_OK; }
|
||||
bool HasCancel() const { return m_Cancel; }
|
||||
|
@ -106,6 +119,10 @@ public:
|
|||
bool HasAbort() const { return m_Abort; }
|
||||
bool HasRetry() const { return m_Retry; }
|
||||
bool HasIgnore() const { return m_Ignore; }
|
||||
bool HasReset() const { return m_Reset; }
|
||||
|
||||
bool HasCustom() const { return !m_CustomLabel.IsEmpty(); }
|
||||
const wxString& GetCustomLabel() const { return m_CustomLabel; }
|
||||
|
||||
bool Allows( wxWindowID id ) const;
|
||||
|
||||
|
@ -180,14 +197,17 @@ namespace Dialogs
|
|||
protected:
|
||||
wxBoxSizer& m_ExtensibleSizer;
|
||||
wxBoxSizer& m_ButtonSizer;
|
||||
|
||||
public:
|
||||
ExtensibleConfirmation( wxWindow* parent, const ConfButtons& type, const wxString& title, const wxString& msg );
|
||||
virtual ~ExtensibleConfirmation() throw() {}
|
||||
|
||||
wxBoxSizer& GetExtensibleSizer() const { return m_ExtensibleSizer; }
|
||||
virtual wxBoxSizer& GetExtensibleSizer() const { return m_ExtensibleSizer; }
|
||||
|
||||
protected:
|
||||
void AddActionButton( wxWindowID id );
|
||||
virtual void AddActionButton( wxWindowID id );
|
||||
virtual void AddCustomButton( wxWindowID id, const wxString& label );
|
||||
virtual void OnActionButtonClicked( wxCommandEvent& evt );
|
||||
};
|
||||
|
||||
wxWindowID IssueConfirmation( wxWindow* parent, const wxString& disablerKey, const ConfButtons& type, const wxString& title, const wxString& msg );
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "App.h"
|
||||
#include "IsoDropTarget.h"
|
||||
|
||||
#include "Dialogs/ModalPopups.h"
|
||||
|
||||
#include "CDVD/IsoFileFormats.h"
|
||||
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
|
||||
wxString GetMsg_ConfirmSysReset()
|
||||
{
|
||||
return pxE( ".Popup:ConfirmSysReset",
|
||||
L"This action will reset the existing PS2 virtual machine state; "
|
||||
L"all current progress will be lost. Are you sure?"
|
||||
);
|
||||
}
|
||||
|
||||
bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames)
|
||||
{
|
||||
bool resume = CoreThread.Suspend();
|
||||
|
||||
if( filenames.GetCount() > 1 )
|
||||
{
|
||||
Dialogs::ExtensibleConfirmation( m_WindowBound, ConfButtons().Cancel(),
|
||||
_("Drag and Drop Error"),
|
||||
_("It is an error to drop multiple files onto a PCSX2 window. One at a time please, thank you.")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLn( L"(Drag&Drop) Received filename: " + filenames[0] );
|
||||
|
||||
// ---------------
|
||||
// ELF CHECK
|
||||
// ---------------
|
||||
{
|
||||
wxFileInputStream filechk( filenames[0] );
|
||||
|
||||
if( !filechk.IsOk() )
|
||||
throw Exception::CreateStream( filenames[0] );
|
||||
|
||||
u8 ident[16];
|
||||
filechk.Read( ident, 16 );
|
||||
static const u8 elfIdent[4] = { 0x7f, 'E', 'L', 'F' };
|
||||
|
||||
if( ((u32&)ident) == ((u32&)elfIdent) )
|
||||
{
|
||||
Console.WriteLn( L"(Drag&Drop) Found ELF file type!" );
|
||||
|
||||
g_Conf->CurrentELF = filenames[0];
|
||||
|
||||
bool confirmed = true;
|
||||
if( SysHasValidState() )
|
||||
{
|
||||
confirmed = Dialogs::IssueConfirmation( m_WindowBound, L"DragDrop:BootELF", ConfButtons().Reset().Cancel(),
|
||||
_("Confirm PS2 Reset"),
|
||||
_("You have dropped the following ELF binary into PCSX2:\n\n") +
|
||||
filenames[0] + L"\n\n" + GetMsg_ConfirmSysReset()
|
||||
) != wxID_CANCEL;
|
||||
}
|
||||
|
||||
if( confirmed )
|
||||
{
|
||||
sApp.SysExecute( g_Conf->CdvdSource, g_Conf->CurrentELF );
|
||||
}
|
||||
|
||||
if( resume ) CoreThread.Resume();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------
|
||||
// ISO CHECK
|
||||
// ---------------
|
||||
|
||||
// FIXME : The whole IsoFileFormats api (meaning isoOpen / isoDetect / etc) needs to be
|
||||
// converted to C++ and wxInputStream . Until then this is a nasty little exception unsafe
|
||||
// hack ;)
|
||||
|
||||
isoFile iso;
|
||||
memzero( iso );
|
||||
iso.handle = _openfile( filenames[0].ToUTF8(), O_RDONLY);
|
||||
|
||||
if( iso.handle == NULL )
|
||||
throw Exception::CreateStream( filenames[0] );
|
||||
|
||||
if( isoDetect( &iso ) == 0 )
|
||||
{
|
||||
Console.WriteLn( L"(Drag&Drop) Found valid ISO file type!" );
|
||||
|
||||
bool confirmed = true;
|
||||
wxWindowID result = wxID_RESET;
|
||||
|
||||
if( SysHasValidState() )
|
||||
{
|
||||
result = Dialogs::IssueConfirmation( m_WindowBound, L"DragDrop:BootIso", ConfButtons().Reset().Cancel().Custom(_("Swap Disc")),
|
||||
_("Confirm PS2 Reset"),
|
||||
_("You have dropped the following ISO image into PCSX2:\n\n") +
|
||||
filenames[0] + L"\n\n" +
|
||||
_("Do you want to swap discs or boot the new image (via system reset)?")
|
||||
);
|
||||
}
|
||||
|
||||
if( result != wxID_CANCEL )
|
||||
{
|
||||
SysUpdateIsoSrcFile( filenames[0] );
|
||||
if( result != wxID_RESET )
|
||||
CDVDsys_ChangeSource( CDVDsrc_Iso );
|
||||
else
|
||||
{
|
||||
sApp.SysExecute( CDVDsrc_Iso );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_closefile( iso.handle );
|
||||
if( resume ) CoreThread.Resume();
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wx\dnd.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// IsoDropTarget
|
||||
// --------------------------------------------------------------------------------------
|
||||
class IsoDropTarget : public wxFileDropTarget
|
||||
{
|
||||
protected:
|
||||
wxWindow* m_WindowBound;
|
||||
|
||||
public:
|
||||
IsoDropTarget( wxWindow* parent ) : wxFileDropTarget()
|
||||
{
|
||||
m_WindowBound = parent;
|
||||
}
|
||||
|
||||
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
||||
};
|
|
@ -17,6 +17,9 @@
|
|||
#include "MainFrame.h"
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include "Dialogs/ModalPopups.h"
|
||||
#include "IsoDropTarget.h"
|
||||
|
||||
#include "Resources/EmbeddedImage.h"
|
||||
#include "Resources/AppIcon16.h"
|
||||
#include "Resources/AppIcon32.h"
|
||||
|
@ -56,14 +59,6 @@ void MainEmuFrame::UpdateIsoSrcSelection()
|
|||
}
|
||||
sMenuBar.Check( cdsrc, true );
|
||||
m_statusbar.SetStatusText( CDVD_SourceLabels[g_Conf->CdvdSource], 1 );
|
||||
}
|
||||
|
||||
void MainEmuFrame::UpdateIsoSrcFile()
|
||||
{
|
||||
UpdateIsoSrcSelection();
|
||||
const bool exists = wxFile::Exists( g_Conf->CurrentIso );
|
||||
if( !exists )
|
||||
g_Conf->CurrentIso.Clear();
|
||||
|
||||
//sMenuBar.SetLabel( MenuId_Src_Iso, wxsFormat( L"%s -> %s", _("Iso"),
|
||||
// exists ? Path::GetFilename(g_Conf->CurrentIso).c_str() : _("Empty") ) );
|
||||
|
@ -147,7 +142,6 @@ void MainEmuFrame::ConnectMenus()
|
|||
ConnectMenu( MenuId_Config_Multitap0Toggle, Menu_MultitapToggle_Click );
|
||||
ConnectMenu( MenuId_Config_Multitap1Toggle, Menu_MultitapToggle_Click );
|
||||
|
||||
ConnectMenuRange(wxID_FILE1, 20, Menu_IsoRecent_Click);
|
||||
ConnectMenuRange(MenuId_Config_GS, PluginId_Count, Menu_ConfigPlugin_Click);
|
||||
ConnectMenuRange(MenuId_Src_Iso, 3, Menu_CdvdSource_Click);
|
||||
|
||||
|
@ -443,7 +437,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
|
|||
Connect( wxEVT_MOVE, wxMoveEventHandler (MainEmuFrame::OnMoveAround) );
|
||||
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainEmuFrame::OnCloseWindow) );
|
||||
|
||||
UpdateIsoSrcFile();
|
||||
SetDropTarget( new IsoDropTarget( this ) );
|
||||
}
|
||||
|
||||
MainEmuFrame::~MainEmuFrame() throw()
|
||||
|
@ -515,7 +509,7 @@ void MainEmuFrame::ApplySettings()
|
|||
menubar.Check( MenuId_Config_Multitap0Toggle, g_Conf->EmuOptions.MultitapPort0_Enabled );
|
||||
menubar.Check( MenuId_Config_Multitap1Toggle, g_Conf->EmuOptions.MultitapPort1_Enabled );
|
||||
|
||||
UpdateIsoSrcFile();
|
||||
UpdateIsoSrcSelection();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
@ -131,7 +131,6 @@ public:
|
|||
void OnLogBoxHidden();
|
||||
|
||||
bool IsPaused() const { return GetMenuBar()->IsChecked( MenuId_Sys_SuspendResume ); }
|
||||
void UpdateIsoSrcFile();
|
||||
void UpdateIsoSrcSelection();
|
||||
void ReloadRecentLists();
|
||||
|
||||
|
@ -153,9 +152,7 @@ protected:
|
|||
void Menu_ConfigSettings_Click(wxCommandEvent &event);
|
||||
void Menu_SelectBios_Click(wxCommandEvent &event);
|
||||
|
||||
void Menu_RunIso_Click(wxCommandEvent &event);
|
||||
void Menu_IsoBrowse_Click(wxCommandEvent &event);
|
||||
void Menu_IsoRecent_Click(wxCommandEvent &event);
|
||||
void Menu_SkipBiosToggle_Click(wxCommandEvent &event);
|
||||
void Menu_EnablePatches_Click(wxCommandEvent &event);
|
||||
|
||||
|
@ -182,7 +179,7 @@ protected:
|
|||
void Menu_ShowConsole(wxCommandEvent &event);
|
||||
void Menu_ShowAboutBox(wxCommandEvent &event);
|
||||
|
||||
bool _DoSelectIsoBrowser();
|
||||
bool _DoSelectIsoBrowser( wxString& dest );
|
||||
bool _DoSelectELFBrowser();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
using namespace Dialogs;
|
||||
|
||||
extern wxString GetMsg_ConfirmSysReset();
|
||||
|
||||
void MainEmuFrame::Menu_ConfigSettings_Click(wxCommandEvent &event)
|
||||
{
|
||||
|
@ -37,20 +38,26 @@ void MainEmuFrame::Menu_SelectBios_Click(wxCommandEvent &event)
|
|||
|
||||
void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event )
|
||||
{
|
||||
CDVD_SourceType newSource = CDVDsrc_NoDisc;
|
||||
|
||||
switch( event.GetId() )
|
||||
{
|
||||
case MenuId_Src_Iso: g_Conf->CdvdSource = CDVDsrc_Iso; break;
|
||||
case MenuId_Src_Plugin: g_Conf->CdvdSource = CDVDsrc_Plugin; break;
|
||||
case MenuId_Src_NoDisc: g_Conf->CdvdSource = CDVDsrc_NoDisc; break;
|
||||
case MenuId_Src_Iso: newSource = CDVDsrc_Iso; break;
|
||||
case MenuId_Src_Plugin: newSource = CDVDsrc_Plugin; break;
|
||||
case MenuId_Src_NoDisc: newSource = CDVDsrc_NoDisc; break;
|
||||
|
||||
jNO_DEFAULT
|
||||
}
|
||||
UpdateIsoSrcSelection();
|
||||
AppSaveSettings();
|
||||
|
||||
if( g_Conf->CdvdSource == newSource ) return;
|
||||
|
||||
bool resume = CoreThread.Suspend();
|
||||
CDVDsys_ChangeSource( g_Conf->CdvdSource = newSource );
|
||||
if( resume ) CoreThread.Resume();
|
||||
}
|
||||
|
||||
// Returns FALSE if the user cancelled the action.
|
||||
bool MainEmuFrame::_DoSelectIsoBrowser()
|
||||
bool MainEmuFrame::_DoSelectIsoBrowser( wxString& result )
|
||||
{
|
||||
static const wxChar* isoFilterTypes =
|
||||
L"All Supported (.iso .mdf .nrg .bin .img .dump)|*.iso;*.mdf;*.nrg;*.bin;*.img;*.dump|"
|
||||
|
@ -63,12 +70,9 @@ bool MainEmuFrame::_DoSelectIsoBrowser()
|
|||
|
||||
if( ctrl.ShowModal() != wxID_CANCEL )
|
||||
{
|
||||
g_Conf->Folders.RunIso = wxFileName( ctrl.GetPath() ).GetPath();
|
||||
g_Conf->CurrentIso = ctrl.GetPath();
|
||||
sApp.GetRecentIsoList().Add( g_Conf->CurrentIso );
|
||||
|
||||
AppSaveSettings();
|
||||
UpdateIsoSrcFile();
|
||||
result = ctrl.GetPath();
|
||||
g_Conf->Folders.RunIso = wxFileName( result ).GetPath();
|
||||
//sApp.GetRecentIsoList().Add( result );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,7 +92,6 @@ bool MainEmuFrame::_DoSelectELFBrowser()
|
|||
{
|
||||
g_Conf->Folders.RunELF = wxFileName( ctrl.GetPath() ).GetPath();
|
||||
g_Conf->CurrentELF = ctrl.GetPath();
|
||||
AppSaveSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,55 +104,46 @@ void MainEmuFrame::Menu_BootCdvd_Click( wxCommandEvent &event )
|
|||
|
||||
if( (g_Conf->CdvdSource == CDVDsrc_Iso) && !wxFileExists(g_Conf->CurrentIso) )
|
||||
{
|
||||
if( !_DoSelectIsoBrowser() )
|
||||
wxString result;
|
||||
if( !_DoSelectIsoBrowser( result ) )
|
||||
{
|
||||
CoreThread.Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
SysUpdateIsoSrcFile( result );
|
||||
}
|
||||
|
||||
if( SysHasValidState() )
|
||||
{
|
||||
// [TODO] : Add one of 'dems checkboxes that read like "[x] don't show this stupid shit again, kthx."
|
||||
bool result = Msgbox::OkCancel( pxE( ".Popup:ConfirmSysReset", L"This will reset the emulator and your current emulation session will be lost. Are you sure?") );
|
||||
bool confirmed = IssueConfirmation( this, L"BootCdvd:ConfirmReset", ConfButtons().Yes().Cancel(),
|
||||
_("Confirm PS2 Reset"), GetMsg_ConfirmSysReset()
|
||||
) != wxID_CANCEL;
|
||||
|
||||
if( !result )
|
||||
if( !confirmed )
|
||||
{
|
||||
CoreThread.Resume();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_Conf->EmuOptions.SkipBiosSplash = GetMenuBar()->IsChecked( MenuId_SkipBiosToggle );
|
||||
g_Conf->EmuOptions.EnablePatches = GetMenuBar()->IsChecked( MenuId_EnablePatches );
|
||||
AppSaveSettings();
|
||||
|
||||
sApp.SysExecute( g_Conf->CdvdSource );
|
||||
}
|
||||
|
||||
void MainEmuFrame::Menu_IsoBrowse_Click( wxCommandEvent &event )
|
||||
{
|
||||
bool resume = CoreThread.Suspend();
|
||||
_DoSelectIsoBrowser();
|
||||
if( resume ) CoreThread.Resume();
|
||||
}
|
||||
wxString result;
|
||||
|
||||
void MainEmuFrame::Menu_RunIso_Click( wxCommandEvent &event )
|
||||
{
|
||||
CoreThread.Suspend();
|
||||
|
||||
if( _DoSelectIsoBrowser() )
|
||||
if( _DoSelectIsoBrowser( result ) )
|
||||
{
|
||||
sApp.SysExecute( CDVDsrc_Iso );
|
||||
// This command does an on-the-fly change of CD media without automatic reset.
|
||||
// (useful for disc swapping)
|
||||
|
||||
SysUpdateIsoSrcFile( result );
|
||||
}
|
||||
|
||||
CoreThread.Resume();
|
||||
}
|
||||
|
||||
void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event)
|
||||
{
|
||||
//Console.Status( "%d", event.GetId() - g_RecentIsoList->GetBaseId() );
|
||||
//Console.WriteLn( Color_Magenta, g_RecentIsoList->GetHistoryFile( event.GetId() - g_RecentIsoList->GetBaseId() ) );
|
||||
if( resume ) CoreThread.Resume();
|
||||
}
|
||||
|
||||
#include "IniInterface.h"
|
||||
|
@ -185,13 +179,13 @@ void MainEmuFrame::Menu_EnablePatches_Click( wxCommandEvent &event )
|
|||
|
||||
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent &event)
|
||||
{
|
||||
CoreThread.Suspend();
|
||||
bool resume = CoreThread.Suspend();
|
||||
if( _DoSelectELFBrowser() )
|
||||
{
|
||||
sApp.SysExecute( g_Conf->CdvdSource, g_Conf->CurrentELF );
|
||||
}
|
||||
|
||||
CoreThread.Resume();
|
||||
if( resume ) CoreThread.Resume();
|
||||
}
|
||||
|
||||
void MainEmuFrame::Menu_LoadStates_Click(wxCommandEvent &event)
|
||||
|
|
|
@ -23,11 +23,12 @@ RecentIsoList::RecentIsoList( wxMenu* menu ) :
|
|||
, m_Separator( NULL )
|
||||
, m_Listener_SettingsLoadSave( wxGetApp().Source_SettingsLoadSave(), EventListener<IniInterface>( this, OnSettingsLoadSave ) )
|
||||
{
|
||||
m_Menu->Connect( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(RecentIsoList::OnChangedSelection) );
|
||||
Connect( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(RecentIsoList::OnChangedSelection) );
|
||||
}
|
||||
|
||||
RecentIsoList::~RecentIsoList() throw()
|
||||
{
|
||||
Disconnect( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(RecentIsoList::OnChangedSelection) );
|
||||
}
|
||||
|
||||
void RecentIsoList::OnChangedSelection( wxCommandEvent& evt )
|
||||
|
@ -36,14 +37,20 @@ void RecentIsoList::OnChangedSelection( wxCommandEvent& evt )
|
|||
uint i=0;
|
||||
for( ; i<cnt; ++i )
|
||||
{
|
||||
if( (m_Items[i].ItemPtr == NULL) || (m_Items[i].ItemPtr->GetId() != evt.GetId()) ) continue;
|
||||
if( (m_Items[i].ItemPtr != NULL) && (m_Items[i].ItemPtr->GetId() == evt.GetId()) ) break;
|
||||
}
|
||||
|
||||
if( i >= m_Items.size() ) return;
|
||||
if( i >= m_Items.size() )
|
||||
{
|
||||
evt.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
m_cursel = i;
|
||||
g_Conf->CurrentIso = m_Items[i].Filename;
|
||||
sMainFrame.UpdateIsoSrcFile();
|
||||
|
||||
bool resume = CoreThread.Suspend();
|
||||
SysUpdateIsoSrcFile( m_Items[i].Filename );
|
||||
if( resume ) CoreThread.Resume();
|
||||
}
|
||||
|
||||
void RecentIsoList::RemoveAllFromMenu()
|
||||
|
@ -53,9 +60,10 @@ void RecentIsoList::RemoveAllFromMenu()
|
|||
int cnt = m_Items.size();
|
||||
for( int i=0; i<cnt; ++i )
|
||||
{
|
||||
if( m_Items[i].ItemPtr == NULL ) continue;
|
||||
m_Menu->Destroy( m_Items[i].ItemPtr );
|
||||
m_Items[i].ItemPtr = NULL;
|
||||
RecentItem& curitem( m_Items[i] );
|
||||
if( curitem.ItemPtr == NULL ) continue;
|
||||
m_Menu->Destroy( curitem.ItemPtr );
|
||||
curitem.ItemPtr = NULL;
|
||||
}
|
||||
|
||||
if( m_Separator != NULL )
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// RecentIsoList
|
||||
// --------------------------------------------------------------------------------------
|
||||
class RecentIsoList : public wxEvtHandler
|
||||
{
|
||||
protected:
|
||||
struct RecentItem
|
||||
{
|
||||
wxString Filename;
|
||||
wxMenuItem* ItemPtr;
|
||||
|
||||
RecentItem() { ItemPtr = NULL; }
|
||||
|
||||
RecentItem( const wxString& src ) :
|
||||
Filename( src )
|
||||
, ItemPtr( NULL )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<RecentItem> m_Items;
|
||||
|
||||
wxMenu* m_Menu;
|
||||
uint m_MaxLength;
|
||||
int m_cursel;
|
||||
|
||||
wxMenuItem* m_Separator;
|
||||
|
||||
EventListenerBinding<IniInterface> m_Listener_SettingsLoadSave;
|
||||
|
||||
public:
|
||||
RecentIsoList( wxMenu* menu );
|
||||
virtual ~RecentIsoList() throw();
|
||||
|
||||
void RemoveAllFromMenu();
|
||||
void Repopulate();
|
||||
void Add( const wxString& src );
|
||||
|
||||
protected:
|
||||
void InsertIntoMenu( int id );
|
||||
void DoSettingsLoadSave( IniInterface& ini );
|
||||
void OnChangedSelection( wxCommandEvent& evt );
|
||||
|
||||
static void __evt_fastcall OnSettingsLoadSave( void* obj, IniInterface& evt );
|
||||
};
|
||||
|
|
@ -1828,6 +1828,10 @@
|
|||
RelativePath="..\..\gui\IniInterface.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\IsoDropTarget.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\MainFrame.cpp"
|
||||
>
|
||||
|
@ -2417,10 +2421,18 @@
|
|||
RelativePath="..\..\gui\IniInterface.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\IsoDropTarget.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\MainFrame.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\RecentIsoList.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\wxHelpers.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue