Project

General

Profile

Actions

Emulator Issues #434

closed

Using game list when rendering to main window

Added by omegadox over 15 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

I coded so the Game List Control can be used to pick the disc to swap in,
works great when rendering to a seperate window. When I render to the main
window, the game list shows over it but it doesn't get the mouse input
because of the render context I guess.

Here is the patch file.

Index: Source/Core/DolphinWX/Src/Frame.cpp

--- Source/Core/DolphinWX/Src/Frame.cpp (revision 1651)
+++ Source/Core/DolphinWX/Src/Frame.cpp (working copy)
@@ -30,6 +30,7 @@

#include "Config.h" // Core
#include "Core.h"
+#include "Plugins/Plugin_Video.h"
#include "HW/DVDInterface.h"
#include "State.h"
#include "VolumeHandler.h"
@@ -56,6 +57,7 @@
#include "../resources/toolbar_stop.c"
};

+bool isSwappingDisc = false;

#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
@@ -107,6 +109,7 @@
EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState)
EVT_MENU_RANGE(IDM_SAVESLOT1, IDM_SAVESLOT10, CFrame::OnSaveState)
EVT_SIZE(CFrame::OnResize)
+EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CFrame::OnEvent_ListCtrl_ItemActivated)
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
END_EVENT_TABLE()

@@ -346,76 +349,34 @@
// -------------
void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
{

  • // Don't allow this for an initialized core
  • //if (Core::GetState() != Core::CORE_UNINITIALIZED)
  • // return;
  •    wxString path = wxFileSelector(
    
  •                    _T("Select the file to load"),
    
  •                    wxEmptyString, wxEmptyString, wxEmptyString,
    
  •                    wxString::Format
    
  •                    (
    
  •                                    _T("All GC/Wii files (elf, dol,
    

gcm, iso)|.elf;.dol;.gcm;.iso;*.gcz|All files (%s)|%s"),

  •                                    wxFileSelectorDefaultWildcardStr,
    
  •                                    wxFileSelectorDefaultWildcardStr
    
  •                    ),
    
  •                    wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
    
  •                    this);
    
  •    if (!path)
    
  •    {
    
  •            return;
    
  •    }
    
  • DoOpen(true);
    -}

-void CFrame::DoOpen(bool Boot)
-{

  • wxString path = wxFileSelector(
  •   	_T("Select the file to load"),
    
  •   	wxEmptyString, wxEmptyString, wxEmptyString,
    
  •   	wxString::Format
    
  •   	(
    
  •   			_T("All GC/Wii files (elf, dol, gcm,
    

iso)|.elf;.dol;.gcm;.iso;*.gcz|All files (%s)|%s"),

  •   			wxFileSelectorDefaultWildcardStr,
    
  •   			wxFileSelectorDefaultWildcardStr
    
  •   	),
    
  •   	wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
    
  •   	this);
    
  • if (!path)
  • {
  •   return;
    
  • }
  • // Should we boot a new game or just change the disc?
  • if(Boot)
  • {
  •   BootManager::BootCore(std::string(path.ToAscii()));
    
  • }
  • else
  • {
  •   // Get the current ISO name
    
  •   std::string OldName =
    

SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename;

  •   // Change the iso and make sure it's a valid file
    
  •   if(!VolumeHandler::SetVolumeName(std::string(path.ToAscii())))
    
  •   {
    
  •   	PanicAlert("The file you selected is not a valid ISO file. Please try
    

again.");

  •   	// Put back the old one
    
  •   	VolumeHandler::SetVolumeName(OldName);
    
  •   }
    
  •   // Yes it is a valid ISO file
    
  •   if (isSwappingDisc)
    
  •   	CFrame::BootGame();
      else
    
  •   {
    
  •   	std::string OldID =
    

SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID;

  •   	std::string NewID = VolumeHandler::GetVolume()->GetUniqueID();
    
  •   	// Warn the user if he's selecting a completely different game
    
  •   	if(OldID != NewID)
    
  •   		PanicAlert(
    
  •   		"The new game ID '%s' is not the same as the old game ID '%s'."
    
  •   		" It is not recommended that you change the disc to another game this
    

way."

  •   		" It may crash your game. If you want to play another game you"
    
  •   		" have to Stop this game and Start a new game."
    
  •   		, NewID.c_str(), OldID.c_str()
    
  •   		);
    
  •   	// Save the new ISO file name
    
  •   	SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename =
    

std::string(path.ToAscii());

  •   }
    
  • }
  •   	BootManager::BootCore(std::string(path.ToAscii()));
    

}

void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED (event))
{
DVDInterface::SetLidOpen(true);

  • DoOpen(false);
  • DVDInterface::SetLidOpen(false);
  • isSwappingDisc = true;
  • UpdateGUI();
  • PluginVideo::Video_Hide();
    }
    // =============

