Play button is now be enabled and disabled at the correct times.

Game list is hidden while games are running.
Fixes issue 2078


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4923 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-01-22 21:41:25 +00:00
parent 8c2bae9802
commit c09ec17bb2
5 changed files with 26 additions and 35 deletions

View File

@ -702,7 +702,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
} }
else else
// Game started by double click // Game started by double click
StartGame(); StartGame(std::string(""));
} }
void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyDown(wxKeyEvent& event)

View File

@ -86,6 +86,7 @@ class CFrame : public wxFrame
void StatusBarMessage(const char * Text, ...); void StatusBarMessage(const char * Text, ...);
void ClearStatusBar(); void ClearStatusBar();
void OnCustomHostMessage(int Id); void OnCustomHostMessage(int Id);
void StartGame(const std::string& filename);
// --------------------------------------- // ---------------------------------------
// Wiimote leds // Wiimote leds
@ -252,7 +253,6 @@ class CFrame : public wxFrame
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif #endif
// Event functions // Event functions
void StartGame();
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event); void OnHelp(wxCommandEvent& event);
void OnToolBar(wxCommandEvent& event); void OnToolBar(wxCommandEvent& event);
@ -333,7 +333,7 @@ class CFrame : public wxFrame
wxMenuItem* m_pSubMenuSave; wxMenuItem* m_pSubMenuSave;
wxMenuItem* m_pSubMenuFrameSkipping; wxMenuItem* m_pSubMenuFrameSkipping;
void BootGame(); void BootGame(const std::string& filename);
// Double click and mouse move options // Double click and mouse move options
double m_fLastClickTime, m_iLastMotionTime; double m_fLastClickTime, m_iLastMotionTime;

View File

@ -464,8 +464,8 @@ void CFrame::InitBitmaps()
aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
} }
// Game loading state
bool game_loading = false;
// Menu items // Menu items
@ -474,16 +474,19 @@ void CFrame::InitBitmaps()
// 1. Show the game list and boot the selected game. // 1. Show the game list and boot the selected game.
// 2. Default ISO // 2. Default ISO
// 3. Boot last selected game // 3. Boot last selected game
void CFrame::BootGame() void CFrame::BootGame(const std::string& filename)
{ {
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
return; return;
// Start filename if non empty.
// Start the selected ISO, or try one of the saved paths. // Start the selected ISO, or try one of the saved paths.
// If all that fails, ask to add a dir and don't boot // If all that fails, ask to add a dir and don't boot
if (m_GameListCtrl->GetSelectedISO() != NULL) if (!filename.empty())
BootManager::BootCore(filename);
else if (m_GameListCtrl->GetSelectedISO() != NULL)
{ {
if (m_GameListCtrl->GetSelectedISO()->IsValid()) if (m_GameListCtrl->GetSelectedISO()->IsValid())
BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName()); BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
@ -503,6 +506,7 @@ void CFrame::BootGame()
else else
{ {
m_GameListCtrl->BrowseForDirectory(); m_GameListCtrl->BrowseForDirectory();
game_loading = false;
m_GameListCtrl->Enable(); m_GameListCtrl->Enable();
m_GameListCtrl->Show(); m_GameListCtrl->Show();
return; return;
@ -590,7 +594,7 @@ void CFrame::OnRecord(wxCommandEvent& WXUNUSED (event))
// TODO: Take controller settings from Gamecube Configuration menu // TODO: Take controller settings from Gamecube Configuration menu
if(Frame::BeginRecordingInput(path.mb_str(), 1)) if(Frame::BeginRecordingInput(path.mb_str(), 1))
BootGame(); BootGame(std::string(""));
} }
void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event)) void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
@ -611,12 +615,9 @@ void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
return; return;
if(Frame::PlayInput(path.mb_str())) if(Frame::PlayInput(path.mb_str()))
BootGame(); BootGame(std::string(""));
} }
// Game loading state
bool game_loading = false;
void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event)) void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
@ -645,11 +646,11 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
} }
else else
// Core is uninitialized, start the game // Core is uninitialized, start the game
StartGame(); StartGame(std::string(""));
} }
// Prepare the GUI to start the game. // Prepare the GUI to start the game.
void CFrame::StartGame() void CFrame::StartGame(const std::string& filename)
{ {
game_loading = true; game_loading = true;
@ -664,7 +665,7 @@ void CFrame::StartGame()
m_GameListCtrl->Hide(); m_GameListCtrl->Hide();
} }
BootGame(); BootGame(filename);
} }
void CFrame::OnBootDrive(wxCommandEvent& event) void CFrame::OnBootDrive(wxCommandEvent& event)
@ -1068,7 +1069,7 @@ void CFrame::UpdateGUI()
if (!Initialized) if (!Initialized)
{ {
if (Core::GetStartupParameter().m_strFilename.empty()) if (m_GameListCtrl->IsEnabled())
{ {
// Prepare to load Default ISO, enable play button // Prepare to load Default ISO, enable play button
if (!Core::GetStartupParameter().m_strDefaultGCM.empty()) if (!Core::GetStartupParameter().m_strDefaultGCM.empty())
@ -1093,13 +1094,6 @@ void CFrame::UpdateGUI()
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false); GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
} }
} }
else
{
// Loading Default ELF automatically, disable play button
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, false);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
}
if (m_GameListCtrl && !game_loading) if (m_GameListCtrl && !game_loading)
{ {

View File

@ -100,7 +100,7 @@ END_EVENT_TABLE()
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl) BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
EVT_SIZE(CGameListCtrl::OnSize) EVT_SIZE(CGameListCtrl::OnSize)
EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick) EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick)
// EVT_LEFT_DOWN(CGameListCtrl::OnLeftClick) // Disabled as stops multi-selection in the game list EVT_LEFT_DOWN(CGameListCtrl::OnLeftClick)
EVT_LIST_KEY_DOWN(LIST_CTRL, CGameListCtrl::OnKeyPress) EVT_LIST_KEY_DOWN(LIST_CTRL, CGameListCtrl::OnKeyPress)
EVT_MOTION(CGameListCtrl::OnMouseMotion) EVT_MOTION(CGameListCtrl::OnMouseMotion)
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag) EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag)
@ -786,17 +786,14 @@ void CGameListCtrl::OnLeftClick(wxMouseEvent& event)
// Focus the clicked item. // Focus the clicked item.
int flags; int flags;
long item = HitTest(event.GetPosition(), flags); long item = HitTest(event.GetPosition(), flags);
if (item != wxNOT_FOUND) if ((item != wxNOT_FOUND) && (GetSelectedItemCount() == 0) && (!event.ControlDown()) && (!event.ShiftDown()))
{ {
if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED) SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
{
UnselectAll();
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
wxGetApp().GetCFrame()->UpdateGUI();
} }
wxGetApp().GetCFrame()->UpdateGUI(); event.Skip();
} }
void CGameListCtrl::OnRightClick(wxMouseEvent& event) void CGameListCtrl::OnRightClick(wxMouseEvent& event)

