Logical reorderring of the GUI boot sequence. Also a little clean up in the OpenGL plugin.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5379 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-04-17 03:17:36 +00:00
parent 3b35cb12f2
commit 0a12b9d9f5
7 changed files with 83 additions and 100 deletions

View File

@ -357,7 +357,7 @@ CFrame::CFrame(wxFrame* parent,
, m_RenderFrame(NULL), m_RenderParent(NULL) , m_RenderFrame(NULL), m_RenderParent(NULL)
, m_LogWindow(NULL) , m_LogWindow(NULL)
, UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false) , UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, m_bControlsCreated(false), m_StopDlg(NULL) , m_bControlsCreated(false), m_bGameLoading(false), m_StopDlg(NULL)
#if wxUSE_TIMER #if wxUSE_TIMER
, m_timer(this) , m_timer(this)
#endif #endif
@ -488,13 +488,6 @@ CFrame::CFrame(wxFrame* parent,
// ------------------------- // -------------------------
// Connect event handlers // Connect event handlers
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(CFrame::OnKeyUp),
(wxObject*)0, this);
m_Mgr->Connect(wxID_ANY, wxEVT_AUI_RENDER, // Resize m_Mgr->Connect(wxID_ANY, wxEVT_AUI_RENDER, // Resize
wxAuiManagerEventHandler(CFrame::OnManagerResize), wxAuiManagerEventHandler(CFrame::OnManagerResize),
(wxObject*)0, this); (wxObject*)0, this);
@ -846,7 +839,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
} }
else else
// Game started by double click // Game started by double click
StartGame(std::string("")); BootGame(std::string(""));
} }
bool IsHotkey(wxKeyEvent &event, int Id) bool IsHotkey(wxKeyEvent &event, int Id)

View File

@ -131,7 +131,7 @@ class CFrame : public CRenderFrame
void ClearStatusBar(); void ClearStatusBar();
void OnCustomHostMessage(int Id); void OnCustomHostMessage(int Id);
void OnSizeRequest(int& x, int& y, int& width, int& height); void OnSizeRequest(int& x, int& y, int& width, int& height);
void StartGame(const std::string& filename); void BootGame(const std::string& filename);
void OnRenderParentClose(wxCloseEvent& event); void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event); void OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus(); bool RendererHasFocus();
@ -232,6 +232,7 @@ class CFrame : public CRenderFrame
bool m_bTabSplit; bool m_bTabSplit;
bool m_bNoDocking; bool m_bNoDocking;
bool m_bControlsCreated; bool m_bControlsCreated;
bool m_bGameLoading;
char newDiscpath[2048]; char newDiscpath[2048];
wxMessageDialog *m_StopDlg; wxMessageDialog *m_StopDlg;
@ -349,6 +350,7 @@ class CFrame : public CRenderFrame
void OnGameListCtrl_ItemActivated(wxListEvent& event); void OnGameListCtrl_ItemActivated(wxListEvent& event);
void OnRenderParentResize(wxSizeEvent& event); void OnRenderParentResize(wxSizeEvent& event);
bool RendererIsFullscreen(); bool RendererIsFullscreen();
void StartGame(const std::string& filename);
#if defined HAVE_X11 && HAVE_X11 #if defined HAVE_X11 && HAVE_X11
void X11_SendClientEvent(const char *message, void X11_SendClientEvent(const char *message,
int data1 = 0, int data2 = 0, int data3 = 0, int data4 = 0); int data1 = 0, int data2 = 0, int data3 = 0, int data4 = 0);
@ -363,8 +365,6 @@ class CFrame : public CRenderFrame
wxMenuItem* m_pSubMenuSave; wxMenuItem* m_pSubMenuSave;
wxMenuItem* m_pSubMenuFrameSkipping; wxMenuItem* m_pSubMenuFrameSkipping;
void BootGame(const std::string& filename);
#if wxUSE_TIMER #if wxUSE_TIMER
// Used to process command events // Used to process command events
void OnTimer(wxTimerEvent& WXUNUSED(event)); void OnTimer(wxTimerEvent& WXUNUSED(event));

View File

