dolphin/Source/Core/DolphinWX/Frame.h

370 lines
11 KiB
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-17 23:08:10 +00:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <array>
2014-02-22 22:36:30 +00:00
#include <cstddef>
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 13:43:40 +00:00
#include <memory>
2014-02-22 22:36:30 +00:00
#include <mutex>
#include <string>
#include <vector>
2014-02-22 22:36:30 +00:00
#include <wx/bitmap.h>
#include <wx/frame.h>
#include <wx/image.h>
#include <wx/panel.h>
#include <wx/string.h>
#include <wx/timer.h>
2014-02-22 22:36:30 +00:00
#include "Common/CommonTypes.h"
#include "Common/Event.h"
2017-05-21 19:52:44 +00:00
#include "Core/ConfigManager.h"
#include "DolphinWX/Globals.h"
#if defined(HAVE_X11) && HAVE_X11
2016-05-05 23:43:38 +00:00
#include "UICommon/X11Utils.h"
#endif
#ifdef __APPLE__
#include <IOKit/pwr_mgt/IOPMLib.h>
#endif
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 13:43:40 +00:00
struct BootParameters;
// Class declarations
class GameListCtrl;
2014-02-22 22:36:30 +00:00
class CCodeWindow;
class CConfigMain;
class CLogWindow;
class FifoPlayerDlg;
2014-02-22 22:36:30 +00:00
class LogConfigWindow;
class NetPlaySetupFrame;
2014-02-22 22:36:30 +00:00
class TASInputDlg;
class wxCheatsWindow;
2014-02-22 22:36:30 +00:00
class wxAuiManager;
class wxAuiManagerEvent;
class wxAuiNotebook;
class wxAuiNotebookEvent;
class wxListEvent;
class wxMenuItem;
class CRenderFrame : public wxFrame
{
public:
CRenderFrame(wxFrame* parent, wxWindowID id = wxID_ANY, const wxString& title = "Dolphin",
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) override;
private:
void OnDropFiles(wxDropFilesEvent& event);
static bool IsValidSavestateDropped(const std::string& filepath);
#ifdef _WIN32
// Receive WndProc messages
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
};
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_BOOT_SOFTWARE, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_STOP_SOFTWARE, wxCommandEvent);
class CFrame : public CRenderFrame
{
public:
CFrame(wxFrame* parent, wxWindowID id = wxID_ANY, const wxString& title = "Dolphin",
2016-08-14 19:54:01 +00:00
wxRect geometry = wxDefaultSize, bool use_debugger = false, bool batch_mode = false,
bool show_log_window = false,
long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
virtual ~CFrame();
void* GetRenderHandle()
{
#if defined(HAVE_X11) && HAVE_X11
2017-05-01 00:11:01 +00:00
return reinterpret_cast<void*>(X11Utils::XWindowFromHandle(m_render_parent->GetHandle()));
#else
2017-05-01 00:11:01 +00:00
return reinterpret_cast<void*>(m_render_parent->GetHandle());
#endif
}
// These have to be public
2017-05-01 00:11:01 +00:00
CCodeWindow* m_code_window = nullptr;
NetPlaySetupFrame* m_netplay_setup_frame = nullptr;
void DoStop();
void UpdateGUI();
void GameListRefresh();
void GameListRescan();
void ToggleLogWindow(bool bShow);
void ToggleLogConfigWindow(bool bShow);
void StatusBarMessage(const char* Text, ...);
void ClearStatusBar();
void BootGame(const std::string& filename);
bool RendererHasFocus();
bool RendererIsFullscreen();
void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY);
wxMenuBar* GetMenuBar() const override;
2017-05-01 00:11:01 +00:00
Common::Event m_panic_event;
bool m_panic_result;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
2017-05-01 00:11:01 +00:00
X11Utils::XRRConfiguration* m_xrr_config;
#endif
// AUI
2017-05-01 00:11:01 +00:00
wxAuiManager* m_mgr = nullptr;
bool m_float_window[IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START] = {};
// Perspectives (Should find a way to make all of this private)
void DoAddPage(wxWindow* Win, int i, bool Float);
void DoRemovePage(wxWindow*, bool bHide = true);
struct SPerspectives
{
2017-05-01 00:11:01 +00:00
std::string name;
wxString perspective;
std::vector<int> width, height;
};
2017-05-01 00:11:01 +00:00
std::vector<SPerspectives> m_perspectives;
u32 m_active_perspective;
private:
enum
{
ADD_PANE_TOP,
ADD_PANE_BOTTOM,
ADD_PANE_LEFT,
ADD_PANE_RIGHT,
ADD_PANE_CENTER
};
GameListCtrl* m_game_list_ctrl = nullptr;
2017-05-01 00:11:01 +00:00
CConfigMain* m_main_config_dialog = nullptr;
wxPanel* m_panel = nullptr;
CRenderFrame* m_render_frame = nullptr;
wxWindow* m_render_parent = nullptr;
CLogWindow* m_log_window = nullptr;
LogConfigWindow* m_log_config_window = nullptr;
FifoPlayerDlg* m_fifo_player_dialog = nullptr;
std::array<TASInputDlg*, 8> m_tas_input_dialogs{};
wxCheatsWindow* m_cheats_window = nullptr;
bool m_use_debugger = false;
bool m_batch_mode = false;
bool m_editing_perspectives = false;
bool m_is_split_tab_notebook = false;
bool m_no_panel_docking = false;
bool m_is_game_loading = false;
bool m_is_closing = false;
bool m_renderer_has_focus = false;
bool m_confirm_stop = false;
bool m_tried_graceful_shutdown = false;
int m_save_slot = 1;
wxTimer m_poll_hotkey_timer;
wxTimer m_handle_signal_timer;
wxMenuBar* m_menubar_shadow = nullptr;
2017-05-01 00:11:01 +00:00
wxString m_aui_fullscreen_perspective;
wxString m_aui_current_perspective;
#ifdef __WXGTK__
std::recursive_mutex m_keystate_lock;
#endif
void BindEvents();
void BindMenuBarEvents();
void BindDebuggerMenuBarEvents();
void BindDebuggerMenuBarUpdateEvents();
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
wxMenuBar* CreateMenuBar() const;
void InitializeTASDialogs();
void InitializeCoreCallbacks();
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 13:43:40 +00:00
void StartGame(std::unique_ptr<BootParameters> boot);
void SetDebuggerStartupParameters() const;
// Utility
wxWindow* GetNotebookPageFromId(wxWindowID Id);
wxAuiNotebook* GetNotebookFromId(u32 NBId);
int GetNotebookCount();
wxAuiNotebook* CreateEmptyNotebook();
void HandleFrameSkipHotkeys();
// Perspectives
void AddRemoveBlankPage();
void OnNotebookAllowDnD(wxAuiNotebookEvent& event);
void OnNotebookPageChanged(wxAuiNotebookEvent& event);
void OnNotebookPageClose(wxAuiNotebookEvent& event);
void OnNotebookTabRightUp(wxAuiNotebookEvent& event);
void OnFloatWindow(wxCommandEvent& event);
void ToggleFloatWindow(int Id);
int GetNotebookAffiliation(wxWindowID Id);
void ClosePages();
void CloseAllNotebooks();
void ShowResizePane();
void TogglePane();
void SetPaneSize();
void TogglePaneStyle(bool On, int EventId);
void ToggleNotebookStyle(bool On, long Style);
void PopulateSavedPerspectives();
// Float window
void DoUnfloatPage(int Id);
void OnFloatingPageClosed(wxCloseEvent& event);
void DoFloatNotebookPage(wxWindowID Id);
wxFrame* CreateParentFrame(wxWindowID Id = wxID_ANY, const wxString& title = "",
wxWindow* = nullptr);
2017-05-01 00:11:01 +00:00
void AddPane(int dir);
void UpdateCurrentPerspective();
void SaveIniPerspectives();
void LoadIniPerspectives();
void OnPaneClose(wxAuiManagerEvent& evt);
void ReloadPanes();
void DoLoadPerspective();
void OnPerspectiveMenu(wxCommandEvent& event);
void OnSelectPerspective(wxCommandEvent& event);
#ifdef _WIN32
// Override window proc for tricks like screensaver disabling
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
// Screensaver
#ifdef __APPLE__
IOPMAssertionID m_power_assertion = kIOPMNullAssertionID;
#endif
void InhibitScreensaver();
void UninhibitScreensaver();
void DoOpen(bool Boot);
void DoPause();
void DoToggleToolbar(bool);
void DoRecordingSave();
void DoFullscreen(bool enable_fullscreen);
void DoExclusiveFullscreen(bool enable_fullscreen);
void ToggleDisplayMode(bool bFullscreen);
bool TriggerSTMPowerEvent();
void OnStopped();
void OnRenderWindowSizeRequest(int width, int height);
void UpdateTitle(const wxString& str);
static void ConnectWiimote(int wm_idx, bool connect);
// Event functions
void PostEvent(wxCommandEvent& event);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnReloadThemeBitmaps(wxCommandEvent& event);
void OnRefreshGameList(wxCommandEvent& event);
void OnRescanGameList(wxCommandEvent& event);
void OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event);
void OnUpdateLoadWiiMenuItem(wxCommandEvent&);
void UpdateLoadWiiMenuItem() const;
void OnOpen(wxCommandEvent& event); // File menu
void OnRefresh(wxCommandEvent& event);
void OnBootDrive(wxCommandEvent& event);
void OnPlay(wxCommandEvent& event); // Emulation
void OnStop(wxCommandEvent& event);
void OnReset(wxCommandEvent& event);
void OnRecord(wxCommandEvent& event);
void OnPlayRecording(wxCommandEvent& event);
2017-02-11 19:39:07 +00:00
void OnStopRecording(wxCommandEvent& event);
void OnRecordExport(wxCommandEvent& event);
void OnRecordReadOnly(wxCommandEvent& event);
void OnTASInput(wxCommandEvent& event);
void OnTogglePauseMovie(wxCommandEvent& event);
void OnToggleDumpFrames(wxCommandEvent& event);
void OnToggleDumpAudio(wxCommandEvent& event);
void OnShowLag(wxCommandEvent& event);
void OnShowFrameCount(wxCommandEvent& event);
void OnShowInputDisplay(wxCommandEvent& event);
2016-07-20 00:23:25 +00:00
void OnShowRTCDisplay(wxCommandEvent& event);
void OnChangeDisc(wxCommandEvent& event);
void OnScreenshot(wxCommandEvent& event);
void OnActive(wxActivateEvent& event);
void OnClose(wxCloseEvent& event);
void OnLoadState(wxCommandEvent& event);
void OnSaveState(wxCommandEvent& event);
void OnLoadStateFromFile(wxCommandEvent& event);
void OnSaveStateToFile(wxCommandEvent& event);
void OnLoadLastState(wxCommandEvent& event);
void OnSaveFirstState(wxCommandEvent& event);
void OnUndoLoadState(wxCommandEvent& event);
void OnUndoSaveState(wxCommandEvent& event);
void OnFrameStep(wxCommandEvent& event);
void OnConfigMain(wxCommandEvent& event); // Options
void OnConfigGFX(wxCommandEvent& event);
void OnConfigAudio(wxCommandEvent& event);
void OnConfigControllers(wxCommandEvent& event);
void OnConfigHotkey(wxCommandEvent& event);
void OnToggleFullscreen(wxCommandEvent& event);
void OnManagerResize(wxAuiManagerEvent& event);
void OnMove(wxMoveEvent& event);
void OnResize(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event);
void OnToggleStatusbar(wxCommandEvent& event);
void OnToggleWindow(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event); // Keyboard
void OnMouse(wxMouseEvent& event); // Mouse
void OnHostMessage(wxCommandEvent& event);
void OnMemcard(wxCommandEvent& event); // Misc
void OnImportSave(wxCommandEvent& event);
void OnExportAllSaves(wxCommandEvent& event);
void OnLoadGameCubeIPLJAP(wxCommandEvent& event);
void OnLoadGameCubeIPLUSA(wxCommandEvent& event);
void OnLoadGameCubeIPLEUR(wxCommandEvent& event);
2017-05-21 19:52:44 +00:00
void OnNetPlay(wxCommandEvent& event);
void OnShowCheatsWindow(wxCommandEvent& event);
void OnLoadWiiMenu(wxCommandEvent& event);
void OnInstallWAD(wxCommandEvent& event);
void OnUninstallWAD(wxCommandEvent& event);
2017-03-19 07:00:49 +00:00
void OnImportBootMiiBackup(wxCommandEvent& event);
void OnExtractCertificates(wxCommandEvent& event);
void OnFifoPlayer(wxCommandEvent& event);
void OnConnectWiimote(wxCommandEvent& event);
void GameListChanged(wxCommandEvent& event);
void OnGameListCtrlItemActivated(wxListEvent& event);
void OnRenderParentResize(wxSizeEvent& event);
void OnChangeColumnsVisible(wxCommandEvent& event);
void OnSelectSlot(wxCommandEvent& event);
void OnSaveCurrentSlot(wxCommandEvent& event);
void OnLoadCurrentSlot(wxCommandEvent& event);
void PollHotkeys(wxTimerEvent&);
void ParseHotkeys();
void HandleSignal(wxTimerEvent&);
bool InitControllers();
// Event table
DECLARE_EVENT_TABLE();
};