@@ -463,6 +424,7 @@
// -------------
void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
{
+
// shuffle2: wxBusyInfo is meant to be created on the stack
// and only stay around for the life of the scope it's in.
// If that is not what we want, find another solution. I don't
@@ -481,24 +443,11 @@
}
UpdateGUI();
}

  • // Start the selected ISO
  • else if (m_GameListCtrl->GetSelectedISO() != 0)
  • else
    {
  •   BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
    
  •   CFrame::BootGame();
    
    }
  • /* Start the default ISO, or if we don't have a default ISO, start the last

  •  started ISO */
    
  • else if
    (!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty() &&

  •   wxFileExists(wxString(SConfig::GetInstance().m_LocalCoreStartupParameter.
    
  •   	m_strDefaultGCM.c_str(), wxConvUTF8)))
    
  • {

BootManager::BootCore(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM);

  • }
  • else if (!SConfig::GetInstance().m_LastFilename.empty() &&
  • wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(),
    wxConvUTF8)))
  • {
  •   BootManager::BootCore(SConfig::GetInstance().m_LastFilename);
    
  • }

}
// =============

@@ -695,6 +644,10 @@
}

+void CFrame::OnEvent_ListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
+{

  • CFrame::BootGame();
    +}
    // =======================================================
    // Update the enabled/disabled status
    // -------------
    @@ -749,7 +702,7 @@
    if (GetToolBar() != NULL) GetToolBar()->Realize();
  • if (!initialized)
  • if (!initialized || isSwappingDisc)
    {
    if (m_GameListCtrl && !m_GameListCtrl->IsShown())
    {
    @@ -768,3 +721,51 @@
    }
    }

+void CFrame::BootGame()
+{

  • // If we are swapping discs, then we are not booting

  • if (isSwappingDisc)

  • {

  •   if (m_GameListCtrl->GetSelectedISO() != 0)
    
  •   {
    
  •   	SwapDisc(m_GameListCtrl->GetSelectedISO()->GetFileName());
    
  •   }
    
  •   DVDInterface::SetLidOpen(false);
    
  •   isSwappingDisc = false;
    
  •   UpdateGUI();
    
  •   PluginVideo::Video_Show();
    
  •   return;
    
  • }

  • // Start the selected ISO

  • if (m_GameListCtrl->GetSelectedISO() != 0)

  • {

  •   BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
    
  • }

  • // Start the default ISO, or if we don't have a default ISO, start the
    last started ISO

  • else if
    (!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty() &&

wxFileExists(wxString(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.c_str(),
wxConvUTF8)))

  • {

BootManager::BootCore(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM);

  • }
  • else if (!SConfig::GetInstance().m_LastFilename.empty() &&
  •   wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(),
    

wxConvUTF8)))

  • {
  •   BootManager::BootCore(SConfig::GetInstance().m_LastFilename);
    
  • }
    +}
    +void CFrame::SwapDisc(const std::string fname)
    +{
  • bool result;
  • VolumeHandler::SetVolumeName(fname);
  • DVDInterface::SetDiscInside(result = VolumeHandler::IsValid());
  • if (result)
  •   SuccessAlert("Swapped Disc!");
    
  • else
  •   PanicAlert("Invalid Disc!");
    

+}
\ No newline at end of file
Index: Source/Core/DolphinWX/Src/Frame.h

