Fixed the button states in the toolbar when loading, starting, and stopping a game.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4877 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2010-01-18 12:10:51 +00:00
parent 896850b176
commit 335c056586
5 changed files with 107 additions and 29 deletions

View file

@ -287,6 +287,8 @@ THREAD_RETURN CpuThread(void *pArg)
// Call browser: Init():g_EmuThread(). See the BootManager.cpp file description for a complete call schedule.
THREAD_RETURN EmuThread(void *pArg)
{
Host_UpdateMainFrame(); // Disable any menus or buttons at boot
cpuRunloopQuit.Init();
Common::SetCurrentThreadName("Emuthread - starting");
@ -389,10 +391,6 @@ THREAD_RETURN EmuThread(void *pArg)
PowerPC::SetMode(PowerPC::MODE_JIT);
else
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
// Update the window again because all stuff is initialized
Host_UpdateDisasmDialog();
Host_UpdateMainFrame();
// Spawn the CPU thread
Common::Thread *cpuThread = NULL;
@ -407,6 +405,13 @@ THREAD_RETURN EmuThread(void *pArg)
cpuThread = new Common::Thread(CpuThread, pArg);
Common::SetCurrentThreadName("Video thread");
if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay(("Loaded " + _CoreParameter.m_strFilename).c_str());
// Update the window again because all stuff is initialized
Host_UpdateDisasmDialog();
Host_UpdateMainFrame();
Plugins.GetVideo()->Video_EnterLoop();
}
else // SingleCore mode
@ -419,6 +424,13 @@ THREAD_RETURN EmuThread(void *pArg)
cpuThread = new Common::Thread(CpuThread, pArg);
Common::SetCurrentThreadName("Emuthread - Idle");
if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay(("Loaded " + _CoreParameter.m_strFilename).c_str());
// Update the window again because all stuff is initialized
Host_UpdateDisasmDialog();
Host_UpdateMainFrame();
// TODO(ector) : investigate using GetMessage instead .. although
// then we lose the powerdown check. ... unless powerdown sends a message :P
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)

View file

@ -509,8 +509,6 @@ void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
void CFrame::OnActive(wxActivateEvent& event)
{
event.Skip();
if (event.GetActive())
UpdateGUI();
}
void CFrame::OnClose(wxCloseEvent& event)
@ -681,7 +679,9 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
m_GameListCtrl->Update();
}
else BootGame();
else
// Game started by double click
StartGame();
}
void CFrame::OnKeyDown(wxKeyEvent& event)
@ -795,6 +795,10 @@ void CFrame::OnMotion(wxMouseEvent& event)
#if wxUSE_TIMER
void CFrame::Update()
{
// Update the GUI while a game has not yet been loaded
if (!Core::isRunning())
UpdateGUI();
// Check if auto hide is on, or if we are already hiding the cursor all the time
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor
|| SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) return;

View file

@ -251,6 +251,7 @@ class CFrame : public wxFrame
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
// Event functions
void StartGame();
void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnToolBar(wxCommandEvent& event);

View file

@ -469,12 +469,23 @@ void CFrame::InitBitmaps()
// Menu items
// ---------------------
// Start the game or change the disc
// Start the game or change the disc.
// Boot priority:
// 1. Default ISO
// 2. Show the game list and boot the selected game.
// 3. Boot last selected game
void CFrame::BootGame()
{
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (Core::GetState() != Core::CORE_UNINITIALIZED)
return;
else if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
{
BootManager::BootCore(StartUp.m_strDefaultGCM);
}
// Start the selected ISO, or try one of the saved paths.
// If all that fails, ask to add a dir and don't boot
else if (m_GameListCtrl->GetSelectedISO() != NULL)
@ -484,14 +495,7 @@ void CFrame::BootGame()
}
else
{
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
{
BootManager::BootCore(StartUp.m_strDefaultGCM);
}
else if (!SConfig::GetInstance().m_LastFilename.empty()
if (!SConfig::GetInstance().m_LastFilename.empty()
&& wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8)))
{
BootManager::BootCore(SConfig::GetInstance().m_LastFilename);
@ -608,10 +612,14 @@ void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
BootGame();
}
// Game loading state
bool game_started = false;
void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
{
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
// Core is initialized and emulator is running
if (UseDebugger)
{
if (CCPU::IsStepping())
@ -630,9 +638,29 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
else
Core::SetState(Core::CORE_RUN);
}
// Update toolbar with Play/Pause status
UpdateGUI();
}
else
// Core is uninitialized, start the game
StartGame();
}
// Prepare the GUI to start the game.
void CFrame::StartGame()
{
game_started = true;
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, false);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
// Game has been started, hide the game list
if (m_GameListCtrl->IsShown())
{
m_GameListCtrl->Disable();
m_GameListCtrl->Hide();
}
BootGame();
}
@ -687,6 +715,7 @@ void CFrame::DoStop()
void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
{
game_started = false;
DoStop();
}
@ -1016,14 +1045,39 @@ void CFrame::UpdateGUI()
m_ToolBar->SetToolShortHelp(IDM_PLAY, _("Play"));
m_ToolBar->SetToolLabel(IDM_PLAY, wxT(" Play "));
}
GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Play\tF10"));
GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Play\tF10"));
}
if (!Initialized)
{
if (m_GameListCtrl)
if (Core::GetStartupParameter().m_strFilename.empty())
{
// Prepare to load Default ISO, enable play button
if (!Core::GetStartupParameter().m_strDefaultGCM.empty())
{
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
else
{
// No game has been selected yet, disable play button
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, 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_started)
{
// Game has not started, show game list
if (!m_GameListCtrl->IsShown())
{
m_GameListCtrl->Reparent(m_Panel);
@ -1031,18 +1085,21 @@ void CFrame::UpdateGUI()
m_GameListCtrl->Show();
sizerPanel->FitInside(m_Panel);
}
// Game has been selected but not started, enable play button
if (m_GameListCtrl->GetSelectedISO() != NULL && m_GameListCtrl->IsEnabled() && !game_started)
{
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
}
}
else
{
if (m_GameListCtrl)
{
if (m_GameListCtrl->IsShown())
{
m_GameListCtrl->Disable();
m_GameListCtrl->Hide();
}
}
// Game has been loaded, enable the play button
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
if (m_ToolBar) m_ToolBar->Refresh();

View file

@ -848,6 +848,10 @@ const GameListItem * CGameListCtrl::GetSelectedISO()
{
return NULL;
}
else if (GetSelectedItemCount() == 0)
{
return NULL;
}
else
{
long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);