2008-12-08 05:30:24 +00:00
|
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
2009-01-14 16:36:43 +00:00
|
|
|
|
// Windows
|
2009-01-04 21:53:41 +00:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CFrame is the main parent window. Inside CFrame there is an m_Panel that is the parent for
|
|
|
|
|
the rendering window (when we render to the main window). In Windows the rendering window is
|
|
|
|
|
created by giving CreateWindow() m_Panel->GetHandle() as parent window and creating a new
|
|
|
|
|
child window to m_Panel. The new child window handle that is returned by CreateWindow() can
|
|
|
|
|
be accessed from Core::GetWindowHandle().
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// includes
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
2008-12-23 08:47:37 +00:00
|
|
|
|
#include "Globals.h" // Local
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#include "Frame.h"
|
2008-12-23 08:47:37 +00:00
|
|
|
|
#include "ConfigMain.h"
|
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
#include "MemcardManager.h"
|
|
|
|
|
#include "CheatsWindow.h"
|
|
|
|
|
#include "AboutDolphin.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#include "GameListCtrl.h"
|
|
|
|
|
#include "BootManager.h"
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#include "Common.h" // Common
|
|
|
|
|
#include "FileUtil.h"
|
|
|
|
|
#include "Timer.h"
|
2009-02-16 06:18:18 +00:00
|
|
|
|
#include "Setup.h"
|
|
|
|
|
#include "ConsoleWindow.h"
|
2008-12-23 08:47:37 +00:00
|
|
|
|
|
2009-01-17 23:41:21 +00:00
|
|
|
|
#include "ConfigManager.h" // Core
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#include "Core.h"
|
2008-12-23 07:34:23 +00:00
|
|
|
|
#include "HW/DVDInterface.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#include "State.h"
|
2008-12-23 08:47:37 +00:00
|
|
|
|
#include "VolumeHandler.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#include <wx/datetime.h> // wxWidgets
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// resources
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#include "../resources/Dolphin.c" // Dolphin icon
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#include "../resources/toolbar_browse.c"
|
|
|
|
|
#include "../resources/toolbar_file_open.c"
|
|
|
|
|
#include "../resources/toolbar_fullscreen.c"
|
|
|
|
|
#include "../resources/toolbar_help.c"
|
|
|
|
|
#include "../resources/toolbar_pause.c"
|
|
|
|
|
#include "../resources/toolbar_play.c"
|
|
|
|
|
#include "../resources/toolbar_plugin_dsp.c"
|
|
|
|
|
#include "../resources/toolbar_plugin_gfx.c"
|
|
|
|
|
#include "../resources/toolbar_plugin_options.c"
|
|
|
|
|
#include "../resources/toolbar_plugin_pad.c"
|
|
|
|
|
#include "../resources/toolbar_refresh.c"
|
|
|
|
|
#include "../resources/toolbar_stop.c"
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#include "../resources/Boomy.h" // Theme packages
|
|
|
|
|
#include "../resources/Vista.h"
|
|
|
|
|
#include "../resources/X-Plastik.h"
|
|
|
|
|
#include "../resources/KDE.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-12-23 04:35:21 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/* Windows functions. Setting the cursor with wxSetCursor() did not work in this instance.
|
|
|
|
|
Probably because it's somehow reset from the WndProc() in the child window */
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
// Declare a blank icon and one that will be the normal cursor
|
2009-01-04 21:53:41 +00:00
|
|
|
|
HCURSOR hCursor = NULL, hCursorBlank = NULL;
|
|
|
|
|
|
|
|
|
|
// Create the default cursor
|
|
|
|
|
void CreateCursor()
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
hCursor = LoadCursor( NULL, IDC_ARROW );
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
void MSWSetCursor(bool Show)
|
|
|
|
|
{
|
|
|
|
|
if(Show)
|
|
|
|
|
SetCursor(hCursor);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetCursor(hCursorBlank);
|
|
|
|
|
//wxSetCursor(wxCursor(wxNullCursor));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// I could not use FindItemByHWND() instead of this, it crashed on that occation I used it */
|
|
|
|
|
HWND MSWGetParent_(HWND Parent)
|
|
|
|
|
{
|
|
|
|
|
return GetParent(Parent);
|
|
|
|
|
}
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#endif
|
2009-01-04 21:53:41 +00:00
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/* The CPanel class to receive MSWWindowProc messages from the video plugin. */
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
extern CFrame* main_frame;
|
|
|
|
|
|
|
|
|
|
class CPanel : public wxPanel
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CPanel(
|
|
|
|
|
wxWindow* parent,
|
|
|
|
|
wxWindowID id = wxID_ANY
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
// Receive WndProc messages
|
|
|
|
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CPanel, wxPanel)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
CPanel::CPanel(
|
|
|
|
|
wxWindow *parent,
|
|
|
|
|
wxWindowID id
|
|
|
|
|
)
|
|
|
|
|
: wxPanel(parent, id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
int abc = 0;
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
WXLRESULT CPanel::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
switch (nMsg)
|
|
|
|
|
{
|
|
|
|
|
//case WM_LBUTTONDOWN:
|
|
|
|
|
//case WM_LBUTTONUP:
|
|
|
|
|
//case WM_MOUSEMOVE:
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
// This doesn't work, strange
|
|
|
|
|
//case WM_LBUTTONDBLCLK:
|
|
|
|
|
//PanicAlert("Double click");
|
|
|
|
|
//break;
|
|
|
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
|
switch(wParam)
|
|
|
|
|
{
|
|
|
|
|
// Stop
|
2009-02-07 03:16:41 +00:00
|
|
|
|
case OPENGL_WM_USER_STOP:
|
2009-01-04 21:53:41 +00:00
|
|
|
|
main_frame->DoStop();
|
|
|
|
|
return 0; // Don't bother letting wxWidgets process this at all
|
|
|
|
|
|
2009-02-07 03:16:41 +00:00
|
|
|
|
case OPENGL_WM_USER_CREATE:
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// We don't have a local setting for bRenderToMain but we can detect it this way instead
|
|
|
|
|
//PanicAlert("main call %i %i %i %i", lParam, (HWND)Core::GetWindowHandle(), MSWGetParent_((HWND)Core::GetWindowHandle()), (HWND)this->GetHWND());
|
|
|
|
|
if (lParam == NULL) main_frame->bRenderToMain = false;
|
|
|
|
|
else main_frame->bRenderToMain = true;
|
|
|
|
|
return 0;
|
2009-02-07 03:16:41 +00:00
|
|
|
|
|
|
|
|
|
case NJOY_RELOAD:
|
|
|
|
|
// DirectInput in nJoy has failed
|
2009-02-11 10:30:02 +00:00
|
|
|
|
Core::ReconnectPad();
|
2009-02-07 03:16:41 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case WIIMOTE_RECONNECT:
|
|
|
|
|
// The Wiimote plugin has been shut down, now reconnect the Wiimote
|
2009-02-11 10:30:02 +00:00
|
|
|
|
//Console::Print("WIIMOTE_RECONNECT\n");
|
2009-02-07 03:16:41 +00:00
|
|
|
|
Core::ReconnectWiimote();
|
|
|
|
|
return 0;
|
2009-02-16 07:17:34 +00:00
|
|
|
|
|
2009-02-22 21:16:12 +00:00
|
|
|
|
// -----------------------------------------
|
2009-02-16 07:17:34 +00:00
|
|
|
|
#ifdef RERECORDING
|
2009-02-22 21:16:12 +00:00
|
|
|
|
// -----------------
|
|
|
|
|
case INPUT_FRAME_COUNTER:
|
|
|
|
|
// Wind back the frame counter after a save state has been loaded
|
|
|
|
|
Core::WindBack((int)lParam);
|
|
|
|
|
return 0;
|
2009-02-16 07:17:34 +00:00
|
|
|
|
#endif
|
2009-02-22 21:16:12 +00:00
|
|
|
|
// -----------------------------
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
#ifdef SETUP_TIMER_WAITING
|
|
|
|
|
// -----------------
|
|
|
|
|
case OPENGL_VIDEO_STOP:
|
|
|
|
|
// The Video thread has been shut down
|
|
|
|
|
Core::VideoThreadEnd();
|
|
|
|
|
//Console::Print("OPENGL_VIDEO_STOP\n");
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
// -----------------------------
|
2009-01-04 21:53:41 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2009-02-22 21:16:12 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
//default:
|
|
|
|
|
// return wxPanel::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// By default let wxWidgets do what it normally does with this event
|
|
|
|
|
return wxPanel::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
/////////////////////////////////////////////////
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// event tables
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
|
|
|
|
|
// help button.
|
|
|
|
|
|
|
|
|
|
const wxEventType wxEVT_HOST_COMMAND = wxNewEventType();
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CFrame, wxFrame)
|
|
|
|
|
EVT_CLOSE(CFrame::OnClose)
|
|
|
|
|
EVT_MENU(wxID_OPEN, CFrame::OnOpen)
|
|
|
|
|
EVT_MENU(wxID_EXIT, CFrame::OnQuit)
|
|
|
|
|
EVT_MENU(IDM_HELPWEBSITE, CFrame::OnHelp)
|
|
|
|
|
EVT_MENU(IDM_HELPGOOGLECODE, CFrame::OnHelp)
|
|
|
|
|
EVT_MENU(IDM_HELPABOUT, CFrame::OnHelp)
|
|
|
|
|
EVT_MENU(wxID_REFRESH, CFrame::OnRefresh)
|
|
|
|
|
EVT_MENU(IDM_PLAY, CFrame::OnPlay)
|
|
|
|
|
EVT_MENU(IDM_STOP, CFrame::OnStop)
|
2009-02-27 03:56:34 +00:00
|
|
|
|
EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot)
|
2008-12-08 05:30:24 +00:00
|
|
|
|
EVT_MENU(IDM_CONFIG_MAIN, CFrame::OnConfigMain)
|
|
|
|
|
EVT_MENU(IDM_CONFIG_GFX_PLUGIN, CFrame::OnPluginGFX)
|
|
|
|
|
EVT_MENU(IDM_CONFIG_DSP_PLUGIN, CFrame::OnPluginDSP)
|
|
|
|
|
EVT_MENU(IDM_CONFIG_PAD_PLUGIN, CFrame::OnPluginPAD)
|
|
|
|
|
EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnPluginWiimote)
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
2009-02-27 23:44:15 +00:00
|
|
|
|
|
2009-01-03 01:38:44 +00:00
|
|
|
|
#ifdef MUSICMOD
|
|
|
|
|
EVT_MENU(IDM_MUTE, CFrame::MM_OnMute)
|
|
|
|
|
EVT_MENU(IDM_MUSIC_PLAY, CFrame::MM_OnPause)
|
|
|
|
|
EVT_COMMAND_SCROLL(IDS_VOLUME, CFrame::MM_OnVolume)
|
|
|
|
|
EVT_MENU(IDT_LOG, CFrame::MM_OnLog)
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
EVT_MENU(IDM_BROWSE, CFrame::OnBrowse)
|
|
|
|
|
EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard)
|
|
|
|
|
EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow)
|
2008-12-23 08:47:37 +00:00
|
|
|
|
EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc)
|
2009-02-01 20:20:58 +00:00
|
|
|
|
EVT_MENU(IDM_SDCARD, CFrame::OnShow_SDCardWindow)
|
2009-02-27 23:44:15 +00:00
|
|
|
|
EVT_MENU(IDM_LOAD_WII_MENU, CFrame::OnLoadWiiMenu)
|
2008-12-08 05:30:24 +00: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)
|
2009-02-27 23:44:15 +00:00
|
|
|
|
|
2008-12-10 08:57:57 +00:00
|
|
|
|
EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState)
|
|
|
|
|
EVT_MENU_RANGE(IDM_SAVESLOT1, IDM_SAVESLOT10, CFrame::OnSaveState)
|
2009-02-21 23:44:40 +00:00
|
|
|
|
EVT_MENU_RANGE(IDM_DRIVE1, IDM_DRIVE24, CFrame::OnBootDrive)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
2008-12-12 03:38:50 +00:00
|
|
|
|
EVT_SIZE(CFrame::OnResize)
|
2009-01-28 16:51:05 +00:00
|
|
|
|
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CFrame::OnGameListCtrl_ItemActivated)
|
2008-12-08 05:30:24 +00:00
|
|
|
|
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#if wxUSE_TIMER
|
|
|
|
|
EVT_TIMER(wxID_ANY, CFrame::OnTimer)
|
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
END_EVENT_TABLE()
|
2009-01-05 04:08:18 +00:00
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2009-01-05 04:08:18 +00:00
|
|
|
|
// Creation and close, quit functions
|
2008-12-08 05:30:24 +00:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
CFrame::CFrame(wxFrame* parent,
|
|
|
|
|
wxWindowID id,
|
|
|
|
|
const wxString& title,
|
|
|
|
|
const wxPoint& pos,
|
|
|
|
|
const wxSize& size,
|
|
|
|
|
long style)
|
|
|
|
|
: wxFrame(parent, id, title, pos, size, style)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
, m_pStatusBar(NULL), bRenderToMain(true)
|
2008-12-09 05:37:15 +00:00
|
|
|
|
, HaveLeds(false), HaveSpeakers(false)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
, m_Panel(NULL)
|
2008-12-10 18:33:13 +00:00
|
|
|
|
, m_pMenuBar(NULL)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
, m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0)
|
|
|
|
|
#if wxUSE_TIMER
|
|
|
|
|
, m_timer(this)
|
|
|
|
|
#endif
|
2008-12-10 18:33:13 +00:00
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Create timer
|
|
|
|
|
#if wxUSE_TIMER
|
|
|
|
|
int TimesPerSecond = 10; // We don't need more than this
|
|
|
|
|
m_timer.Start( floor((double)(1000 / TimesPerSecond)) );
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Create toolbar bitmaps
|
2008-12-08 05:30:24 +00:00
|
|
|
|
InitBitmaps();
|
|
|
|
|
|
|
|
|
|
// Give it an icon
|
|
|
|
|
wxIcon IconTemp;
|
|
|
|
|
IconTemp.CopyFromBitmap(wxGetBitmapFromMemory(dolphin_png));
|
|
|
|
|
SetIcon(IconTemp);
|
|
|
|
|
|
2008-12-09 14:57:55 +00:00
|
|
|
|
// Give it a status bar
|
2009-01-18 11:43:10 +00:00
|
|
|
|
m_pStatusBar = CreateStatusBar(1, wxST_SIZEGRIP, ID_STATUSBAR);
|
2008-12-09 05:37:15 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Give it a menu bar
|
2008-12-08 05:30:24 +00:00
|
|
|
|
CreateMenu();
|
|
|
|
|
|
|
|
|
|
// This panel is the parent for rendering and it holds the gamelistctrl
|
2009-01-04 21:53:41 +00:00
|
|
|
|
//m_Panel = new wxPanel(this, IDM_MPANEL);
|
|
|
|
|
m_Panel = new CPanel(this, IDM_MPANEL);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
|
|
m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
|
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);
|
|
|
|
|
|
|
|
|
|
sizerPanel = new wxBoxSizer(wxHORIZONTAL);
|
2009-03-07 05:32:16 +00:00
|
|
|
|
sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
m_Panel->SetSizer(sizerPanel);
|
|
|
|
|
|
2009-03-07 05:32:16 +00:00
|
|
|
|
sizerFrame = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
sizerFrame->Add(m_Panel, 1, wxEXPAND | wxALL);
|
|
|
|
|
this->SetSizer(sizerFrame);
|
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
// Create the toolbar
|
|
|
|
|
RecreateToolbar();
|
2009-01-15 06:48:15 +00:00
|
|
|
|
|
2009-03-07 05:32:16 +00:00
|
|
|
|
FitInside();
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
Show(); // Show the window
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-02-08 10:09:26 +00:00
|
|
|
|
// Create list of available plugins for the configuration window
|
2009-01-09 12:46:04 +00:00
|
|
|
|
CPluginManager::GetInstance().ScanForPlugins();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
|
//if we are ever going back to optional iso caching:
|
2008-12-08 05:30:24 +00:00
|
|
|
|
//m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache);
|
|
|
|
|
m_GameListCtrl->Update();
|
|
|
|
|
//sizerPanel->SetSizeHints(m_Panel);
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Create cursors
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
CreateCursor();
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// -------------------------
|
|
|
|
|
// Connect event handlers
|
|
|
|
|
// ----------
|
|
|
|
|
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
|
|
|
|
|
wxKeyEventHandler(CFrame::OnKeyDown),
|
|
|
|
|
(wxObject*)0, this);
|
2008-12-28 18:50:24 +00:00
|
|
|
|
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
|
|
|
|
|
wxKeyEventHandler(CFrame::OnKeyUp),
|
|
|
|
|
(wxObject*)0, this);
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#ifdef _WIN32 // The functions are only tested in Windows so far
|
|
|
|
|
wxTheApp->Connect(wxID_ANY, wxEVT_LEFT_DOWN, // Mouse
|
|
|
|
|
wxMouseEventHandler(CFrame::OnDoubleClick),
|
|
|
|
|
(wxObject*)0, this);
|
|
|
|
|
wxTheApp->Connect(wxID_ANY, wxEVT_MOTION,
|
|
|
|
|
wxMouseEventHandler(CFrame::OnMotion),
|
|
|
|
|
(wxObject*)0, this);
|
|
|
|
|
#endif
|
|
|
|
|
// ----------
|
2009-01-15 06:48:15 +00:00
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
UpdateGUI();
|
2009-02-16 06:18:18 +00:00
|
|
|
|
|
|
|
|
|
// If we are rerecording create the status bar now instead of later when a game starts
|
|
|
|
|
#ifdef RERECORDING
|
|
|
|
|
ModifyStatusBar();
|
|
|
|
|
// It's to early for the OnHostMessage(), we will update the status when Ctrl or Space is pressed
|
|
|
|
|
//Core::WriteStatus();
|
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Destructor
|
|
|
|
|
CFrame::~CFrame()
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-02-24 15:04:12 +00:00
|
|
|
|
cdio_free_device_list(drives);
|
2009-01-04 23:24:13 +00:00
|
|
|
|
/* The statbar sample has this so I add this to, but I guess timer will be deleted after
|
2009-01-04 21:53:41 +00:00
|
|
|
|
this anyway */
|
|
|
|
|
#if wxUSE_TIMER
|
|
|
|
|
if (m_timer.IsRunning()) m_timer.Stop();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 04:08:18 +00:00
|
|
|
|
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
|
|
|
|
{
|
|
|
|
|
Close(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CFrame::OnClose(wxCloseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
// Don't forget the skip of the window won't be destroyed
|
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
|
|
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
|
|
|
|
{
|
|
|
|
|
Core::Stop();
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Input and host messages
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2008-12-14 17:37:59 +00:00
|
|
|
|
#ifdef _WIN32
|
2009-01-04 21:53:41 +00:00
|
|
|
|
WXLRESULT CFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
2008-12-23 08:47:37 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
switch (nMsg)
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
case WM_SYSCOMMAND:
|
2009-01-15 06:48:15 +00:00
|
|
|
|
switch (wParam)
|
2009-01-04 21:53:41 +00:00
|
|
|
|
{
|
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
|
case SC_MONITORPOWER:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
// Let wxWidgets process it as normal
|
|
|
|
|
return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CFrame::OnHostMessage(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
switch (event.GetId())
|
|
|
|
|
{
|
2008-12-10 08:57:57 +00:00
|
|
|
|
case IDM_UPDATEGUI:
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case IDM_UPDATESTATUSBAR:
|
|
|
|
|
if (m_pStatusBar != NULL)
|
|
|
|
|
{
|
|
|
|
|
m_pStatusBar->SetStatusText(event.GetString(), event.GetInt());
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-01-28 16:51:05 +00:00
|
|
|
|
void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
2009-01-07 09:06:42 +00:00
|
|
|
|
{
|
|
|
|
|
BootGame();
|
|
|
|
|
}
|
2009-01-28 16:51:05 +00:00
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
|
void CFrame::OnKeyDown(wxKeyEvent& event)
|
|
|
|
|
{
|
|
|
|
|
// Toggle fullscreen from Alt + Enter or Esc
|
|
|
|
|
if (((event.GetKeyCode() == WXK_RETURN) && (event.GetModifiers() == wxMOD_ALT)) ||
|
|
|
|
|
(event.GetKeyCode() == WXK_ESCAPE))
|
|
|
|
|
{
|
|
|
|
|
ShowFullScreen(!IsFullScreen());
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
}
|
|
|
|
|
#ifdef _WIN32
|
2009-02-16 06:18:18 +00:00
|
|
|
|
if(event.GetKeyCode() == 'E') // Send this to the video plugin WndProc
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
|
|
|
|
PostMessage((HWND)Core::GetWindowHandle(), WM_KEYDOWN, event.GetKeyCode(), 0);
|
2009-01-04 21:53:41 +00:00
|
|
|
|
event.Skip(); // Don't block the E key
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2009-02-16 06:18:18 +00:00
|
|
|
|
|
|
|
|
|
#ifdef RERECORDING
|
|
|
|
|
// Turn on or off frame advance
|
|
|
|
|
if (event.GetKeyCode() == WXK_CONTROL) Core::FrameStepOnOff();
|
|
|
|
|
|
|
|
|
|
// Step forward
|
|
|
|
|
if (event.GetKeyCode() == WXK_SPACE) Core::FrameAdvance();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Send the keyboard status to the Input plugin
|
|
|
|
|
if(Core::GetState() != Core::CORE_UNINITIALIZED)
|
|
|
|
|
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
|
|
|
|
|
|
|
|
|
|
// Don't block other events
|
|
|
|
|
event.Skip();
|
2008-12-28 18:50:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CFrame::OnKeyUp(wxKeyEvent& event)
|
|
|
|
|
{
|
|
|
|
|
if(Core::GetState() != Core::CORE_UNINITIALIZED)
|
2009-01-24 12:09:30 +00:00
|
|
|
|
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 0); // 0 = Up
|
2008-12-28 18:50:24 +00:00
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-23 08:47:37 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Returns a timestamp with decimals for precise time comparisons
|
2009-03-07 05:32:16 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
2009-01-04 21:53:41 +00:00
|
|
|
|
double GetDoubleTime()
|
|
|
|
|
{
|
|
|
|
|
wxDateTime datetime = wxDateTime::UNow(); // Get timestamp
|
2009-01-23 21:28:55 +00:00
|
|
|
|
u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continous timestamp
|
2009-01-15 06:48:15 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
/* Remove a few years. We only really want enough seconds to make sure that we are
|
|
|
|
|
detecting actual actions, perhaps 60 seconds is enough really, but I leave a
|
|
|
|
|
year of seconds anyway, in case the user's clock is incorrect or something like that */
|
|
|
|
|
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
|
|
|
|
|
|
|
|
|
|
//if (TmpSeconds < 0) return 0; // Check the the user's clock is working somewhat
|
|
|
|
|
|
|
|
|
|
u32 Seconds = (u32)TmpSeconds; // Make a smaller integer that fits in the double
|
|
|
|
|
double ms = datetime.GetMillisecond() / 1000.0;
|
|
|
|
|
double TmpTime = Seconds + ms;
|
|
|
|
|
return TmpTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Detect double click. Kind of, for some reason we have to manually create the double click for now.
|
2009-03-07 05:32:16 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
2009-01-04 21:53:41 +00:00
|
|
|
|
void CFrame::OnDoubleClick(wxMouseEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Don't block the mouse click
|
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
|
|
// Don't use this in Wii mode since we use the mouse as input to the game there
|
|
|
|
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) return;
|
|
|
|
|
|
|
|
|
|
// Only detect double clicks in the rendering window, and only use this when a game is running
|
|
|
|
|
if(Core::GetState() == Core::CORE_UNINITIALIZED || event.GetId() != IDM_MPANEL) return;
|
|
|
|
|
|
|
|
|
|
// For first click just save the time
|
|
|
|
|
if(m_fLastClickTime == 0) { m_fLastClickTime = GetDoubleTime(); return; }
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
/* Manually detect double clicks since both wxEVT_LEFT_DCLICK and WM_LBUTTONDBLCLK stops
|
|
|
|
|
working after the child window is created by the plugin */
|
|
|
|
|
// ----------------------
|
|
|
|
|
double TmpTime = GetDoubleTime();
|
|
|
|
|
int Elapsed = (TmpTime - m_fLastClickTime) * 1000;
|
|
|
|
|
|
|
|
|
|
// Get the double click time, if avaliable
|
|
|
|
|
int DoubleClickTime;
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
DoubleClickTime = GetDoubleClickTime();
|
|
|
|
|
#else
|
|
|
|
|
DoubleClickTime = 500; // The default in Windows
|
2009-01-03 01:38:44 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
m_fLastClickTime = TmpTime; // Save the click time
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
if (Elapsed < DoubleClickTime)
|
2008-12-12 03:38:50 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
ShowFullScreen(!IsFullScreen());
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
MSWSetCursor(true); // Show the cursor again, in case it was hidden
|
|
|
|
|
#endif
|
2009-01-04 21:53:41 +00:00
|
|
|
|
m_fLastClickTime -= 10; // Don't treat repeated clicks as double clicks
|
|
|
|
|
}
|
|
|
|
|
// --------------------------
|
|
|
|
|
}
|
2008-12-23 08:47:37 +00:00
|
|
|
|
|
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// Check for mouse motion. Here we process the bHideCursor setting.
|
2009-03-07 05:32:16 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
2009-01-04 21:53:41 +00:00
|
|
|
|
void CFrame::OnMotion(wxMouseEvent& event)
|
2009-01-15 06:48:15 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
// The following is only interesting when a game is running
|
|
|
|
|
if(Core::GetState() == Core::CORE_UNINITIALIZED) return;
|
2008-12-23 08:47:37 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
/* For some reason WM_MOUSEMOVE events are sent from the plugin even when there is no movement
|
|
|
|
|
so we have to check that the cursor position has actually changed */
|
|
|
|
|
if(bRenderToMain) //
|
2008-12-12 03:38:50 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
bool PositionIdentical = false;
|
|
|
|
|
if (event.GetX() == LastMouseX && event.GetY() == LastMouseY) PositionIdentical = true;
|
|
|
|
|
LastMouseX = event.GetX(); LastMouseY = event.GetY();
|
|
|
|
|
if(PositionIdentical) return;
|
2008-12-12 03:38:50 +00:00
|
|
|
|
}
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
|
|
|
|
// Now we know that we have an actual mouse movement event
|
|
|
|
|
|
|
|
|
|
// Update motion for the auto hide option and return
|
|
|
|
|
if(IsFullScreen() && SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor)
|
2008-12-12 03:38:50 +00:00
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
|
m_iLastMotionTime = GetDoubleTime();
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
MSWSetCursor(true);
|
|
|
|
|
#endif
|
2009-01-04 21:53:41 +00:00
|
|
|
|
return;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
2008-12-12 03:38:50 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
if(SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && event.GetId() == IDM_MPANEL)
|
2008-12-08 05:30:24 +00:00
|
|
|
|
{
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
if(bRenderToMain) MSWSetCursor(false);
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
2009-01-04 23:24:13 +00:00
|
|
|
|
/* We only need to use this if we are rendering to a separate window. It does work
|
|
|
|
|
for rendering to the main window to, but in that case our MSWSetCursor() works to
|
|
|
|
|
so we can use that instead. If we one day determine that the separate window
|
|
|
|
|
rendering is superfluous we could do without this */
|
|
|
|
|
else PostMessage((HWND)Core::GetWindowHandle(), WM_USER, 10, 0);
|
|
|
|
|
#endif
|
2008-12-12 03:38:50 +00:00
|
|
|
|
}
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
|
|
|
|
// For some reason we need this to, otherwise the cursor can get stuck with the resizing arrows
|
2008-12-12 03:38:50 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
if(bRenderToMain) MSWSetCursor(true);
|
|
|
|
|
else PostMessage((HWND)Core::GetWindowHandle(), WM_USER, 10, 1);
|
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
2009-01-15 06:48:15 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for mouse status a couple of times per second for the auto hide option
|
2009-03-07 05:32:16 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#if wxUSE_TIMER
|
|
|
|
|
void CFrame::Update()
|
|
|
|
|
{
|
|
|
|
|
// Check if auto hide is on, or if we are already hiding the cursor all the time
|
|
|
|
|
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor
|
|
|
|
|
|| SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) return;
|
|
|
|
|
|
|
|
|
|
if(IsFullScreen())
|
|
|
|
|
{
|
|
|
|
|
int HideDelay = 1; // Wait 1 second to hide the cursor, just like Windows Media Player
|
|
|
|
|
double TmpSeconds = GetDoubleTime(); // Get timestamp
|
|
|
|
|
double CompareTime = TmpSeconds - HideDelay; // Compare it
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
|
if(m_iLastMotionTime < CompareTime) // Update cursor
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#ifdef _WIN32
|
2009-01-04 21:53:41 +00:00
|
|
|
|
MSWSetCursor(false);
|
2009-01-04 23:24:13 +00:00
|
|
|
|
#else
|
|
|
|
|
{}
|
|
|
|
|
#endif
|
2009-01-04 21:53:41 +00:00
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
}
|
2009-01-04 21:53:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
//////////////////////////////////////////
|