@ -483,9 +483,6 @@ 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
// Start the game or change the disc. // Start the game or change the disc.
@ -495,7 +492,7 @@ bool game_loading = false;
// 3. Boot last selected game // 3. Boot last selected game
void CFrame::BootGame(const std::string& filename) void CFrame::BootGame(const std::string& filename)
{ {
bool success = false; std::string bootfile = 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)
@ -504,44 +501,30 @@ void CFrame::BootGame(const std::string& filename)
// Start filename if non empty. // 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 (!filename.empty()) if (bootfile.empty())
success = BootManager::BootCore(filename);
else if (m_GameListCtrl->GetSelectedISO() != NULL)
{ {
if (m_GameListCtrl->GetSelectedISO()->IsValid()) if (m_GameListCtrl->GetSelectedISO() != NULL)
success = BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
}
else if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
{
success = BootManager::BootCore(StartUp.m_strDefaultGCM);
}
else
{
if (!SConfig::GetInstance().m_LastFilename.empty()
&& wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8)))
{ {
success = BootManager::BootCore(SConfig::GetInstance().m_LastFilename); if (m_GameListCtrl->GetSelectedISO()->IsValid())
bootfile = m_GameListCtrl->GetSelectedISO()->GetFileName();
} }
else if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
bootfile = StartUp.m_strDefaultGCM;
else else
{ {
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (!SConfig::GetInstance().m_LastFilename.empty()
m_RenderFrame->Destroy(); && wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8)))
m_GameListCtrl->BrowseForDirectory(); bootfile = SConfig::GetInstance().m_LastFilename;
game_loading = false; else
m_GameListCtrl->Enable(); {
m_GameListCtrl->Show(); m_GameListCtrl->BrowseForDirectory();
return; return;
}
} }
} }
if (!success) if (!bootfile.empty())
{ StartGame(bootfile);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
game_loading = false;
m_GameListCtrl->Enable();
m_GameListCtrl->Show();
}
} }
// Open file to boot // Open file to boot
@ -582,7 +565,7 @@ void CFrame::DoOpen(bool Boot)
{ {
if (!fileChosen) if (!fileChosen)
return; return;
StartGame(std::string(path.mb_str())); BootGame(std::string(path.mb_str()));
} }
else else
{ {
@ -667,13 +650,12 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
} }
else else
// Core is uninitialized, start the game // Core is uninitialized, start the game
StartGame(std::string("")); BootGame(std::string(""));
} }
void CFrame::OnRenderParentClose(wxCloseEvent& event) void CFrame::OnRenderParentClose(wxCloseEvent& event)
{ {
if ((Core::GetState() == Core::CORE_RUN) || (Core::GetState() == Core::CORE_PAUSE)) DoStop();
DoStop();
event.Skip(); event.Skip();
} }
@ -689,30 +671,27 @@ void CFrame::OnRenderParentMove(wxMoveEvent& event)
void CFrame::OnRenderParentResize(wxSizeEvent& event) void CFrame::OnRenderParentResize(wxSizeEvent& event)
{ {
event.Skip(); int width, height;
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
!RendererIsFullscreen() && !m_RenderFrame->IsMaximized())
{ {
int width, height; m_RenderFrame->GetSize(&width, &height);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth = width;
!RendererIsFullscreen() && !m_RenderFrame->IsMaximized()) SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight = height;
{
m_RenderFrame->GetSize(&width, &height);
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth = width;
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight = height;
}
#if defined(HAVE_X11) && HAVE_X11
int x, y;
m_RenderParent->GetSize(&width, &height);
m_RenderParent->GetPosition(&x, &y);
X11_SendClientEvent("RESIZE", x, y, width, height);
#endif
} }
#if defined(HAVE_X11) && HAVE_X11
int x, y;
m_RenderParent->GetSize(&width, &height);
m_RenderParent->GetPosition(&x, &y);
X11_SendClientEvent("RESIZE", x, y, width, height);
#endif
event.Skip();
} }
// Prepare the GUI to start the game. // Prepare the GUI to start the game.
void CFrame::StartGame(const std::string& filename) void CFrame::StartGame(const std::string& filename)
{ {
game_loading = true; m_bGameLoading = true;
if (m_ToolBar) if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, false); m_ToolBar->EnableTool(IDM_PLAY, false);
@ -746,27 +725,41 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->Connect(wxID_ANY, wxEVT_MOVE, m_RenderFrame->Connect(wxID_ANY, wxEVT_MOVE,
wxMoveEventHandler(CFrame::OnRenderParentMove), wxMoveEventHandler(CFrame::OnRenderParentMove),
(wxObject*)0, this); (wxObject*)0, this);
m_RenderFrame->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
m_RenderParent = new CPanel(m_RenderFrame, wxID_ANY); m_RenderParent = new CPanel(m_RenderFrame, wxID_ANY);
m_RenderFrame->Show(); m_RenderFrame->Show();
} }
m_RenderFrame->Connect(wxID_ANY, wxEVT_SIZE,
wxSizeEventHandler(CFrame::OnRenderParentResize),
(wxObject*)0, this);
#ifdef _WIN32 #ifdef _WIN32
::SetFocus((HWND)m_RenderParent->GetHandle()); ::SetFocus((HWND)m_RenderParent->GetHandle());
#else #else
m_RenderParent->SetFocus(); m_RenderParent->SetFocus();
#endif #endif
BootGame(filename); if (!BootManager::BootCore(filename))
{
// Destroy the renderer frame when not rendering to main
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
m_RenderParent = NULL;
m_bGameLoading = false;
UpdateGUI();
}
else
{
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(CFrame::OnKeyUp),
(wxObject*)0, this);
m_RenderFrame->Connect(wxID_ANY, wxEVT_SIZE,
wxSizeEventHandler(CFrame::OnRenderParentResize),
(wxObject*)0, this);
}
} }
void CFrame::OnBootDrive(wxCommandEvent& event) void CFrame::OnBootDrive(wxCommandEvent& event)
{ {
StartGame(drives[event.GetId()-IDM_DRIVE1]); BootGame(drives[event.GetId()-IDM_DRIVE1]);
} }
@ -843,6 +836,15 @@ void CFrame::DoStop()
UpdateGUI(); UpdateGUI();
// Destroy the renderer frame when not rendering to main // Destroy the renderer frame when not rendering to main
m_RenderFrame->Disconnect(wxID_ANY, wxEVT_SIZE,
wxSizeEventHandler(CFrame::OnRenderParentResize),
(wxObject*)0, this);
wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(CFrame::OnKeyUp),
(wxObject*)0, this);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_ARROW); m_RenderParent->SetCursor(wxCURSOR_ARROW);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
@ -863,7 +865,7 @@ void CFrame::DoStop()
void CFrame::OnStop(wxCommandEvent& WXUNUSED (event)) void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
{ {
game_loading = false; m_bGameLoading = false;
DoStop(); DoStop();
} }
@ -1000,7 +1002,7 @@ void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event))
void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED (event)) void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED (event))
{ {
StartGame(std::string (File::GetUserPath(D_WIIMENU_IDX))); BootGame(std::string (File::GetUserPath(D_WIIMENU_IDX)));
} }
void CFrame::OnConnectWiimote(wxCommandEvent& event) void CFrame::OnConnectWiimote(wxCommandEvent& event)
@ -1222,7 +1224,7 @@ void CFrame::UpdateGUI()
} }
} }
if (m_GameListCtrl && !game_loading) if (m_GameListCtrl && !m_bGameLoading)
{ {
// Game has not started, show game list // Game has not started, show game list
if (!m_GameListCtrl->IsShown()) if (!m_GameListCtrl->IsShown())
@ -1233,7 +1235,7 @@ void CFrame::UpdateGUI()
sizerPanel->FitInside(m_Panel); sizerPanel->FitInside(m_Panel);
} }
// Game has been selected but not started, enable play button // Game has been selected but not started, enable play button
if (m_GameListCtrl->GetSelectedISO() != NULL && m_GameListCtrl->IsEnabled() && !game_loading) if (m_GameListCtrl->GetSelectedISO() != NULL && m_GameListCtrl->IsEnabled() && !m_bGameLoading)
{ {
if (m_ToolBar) if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true); m_ToolBar->EnableTool(IDM_PLAY, true);
@ -1249,7 +1251,7 @@ void CFrame::UpdateGUI()
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true); GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
// Reset game loading flag // Reset game loading flag
game_loading = false; m_bGameLoading = false;
} }
if (m_ToolBar) m_ToolBar->Refresh(); if (m_ToolBar) m_ToolBar->Refresh();

