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_LogWindow(NULL)
, 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
, m_timer(this)
#endif
@ -488,13 +488,6 @@ CFrame::CFrame(wxFrame* parent,
// -------------------------
// 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
wxAuiManagerEventHandler(CFrame::OnManagerResize),
(wxObject*)0, this);
@ -846,7 +839,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
}
else
// Game started by double click
StartGame(std::string(""));
BootGame(std::string(""));
}
bool IsHotkey(wxKeyEvent &event, int Id)

View File

@ -131,7 +131,7 @@ class CFrame : public CRenderFrame
void ClearStatusBar();
void OnCustomHostMessage(int Id);
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 OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus();
@ -232,6 +232,7 @@ class CFrame : public CRenderFrame
bool m_bTabSplit;
bool m_bNoDocking;
bool m_bControlsCreated;
bool m_bGameLoading;
char newDiscpath[2048];
wxMessageDialog *m_StopDlg;
@ -349,6 +350,7 @@ class CFrame : public CRenderFrame
void OnGameListCtrl_ItemActivated(wxListEvent& event);
void OnRenderParentResize(wxSizeEvent& event);
bool RendererIsFullscreen();
void StartGame(const std::string& filename);
#if defined HAVE_X11 && HAVE_X11
void X11_SendClientEvent(const char *message,
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_pSubMenuFrameSkipping;
void BootGame(const std::string& filename);
#if wxUSE_TIMER
// Used to process command events
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));
}
// Game loading state
bool game_loading = false;
// Menu items
// Start the game or change the disc.
@ -495,7 +492,7 @@ bool game_loading = false;
// 3. Boot last selected game
void CFrame::BootGame(const std::string& filename)
{
bool success = false;
std::string bootfile = filename;
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (Core::GetState() != Core::CORE_UNINITIALIZED)
@ -504,44 +501,30 @@ void CFrame::BootGame(const std::string& filename)
// Start filename if non empty.
// 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 (!filename.empty())
success = BootManager::BootCore(filename);
else if (m_GameListCtrl->GetSelectedISO() != NULL)
if (bootfile.empty())
{
if (m_GameListCtrl->GetSelectedISO() != NULL)
{
if (m_GameListCtrl->GetSelectedISO()->IsValid())
success = BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
bootfile = m_GameListCtrl->GetSelectedISO()->GetFileName();
}
else if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
{
success = BootManager::BootCore(StartUp.m_strDefaultGCM);
}
bootfile = 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);
}
bootfile = SConfig::GetInstance().m_LastFilename;
else
{
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
m_GameListCtrl->BrowseForDirectory();
game_loading = false;
m_GameListCtrl->Enable();
m_GameListCtrl->Show();
return;
}
}
if (!success)
{
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
game_loading = false;
m_GameListCtrl->Enable();
m_GameListCtrl->Show();
}
if (!bootfile.empty())
StartGame(bootfile);
}
// Open file to boot
@ -582,7 +565,7 @@ void CFrame::DoOpen(bool Boot)
{
if (!fileChosen)
return;
StartGame(std::string(path.mb_str()));
BootGame(std::string(path.mb_str()));
}
else
{
@ -667,12 +650,11 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
}
else
// Core is uninitialized, start the game
StartGame(std::string(""));
BootGame(std::string(""));
}
void CFrame::OnRenderParentClose(wxCloseEvent& event)
{
if ((Core::GetState() == Core::CORE_RUN) || (Core::GetState() == Core::CORE_PAUSE))
DoStop();
event.Skip();
}
@ -688,9 +670,6 @@ void CFrame::OnRenderParentMove(wxMoveEvent& event)
}
void CFrame::OnRenderParentResize(wxSizeEvent& event)
{
event.Skip();
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
int width, height;
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
@ -706,13 +685,13 @@ void CFrame::OnRenderParentResize(wxSizeEvent& event)
m_RenderParent->GetPosition(&x, &y);
X11_SendClientEvent("RESIZE", x, y, width, height);
#endif
}
event.Skip();
}
// Prepare the GUI to start the game.
void CFrame::StartGame(const std::string& filename)
{
game_loading = true;
m_bGameLoading = true;
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, false);
@ -746,27 +725,41 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->Connect(wxID_ANY, wxEVT_MOVE,
wxMoveEventHandler(CFrame::OnRenderParentMove),
(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_RenderFrame->Show();
}
m_RenderFrame->Connect(wxID_ANY, wxEVT_SIZE,
wxSizeEventHandler(CFrame::OnRenderParentResize),
(wxObject*)0, this);
#ifdef _WIN32
::SetFocus((HWND)m_RenderParent->GetHandle());
#else
m_RenderParent->SetFocus();
#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)
{
StartGame(drives[event.GetId()-IDM_DRIVE1]);
BootGame(drives[event.GetId()-IDM_DRIVE1]);
}
@ -843,6 +836,15 @@ void CFrame::DoStop()
UpdateGUI();
// 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)
m_RenderParent->SetCursor(wxCURSOR_ARROW);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
@ -863,7 +865,7 @@ void CFrame::DoStop()
void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
{
game_loading = false;
m_bGameLoading = false;
DoStop();
}
@ -1000,7 +1002,7 @@ void CFrame::OnShow_CheatsWindow(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)
@ -1222,7 +1224,7 @@ void CFrame::UpdateGUI()
}
}
if (m_GameListCtrl && !game_loading)
if (m_GameListCtrl && !m_bGameLoading)
{
// Game has not started, show game list
if (!m_GameListCtrl->IsShown())
@ -1233,7 +1235,7 @@ void CFrame::UpdateGUI()
sizerPanel->FitInside(m_Panel);
}
// 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)
m_ToolBar->EnableTool(IDM_PLAY, true);
@ -1249,7 +1251,7 @@ void CFrame::UpdateGUI()
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
// Reset game loading flag
game_loading = false;
m_bGameLoading = false;
}
if (m_ToolBar) m_ToolBar->Refresh();

View File

@ -455,7 +455,7 @@ bool DolphinApp::OnInit()
// First check if we have an elf command line.
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
// ISO exists, start the last loaded ISO
@ -467,13 +467,13 @@ bool DolphinApp::OnInit()
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.
m_strDefaultGCM.c_str()))
{
main_frame->StartGame(SConfig::GetInstance().m_LocalCoreStartupParameter.
main_frame->BootGame(SConfig::GetInstance().m_LocalCoreStartupParameter.
m_strDefaultGCM);
}
else if(!SConfig::GetInstance().m_LastFilename.empty()
&& 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;
}
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()
{
// 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);
void OpenGL_Shutdown();
void OpenGL_Update();
bool OpenGL_Initialize();
bool OpenGL_MakeCurrent();
void OpenGL_SwapBuffers();

View File

@ -349,7 +349,7 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
// This is called after Video_Initialize() from the Core
void Video_Prepare(void)
{
OpenGL_Initialize();
OpenGL_MakeCurrent();
if (!Renderer::Init()) {
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");
@ -379,6 +379,9 @@ void Video_Prepare(void)
TextureConverter::Init();
DLCache::Init();
// Notify the core that the video plugin is ready
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
s_PluginInitialized = true;
INFO_LOG(VIDEO, "Video plugin initialized.");
}