2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2010-07-20 03:23:25 +00:00
|
|
|
#include "Common.h"
|
|
|
|
#include "CommonPaths.h"
|
2010-02-20 04:18:19 +00:00
|
|
|
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
2009-10-29 21:12:11 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "CPUDetect.h"
|
|
|
|
#include "IniFile.h"
|
|
|
|
#include "FileUtil.h"
|
2009-02-22 21:16:12 +00:00
|
|
|
#include "Setup.h"
|
|
|
|
|
|
|
|
#include "Host.h" // Core
|
2009-03-18 17:17:58 +00:00
|
|
|
#include "PluginManager.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-02-22 21:16:12 +00:00
|
|
|
#include "Globals.h" // Local
|
|
|
|
#include "Main.h"
|
2009-01-17 23:41:21 +00:00
|
|
|
#include "ConfigManager.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "CodeWindow.h"
|
2009-08-31 23:09:50 +00:00
|
|
|
#include "LogWindow.h"
|
2009-07-11 20:37:55 +00:00
|
|
|
#include "JitWindow.h"
|
2009-01-09 00:09:07 +00:00
|
|
|
#include "ExtendedTrace.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "BootManager.h"
|
2010-01-22 21:41:25 +00:00
|
|
|
#include "Frame.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-03 20:00:09 +00:00
|
|
|
// Main window
|
2009-09-06 01:40:44 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
IMPLEMENT_APP(DolphinApp)
|
|
|
|
|
2010-07-07 22:00:41 +00:00
|
|
|
BEGIN_EVENT_TABLE(DolphinApp, wxApp)
|
|
|
|
EVT_TIMER(wxID_ANY, DolphinApp::AfterInit)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
bool wxMsgAlert(const char*, const char*, bool, int);
|
2008-12-14 12:30:37 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
CFrame* main_frame = NULL;
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
//Has no error handling.
|
|
|
|
//I think that if an error occurs here there's no way to handle it anyway.
|
|
|
|
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
|
|
|
//EnterCriticalSection(&g_uefcs);
|
|
|
|
|
2009-02-17 22:48:16 +00:00
|
|
|
FILE* file = NULL;
|
2008-12-08 05:30:24 +00:00
|
|
|
fopen_s(&file, "exceptioninfo.txt", "a");
|
|
|
|
fseek(file, 0, SEEK_END);
|
2009-01-09 00:09:07 +00:00
|
|
|
etfprint(file, "\n");
|
|
|
|
//etfprint(file, g_buildtime);
|
|
|
|
//etfprint(file, "\n");
|
2008-12-08 05:30:24 +00:00
|
|
|
//dumpCurrentDate(file);
|
2009-01-09 00:09:07 +00:00
|
|
|
etfprintf(file, "Unhandled Exception\n Code: 0x%08X\n",
|
2008-12-08 05:30:24 +00:00
|
|
|
e->ExceptionRecord->ExceptionCode);
|
|
|
|
#ifndef _M_X64
|
|
|
|
STACKTRACE2(file, e->ContextRecord->Eip, e->ContextRecord->Esp, e->ContextRecord->Ebp);
|
|
|
|
#else
|
|
|
|
STACKTRACE2(file, e->ContextRecord->Rip, e->ContextRecord->Rsp, e->ContextRecord->Rbp);
|
|
|
|
#endif
|
|
|
|
fclose(file);
|
|
|
|
_flushall();
|
|
|
|
|
|
|
|
//LeaveCriticalSection(&g_uefcs);
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-12 04:10:52 +00:00
|
|
|
// The `main program' equivalent that creates the main window and return the main frame
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
bool DolphinApp::OnInit()
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
// Declarations and definitions
|
|
|
|
bool UseDebugger = false;
|
2010-07-08 23:27:51 +00:00
|
|
|
bool BatchMode = false;
|
2009-09-01 15:16:44 +00:00
|
|
|
bool UseLogger = false;
|
2009-09-06 02:55:14 +00:00
|
|
|
bool selectVideoPlugin = false;
|
|
|
|
bool selectAudioPlugin = false;
|
|
|
|
bool selectWiimotePlugin = false;
|
|
|
|
|
|
|
|
wxString videoPluginFilename;
|
|
|
|
wxString audioPluginFilename;
|
|
|
|
wxString wiimotePluginFilename;
|
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
#if wxUSE_CMDLINE_PARSER // Parse command lines
|
|
|
|
#if wxCHECK_VERSION(2, 9, 0)
|
|
|
|
wxCmdLineEntryDesc cmdLineDesc[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, "h", "help", "Show this help message",
|
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, "d", "debugger", "Opens the debugger"
|
|
|
|
},
|
|
|
|
{
|
2010-07-08 17:25:20 +00:00
|
|
|
wxCMD_LINE_SWITCH, "l", "logger", "Opens the logger"
|
2010-03-18 14:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2010-07-03 10:24:55 +00:00
|
|
|
wxCMD_LINE_OPTION, "e", "exec", "Loads the specified file (DOL, ELF, WAD, GCM, ISO)",
|
2010-03-18 14:34:37 +00:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2010-07-08 23:27:51 +00:00
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, "b", "batch", "Exit Dolphin with emulator"
|
|
|
|
},
|
2010-03-18 14:34:37 +00:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "V", "video_plugin","Specify a video plugin",
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "A", "audio_plugin","Specify an audio plugin",
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "W", "wiimote_plugin","Specify a wiimote plugin",
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_NONE
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
wxCmdLineEntryDesc cmdLineDesc[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _("h"), _("help"),
|
|
|
|
wxT("Show this help message"),
|
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _("d"), _("debugger"), wxT("Opens the debugger")
|
|
|
|
},
|
|
|
|
{
|
2010-07-08 17:25:20 +00:00
|
|
|
wxCMD_LINE_SWITCH, _("l"), _("logger"), wxT("Opens the logger")
|
2010-03-18 14:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2010-07-03 10:24:55 +00:00
|
|
|
wxCMD_LINE_OPTION, _("e"), _("exec"), wxT("Loads the specified file (DOL, ELF, WAD, GCM, ISO)"),
|
2010-03-18 14:34:37 +00:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2010-07-08 23:27:51 +00:00
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _("b"), _("batch"), wxT("Exit Dolphin with emulator")
|
|
|
|
},
|
2010-03-18 14:34:37 +00:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, _("V"), _("video_plugin"), wxT("Specify a video plugin"),
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, _("A"), _("audio_plugin"), wxT("Specify an audio plugin"),
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, _("W"), _("wiimote_plugin"), wxT("Specify a wiimote plugin"),
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_NONE
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
// Gets the command line parameters
|
|
|
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
|
|
|
|
|
|
|
if (parser.Parse() != 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#if wxCHECK_VERSION(2, 9, 0)
|
2010-06-05 03:03:01 +00:00
|
|
|
UseDebugger = parser.Found("debugger");
|
|
|
|
UseLogger = parser.Found("logger");
|
2010-07-03 10:24:55 +00:00
|
|
|
LoadFile = parser.Found("exec", &FileToLoad);
|
2010-07-08 23:27:51 +00:00
|
|
|
BatchMode = parser.Found("batch");
|
2010-03-18 14:34:37 +00:00
|
|
|
#else
|
2010-06-05 01:38:22 +00:00
|
|
|
UseDebugger = parser.Found(wxT("debugger"));
|
|
|
|
UseLogger = parser.Found(wxT("logger"));
|
2010-07-03 10:24:55 +00:00
|
|
|
LoadFile = parser.Found(wxT("exec"), &FileToLoad);
|
2010-07-08 23:27:51 +00:00
|
|
|
BatchMode = parser.Found(wxT("batch"));
|
2010-03-18 14:34:37 +00:00
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
#if wxCHECK_VERSION(2, 9, 0)
|
2010-06-05 03:03:01 +00:00
|
|
|
selectVideoPlugin = parser.Found("video_plugin", &videoPluginFilename);
|
|
|
|
selectAudioPlugin = parser.Found("audio_plugin", &audioPluginFilename);
|
|
|
|
selectWiimotePlugin = parser.Found("wiimote_plugin", &wiimotePluginFilename);
|
2010-03-18 14:34:37 +00:00
|
|
|
#else
|
2010-06-05 01:38:22 +00:00
|
|
|
selectVideoPlugin = parser.Found(wxT("video_plugin"), &videoPluginFilename);
|
|
|
|
selectAudioPlugin = parser.Found(wxT("audio_plugin"), &audioPluginFilename);
|
|
|
|
selectWiimotePlugin = parser.Found(wxT("wiimote_plugin"), &wiimotePluginFilename);
|
2010-03-18 14:34:37 +00:00
|
|
|
#endif
|
|
|
|
#endif // wxUSE_CMDLINE_PARSER
|
|
|
|
|
|
|
|
#if defined _DEBUG && defined _WIN32
|
|
|
|
int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
|
|
|
tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF;
|
|
|
|
_CrtSetDbgFlag(tmpflag);
|
|
|
|
#endif
|
2010-02-16 04:34:41 +00:00
|
|
|
|
2009-01-04 21:53:41 +00:00
|
|
|
// Register message box handler
|
2010-03-18 14:34:37 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
RegisterMsgAlertHandler(&wxMsgAlert);
|
2009-01-18 08:47:24 +00:00
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-08-11 00:35:07 +00:00
|
|
|
// "ExtendedTrace" looks freakin dangerous!!!
|
2010-03-18 14:34:37 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
EXTENDEDTRACEINITIALIZE(".");
|
|
|
|
SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
|
|
|
|
#endif
|
|
|
|
|
2009-08-11 00:35:07 +00:00
|
|
|
// TODO: if First Boot
|
|
|
|
if (!cpu_info.bSSE2)
|
|
|
|
{
|
|
|
|
PanicAlert("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
|
2010-03-18 14:34:37 +00:00
|
|
|
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
|
|
|
|
"Sayonara!\n");
|
2009-08-11 00:35:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-03-18 14:34:37 +00:00
|
|
|
|
2010-07-22 08:09:14 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-12 04:10:52 +00:00
|
|
|
// Keep the user config dir free unless user wants to save the working dir
|
2010-02-02 21:56:29 +00:00
|
|
|
if (!File::Exists((std::string(File::GetUserPath(D_CONFIG_IDX)) + "portable").c_str()))
|
2009-07-12 04:10:52 +00:00
|
|
|
{
|
|
|
|
char tmp[1024];
|
2009-08-02 05:59:55 +00:00
|
|
|
sprintf(tmp, "%s/.dolphin%swd", (const char*)wxStandardPaths::Get().GetUserConfigDir().mb_str(),
|
2009-07-17 06:03:53 +00:00
|
|
|
#ifdef _M_IX86
|
|
|
|
"x32");
|
|
|
|
#else
|
|
|
|
"x64");
|
|
|
|
#endif
|
2009-07-12 04:10:52 +00:00
|
|
|
FILE* workingDir = fopen(tmp, "r");
|
|
|
|
if (!workingDir)
|
|
|
|
{
|
|
|
|
if (PanicYesNo("Dolphin has not been configured with an install location,\nKeep Dolphin portable?"))
|
|
|
|
{
|
2010-02-02 21:56:29 +00:00
|
|
|
FILE* portable = fopen((std::string(File::GetUserPath(D_CONFIG_IDX)) + "portable").c_str(), "w");
|
2009-07-12 04:10:52 +00:00
|
|
|
if (!portable)
|
|
|
|
{
|
|
|
|
PanicAlert("Portable Setting could not be saved\n Are you running Dolphin from read only media or from a directory that dolphin is not located in?");
|
|
|
|
}
|
2009-08-31 22:51:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fclose(portable);
|
|
|
|
}
|
2009-07-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char CWD[1024];
|
2009-08-02 05:59:55 +00:00
|
|
|
sprintf(CWD, "%s", (const char*)wxGetCwd().mb_str());
|
2009-07-12 04:10:52 +00:00
|
|
|
if (PanicYesNo("Set install location to:\n %s ?", CWD))
|
|
|
|
{
|
|
|
|
FILE* workingDirF = fopen(tmp, "w");
|
2009-08-11 12:09:46 +00:00
|
|
|
if (!workingDirF)
|
|
|
|
PanicAlert("Install directory could not be saved");
|
2009-07-12 04:10:52 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fwrite(CWD, ((std::string)CWD).size()+1, 1, workingDirF);
|
|
|
|
fwrite("", 1, 1, workingDirF); //seems to be needed on linux
|
|
|
|
fclose(workingDirF);
|
|
|
|
}
|
|
|
|
}
|
2009-08-11 12:09:46 +00:00
|
|
|
else
|
|
|
|
PanicAlert("Relaunch Dolphin from the install directory and save from there");
|
2009-07-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-12 07:17:43 +00:00
|
|
|
char *tmpChar;
|
|
|
|
long len;
|
2009-08-11 12:09:46 +00:00
|
|
|
fseek(workingDir, 0, SEEK_END);
|
|
|
|
len = ftell(workingDir);
|
|
|
|
fseek(workingDir, 0, SEEK_SET);
|
2009-07-12 07:17:43 +00:00
|
|
|
tmpChar = new char[len];
|
|
|
|
fread(tmpChar, len, 1, workingDir);
|
2009-07-12 04:10:52 +00:00
|
|
|
fclose(workingDir);
|
2010-06-11 08:39:03 +00:00
|
|
|
if (!wxSetWorkingDirectory(wxString::From8BitData(tmpChar)))
|
2009-07-12 04:10:52 +00:00
|
|
|
{
|
2009-07-17 06:03:53 +00:00
|
|
|
INFO_LOG(CONSOLE, "set working directory failed");
|
2009-07-12 04:10:52 +00:00
|
|
|
}
|
2009-07-12 07:17:43 +00:00
|
|
|
delete [] tmpChar;
|
2009-07-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-05-12 04:26:32 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
const char *AppSupportDir = File::GetUserPath(D_USER_IDX);
|
2010-03-18 14:34:37 +00:00
|
|
|
|
|
|
|
if (!File::Exists(AppSupportDir))
|
2010-05-12 04:26:32 +00:00
|
|
|
{
|
|
|
|
// Fresh run: create Dolphin dir and copy contents of User within the bundle to App Support
|
|
|
|
File::CopyDir(std::string(File::GetBundleDirectory() + DIR_SEP USERDATA_DIR DIR_SEP).c_str(), AppSupportDir);
|
|
|
|
}
|
|
|
|
else if (!File::IsDirectory(AppSupportDir))
|
2010-03-18 14:34:37 +00:00
|
|
|
PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory");
|
2010-07-22 08:58:23 +00:00
|
|
|
#elif !defined _WIN32
|
2010-03-18 14:34:37 +00:00
|
|
|
//create all necessary directories in user directory
|
|
|
|
//TODO : detect the revision and upgrade where necessary
|
|
|
|
File::CopyDir(SHARED_USER_DIR CONFIG_DIR DIR_SEP, File::GetUserPath(D_CONFIG_IDX));
|
|
|
|
File::CopyDir(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP, File::GetUserPath(D_GAMECONFIG_IDX));
|
|
|
|
File::CopyDir(SHARED_USER_DIR MAPS_DIR DIR_SEP, File::GetUserPath(D_MAPS_IDX));
|
|
|
|
File::CopyDir(SHARED_USER_DIR SHADERS_DIR DIR_SEP, File::GetUserPath(D_SHADERS_IDX));
|
|
|
|
File::CopyDir(SHARED_USER_DIR WII_USER_DIR DIR_SEP, File::GetUserPath(D_WIIUSER_IDX));
|
|
|
|
|
|
|
|
if (!File::Exists(File::GetUserPath(D_GCUSER_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_CACHE_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
|
2010-03-18 14:34:37 +00:00
|
|
|
if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX)))
|
2010-06-05 01:38:22 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
|
2010-02-02 21:56:29 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
LogManager::Init();
|
|
|
|
SConfig::Init();
|
|
|
|
CPluginManager::Init();
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
if (selectVideoPlugin && videoPluginFilename != wxEmptyString)
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin =
|
|
|
|
std::string(videoPluginFilename.mb_str());
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
if (selectAudioPlugin && audioPluginFilename != wxEmptyString)
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin =
|
2010-06-05 01:38:22 +00:00
|
|
|
std::string(audioPluginFilename.mb_str());
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
if (selectWiimotePlugin && wiimotePluginFilename != wxEmptyString)
|
2010-06-12 20:13:58 +00:00
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin =
|
|
|
|
std::string(wiimotePluginFilename.mb_str());
|
2010-03-18 14:34:37 +00:00
|
|
|
|
2010-08-01 15:48:11 +00:00
|
|
|
// Enable the PNG image handler for screenshots
|
|
|
|
wxImage::AddHandler(new wxPNGHandler);
|
2009-09-06 02:55:14 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-01-18 18:01:03 +00:00
|
|
|
int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX;
|
|
|
|
int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY;
|
|
|
|
int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth;
|
|
|
|
int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight;
|
2009-09-15 21:35:32 +00:00
|
|
|
|
2010-03-18 14:34:37 +00:00
|
|
|
// The following is not needed in linux. Linux window managers do not allow windows to
|
|
|
|
// be created off the desktop.
|
2010-01-25 12:17:48 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Out of desktop check
|
|
|
|
HWND hDesktop = GetDesktopWindow();
|
|
|
|
RECT rc;
|
|
|
|
GetWindowRect(hDesktop, &rc);
|
|
|
|
if (rc.right < x + w || rc.bottom < y + h)
|
|
|
|
x = y = -1;
|
|
|
|
#endif
|
|
|
|
|
2010-07-08 15:25:01 +00:00
|
|
|
main_frame = new CFrame((wxFrame*)NULL, wxID_ANY,
|
|
|
|
wxString::FromAscii(svn_rev_str),
|
|
|
|
wxPoint(x, y), wxSize(w, h),
|
2010-07-08 23:27:51 +00:00
|
|
|
UseDebugger, BatchMode, UseLogger);
|
2010-07-07 22:00:41 +00:00
|
|
|
SetTopWindow(main_frame);
|
|
|
|
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
|
|
|
XInitThreads();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Postpone final actions until event handler is running
|
|
|
|
m_afterinit = new wxTimer(this, wxID_ANY);
|
|
|
|
m_afterinit->Start(1, wxTIMER_ONE_SHOT);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
delete m_afterinit;
|
|
|
|
|
|
|
|
// Updating the game list makes use of wxProgressDialog which may
|
|
|
|
// only be run after OnInit() when the event handler is running.
|
|
|
|
main_frame->UpdateGameList();
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2010-07-07 22:00:41 +00:00
|
|
|
// Check the autoboot options:
|
2009-09-06 01:40:44 +00:00
|
|
|
|
2010-07-03 10:24:55 +00:00
|
|
|
// First check if we have an exec command line.
|
|
|
|
if (LoadFile && FileToLoad != wxEmptyString)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-07-03 10:24:55 +00:00
|
|
|
main_frame->BootGame(std::string(FileToLoad.mb_str()));
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-07 22:00:41 +00:00
|
|
|
|
|
|
|
// If we have selected Automatic Start, start the default ISO,
|
|
|
|
// or if no default ISO exists, start the last loaded ISO
|
2009-09-07 12:40:43 +00:00
|
|
|
else if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-08-25 01:50:27 +00:00
|
|
|
if (main_frame->g_pCodeWindow->AutomaticStart())
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-08-25 01:50:27 +00:00
|
|
|
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty()
|
2010-03-18 14:34:37 +00:00
|
|
|
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.
|
|
|
|
m_strDefaultGCM.c_str()))
|
2009-08-25 01:50:27 +00:00
|
|
|
{
|
2010-04-17 03:17:36 +00:00
|
|
|
main_frame->BootGame(SConfig::GetInstance().m_LocalCoreStartupParameter.
|
2010-03-18 14:34:37 +00:00
|
|
|
m_strDefaultGCM);
|
2009-08-25 01:50:27 +00:00
|
|
|
}
|
|
|
|
else if(!SConfig::GetInstance().m_LastFilename.empty()
|
2010-03-18 14:34:37 +00:00
|
|
|
&& File::Exists(SConfig::GetInstance().m_LastFilename.c_str()))
|
2009-08-25 01:50:27 +00:00
|
|
|
{
|
2010-04-17 03:17:36 +00:00
|
|
|
main_frame->BootGame(SConfig::GetInstance().m_LastFilename);
|
2009-08-25 01:50:27 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinApp::OnEndSession()
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
|
|
|
}
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2010-02-16 04:34:41 +00:00
|
|
|
int DolphinApp::OnExit()
|
|
|
|
{
|
2010-06-20 02:17:53 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (SConfig::GetInstance().m_WiiAutoUnpair)
|
|
|
|
{
|
|
|
|
if (CPluginManager::GetInstance().GetWiimote())
|
|
|
|
CPluginManager::GetInstance().GetWiimote()->Wiimote_UnPairWiimotes();
|
|
|
|
}
|
|
|
|
#endif
|
2010-02-16 04:34:41 +00:00
|
|
|
CPluginManager::Shutdown();
|
|
|
|
SConfig::Shutdown();
|
|
|
|
LogManager::Shutdown();
|
|
|
|
|
|
|
|
return wxApp::OnExit();
|
|
|
|
}
|
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-03 20:00:09 +00:00
|
|
|
// Talk to GUI
|
2009-09-06 01:40:44 +00:00
|
|
|
|
2009-09-03 20:00:09 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
// g_VideoInitialize.pSysMessage() goes here
|
|
|
|
void Host_SysMessage(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
|
|
|
|
//wxMessageBox(wxString::FromAscii(msg));
|
|
|
|
PanicAlert("%s", msg);
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:45:46 +00:00
|
|
|
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
|
2008-12-28 18:50:24 +00:00
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
return wxYES == wxMessageBox(wxString::FromAscii(text),
|
2009-01-18 08:47:24 +00:00
|
|
|
wxString::FromAscii(caption),
|
|
|
|
(yes_no)?wxYES_NO:wxOK);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 18:25:36 +00:00
|
|
|
// Accessor for the main window class
|
|
|
|
CFrame* DolphinApp::GetCFrame()
|
|
|
|
{
|
|
|
|
return main_frame;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-07 12:40:43 +00:00
|
|
|
void Host_Message(int Id)
|
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, Id);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-09-07 12:40:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
// OK, this thread boundary is DANGEROUS on linux
|
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED);
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateLogDisplay()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY);
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG);
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-07-15 15:09:20 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-11 20:37:55 +00:00
|
|
|
void Host_ShowJitResults(unsigned int address)
|
|
|
|
{
|
|
|
|
CJitWindow::ViewAddr(address);
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-27 21:28:09 +00:00
|
|
|
|
2010-04-15 20:58:34 +00:00
|
|
|
void Host_UpdateTitle(const char* title)
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATETITLE);
|
|
|
|
event.SetString(wxString::FromAscii(title));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void Host_UpdateBreakPointView()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS);
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-03 07:59:24 +00:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Host_UpdateMemoryView()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void Host_SetDebugMode(bool)
|
|
|
|
{}
|
|
|
|
|
2010-04-12 01:33:10 +00:00
|
|
|
void Host_RequestWindowSize(int& x, int& y, int& width, int& height)
|
|
|
|
{
|
|
|
|
main_frame->OnSizeRequest(x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void Host_SetWaitCursor(bool enable)
|
|
|
|
{
|
2009-12-01 15:39:37 +00:00
|
|
|
if (enable)
|
2010-04-12 01:33:10 +00:00
|
|
|
wxBeginBusyCursor();
|
2009-12-01 15:39:37 +00:00
|
|
|
else
|
2010-04-12 01:33:10 +00:00
|
|
|
wxEndBusyCursor();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-16 06:18:18 +00:00
|
|
|
void Host_UpdateStatusBar(const char* _pText, int Field)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
2009-02-16 06:18:18 +00:00
|
|
|
// Set the event string
|
2008-12-08 05:30:24 +00:00
|
|
|
event.SetString(wxString::FromAscii(_pText));
|
2009-02-16 06:18:18 +00:00
|
|
|
// Update statusbar field
|
|
|
|
event.SetInt(Field);
|
|
|
|
// Post message
|
2009-08-01 18:16:12 +00:00
|
|
|
// TODO : this has been said to cause hang (??) how is that even possible ? :d
|
2009-09-03 09:13:41 +00:00
|
|
|
event.StopPropagation();
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Host_SetWiiMoteConnectionState(int _State)
|
|
|
|
{
|
|
|
|
static int currentState = -1;
|
|
|
|
if (_State == currentState)
|
|
|
|
return;
|
|
|
|
currentState = _State;
|
|
|
|
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
|
|
|
|
|
|
|
switch(_State)
|
|
|
|
{
|
|
|
|
case 0: event.SetString(wxString::FromAscii("Not connected")); break;
|
|
|
|
case 1: event.SetString(wxString::FromAscii("Connecting...")); break;
|
|
|
|
case 2: event.SetString(wxString::FromAscii("Wiimote Connected")); break;
|
|
|
|
}
|
2009-02-16 06:18:18 +00:00
|
|
|
// Update field 1 or 2
|
2010-01-01 03:55:39 +00:00
|
|
|
event.SetInt(1);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-01-20 11:49:11 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-04-12 01:33:10 +00:00
|
|
|
|
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
|
|
|
return main_frame->RendererHasFocus();
|
|
|
|
}
|