View File

@ -455,7 +455,7 @@ bool DolphinApp::OnInit()
// First check if we have an elf command line. // First check if we have an elf command line.
if (LoadElf && ElfFile != wxEmptyString) if (LoadElf && ElfFile != wxEmptyString)
{ {
main_frame->StartGame(std::string(ElfFile.mb_str())); main_frame->BootGame(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
@ -467,13 +467,13 @@ bool DolphinApp::OnInit()
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter. && File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.
m_strDefaultGCM.c_str())) m_strDefaultGCM.c_str()))
{ {
main_frame->StartGame(SConfig::GetInstance().m_LocalCoreStartupParameter. main_frame->BootGame(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()))
{ {
main_frame->StartGame(SConfig::GetInstance().m_LastFilename); main_frame->BootGame(SConfig::GetInstance().m_LastFilename);
} }
} }
} }

View File

@ -445,20 +445,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
return true; return true;
} }
bool OpenGL_Initialize()
{
bool success = OpenGL_MakeCurrent();
if (!success)
{
PanicAlert("Can't Activate The GL Rendering Context.");
return false;
}
// Notify the core that the window is current
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
return success;
}
bool OpenGL_MakeCurrent() bool OpenGL_MakeCurrent()
{ {
// connect the glx-context to the window // connect the glx-context to the window

View File

@ -115,7 +115,6 @@ extern GLWindow GLWin;
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
void OpenGL_Shutdown(); void OpenGL_Shutdown();
void OpenGL_Update(); void OpenGL_Update();
bool OpenGL_Initialize();
bool OpenGL_MakeCurrent(); bool OpenGL_MakeCurrent();
void OpenGL_SwapBuffers(); void OpenGL_SwapBuffers();

View File

@ -349,7 +349,7 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
// This is called after Video_Initialize() from the Core // This is called after Video_Initialize() from the Core
void Video_Prepare(void) void Video_Prepare(void)
{ {
OpenGL_Initialize(); OpenGL_MakeCurrent();
if (!Renderer::Init()) { if (!Renderer::Init()) {
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
PanicAlert("Can't create opengl renderer. You might be missing some required opengl extensions, check the logs for more info"); PanicAlert("Can't create opengl renderer. You might be missing some required opengl extensions, check the logs for more info");
@ -379,6 +379,9 @@ void Video_Prepare(void)
TextureConverter::Init(); TextureConverter::Init();
DLCache::Init(); DLCache::Init();
// Notify the core that the video plugin is ready
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
s_PluginInitialized = true; s_PluginInitialized = true;
INFO_LOG(VIDEO, "Video plugin initialized."); INFO_LOG(VIDEO, "Video plugin initialized.");
} }