2013-04-18 06:43:35 +03:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2014-02-19 02:08:17 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#endif
|
2014-02-23 00:36:30 +02:00
|
|
|
|
|
|
|
#include <cstddef>
|
2014-06-24 23:41:12 +03:00
|
|
|
#include <fstream>
|
2014-02-23 00:36:30 +02:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/event.h>
|
2014-06-21 03:59:07 +03:00
|
|
|
#include <wx/filename.h>
|
2014-02-23 00:36:30 +02:00
|
|
|
#include <wx/frame.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/icon.h>
|
|
|
|
#include <wx/listbase.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/menuitem.h>
|
|
|
|
#include <wx/mousestate.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/statusbr.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/thread.h>
|
|
|
|
#include <wx/toplevel.h>
|
|
|
|
#include <wx/translation.h>
|
|
|
|
#include <wx/window.h>
|
|
|
|
#include <wx/windowid.h>
|
|
|
|
#include <wx/aui/auibook.h>
|
|
|
|
#include <wx/aui/framemanager.h>
|
2014-02-17 12:18:15 +02:00
|
|
|
|
|
|
|
#include "Common/Common.h"
|
|
|
|
#include "Common/FileUtil.h"
|
2014-02-23 00:36:30 +02:00
|
|
|
#include "Common/Thread.h"
|
2014-06-06 02:29:54 +03:00
|
|
|
#include "Common/Logging/ConsoleListener.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
2014-02-23 00:36:30 +02:00
|
|
|
#include "Core/CoreParameter.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "Core/Movie.h"
|
|
|
|
#include "Core/State.h"
|
2014-06-21 03:59:07 +03:00
|
|
|
#include "Core/HW/DVDInterface.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
|
2014-02-19 03:56:29 +02:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/GameListCtrl.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2014-02-23 00:36:30 +02:00
|
|
|
#include "DolphinWX/LogWindow.h"
|
2014-07-08 17:49:33 +03:00
|
|
|
#include "DolphinWX/Main.h"
|
2014-02-23 00:36:30 +02:00
|
|
|
#include "DolphinWX/TASInputDlg.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
|
|
|
|
|
|
|
#include "InputCommon/GCPadStatus.h"
|
2014-02-19 03:56:29 +02:00
|
|
|
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2009-09-01 16:06:37 +03:00
|
|
|
// Resources
|
2009-09-01 15:44:02 +03:00
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
extern "C" {
|
2014-02-19 03:56:29 +02:00
|
|
|
#include "DolphinWX/resources/Dolphin.c" // NOLINT: Dolphin icon
|
2008-12-08 07:30:24 +02:00
|
|
|
};
|
|
|
|
|
2009-09-01 15:44:02 +03:00
|
|
|
|
2010-04-15 06:25:35 +03:00
|
|
|
CRenderFrame::CRenderFrame(wxFrame* parent, wxWindowID id, const wxString& title,
|
2014-02-17 06:51:41 +02:00
|
|
|
const wxPoint& pos, const wxSize& size, long style)
|
2010-04-15 06:25:35 +03:00
|
|
|
: wxFrame(parent, id, title, pos, size, style)
|
|
|
|
{
|
2011-02-18 22:03:01 +02:00
|
|
|
// Give it an icon
|
|
|
|
wxIcon IconTemp;
|
2013-09-14 21:48:23 +03:00
|
|
|
IconTemp.CopyFromBitmap(wxGetBitmapFromMemory(Dolphin_png));
|
2011-02-18 22:03:01 +02:00
|
|
|
SetIcon(IconTemp);
|
2013-09-27 15:38:12 +03:00
|
|
|
|
|
|
|
DragAcceptFiles(true);
|
2014-07-08 22:40:23 +03:00
|
|
|
Bind(wxEVT_DROP_FILES, &CRenderFrame::OnDropFiles, this);
|
2013-09-27 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRenderFrame::OnDropFiles(wxDropFilesEvent& event)
|
|
|
|
{
|
|
|
|
if (event.GetNumberOfFiles() != 1)
|
|
|
|
return;
|
2014-06-21 03:59:07 +03:00
|
|
|
if (File::IsDirectory(WxStrToStr(event.GetFiles()[0])))
|
2013-09-27 15:38:12 +03:00
|
|
|
return;
|
|
|
|
|
2014-06-21 03:59:07 +03:00
|
|
|
wxFileName file = event.GetFiles()[0];
|
2014-06-24 23:41:12 +03:00
|
|
|
const std::string filepath = WxStrToStr(file.GetFullPath());
|
2014-06-21 03:59:07 +03:00
|
|
|
|
|
|
|
if (file.GetExt() == "dtm")
|
|
|
|
{
|
|
|
|
if (Core::IsRunning())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Movie::IsReadOnly())
|
|
|
|
{
|
|
|
|
// let's make the read-only flag consistent at the start of a movie.
|
|
|
|
Movie::SetReadOnly(true);
|
|
|
|
main_frame->GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true);
|
|
|
|
}
|
|
|
|
|
2014-06-24 23:41:12 +03:00
|
|
|
if (Movie::PlayInput(filepath))
|
2014-06-21 03:59:07 +03:00
|
|
|
main_frame->BootGame("");
|
|
|
|
}
|
|
|
|
else if (!Core::IsRunning())
|
|
|
|
{
|
2014-06-24 23:41:12 +03:00
|
|
|
main_frame->BootGame(filepath);
|
|
|
|
}
|
|
|
|
else if (IsValidSavestateDropped(filepath) && Core::IsRunning())
|
|
|
|
{
|
|
|
|
State::LoadAs(filepath);
|
2014-06-21 03:59:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-24 23:41:12 +03:00
|
|
|
DVDInterface::ChangeDisc(filepath);
|
2014-06-21 03:59:07 +03:00
|
|
|
}
|
2010-04-15 06:25:35 +03:00
|
|
|
}
|
|
|
|
|
2014-06-24 23:41:12 +03:00
|
|
|
bool CRenderFrame::IsValidSavestateDropped(const std::string& filepath)
|
|
|
|
{
|
|
|
|
const int game_id_length = 6;
|
|
|
|
std::ifstream file(filepath, std::ios::in | std::ios::binary);
|
|
|
|
|
|
|
|
if (!file)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
std::string internal_game_id(game_id_length, ' ');
|
|
|
|
file.read(&internal_game_id[0], game_id_length);
|
|
|
|
|
|
|
|
return internal_game_id == SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID();
|
|
|
|
}
|
|
|
|
|
2010-04-15 06:25:35 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (nMsg)
|
|
|
|
{
|
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
case SC_MONITORPOWER:
|
2011-08-25 22:44:13 +03:00
|
|
|
if (Core::GetState() == Core::CORE_RUN && SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
|
2010-04-15 06:25:35 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
break;
|
2010-10-04 14:09:32 +03:00
|
|
|
|
2014-06-15 13:12:19 +03:00
|
|
|
case WM_USER:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case WM_USER_STOP:
|
|
|
|
main_frame->DoStop();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER_SETCURSOR:
|
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
|
|
|
main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN)
|
|
|
|
SetCursor(wxCURSOR_BLANK);
|
|
|
|
else
|
|
|
|
SetCursor(wxNullCursor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-10-04 14:09:32 +03:00
|
|
|
case WM_CLOSE:
|
|
|
|
// Let Core finish initializing before accepting any WM_CLOSE messages
|
2014-07-08 01:47:57 +03:00
|
|
|
if (!Core::IsRunning()) break;
|
2010-10-04 14:09:32 +03:00
|
|
|
// Use default action otherwise
|
|
|
|
|
2010-04-15 06:25:35 +03:00
|
|
|
default:
|
|
|
|
// By default let wxWidgets do what it normally does with this event
|
|
|
|
return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-08-04 00:36:54 +03:00
|
|
|
bool CRenderFrame::ShowFullScreen(bool show, long style)
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
// OpenGL requires the pop-up style to activate exclusive mode.
|
|
|
|
SetWindowStyle((GetWindowStyle() & ~wxDEFAULT_FRAME_STYLE) | wxPOPUP_WINDOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool result = wxTopLevelWindow::ShowFullScreen(show, style);
|
|
|
|
|
|
|
|
if (!show)
|
|
|
|
{
|
|
|
|
// Restore the default style.
|
|
|
|
SetWindowStyle((GetWindowStyle() & ~wxPOPUP_WINDOW) | wxDEFAULT_FRAME_STYLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-01 15:44:02 +03:00
|
|
|
// event tables
|
2008-12-08 07:30:24 +02:00
|
|
|
// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
|
|
|
|
// help button.
|
|
|
|
|
|
|
|
const wxEventType wxEVT_HOST_COMMAND = wxNewEventType();
|
|
|
|
|
2010-04-15 06:25:35 +03:00
|
|
|
BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
|
2009-09-03 08:24:30 +03:00
|
|
|
|
|
|
|
// Menu bar
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_MENU(wxID_OPEN, CFrame::OnOpen)
|
|
|
|
EVT_MENU(wxID_EXIT, CFrame::OnQuit)
|
|
|
|
EVT_MENU(IDM_HELPWEBSITE, CFrame::OnHelp)
|
2013-08-31 11:31:34 +03:00
|
|
|
EVT_MENU(IDM_HELPONLINEDOCS, CFrame::OnHelp)
|
2014-06-18 22:33:14 +03:00
|
|
|
EVT_MENU(IDM_HELPGITHUB, CFrame::OnHelp)
|
2010-06-02 00:03:02 +03:00
|
|
|
EVT_MENU(wxID_ABOUT, CFrame::OnHelp)
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_MENU(wxID_REFRESH, CFrame::OnRefresh)
|
|
|
|
EVT_MENU(IDM_PLAY, CFrame::OnPlay)
|
2009-10-06 18:49:20 +03:00
|
|
|
EVT_MENU(IDM_STOP, CFrame::OnStop)
|
|
|
|
EVT_MENU(IDM_RESET, CFrame::OnReset)
|
2009-08-21 12:26:34 +03:00
|
|
|
EVT_MENU(IDM_RECORD, CFrame::OnRecord)
|
2009-08-21 22:55:03 +03:00
|
|
|
EVT_MENU(IDM_PLAYRECORD, CFrame::OnPlayRecording)
|
2010-08-30 10:05:47 +03:00
|
|
|
EVT_MENU(IDM_RECORDEXPORT, CFrame::OnRecordExport)
|
2011-02-12 04:14:20 +02:00
|
|
|
EVT_MENU(IDM_RECORDREADONLY, CFrame::OnRecordReadOnly)
|
2011-06-24 09:50:50 +03:00
|
|
|
EVT_MENU(IDM_TASINPUT, CFrame::OnTASInput)
|
2012-11-11 04:57:31 +02:00
|
|
|
EVT_MENU(IDM_TOGGLE_PAUSEMOVIE, CFrame::OnTogglePauseMovie)
|
2012-11-12 00:57:06 +02:00
|
|
|
EVT_MENU(IDM_SHOWLAG, CFrame::OnShowLag)
|
2009-08-22 05:05:02 +03:00
|
|
|
EVT_MENU(IDM_FRAMESTEP, CFrame::OnFrameStep)
|
2009-02-27 05:56:34 +02:00
|
|
|
EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot)
|
2010-06-02 00:03:02 +03:00
|
|
|
EVT_MENU(wxID_PREFERENCES, CFrame::OnConfigMain)
|
2011-02-14 04:18:03 +02:00
|
|
|
EVT_MENU(IDM_CONFIG_GFX_BACKEND, CFrame::OnConfigGFX)
|
|
|
|
EVT_MENU(IDM_CONFIG_DSP_EMULATOR, CFrame::OnConfigDSP)
|
2011-02-02 18:34:12 +02:00
|
|
|
EVT_MENU(IDM_CONFIG_PAD_PLUGIN, CFrame::OnConfigPAD)
|
|
|
|
EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnConfigWiimote)
|
2011-02-12 08:46:33 +02:00
|
|
|
EVT_MENU(IDM_CONFIG_HOTKEYS, CFrame::OnConfigHotkey)
|
2009-01-03 03:38:44 +02:00
|
|
|
|
2014-08-09 10:42:32 +03:00
|
|
|
EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnPerspectiveMenu)
|
|
|
|
EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu)
|
2009-09-01 22:47:04 +03:00
|
|
|
// Drop down
|
2014-08-09 10:42:32 +03:00
|
|
|
EVT_MENU(IDM_PERSPECTIVES_ADD_PANE, CFrame::OnPerspectiveMenu)
|
2009-08-30 22:44:42 +03:00
|
|
|
EVT_MENU_RANGE(IDM_PERSPECTIVES_0, IDM_PERSPECTIVES_100, CFrame::OnSelectPerspective)
|
2014-08-09 10:42:32 +03:00
|
|
|
EVT_MENU(IDM_ADD_PERSPECTIVE, CFrame::OnPerspectiveMenu)
|
|
|
|
EVT_MENU(IDM_TAB_SPLIT, CFrame::OnPerspectiveMenu)
|
|
|
|
EVT_MENU(IDM_NO_DOCKING, CFrame::OnPerspectiveMenu)
|
2009-09-05 07:50:45 +03:00
|
|
|
// Drop down float
|
2010-07-26 06:46:14 +03:00
|
|
|
EVT_MENU_RANGE(IDM_FLOAT_LOGWINDOW, IDM_FLOAT_CODEWINDOW, CFrame::OnFloatWindow)
|
2009-09-05 07:50:45 +03:00
|
|
|
|
2009-05-14 00:50:24 +03:00
|
|
|
EVT_MENU(IDM_NETPLAY, CFrame::OnNetPlay)
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_MENU(IDM_BROWSE, CFrame::OnBrowse)
|
|
|
|
EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard)
|
2010-01-05 09:34:03 +02:00
|
|
|
EVT_MENU(IDM_IMPORTSAVE, CFrame::OnImportSave)
|
2013-08-19 00:59:05 +03:00
|
|
|
EVT_MENU(IDM_EXPORTALLSAVE, CFrame::OnExportAllSaves)
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow)
|
2008-12-23 10:47:37 +02:00
|
|
|
EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc)
|
2011-05-08 05:56:09 +03:00
|
|
|
EVT_MENU(IDM_MENU_INSTALLWAD, CFrame::OnInstallWAD)
|
|
|
|
EVT_MENU(IDM_LIST_INSTALLWAD, CFrame::OnInstallWAD)
|
2009-02-28 01:44:15 +02:00
|
|
|
EVT_MENU(IDM_LOAD_WII_MENU, CFrame::OnLoadWiiMenu)
|
2011-03-27 05:55:08 +03:00
|
|
|
EVT_MENU(IDM_FIFOPLAYER, CFrame::OnFifoPlayer)
|
2010-01-08 23:57:31 +02:00
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)
|
|
|
|
EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore)
|
|
|
|
EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle)
|
|
|
|
EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar)
|
|
|
|
EVT_MENU(IDM_TOGGLE_STATUSBAR, CFrame::OnToggleStatusbar)
|
2010-07-26 06:46:14 +03:00
|
|
|
EVT_MENU_RANGE(IDM_LOGWINDOW, IDM_VIDEOWINDOW, CFrame::OnToggleWindow)
|
2014-06-04 16:54:48 +03:00
|
|
|
EVT_MENU_RANGE(IDM_SHOW_SYSTEM, IDM_SHOW_STATE, CFrame::OnChangeColumnsVisible)
|
2009-02-28 01:44:15 +02:00
|
|
|
|
2009-06-06 10:36:22 +03:00
|
|
|
EVT_MENU(IDM_PURGECACHE, CFrame::GameListChanged)
|
2009-04-28 05:30:50 +03:00
|
|
|
|
2012-11-08 09:40:49 +02:00
|
|
|
EVT_MENU(IDM_SAVEFIRSTSTATE, CFrame::OnSaveFirstState)
|
2009-06-29 00:11:51 +03:00
|
|
|
EVT_MENU(IDM_UNDOLOADSTATE, CFrame::OnUndoLoadState)
|
|
|
|
EVT_MENU(IDM_UNDOSAVESTATE, CFrame::OnUndoSaveState)
|
2009-06-28 04:11:35 +03:00
|
|
|
EVT_MENU(IDM_LOADSTATEFILE, CFrame::OnLoadStateFromFile)
|
|
|
|
EVT_MENU(IDM_SAVESTATEFILE, CFrame::OnSaveStateToFile)
|
|
|
|
|
2013-08-03 03:42:30 +03:00
|
|
|
EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState)
|
2012-11-08 09:40:49 +02:00
|
|
|
EVT_MENU_RANGE(IDM_LOADLAST1, IDM_LOADLAST8, CFrame::OnLoadLastState)
|
2013-08-03 03:42:30 +03:00
|
|
|
EVT_MENU_RANGE(IDM_SAVESLOT1, IDM_SAVESLOT10, CFrame::OnSaveState)
|
2009-08-08 04:39:56 +03:00
|
|
|
EVT_MENU_RANGE(IDM_FRAMESKIP0, IDM_FRAMESKIP9, CFrame::OnFrameSkip)
|
2009-02-22 01:44:40 +02:00
|
|
|
EVT_MENU_RANGE(IDM_DRIVE1, IDM_DRIVE24, CFrame::OnBootDrive)
|
2013-06-26 13:23:29 +03:00
|
|
|
EVT_MENU_RANGE(IDM_CONNECT_WIIMOTE1, IDM_CONNECT_BALANCEBOARD, CFrame::OnConnectWiimote)
|
2010-01-11 07:07:56 +02:00
|
|
|
EVT_MENU_RANGE(IDM_LISTWAD, IDM_LISTDRIVES, CFrame::GameListChanged)
|
2009-01-04 23:53:41 +02:00
|
|
|
|
2009-09-03 08:24:30 +03:00
|
|
|
// Other
|
2009-12-30 11:00:43 +02:00
|
|
|
EVT_ACTIVATE(CFrame::OnActive)
|
2009-09-03 08:24:30 +03:00
|
|
|
EVT_CLOSE(CFrame::OnClose)
|
2008-12-12 05:38:50 +02:00
|
|
|
EVT_SIZE(CFrame::OnResize)
|
2010-01-18 20:01:03 +02:00
|
|
|
EVT_MOVE(CFrame::OnMove)
|
2009-01-28 18:51:05 +02:00
|
|
|
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CFrame::OnGameListCtrl_ItemActivated)
|
2008-12-08 07:30:24 +02:00
|
|
|
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
|
2009-08-25 04:50:27 +03:00
|
|
|
|
2009-08-30 22:44:42 +03:00
|
|
|
EVT_AUI_PANE_CLOSE(CFrame::OnPaneClose)
|
2009-08-26 12:19:15 +03:00
|
|
|
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, CFrame::OnNotebookPageClose)
|
2009-08-26 18:23:48 +03:00
|
|
|
EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, CFrame::OnAllowNotebookDnD)
|
2009-08-27 18:53:19 +03:00
|
|
|
EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, CFrame::OnNotebookPageChanged)
|
2009-09-05 07:50:45 +03:00
|
|
|
EVT_AUINOTEBOOK_TAB_RIGHT_UP(wxID_ANY, CFrame::OnTab)
|
2009-08-26 12:19:15 +03:00
|
|
|
|
2009-09-03 08:24:30 +03:00
|
|
|
// Post events to child panels
|
2010-07-27 05:39:12 +03:00
|
|
|
EVT_MENU_RANGE(IDM_INTERPRETER, IDM_ADDRBOX, CFrame::PostEvent)
|
|
|
|
EVT_TEXT(IDM_ADDRBOX, CFrame::PostEvent)
|
2009-09-03 08:24:30 +03:00
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
END_EVENT_TABLE()
|
2009-01-05 06:08:18 +02:00
|
|
|
|
2009-09-03 10:56:35 +03:00
|
|
|
// ---------------
|
2009-09-01 15:44:02 +03:00
|
|
|
// Creation and close, quit functions
|
2009-09-01 16:06:37 +03:00
|
|
|
|
2009-09-01 17:33:16 +03:00
|
|
|
CFrame::CFrame(wxFrame* parent,
|
2008-12-08 07:30:24 +02:00
|
|
|
wxWindowID id,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
2009-08-25 04:50:27 +03:00
|
|
|
bool _UseDebugger,
|
2010-07-09 02:27:51 +03:00
|
|
|
bool _BatchMode,
|
2009-09-01 18:16:44 +03:00
|
|
|
bool ShowLogWindow,
|
2008-12-08 07:30:24 +02:00
|
|
|
long style)
|
2010-04-15 06:25:35 +03:00
|
|
|
: CRenderFrame(parent, id, title, pos, size, style)
|
2014-03-09 22:14:26 +02:00
|
|
|
, g_pCodeWindow(nullptr), g_NetPlaySetupDiag(nullptr), g_CheatsWindow(nullptr)
|
2014-08-10 00:51:59 +03:00
|
|
|
, m_SavedPerspectives(nullptr), m_ToolBar(nullptr)
|
2014-03-09 22:14:26 +02:00
|
|
|
, m_GameListCtrl(nullptr), m_Panel(nullptr)
|
|
|
|
, m_RenderFrame(nullptr), m_RenderParent(nullptr)
|
|
|
|
, m_LogWindow(nullptr), m_LogConfigWindow(nullptr)
|
|
|
|
, m_FifoPlayerDlg(nullptr), UseDebugger(_UseDebugger)
|
2010-07-09 02:27:51 +03:00
|
|
|
, m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
|
2014-07-21 18:55:21 +03:00
|
|
|
, m_bGameLoading(false), m_bClosing(false), m_confirmStop(false)
|
2008-12-08 07:30:24 +02:00
|
|
|
{
|
2010-07-26 06:46:14 +03:00
|
|
|
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
2010-07-22 05:05:28 +03:00
|
|
|
bFloatWindow[i] = false;
|
|
|
|
|
2014-02-23 09:38:46 +02:00
|
|
|
if (ShowLogWindow)
|
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = true;
|
2009-08-27 18:53:19 +03:00
|
|
|
|
2013-01-17 05:23:42 +02:00
|
|
|
// Start debugging maximized
|
2014-02-23 09:38:46 +02:00
|
|
|
if (UseDebugger)
|
|
|
|
this->Maximize(true);
|
|
|
|
|
2009-08-25 04:50:27 +03:00
|
|
|
// Debugger class
|
|
|
|
if (UseDebugger)
|
2009-08-30 22:44:42 +03:00
|
|
|
{
|
2009-09-07 15:40:43 +03:00
|
|
|
g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, IDM_CODEWINDOW);
|
2010-07-26 06:46:14 +03:00
|
|
|
LoadIniPerspectives();
|
2010-07-28 18:22:27 +03:00
|
|
|
g_pCodeWindow->Load();
|
2010-07-24 05:36:22 +03:00
|
|
|
}
|
2009-08-25 04:50:27 +03:00
|
|
|
|
2010-07-24 05:36:22 +03:00
|
|
|
// Create toolbar bitmaps
|
2008-12-08 07:30:24 +02:00
|
|
|
InitBitmaps();
|
|
|
|
|
2008-12-09 16:57:55 +02:00
|
|
|
// Give it a status bar
|
2010-07-30 06:51:49 +03:00
|
|
|
SetStatusBar(CreateStatusBar(2, wxST_SIZEGRIP, ID_STATUSBAR));
|
2009-03-18 19:17:58 +02:00
|
|
|
if (!SConfig::GetInstance().m_InterfaceStatusbar)
|
2010-07-30 06:51:49 +03:00
|
|
|
GetStatusBar()->Hide();
|
2008-12-09 07:37:15 +02:00
|
|
|
|
2009-01-04 23:53:41 +02:00
|
|
|
// Give it a menu bar
|
2008-12-08 07:30:24 +02:00
|
|
|
CreateMenu();
|
|
|
|
|
2009-09-01 16:06:37 +03:00
|
|
|
// ---------------
|
2009-09-01 15:44:02 +03:00
|
|
|
// Main panel
|
2009-08-27 14:08:52 +03:00
|
|
|
// This panel is the parent for rendering and it holds the gamelistctrl
|
2014-06-15 13:12:19 +03:00
|
|
|
m_Panel = new wxPanel(this, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0);
|
2009-03-18 19:17:58 +02:00
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);
|
|
|
|
|
2010-07-24 05:36:22 +03:00
|
|
|
wxBoxSizer *sizerPanel = new wxBoxSizer(wxHORIZONTAL);
|
2009-03-07 07:32:16 +02:00
|
|
|
sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL);
|
2008-12-08 07:30:24 +02:00
|
|
|
m_Panel->SetSizer(sizerPanel);
|
2009-09-01 16:06:37 +03:00
|
|
|
// ---------------
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2009-09-01 22:47:04 +03:00
|
|
|
// Manager
|
|
|
|
m_Mgr = new wxAuiManager(this, wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
2009-08-27 10:33:07 +03:00
|
|
|
|
2011-03-23 04:06:40 +02:00
|
|
|
m_Mgr->AddPane(m_Panel, wxAuiPaneInfo()
|
2014-05-17 20:17:28 +03:00
|
|
|
.Name("Pane 0").Caption("Pane 0").PaneBorder(false)
|
2011-03-23 04:06:40 +02:00
|
|
|
.CaptionVisible(false).Layer(0).Center().Show());
|
|
|
|
if (!g_pCodeWindow)
|
2010-07-30 06:51:49 +03:00
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
|
2014-05-17 20:17:28 +03:00
|
|
|
.Name("Pane 1").Caption(_("Logging")).CaptionVisible(true)
|
2010-07-30 06:51:49 +03:00
|
|
|
.Layer(0).FloatingSize(wxSize(600, 350)).CloseButton(true).Hide());
|
2011-03-23 04:06:40 +02:00
|
|
|
AuiFullscreen = m_Mgr->SavePerspective();
|
2009-08-27 10:33:07 +03:00
|
|
|
|
2009-08-27 13:46:43 +03:00
|
|
|
// Create toolbar
|
|
|
|
RecreateToolbar();
|
|
|
|
if (!SConfig::GetInstance().m_InterfaceToolbar) DoToggleToolbar(false);
|
|
|
|
|
2010-08-02 04:52:00 +03:00
|
|
|
m_LogWindow = new CLogWindow(this, IDM_LOGWINDOW);
|
|
|
|
m_LogWindow->Hide();
|
|
|
|
m_LogWindow->Disable();
|
|
|
|
|
2012-11-12 00:38:01 +02:00
|
|
|
g_TASInputDlg[0] = new TASInputDlg(this);
|
|
|
|
g_TASInputDlg[1] = new TASInputDlg(this);
|
|
|
|
g_TASInputDlg[2] = new TASInputDlg(this);
|
|
|
|
g_TASInputDlg[3] = new TASInputDlg(this);
|
|
|
|
|
2011-06-24 09:50:50 +03:00
|
|
|
Movie::SetInputManip(TASManipFunction);
|
|
|
|
|
2011-12-18 11:15:59 +02:00
|
|
|
State::SetOnAfterLoadCallback(OnAfterLoadCallback);
|
2014-06-20 03:43:57 +03:00
|
|
|
Core::SetOnStoppedCallback(OnStoppedCallback);
|
2011-12-18 11:15:59 +02:00
|
|
|
|
2009-08-27 13:46:43 +03:00
|
|
|
// Setup perspectives
|
2009-09-07 15:40:43 +03:00
|
|
|
if (g_pCodeWindow)
|
2010-07-24 05:36:22 +03:00
|
|
|
{
|
2009-08-27 10:33:07 +03:00
|
|
|
// Load perspective
|
2009-08-31 08:56:30 +03:00
|
|
|
DoLoadPerspective();
|
2009-08-27 10:33:07 +03:00
|
|
|
}
|
|
|
|
else
|
2009-08-31 08:56:30 +03:00
|
|
|
{
|
2010-07-19 05:09:34 +03:00
|
|
|
if (SConfig::GetInstance().m_InterfaceLogWindow)
|
2010-08-01 07:09:59 +03:00
|
|
|
ToggleLogWindow(true);
|
2011-02-21 17:01:00 +02:00
|
|
|
if (SConfig::GetInstance().m_InterfaceLogConfigWindow)
|
|
|
|
ToggleLogConfigWindow(true);
|
2009-08-31 08:56:30 +03:00
|
|
|
}
|
2009-08-27 13:10:07 +03:00
|
|
|
|
2009-09-16 00:35:32 +03:00
|
|
|
// Show window
|
|
|
|
Show();
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2010-07-24 05:36:22 +03:00
|
|
|
// Commit
|
2009-08-25 04:50:27 +03:00
|
|
|
m_Mgr->Update();
|
|
|
|
|
2009-01-05 01:24:13 +02:00
|
|
|
#ifdef _WIN32
|
2014-05-17 20:17:28 +03:00
|
|
|
SetToolTip("");
|
2011-04-20 18:25:21 +03:00
|
|
|
GetToolTip()->SetAutoPop(25000);
|
2009-01-05 01:24:13 +02:00
|
|
|
#endif
|
|
|
|
|
2010-04-22 07:28:34 +03:00
|
|
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
|
|
|
m_XRRConfig = new X11Utils::XRRConfiguration(X11Utils::XDisplayFromHandle(GetHandle()),
|
2010-08-01 07:09:59 +03:00
|
|
|
X11Utils::XWindowFromHandle(GetHandle()));
|
2010-04-22 07:28:34 +03:00
|
|
|
#endif
|
|
|
|
|
2009-09-01 15:44:02 +03:00
|
|
|
// -------------------------
|
|
|
|
// Connect event handlers
|
2009-09-03 10:56:35 +03:00
|
|
|
|
2013-01-13 20:07:45 +02:00
|
|
|
m_Mgr->Bind(wxEVT_AUI_RENDER, &CFrame::OnManagerResize, this);
|
2009-09-01 15:44:02 +03:00
|
|
|
// ----------
|
2009-01-15 08:48:15 +02:00
|
|
|
|
2009-09-01 15:44:02 +03:00
|
|
|
// Update controls
|
2008-12-08 07:30:24 +02:00
|
|
|
UpdateGUI();
|
|
|
|
}
|
2009-01-04 23:53:41 +02:00
|
|
|
// Destructor
|
|
|
|
CFrame::~CFrame()
|
2008-12-08 07:30:24 +02:00
|
|
|
{
|
2010-02-16 10:46:21 +02:00
|
|
|
drives.clear();
|
2009-09-01 15:44:02 +03:00
|
|
|
|
2010-04-22 07:28:34 +03:00
|
|
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
|
|
|
delete m_XRRConfig;
|
|
|
|
#endif
|
2013-09-10 11:04:29 +03:00
|
|
|
|
|
|
|
ClosePages();
|
|
|
|
|
|
|
|
delete m_Mgr;
|
2008-12-08 07:30:24 +02:00
|
|
|
}
|
|
|
|
|
2010-04-12 04:33:10 +03:00
|
|
|
bool CFrame::RendererIsFullscreen()
|
|
|
|
{
|
2013-03-31 19:08:29 +03:00
|
|
|
bool fullscreen = false;
|
|
|
|
|
2010-04-12 04:33:10 +03:00
|
|
|
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
|
|
|
|
{
|
2014-07-28 23:45:53 +03:00
|
|
|
fullscreen = m_RenderFrame->IsFullScreen();
|
2012-12-23 10:33:52 +02:00
|
|
|
}
|
2013-03-31 19:08:29 +03:00
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
2014-03-09 22:14:26 +02:00
|
|
|
if (m_RenderFrame != nullptr)
|
2013-03-31 19:08:29 +03:00
|
|
|
{
|
|
|
|
NSView *view = (NSView *) m_RenderFrame->GetHandle();
|
|
|
|
NSWindow *window = [view window];
|
|
|
|
|
|
|
|
fullscreen = (([window styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return fullscreen;
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
|
|
|
|
2009-01-05 06:08:18 +02:00
|
|
|
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
|
|
|
Close(true);
|
|
|
|
}
|
|
|
|
|
2009-09-03 10:56:35 +03:00
|
|
|
// --------
|
2009-09-01 18:16:44 +03:00
|
|
|
// Events
|
2009-12-30 11:00:43 +02:00
|
|
|
void CFrame::OnActive(wxActivateEvent& event)
|
|
|
|
{
|
2010-03-16 01:25:11 +02:00
|
|
|
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
|
|
|
|
{
|
2010-04-12 04:33:10 +03:00
|
|
|
if (event.GetActive() && event.GetEventObject() == m_RenderFrame)
|
|
|
|
{
|
2014-08-01 22:31:17 +03:00
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
|
|
|
{
|
2012-03-19 16:39:04 +02:00
|
|
|
#ifdef __WXMSW__
|
2014-08-01 22:31:17 +03:00
|
|
|
::SetFocus((HWND)m_RenderParent->GetHandle());
|
2012-03-19 16:46:23 +02:00
|
|
|
#else
|
2014-08-01 22:31:17 +03:00
|
|
|
m_RenderParent->SetFocus();
|
2012-03-19 16:39:04 +02:00
|
|
|
#endif
|
2014-08-01 22:31:17 +03:00
|
|
|
}
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2012-12-15 08:04:10 +02:00
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
2010-04-12 04:33:10 +03:00
|
|
|
Core::GetState() == Core::CORE_RUN)
|
2012-12-17 05:32:14 +02:00
|
|
|
m_RenderParent->SetCursor(wxCURSOR_BLANK);
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
2010-03-16 01:25:11 +02:00
|
|
|
else
|
2010-04-12 04:33:10 +03:00
|
|
|
{
|
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
2012-12-17 19:32:10 +02:00
|
|
|
m_RenderParent->SetCursor(wxNullCursor);
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
2010-03-16 01:25:11 +02:00
|
|
|
}
|
2009-12-30 11:00:43 +02:00
|
|
|
event.Skip();
|
|
|
|
}
|
2009-09-01 18:16:44 +03:00
|
|
|
|
2009-01-05 06:08:18 +02:00
|
|
|
void CFrame::OnClose(wxCloseEvent& event)
|
|
|
|
{
|
2014-06-20 04:03:00 +03:00
|
|
|
m_bClosing = true;
|
|
|
|
|
|
|
|
// Before closing the window we need to shut down the emulation core.
|
|
|
|
// We'll try to close this window again once that is done.
|
2010-12-17 17:23:33 +02:00
|
|
|
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
|
|
|
{
|
|
|
|
DoStop();
|
2014-07-29 12:26:19 +03:00
|
|
|
if (event.CanVeto())
|
|
|
|
{
|
|
|
|
event.Veto();
|
|
|
|
}
|
2014-06-20 04:03:00 +03:00
|
|
|
return;
|
2010-12-17 17:23:33 +02:00
|
|
|
}
|
|
|
|
|
2014-06-20 04:03:00 +03:00
|
|
|
// Stop Dolphin from saving the minimized Xpos and Ypos
|
2014-03-10 13:30:55 +02:00
|
|
|
if (main_frame->IsIconized())
|
2010-01-23 08:15:17 +02:00
|
|
|
main_frame->Iconize(false);
|
|
|
|
|
2009-04-15 23:19:25 +03:00
|
|
|
// Don't forget the skip or the window won't be destroyed
|
2009-01-05 06:08:18 +02:00
|
|
|
event.Skip();
|
2010-12-17 17:23:33 +02:00
|
|
|
|
2009-08-27 04:30:08 +03:00
|
|
|
// Save GUI settings
|
2013-04-08 08:16:50 +03:00
|
|
|
if (g_pCodeWindow)
|
|
|
|
{
|
|
|
|
SaveIniPerspectives();
|
|
|
|
}
|
2011-03-23 04:06:40 +02:00
|
|
|
else
|
|
|
|
{
|
2013-04-08 08:16:50 +03:00
|
|
|
// Close the log window now so that its settings are saved
|
2011-03-23 04:06:40 +02:00
|
|
|
m_LogWindow->Close();
|
2014-03-09 22:14:26 +02:00
|
|
|
m_LogWindow = nullptr;
|
2011-03-23 04:06:40 +02:00
|
|
|
}
|
|
|
|
|
2010-07-27 05:39:12 +03:00
|
|
|
|
2009-09-01 05:41:48 +03:00
|
|
|
// Uninit
|
|
|
|
m_Mgr->UnInit();
|
2009-01-05 06:08:18 +02:00
|
|
|
}
|
2009-08-26 12:19:15 +03:00
|
|
|
|
2009-09-01 18:16:44 +03:00
|
|
|
// Post events
|
2009-09-01 10:32:07 +03:00
|
|
|
|
2009-09-01 18:16:44 +03:00
|
|
|
// Warning: This may cause an endless loop if the event is propagated back to its parent
|
|
|
|
void CFrame::PostEvent(wxCommandEvent& event)
|
2009-08-27 10:33:07 +03:00
|
|
|
{
|
2010-07-27 05:39:12 +03:00
|
|
|
if (g_pCodeWindow &&
|
|
|
|
event.GetId() >= IDM_INTERPRETER &&
|
|
|
|
event.GetId() <= IDM_ADDRBOX)
|
2009-09-03 08:24:30 +03:00
|
|
|
{
|
|
|
|
event.StopPropagation();
|
2010-01-20 13:49:11 +02:00
|
|
|
g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2009-09-03 08:24:30 +03:00
|
|
|
}
|
|
|
|
else
|
2013-04-08 08:16:50 +03:00
|
|
|
{
|
2009-09-03 08:24:30 +03:00
|
|
|
event.Skip();
|
2013-04-08 08:16:50 +03:00
|
|
|
}
|
2009-08-31 08:56:30 +03:00
|
|
|
}
|
|
|
|
|
2010-01-18 20:01:03 +02:00
|
|
|
void CFrame::OnMove(wxMoveEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
|
2010-04-12 04:33:10 +03:00
|
|
|
if (!IsMaximized() &&
|
2010-10-17 15:42:04 +03:00
|
|
|
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()))
|
2010-04-12 04:33:10 +03:00
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX = GetPosition().x;
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY = GetPosition().y;
|
|
|
|
}
|
2010-01-18 20:01:03 +02:00
|
|
|
}
|
2010-03-09 01:29:16 +02:00
|
|
|
|
2009-09-07 15:40:43 +03:00
|
|
|
void CFrame::OnResize(wxSizeEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2010-10-17 15:42:04 +03:00
|
|
|
|
2010-04-12 04:33:10 +03:00
|
|
|
if (!IsMaximized() &&
|
2011-01-25 05:30:12 +02:00
|
|
|
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()) &&
|
|
|
|
!(Core::GetState() != Core::CORE_UNINITIALIZED &&
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize))
|
2010-04-12 04:33:10 +03:00
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth = GetSize().GetWidth();
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight = GetSize().GetHeight();
|
|
|
|
}
|
2011-03-23 04:06:40 +02:00
|
|
|
|
|
|
|
// Make sure the logger pane is a sane size
|
2014-05-17 20:17:28 +03:00
|
|
|
if (!g_pCodeWindow && m_LogWindow && m_Mgr->GetPane("Pane 1").IsShown() &&
|
|
|
|
!m_Mgr->GetPane("Pane 1").IsFloating() &&
|
2011-03-23 04:06:40 +02:00
|
|
|
(m_LogWindow->x > GetClientRect().GetWidth() ||
|
|
|
|
m_LogWindow->y > GetClientRect().GetHeight()))
|
|
|
|
ShowResizePane();
|
2009-09-07 15:40:43 +03:00
|
|
|
}
|
2009-08-31 08:56:30 +03:00
|
|
|
|
2009-09-01 15:44:02 +03:00
|
|
|
// Host messages
|
2009-09-01 16:06:37 +03:00
|
|
|
|
2008-12-14 19:37:59 +02:00
|
|
|
#ifdef _WIN32
|
2009-07-03 00:17:36 +03:00
|
|
|
WXLRESULT CFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|
|
|
{
|
2011-03-16 01:09:12 +02:00
|
|
|
if (WM_SYSCOMMAND == nMsg && (SC_SCREENSAVE == wParam || SC_MONITORPOWER == wParam))
|
2013-09-10 13:14:21 +03:00
|
|
|
{
|
2011-03-16 01:09:12 +02:00
|
|
|
return 0;
|
2013-09-10 13:14:21 +03:00
|
|
|
}
|
|
|
|
else if (nMsg == WM_QUERYENDSESSION)
|
|
|
|
{
|
|
|
|
// Indicate that the application will be able to close
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (nMsg == WM_ENDSESSION)
|
|
|
|
{
|
|
|
|
// Actually trigger the close now
|
|
|
|
Close(true);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-16 01:09:12 +02:00
|
|
|
else
|
2013-09-10 13:14:21 +03:00
|
|
|
{
|
2010-02-25 08:12:35 +02:00
|
|
|
return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
|
2013-09-10 13:14:21 +03:00
|
|
|
}
|
2009-07-03 00:17:36 +03:00
|
|
|
}
|
2009-01-04 23:53:41 +02:00
|
|
|
#endif
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2014-08-19 17:17:33 +03:00
|
|
|
void CFrame::UpdateTitle(const std::string &str)
|
|
|
|
{
|
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
|
|
|
|
SConfig::GetInstance().m_InterfaceStatusbar)
|
|
|
|
{
|
|
|
|
GetStatusBar()->SetStatusText(str, 0);
|
|
|
|
m_RenderFrame->SetTitle(scm_rev_str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string titleStr = StringFromFormat("%s | %s", scm_rev_str, str.c_str());
|
|
|
|
m_RenderFrame->SetTitle(titleStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
void CFrame::OnHostMessage(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-10 10:57:57 +02:00
|
|
|
case IDM_UPDATEGUI:
|
|
|
|
UpdateGUI();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_UPDATESTATUSBAR:
|
2014-03-09 22:14:26 +02:00
|
|
|
if (GetStatusBar() != nullptr)
|
2010-07-30 06:51:49 +03:00
|
|
|
GetStatusBar()->SetStatusText(event.GetString(), event.GetInt());
|
2008-12-10 10:57:57 +02:00
|
|
|
break;
|
2010-04-12 04:33:10 +03:00
|
|
|
|
2010-04-15 23:58:34 +03:00
|
|
|
case IDM_UPDATETITLE:
|
2014-08-23 00:28:02 +03:00
|
|
|
UpdateTitle(WxStrToStr(event.GetString()));
|
2010-04-15 23:58:34 +03:00
|
|
|
break;
|
|
|
|
|
2011-02-01 06:35:25 +02:00
|
|
|
case IDM_WINDOWSIZEREQUEST:
|
|
|
|
{
|
|
|
|
std::pair<int, int> *win_size = (std::pair<int, int> *)(event.GetClientData());
|
|
|
|
OnRenderWindowSizeRequest(win_size->first, win_size->second);
|
|
|
|
delete win_size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-07-16 16:53:33 +03:00
|
|
|
case IDM_FULLSCREENREQUEST:
|
2014-07-21 20:56:52 +03:00
|
|
|
{
|
2014-07-26 13:43:49 +03:00
|
|
|
bool enable_fullscreen = event.GetInt() == 0 ? false : true;
|
|
|
|
ToggleDisplayMode(enable_fullscreen);
|
2014-07-21 20:56:52 +03:00
|
|
|
if (m_RenderFrame != nullptr)
|
2014-07-26 13:43:49 +03:00
|
|
|
m_RenderFrame->ShowFullScreen(enable_fullscreen);
|
|
|
|
|
|
|
|
// If the stop dialog initiated this fullscreen switch then we need
|
|
|
|
// to pause the emulator after we've completed the switch.
|
|
|
|
// TODO: Allow the renderer to switch fullscreen modes while paused.
|
2014-07-21 20:56:52 +03:00
|
|
|
if (m_confirmStop)
|
|
|
|
Core::SetState(Core::CORE_PAUSE);
|
|
|
|
}
|
2014-07-16 16:53:33 +03:00
|
|
|
break;
|
|
|
|
|
2012-05-02 22:40:40 +03:00
|
|
|
case WM_USER_CREATE:
|
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
|
|
|
m_RenderParent->SetCursor(wxCURSOR_BLANK);
|
|
|
|
break;
|
|
|
|
|
2012-12-17 05:32:14 +02:00
|
|
|
#ifdef __WXGTK__
|
2010-11-11 02:55:06 +02:00
|
|
|
case IDM_PANIC:
|
2011-07-15 17:49:34 +03:00
|
|
|
{
|
|
|
|
wxString caption = event.GetString().BeforeFirst(':');
|
|
|
|
wxString text = event.GetString().AfterFirst(':');
|
2013-10-29 07:23:17 +02:00
|
|
|
bPanicResult = (wxYES == wxMessageBox(text,
|
2011-07-15 17:49:34 +03:00
|
|
|
caption, event.GetInt() ? wxYES_NO : wxOK, wxGetActiveWindow()));
|
|
|
|
panic_event.Set();
|
|
|
|
}
|
2011-01-31 00:02:47 +02:00
|
|
|
break;
|
2010-11-11 02:55:06 +02:00
|
|
|
#endif
|
|
|
|
|
2010-02-07 04:41:02 +02:00
|
|
|
case WM_USER_STOP:
|
2010-03-16 01:25:11 +02:00
|
|
|
DoStop();
|
2010-02-07 08:07:56 +02:00
|
|
|
break;
|
2014-06-20 03:43:57 +03:00
|
|
|
|
|
|
|
case IDM_STOPPED:
|
|
|
|
OnStopped();
|
|
|
|
break;
|
2009-09-07 15:40:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 06:57:59 +02:00
|
|
|
void CFrame::GetRenderWindowSize(int& x, int& y, int& width, int& height)
|
2010-04-12 04:33:10 +03:00
|
|
|
{
|
2011-02-21 00:56:03 +02:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
if (!wxIsMainThread())
|
|
|
|
wxMutexGuiEnter();
|
|
|
|
#endif
|
2012-05-02 22:40:40 +03:00
|
|
|
wxRect client_rect = m_RenderParent->GetClientRect();
|
|
|
|
width = client_rect.width;
|
|
|
|
height = client_rect.height;
|
|
|
|
x = client_rect.x;
|
|
|
|
y = client_rect.y;
|
2011-02-21 00:56:03 +02:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
if (!wxIsMainThread())
|
|
|
|
wxMutexGuiLeave();
|
|
|
|
#endif
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
|
|
|
|
2011-01-25 05:30:12 +02:00
|
|
|
void CFrame::OnRenderWindowSizeRequest(int width, int height)
|
2011-01-07 06:57:59 +02:00
|
|
|
{
|
2014-07-08 01:47:57 +03:00
|
|
|
if (!Core::IsRunning() ||
|
2013-10-29 07:23:17 +02:00
|
|
|
!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize ||
|
2011-01-25 14:52:20 +02:00
|
|
|
RendererIsFullscreen() || m_RenderFrame->IsMaximized())
|
2011-01-25 05:30:12 +02:00
|
|
|
return;
|
2011-01-07 06:57:59 +02:00
|
|
|
|
2011-02-01 06:35:25 +02:00
|
|
|
int old_width, old_height, log_width = 0, log_height = 0;
|
2011-01-25 05:30:12 +02:00
|
|
|
m_RenderFrame->GetClientSize(&old_width, &old_height);
|
2011-02-01 06:35:25 +02:00
|
|
|
|
|
|
|
// Add space for the log/console/debugger window
|
2011-03-15 14:50:58 +02:00
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
|
|
|
|
(SConfig::GetInstance().m_InterfaceLogWindow ||
|
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow) &&
|
2014-05-17 20:17:28 +03:00
|
|
|
!m_Mgr->GetPane("Pane 1").IsFloating())
|
2011-01-07 06:57:59 +02:00
|
|
|
{
|
2014-05-17 20:17:28 +03:00
|
|
|
switch (m_Mgr->GetPane("Pane 1").dock_direction)
|
2011-02-01 06:35:25 +02:00
|
|
|
{
|
|
|
|
case wxAUI_DOCK_LEFT:
|
|
|
|
case wxAUI_DOCK_RIGHT:
|
2014-05-17 20:17:28 +03:00
|
|
|
log_width = m_Mgr->GetPane("Pane 1").rect.GetWidth();
|
2011-02-01 06:35:25 +02:00
|
|
|
break;
|
|
|
|
case wxAUI_DOCK_TOP:
|
|
|
|
case wxAUI_DOCK_BOTTOM:
|
2014-05-17 20:17:28 +03:00
|
|
|
log_height = m_Mgr->GetPane("Pane 1").rect.GetHeight();
|
2011-02-01 06:35:25 +02:00
|
|
|
break;
|
|
|
|
}
|
2011-01-07 06:57:59 +02:00
|
|
|
}
|
2011-02-01 06:35:25 +02:00
|
|
|
|
|
|
|
if (old_width != width + log_width || old_height != height + log_height)
|
|
|
|
m_RenderFrame->SetClientSize(width + log_width, height + log_height);
|
2011-01-07 06:57:59 +02:00
|
|
|
}
|
|
|
|
|
2010-04-12 04:33:10 +03:00
|
|
|
bool CFrame::RendererHasFocus()
|
|
|
|
{
|
2014-07-16 17:21:22 +03:00
|
|
|
if (m_RenderParent == nullptr)
|
|
|
|
return false;
|
|
|
|
#ifdef _WIN32
|
2014-06-15 14:13:37 +03:00
|
|
|
HWND window = GetForegroundWindow();
|
|
|
|
if (window == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (m_RenderFrame->GetHWND() == window)
|
2014-07-16 17:21:22 +03:00
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
wxWindow *window = wxWindow::FindFocus();
|
|
|
|
if (window == nullptr)
|
|
|
|
return false;
|
|
|
|
// Why these different cases?
|
|
|
|
if (m_RenderParent == window ||
|
|
|
|
m_RenderParent == window->GetParent() ||
|
|
|
|
m_RenderParent->GetParent() == window->GetParent())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
|
|
|
|
2014-07-16 17:24:40 +03:00
|
|
|
bool CFrame::UIHasFocus()
|
|
|
|
{
|
|
|
|
// UIHasFocus should return true any time any one of our UI
|
|
|
|
// windows has the focus, including any dialogs or other windows.
|
|
|
|
//
|
|
|
|
// wxGetActiveWindow() returns the current wxWindow which has
|
|
|
|
// focus. If it's not one of our windows, then it will return
|
|
|
|
// null.
|
|
|
|
|
|
|
|
wxWindow *focusWindow = wxGetActiveWindow();
|
|
|
|
return (focusWindow != nullptr);
|
|
|
|
}
|
|
|
|
|
2009-01-28 18:51:05 +02:00
|
|
|
void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
2009-01-07 11:06:42 +02:00
|
|
|
{
|
2009-06-09 08:08:58 +03:00
|
|
|
// Show all platforms and regions if...
|
|
|
|
// 1. All platforms are set to hide
|
|
|
|
// 2. All Regions are set to hide
|
|
|
|
// Otherwise call BootGame to either...
|
|
|
|
// 1. Boot the selected iso
|
2009-07-01 07:55:53 +03:00
|
|
|
// 2. Boot the default or last loaded iso.
|
|
|
|
// 3. Call BrowseForDirectory if the gamelist is empty
|
2013-03-04 01:56:40 +02:00
|
|
|
if (!m_GameListCtrl->GetISO(0) &&
|
2009-09-25 19:29:00 +03:00
|
|
|
!((SConfig::GetInstance().m_ListGC &&
|
|
|
|
SConfig::GetInstance().m_ListWii &&
|
2009-06-09 08:08:58 +03:00
|
|
|
SConfig::GetInstance().m_ListWad) &&
|
2009-09-25 19:29:00 +03:00
|
|
|
(SConfig::GetInstance().m_ListJap &&
|
|
|
|
SConfig::GetInstance().m_ListUsa &&
|
2010-01-11 07:07:56 +02:00
|
|
|
SConfig::GetInstance().m_ListPal &&
|
|
|
|
SConfig::GetInstance().m_ListFrance &&
|
|
|
|
SConfig::GetInstance().m_ListItaly &&
|
|
|
|
SConfig::GetInstance().m_ListKorea &&
|
|
|
|
SConfig::GetInstance().m_ListTaiwan &&
|
|
|
|
SConfig::GetInstance().m_ListUnknown)))
|
2009-06-09 08:08:58 +03:00
|
|
|
{
|
2014-02-17 06:51:41 +02:00
|
|
|
SConfig::GetInstance().m_ListGC = SConfig::GetInstance().m_ListWii =
|
|
|
|
SConfig::GetInstance().m_ListWad = SConfig::GetInstance().m_ListJap =
|
|
|
|
SConfig::GetInstance().m_ListUsa = SConfig::GetInstance().m_ListPal =
|
|
|
|
SConfig::GetInstance().m_ListFrance = SConfig::GetInstance().m_ListItaly =
|
|
|
|
SConfig::GetInstance().m_ListKorea = SConfig::GetInstance().m_ListTaiwan =
|
|
|
|
SConfig::GetInstance().m_ListUnknown = true;
|
2009-06-09 08:08:58 +03:00
|
|
|
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTGC)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTWII)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTWAD)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTJAP)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTUSA)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTPAL)->Check(true);
|
2010-01-11 07:07:56 +02:00
|
|
|
GetMenuBar()->FindItem(IDM_LISTFRANCE)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTITALY)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTKOREA)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LISTTAIWAN)->Check(true);
|
|
|
|
GetMenuBar()->FindItem(IDM_LIST_UNK)->Check(true);
|
2009-06-09 08:08:58 +03:00
|
|
|
|
|
|
|
m_GameListCtrl->Update();
|
2010-07-24 05:36:22 +03:00
|
|
|
}
|
2013-03-04 01:56:40 +02:00
|
|
|
else if (!m_GameListCtrl->GetISO(0))
|
2013-04-08 08:16:50 +03:00
|
|
|
{
|
2010-08-03 06:20:44 +03:00
|
|
|
m_GameListCtrl->BrowseForDirectory();
|
2013-04-08 08:16:50 +03:00
|
|
|
}
|
2010-01-18 14:10:51 +02:00
|
|
|
else
|
2013-04-08 08:16:50 +03:00
|
|
|
{
|
2010-01-18 14:10:51 +02:00
|
|
|
// Game started by double click
|
2014-05-17 20:17:28 +03:00
|
|
|
BootGame("");
|
2013-04-08 08:16:50 +03:00
|
|
|
}
|
2009-01-07 11:06:42 +02:00
|
|
|
}
|
2009-01-28 18:51:05 +02:00
|
|
|
|
2014-07-08 15:29:26 +03:00
|
|
|
static bool IsHotkey(wxKeyEvent &event, int Id)
|
2010-04-12 04:33:10 +03:00
|
|
|
{
|
2012-08-06 15:21:49 +03:00
|
|
|
return (event.GetKeyCode() != WXK_NONE &&
|
2013-04-08 08:16:50 +03:00
|
|
|
event.GetKeyCode() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id] &&
|
2013-02-26 21:49:00 +02:00
|
|
|
event.GetModifiers() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id]);
|
2010-04-12 04:33:10 +03:00
|
|
|
}
|
|
|
|
|
2011-02-14 03:18:01 +02:00
|
|
|
int GetCmdForHotkey(unsigned int key)
|
|
|
|
{
|
2013-01-17 05:23:42 +02:00
|
|
|
switch (key)
|
|
|
|
{
|
2012-11-08 09:40:49 +02:00
|
|
|
case HK_OPEN: return wxID_OPEN;
|
|
|
|
case HK_CHANGE_DISC: return IDM_CHANGEDISC;
|
|
|
|
case HK_REFRESH_LIST: return wxID_REFRESH;
|
|
|
|
case HK_PLAY_PAUSE: return IDM_PLAY;
|
|
|
|
case HK_STOP: return IDM_STOP;
|
|
|
|
case HK_RESET: return IDM_RESET;
|
|
|
|
case HK_FRAME_ADVANCE: return IDM_FRAMESTEP;
|
|
|
|
case HK_START_RECORDING: return IDM_RECORD;
|
|
|
|
case HK_PLAY_RECORDING: return IDM_PLAYRECORD;
|
|
|
|
case HK_EXPORT_RECORDING: return IDM_RECORDEXPORT;
|
|
|
|
case HK_READ_ONLY_MODE: return IDM_RECORDREADONLY;
|
|
|
|
case HK_FULLSCREEN: return IDM_TOGGLE_FULLSCREEN;
|
|
|
|
case HK_SCREENSHOT: return IDM_SCREENSHOT;
|
|
|
|
case HK_EXIT: return wxID_EXIT;
|
|
|
|
|
|
|
|
case HK_WIIMOTE1_CONNECT: return IDM_CONNECT_WIIMOTE1;
|
|
|
|
case HK_WIIMOTE2_CONNECT: return IDM_CONNECT_WIIMOTE2;
|
|
|
|
case HK_WIIMOTE3_CONNECT: return IDM_CONNECT_WIIMOTE3;
|
|
|
|
case HK_WIIMOTE4_CONNECT: return IDM_CONNECT_WIIMOTE4;
|
2013-06-26 13:23:29 +03:00
|
|
|
case HK_BALANCEBOARD_CONNECT: return IDM_CONNECT_BALANCEBOARD;
|
2012-11-08 09:40:49 +02:00
|
|
|
|
|
|
|
case HK_LOAD_STATE_SLOT_1: return IDM_LOADSLOT1;
|
|
|
|
case HK_LOAD_STATE_SLOT_2: return IDM_LOADSLOT2;
|
|
|
|
case HK_LOAD_STATE_SLOT_3: return IDM_LOADSLOT3;
|
|
|
|
case HK_LOAD_STATE_SLOT_4: return IDM_LOADSLOT4;
|
|
|
|
case HK_LOAD_STATE_SLOT_5: return IDM_LOADSLOT5;
|
|
|
|
case HK_LOAD_STATE_SLOT_6: return IDM_LOADSLOT6;
|
|
|
|
case HK_LOAD_STATE_SLOT_7: return IDM_LOADSLOT7;
|
|
|
|
case HK_LOAD_STATE_SLOT_8: return IDM_LOADSLOT8;
|
2013-08-03 03:42:30 +03:00
|
|
|
case HK_LOAD_STATE_SLOT_9: return IDM_LOADSLOT9;
|
|
|
|
case HK_LOAD_STATE_SLOT_10: return IDM_LOADSLOT10;
|
2012-11-08 09:40:49 +02:00
|
|
|
|
|
|
|
case HK_SAVE_STATE_SLOT_1: return IDM_SAVESLOT1;
|
|
|
|
case HK_SAVE_STATE_SLOT_2: return IDM_SAVESLOT2;
|
|
|
|
case HK_SAVE_STATE_SLOT_3: return IDM_SAVESLOT3;
|
|
|
|
case HK_SAVE_STATE_SLOT_4: return IDM_SAVESLOT4;
|
|
|
|
case HK_SAVE_STATE_SLOT_5: return IDM_SAVESLOT5;
|
|
|
|
case HK_SAVE_STATE_SLOT_6: return IDM_SAVESLOT6;
|
|
|
|
case HK_SAVE_STATE_SLOT_7: return IDM_SAVESLOT7;
|
|
|
|
case HK_SAVE_STATE_SLOT_8: return IDM_SAVESLOT8;
|
2013-08-03 03:42:30 +03:00
|
|
|
case HK_SAVE_STATE_SLOT_9: return IDM_SAVESLOT9;
|
|
|
|
case HK_SAVE_STATE_SLOT_10: return IDM_SAVESLOT10;
|
2012-11-08 09:40:49 +02:00
|
|
|
|
|
|
|
case HK_LOAD_LAST_STATE_1: return IDM_LOADLAST1;
|
|
|
|
case HK_LOAD_LAST_STATE_2: return IDM_LOADLAST2;
|
|
|
|
case HK_LOAD_LAST_STATE_3: return IDM_LOADLAST3;
|
|
|
|
case HK_LOAD_LAST_STATE_4: return IDM_LOADLAST4;
|
|
|
|
case HK_LOAD_LAST_STATE_5: return IDM_LOADLAST5;
|
|
|
|
case HK_LOAD_LAST_STATE_6: return IDM_LOADLAST6;
|
|
|
|
case HK_LOAD_LAST_STATE_7: return IDM_LOADLAST7;
|
|
|
|
case HK_LOAD_LAST_STATE_8: return IDM_LOADLAST8;
|
|
|
|
|
|
|
|
case HK_SAVE_FIRST_STATE: return IDM_SAVEFIRSTSTATE;
|
|
|
|
case HK_UNDO_LOAD_STATE: return IDM_UNDOLOADSTATE;
|
|
|
|
case HK_UNDO_SAVE_STATE: return IDM_UNDOSAVESTATE;
|
2013-07-01 02:01:30 +03:00
|
|
|
case HK_LOAD_STATE_FILE: return IDM_LOADSTATEFILE;
|
|
|
|
case HK_SAVE_STATE_FILE: return IDM_SAVESTATEFILE;
|
2013-01-17 05:23:42 +02:00
|
|
|
}
|
2011-02-14 03:18:01 +02:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-12-18 11:15:59 +02:00
|
|
|
void OnAfterLoadCallback()
|
|
|
|
{
|
2011-12-19 06:38:54 +02:00
|
|
|
// warning: this gets called from the CPU thread, so we should only queue things to do on the proper thread
|
2012-11-12 00:38:01 +02:00
|
|
|
if (main_frame)
|
2011-12-19 06:38:54 +02:00
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
2011-12-18 11:15:59 +02:00
|
|
|
}
|
|
|
|
|
2014-06-20 03:43:57 +03:00
|
|
|
void OnStoppedCallback()
|
|
|
|
{
|
|
|
|
// warning: this gets called from the EmuThread, so we should only queue things to do on the proper thread
|
|
|
|
if (main_frame)
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_STOPPED);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-11 05:02:32 +03:00
|
|
|
void TASManipFunction(GCPadStatus* PadStatus, int controllerID)
|
2011-06-24 09:50:50 +03:00
|
|
|
{
|
2012-11-12 00:38:01 +02:00
|
|
|
if (main_frame)
|
|
|
|
main_frame->g_TASInputDlg[controllerID]->GetValues(PadStatus, controllerID);
|
2011-06-24 09:50:50 +03:00
|
|
|
}
|
|
|
|
|
2012-11-11 23:35:08 +02:00
|
|
|
bool TASInputHasFocus()
|
|
|
|
{
|
2012-11-12 00:38:01 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2013-08-29 08:33:24 +03:00
|
|
|
if (main_frame->g_TASInputDlg[i]->TASHasFocus())
|
2012-11-12 00:38:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2012-11-11 23:35:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-08 07:30:24 +02:00
|
|
|
void CFrame::OnKeyDown(wxKeyEvent& event)
|
|
|
|
{
|
2014-03-10 13:30:55 +02:00
|
|
|
if (Core::GetState() != Core::CORE_UNINITIALIZED &&
|
|
|
|
(RendererHasFocus() || TASInputHasFocus()))
|
2008-12-08 07:30:24 +02:00
|
|
|
{
|
2010-04-25 23:10:16 +03:00
|
|
|
int WiimoteId = -1;
|
2010-04-10 23:44:56 +03:00
|
|
|
// Toggle fullscreen
|
2010-04-12 04:33:10 +03:00
|
|
|
if (IsHotkey(event, HK_FULLSCREEN))
|
|
|
|
DoFullscreen(!RendererIsFullscreen());
|
2010-08-08 09:00:22 +03:00
|
|
|
// Send Debugger keys to CodeWindow
|
2011-02-14 20:53:54 +02:00
|
|
|
else if (g_pCodeWindow && (event.GetKeyCode() >= WXK_F9 && event.GetKeyCode() <= WXK_F11))
|
2013-04-08 08:16:50 +03:00
|
|
|
event.Skip();
|
2010-04-12 04:33:10 +03:00
|
|
|
// Pause and Unpause
|
|
|
|
else if (IsHotkey(event, HK_PLAY_PAUSE))
|
|
|
|
DoPause();
|
|
|
|
// Stop
|
|
|
|
else if (IsHotkey(event, HK_STOP))
|
|
|
|
DoStop();
|
2010-08-08 03:13:05 +03:00
|
|
|
// Screenshot hotkey
|
|
|
|
else if (IsHotkey(event, HK_SCREENSHOT))
|
2011-03-16 01:09:12 +02:00
|
|
|
Core::SaveScreenShot();
|
2012-11-08 09:40:49 +02:00
|
|
|
else if (IsHotkey(event, HK_EXIT))
|
|
|
|
wxPostEvent(this, wxCommandEvent(wxID_EXIT));
|
2010-04-25 23:10:16 +03:00
|
|
|
// Wiimote connect and disconnect hotkeys
|
|
|
|
else if (IsHotkey(event, HK_WIIMOTE1_CONNECT))
|
|
|
|
WiimoteId = 0;
|
|
|
|
else if (IsHotkey(event, HK_WIIMOTE2_CONNECT))
|
|
|
|
WiimoteId = 1;
|
|
|
|
else if (IsHotkey(event, HK_WIIMOTE3_CONNECT))
|
|
|
|
WiimoteId = 2;
|
|
|
|
else if (IsHotkey(event, HK_WIIMOTE4_CONNECT))
|
|
|
|
WiimoteId = 3;
|
2013-06-26 13:23:29 +03:00
|
|
|
else if (IsHotkey(event, HK_BALANCEBOARD_CONNECT))
|
|
|
|
WiimoteId = 4;
|
2013-08-02 23:14:34 +03:00
|
|
|
else if (IsHotkey(event, HK_TOGGLE_IR))
|
2013-07-30 12:49:02 +03:00
|
|
|
{
|
|
|
|
OSDChoice = 1;
|
|
|
|
// Toggle native resolution
|
|
|
|
if (++g_Config.iEFBScale > SCALE_4X)
|
|
|
|
g_Config.iEFBScale = SCALE_AUTO;
|
|
|
|
}
|
2013-07-31 02:25:12 +03:00
|
|
|
else if (IsHotkey(event, HK_TOGGLE_AR))
|
2013-07-30 12:49:02 +03:00
|
|
|
{
|
|
|
|
OSDChoice = 2;
|
|
|
|
// Toggle aspect ratio
|
|
|
|
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
|
|
|
|
}
|
2013-07-31 02:25:12 +03:00
|
|
|
else if (IsHotkey(event, HK_TOGGLE_EFBCOPIES))
|
2013-07-30 12:49:02 +03:00
|
|
|
{
|
|
|
|
OSDChoice = 3;
|
|
|
|
// Toggle EFB copy
|
|
|
|
if (!g_Config.bEFBCopyEnable || g_Config.bCopyEFBToTexture)
|
|
|
|
{
|
|
|
|
g_Config.bEFBCopyEnable ^= true;
|
|
|
|
g_Config.bCopyEFBToTexture = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_Config.bCopyEFBToTexture = !g_Config.bCopyEFBToTexture;
|
|
|
|
}
|
|
|
|
}
|
2013-07-31 02:25:12 +03:00
|
|
|
else if (IsHotkey(event, HK_TOGGLE_FOG))
|
2013-07-30 12:49:02 +03:00
|
|
|
{
|
|
|
|
OSDChoice = 4;
|
|
|
|
g_Config.bDisableFog = !g_Config.bDisableFog;
|
|
|
|
}
|
2014-02-17 00:13:01 +02:00
|
|
|
else if (IsHotkey(event, HK_TOGGLE_THROTTLE))
|
|
|
|
{
|
2014-04-30 13:50:29 +03:00
|
|
|
Core::SetIsFramelimiterTempDisabled(true);
|
2014-02-17 00:13:01 +02:00
|
|
|
}
|
2013-07-31 02:25:12 +03:00
|
|
|
else if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT))
|
|
|
|
{
|
|
|
|
if (++SConfig::GetInstance().m_Framelimit > 0x19)
|
|
|
|
SConfig::GetInstance().m_Framelimit = 0;
|
|
|
|
}
|
|
|
|
else if (IsHotkey(event, HK_DECREASE_FRAME_LIMIT))
|
|
|
|
{
|
|
|
|
if (--SConfig::GetInstance().m_Framelimit > 0x19)
|
|
|
|
SConfig::GetInstance().m_Framelimit = 0x19;
|
|
|
|
}
|
2010-06-13 12:26:00 +03:00
|
|
|
else
|
2011-02-14 03:18:01 +02:00
|
|
|
{
|
|
|
|
unsigned int i = NUM_HOTKEYS;
|
2012-11-11 23:35:08 +02:00
|
|
|
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain || TASInputHasFocus())
|
2011-02-14 03:18:01 +02:00
|
|
|
{
|
|
|
|
for (i = 0; i < NUM_HOTKEYS; i++)
|
|
|
|
{
|
|
|
|
if (IsHotkey(event, i))
|
|
|
|
{
|
|
|
|
int cmd = GetCmdForHotkey(i);
|
|
|
|
if (cmd >= 0)
|
2013-10-29 07:23:17 +02:00
|
|
|
{
|
2014-05-17 19:49:00 +03:00
|
|
|
wxCommandEvent evt(wxEVT_MENU, cmd);
|
2011-02-14 03:18:01 +02:00
|
|
|
wxMenuItem *item = GetMenuBar()->FindItem(cmd);
|
|
|
|
if (item && item->IsCheckable())
|
|
|
|
{
|
|
|
|
item->wxMenuItemBase::Toggle();
|
|
|
|
evt.SetInt(item->IsChecked());
|
|
|
|
}
|
2011-02-22 04:02:56 +02:00
|
|
|
GetEventHandler()->AddPendingEvent(evt);
|
2011-02-14 03:18:01 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-22 22:25:24 +02:00
|
|
|
// On OS X, we claim all keyboard events while
|
|
|
|
// emulation is running to avoid wxWidgets sounding
|
|
|
|
// the system beep for unhandled key events when
|
|
|
|
// receiving pad/wiimote keypresses which take an
|
|
|
|
// entirely different path through the HID subsystem.
|
|
|
|
#ifndef __APPLE__
|
|
|
|
// On other platforms, we leave the key event alone
|
|
|
|
// so it can be passed on to the windowing system.
|
2011-02-14 03:18:01 +02:00
|
|
|
if (i == NUM_HOTKEYS)
|
|
|
|
event.Skip();
|
2010-12-20 19:36:51 +02:00
|
|
|
#endif
|
2011-02-14 03:18:01 +02:00
|
|
|
}
|
2010-04-19 22:20:33 +03:00
|
|
|
|
2010-04-25 23:10:16 +03:00
|
|
|
// Actually perform the wiimote connection or disconnection
|
|
|
|
if (WiimoteId >= 0)
|
|
|
|
{
|
2011-01-07 17:18:00 +02:00
|
|
|
bool connect = !GetMenuBar()->IsChecked(IDM_CONNECT_WIIMOTE1 + WiimoteId);
|
|
|
|
ConnectWiimote(WiimoteId, connect);
|
2010-04-25 23:10:16 +03:00
|
|
|
}
|
|
|
|
|
2013-07-22 00:54:43 +03:00
|
|
|
if (g_Config.bFreeLook && event.GetModifiers() == wxMOD_SHIFT)
|
2010-12-22 01:58:25 +02:00
|
|
|
{
|
2013-07-22 00:54:43 +03:00
|
|
|
static float debugSpeed = 1.0f;
|
|
|
|
switch (event.GetKeyCode())
|
|
|
|
{
|
|
|
|
case '9':
|
|
|
|
debugSpeed /= 2.0f;
|
|
|
|
break;
|
|
|
|
case '0':
|
|
|
|
debugSpeed *= 2.0f;
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
VertexShaderManager::TranslateView(0.0f, debugSpeed);
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
VertexShaderManager::TranslateView(0.0f, -debugSpeed);
|
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
VertexShaderManager::TranslateView(debugSpeed, 0.0f);
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
|
|
|
|
break;
|
2013-07-22 07:14:42 +03:00
|
|
|
case 'Q':
|
|
|
|
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
|
|
|
|
break;
|
2013-07-22 00:54:43 +03:00
|
|
|
case 'R':
|
|
|
|
VertexShaderManager::ResetView();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-12-22 01:58:25 +02:00
|
|
|
}
|
2010-04-10 23:44:56 +03:00
|
|
|
}
|
2010-04-12 04:33:10 +03:00
|
|
|
else
|
2013-04-08 08:16:50 +03:00
|
|
|
{
|
2010-04-12 04:33:10 +03:00
|
|
|
event.Skip();
|
2013-04-08 08:16:50 +03:00
|
|
|
}
|
2008-12-28 20:50:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::OnKeyUp(wxKeyEvent& event)
|
|
|
|
{
|
2014-07-08 01:47:57 +03:00
|
|
|
if(Core::IsRunning() && (RendererHasFocus() || TASInputHasFocus()))
|
2014-02-17 00:13:01 +02:00
|
|
|
{
|
|
|
|
if (IsHotkey(event, HK_TOGGLE_THROTTLE))
|
|
|
|
{
|
2014-04-30 13:50:29 +03:00
|
|
|
Core::SetIsFramelimiterTempDisabled(false);
|
2014-02-17 00:13:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
2008-12-08 07:30:24 +02:00
|
|
|
}
|
2009-09-01 15:44:02 +03:00
|
|
|
|
2010-12-22 01:58:25 +02:00
|
|
|
void CFrame::OnMouse(wxMouseEvent& event)
|
|
|
|
{
|
2013-11-29 07:09:54 +02:00
|
|
|
// next handlers are all for FreeLook, so we don't need to check them if disabled
|
2014-03-10 13:30:55 +02:00
|
|
|
if (!g_Config.bFreeLook)
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Free look variables
|
|
|
|
static bool mouseLookEnabled = false;
|
|
|
|
static bool mouseMoveEnabled = false;
|
|
|
|
static float lastMouse[2];
|
|
|
|
|
2014-03-10 13:30:55 +02:00
|
|
|
if (event.MiddleDown())
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
lastMouse[0] = event.GetX();
|
|
|
|
lastMouse[1] = event.GetY();
|
|
|
|
mouseMoveEnabled = true;
|
|
|
|
}
|
2014-03-10 13:30:55 +02:00
|
|
|
else if (event.RightDown())
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
lastMouse[0] = event.GetX();
|
|
|
|
lastMouse[1] = event.GetY();
|
|
|
|
mouseLookEnabled = true;
|
|
|
|
}
|
2014-03-10 13:30:55 +02:00
|
|
|
else if (event.MiddleUp())
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
mouseMoveEnabled = false;
|
|
|
|
}
|
2014-03-10 13:30:55 +02:00
|
|
|
else if (event.RightUp())
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
mouseLookEnabled = false;
|
|
|
|
}
|
|
|
|
// no button, so it's a move event
|
2014-03-10 13:30:55 +02:00
|
|
|
else if (event.GetButton() == wxMOUSE_BTN_NONE)
|
2013-11-29 07:09:54 +02:00
|
|
|
{
|
|
|
|
if (mouseLookEnabled)
|
|
|
|
{
|
|
|
|
VertexShaderManager::RotateView((event.GetX() - lastMouse[0]) / 200.0f,
|
|
|
|
(event.GetY() - lastMouse[1]) / 200.0f);
|
|
|
|
lastMouse[0] = event.GetX();
|
|
|
|
lastMouse[1] = event.GetY();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mouseMoveEnabled)
|
|
|
|
{
|
|
|
|
VertexShaderManager::TranslateView((event.GetX() - lastMouse[0]) / 50.0f,
|
|
|
|
(event.GetY() - lastMouse[1]) / 50.0f);
|
|
|
|
lastMouse[0] = event.GetX();
|
|
|
|
lastMouse[1] = event.GetY();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-03 02:36:50 +03:00
|
|
|
event.Skip();
|
2010-12-22 01:58:25 +02:00
|
|
|
}
|
|
|
|
|
2014-07-26 13:43:49 +03:00
|
|
|
void CFrame::DoFullscreen(bool enable_fullscreen)
|
2009-09-01 18:16:44 +03:00
|
|
|
{
|
2014-07-29 00:26:40 +03:00
|
|
|
if (!g_Config.BorderlessFullscreenEnabled() &&
|
2014-07-25 16:33:50 +03:00
|
|
|
!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
|
2014-07-27 01:08:27 +03:00
|
|
|
Core::GetState() == Core::CORE_PAUSE)
|
2014-07-25 16:33:50 +03:00
|
|
|
{
|
2014-07-26 13:43:49 +03:00
|
|
|
// A responsive renderer is required for exclusive fullscreen, but the
|
|
|
|
// renderer can only respond in the running state. Therefore we ignore
|
|
|
|
// fullscreen switches if we support exclusive fullscreen, but the
|
|
|
|
// renderer is not running.
|
|
|
|
// TODO: Allow the renderer to switch fullscreen modes while paused.
|
2014-07-25 16:33:50 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-26 13:43:49 +03:00
|
|
|
ToggleDisplayMode(enable_fullscreen);
|
2010-04-22 07:28:34 +03:00
|
|
|
|
2013-03-31 19:08:29 +03:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
NSView *view = (NSView *) m_RenderFrame->GetHandle();
|
|
|
|
NSWindow *window = [view window];
|
|
|
|
|
2014-07-26 13:43:49 +03:00
|
|
|
if (enable_fullscreen != RendererIsFullscreen())
|
2013-03-31 19:08:29 +03:00
|
|
|
{
|
|
|
|
[window toggleFullScreen:nil];
|
|
|
|
}
|
|
|
|
#else
|
2014-07-26 13:43:49 +03:00
|
|
|
if (enable_fullscreen)
|
2014-07-16 16:53:33 +03:00
|
|
|
{
|
|
|
|
m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL);
|
|
|
|
}
|
2014-07-29 00:26:40 +03:00
|
|
|
else if (g_Config.BorderlessFullscreenEnabled() ||
|
2014-07-21 18:55:21 +03:00
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
2014-07-16 16:53:33 +03:00
|
|
|
{
|
|
|
|
// Exiting exclusive fullscreen should be done from a Renderer callback.
|
|
|
|
// Therefore we don't exit fullscreen from here if we support exclusive mode.
|
|
|
|
m_RenderFrame->ShowFullScreen(false, wxFULLSCREEN_ALL);
|
|
|
|
}
|
2013-03-31 19:08:29 +03:00
|
|
|
#endif
|
|
|
|
|
2010-04-22 07:28:34 +03:00
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
2009-09-01 18:16:44 +03:00
|
|
|
{
|
2014-07-26 13:43:49 +03:00
|
|
|
if (enable_fullscreen)
|
2009-10-25 00:31:28 +03:00
|
|
|
{
|
2010-04-22 07:28:34 +03:00
|
|
|
// Save the current mode before going to fullscreen
|
|
|
|
AuiCurrent = m_Mgr->SavePerspective();
|
|
|
|
m_Mgr->LoadPerspective(AuiFullscreen, true);
|
2014-08-13 12:21:21 +03:00
|
|
|
|
2014-08-13 03:47:25 +03:00
|
|
|
// Hide toolbar
|
|
|
|
DoToggleToolbar(false);
|
2014-08-13 12:21:21 +03:00
|
|
|
|
2014-08-25 06:57:57 +03:00
|
|
|
// Hide menubar (by having wxwidgets delete it)
|
|
|
|
SetMenuBar(nullptr);
|
|
|
|
|
|
|
|
// Hide the statusbar if enabled
|
|
|
|
if (GetStatusBar()->IsShown())
|
|
|
|
{
|
|
|
|
GetStatusBar()->Hide();
|
|
|
|
this->SendSizeEvent();
|
|
|
|
}
|
2009-10-25 00:31:28 +03:00
|
|
|
}
|
2010-04-12 04:33:10 +03:00
|
|
|
else
|
2010-04-22 07:28:34 +03:00
|
|
|
{
|
|
|
|
// Restore saved perspective
|
|
|
|
m_Mgr->LoadPerspective(AuiCurrent, true);
|
2014-08-13 12:21:21 +03:00
|
|
|
|
2014-08-13 03:47:25 +03:00
|
|
|
// Restore toolbar to the status it was at before going fullscreen.
|
|
|
|
DoToggleToolbar(SConfig::GetInstance().m_InterfaceToolbar);
|
2014-08-13 12:21:21 +03:00
|
|
|
|
2014-08-25 06:57:57 +03:00
|
|
|
// Recreate the menubar if needed.
|
|
|
|
if (GetMenuBar() == nullptr)
|
|
|
|
{
|
|
|
|
CreateMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show statusbar if enabled
|
|
|
|
if (SConfig::GetInstance().m_InterfaceStatusbar)
|
|
|
|
{
|
|
|
|
GetStatusBar()->Show();
|
|
|
|
this->SendSizeEvent();
|
|
|
|
}
|
2010-04-22 07:28:34 +03:00
|
|
|
}
|
2010-03-16 01:25:11 +02:00
|
|
|
}
|
2010-04-22 07:28:34 +03:00
|
|
|
else
|
2013-04-08 08:16:50 +03:00
|
|
|
{
|
2010-04-22 07:28:34 +03:00
|
|
|
m_RenderFrame->Raise();
|
2013-04-08 08:16:50 +03:00
|
|
|
}
|
2014-06-18 16:04:23 +03:00
|
|
|
|
2014-07-29 00:26:40 +03:00
|
|
|
g_Config.bFullscreen = (g_Config.BorderlessFullscreenEnabled() ||
|
2014-07-30 13:03:09 +03:00
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) ? false : enable_fullscreen;
|
2009-09-05 07:50:45 +03:00
|
|
|
}
|
2011-02-14 00:36:12 +02:00
|
|
|
|
2011-02-21 01:42:21 +02:00
|
|
|
const CGameListCtrl *CFrame::GetGameListCtrl() const
|
2011-02-14 00:36:12 +02:00
|
|
|
{
|
2011-02-21 01:42:21 +02:00
|
|
|
return m_GameListCtrl;
|
2011-02-14 00:36:12 +02:00
|
|
|
}
|