--- Source/Core/DolphinWX/Src/Frame.h (revision 1651)
+++ Source/Core/DolphinWX/Src/Frame.h (working copy)
@@ -123,6 +123,11 @@
void OnMemcard(wxCommandEvent& event); // Misc
void OnShow_CheatsWindow(wxCommandEvent& event);

  •   void OnEvent_ListCtrl_ItemActivated(wxListEvent& event);
    
  •   void BootGame();
    
  •   void SwapDisc(const std::string fname);
    
  •   // Menu items
      wxMenuBar* m_pMenuBar;
    

Index: Source/Core/DolphinWX/Src/GameListCtrl.cpp

--- Source/Core/DolphinWX/Src/GameListCtrl.cpp (revision 1651)
+++ Source/Core/DolphinWX/Src/GameListCtrl.cpp (working copy)
@@ -31,6 +31,7 @@
#include "ISOProperties.h"
#include "IniFile.h"

#if USE_XPM_BITMAPS
#include "../resources/Flag_Europe.xpm"
#include "../resources/Flag_France.xpm"
@@ -62,7 +63,6 @@
EVT_SIZE(CGameListCtrl::OnSize)
EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick)
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag)
-EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CGameListCtrl::OnActivated)
EVT_LIST_COL_CLICK(LIST_CTRL, CGameListCtrl::OnColumnClick)
EVT_MENU(IDM_PROPERTIES, CGameListCtrl::OnProperties)
EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
@@ -520,23 +520,6 @@
}
}

-void CGameListCtrl::OnActivated(wxListEvent& event)
-{

  • if (m_ISOFiles.size() == 0)
  • {
  •   BrowseForDirectory();
    
  • }
  • else
  • {
  •   size_t Index = event.GetData();
    
  •   if (Index < m_ISOFiles.size())
    
  •   {
    
  •   	const GameListItem& rISOFile = m_ISOFiles[Index];
    
  •   	BootManager::BootCore(rISOFile.GetFileName());
    
  •   }
    
  • }
    -}

const GameListItem * CGameListCtrl::GetSelectedISO()
{
long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@@ -816,3 +799,8 @@
}

}
+
+int CGameListCtrl::GetISOCount()
+{

  • return m_ISOFiles.size();
    +}
    \ No newline at end of file
    Index: Source/Core/DolphinWX/Src/GameListCtrl.h
    ===================================================================
    --- Source/Core/DolphinWX/Src/GameListCtrl.h (revision 1651)
    +++ Source/Core/DolphinWX/Src/GameListCtrl.h (working copy)
    @@ -21,9 +21,11 @@
    #include <vector>

#include <wx/listctrl.h>
+#include <wx/event.h>

#include "ISOFile.h"

class CGameListCtrl : public wxListCtrl
{
public:
@@ -33,6 +35,7 @@

void Update();
void BrowseForDirectory();
  • int GetISOCount();
    const GameListItem *GetSelectedISO();
    const GameListItem *GetISO(int index) const;
Actions #1

Updated by omegadox over 15 years ago

Sorry, the file attachment quota is maxed!

Actions #3

Updated by Anonymous over 15 years ago

I don't see why this is necessary, we could just scan for a matching gameid in the
user's iso dir ("auto-switch"), and/or popup a file selection dialog. I say this
because all games with multiple discs only have one (or two?) other discs...so you
don't need to see all your games in order to switch.

Actions #4

Updated by omegadox over 15 years ago

That was nakee's idea and also to support manual switch.

Actions #5

Updated by Sonicadvance1 over 15 years ago

Indeed, Maybe we don't want to do a switch to a second game =o
Specially if we get the BIOS working :D

Actions #6

Updated by XTra.KrazzY over 15 years ago

  • Status changed from New to Fixed

Haven't we established disc switching already? Comment and I'll unfix.

Actions

Also available in: Atom PDF