View File

@ -44,7 +44,7 @@
#include "JitWindow.h" #include "JitWindow.h"
#include "ExtendedTrace.h" #include "ExtendedTrace.h"
#include "BootManager.h" #include "BootManager.h"
#include "Frame.h"
// ------------ // ------------
// Main window // Main window
@ -408,7 +408,7 @@ bool DolphinApp::OnInit()
// First check if we have a elf command line. Todo: Should we place this under #if wxUSE_CMDLINE_PARSER? // First check if we have a elf command line. Todo: Should we place this under #if wxUSE_CMDLINE_PARSER?
if (LoadElf && ElfFile != wxEmptyString) if (LoadElf && ElfFile != wxEmptyString)
{ {
BootManager::BootCore(std::string(ElfFile.mb_str())); main_frame->StartGame(std::string(ElfFile.mb_str()));
} }
/* If we have selected Automatic Start, start the default ISO, or if no default /* If we have selected Automatic Start, start the default ISO, or if no default
ISO exists, start the last loaded ISO */ ISO exists, start the last loaded ISO */
@ -420,13 +420,13 @@ bool DolphinApp::OnInit()
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter. && File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.
m_strDefaultGCM.c_str())) m_strDefaultGCM.c_str()))
{ {
BootManager::BootCore(SConfig::GetInstance().m_LocalCoreStartupParameter. main_frame->StartGame(SConfig::GetInstance().m_LocalCoreStartupParameter.
m_strDefaultGCM); m_strDefaultGCM);
} }
else if(!SConfig::GetInstance().m_LastFilename.empty() else if(!SConfig::GetInstance().m_LastFilename.empty()
&& File::Exists(SConfig::GetInstance().m_LastFilename.c_str())) && File::Exists(SConfig::GetInstance().m_LastFilename.c_str()))
{ {
BootManager::BootCore(SConfig::GetInstance().m_LastFilename); main_frame->StartGame(SConfig::GetInstance().m_LastFilename);
} }
} }
} }