From f885eb2de0103699347da903c63acece4db0cb7f Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 18 Mar 2010 14:34:37 +0000 Subject: [PATCH] Did some clean up of the GUI main. Also, parse command line options first, then set up directories (linux and apple), then load the log manager, sconfig, etc. Removes the need for my silly log manager and sysconf reload. Changed the default font for the log window to the local font (why was a Japanese font the default?). Also fixed an issue that prevented the log windows settings from being saved properly. Lots more needs to be done with the AUI manager. That stuff doesn't work. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5213 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/LogManager.cpp | 4 - Source/Core/Common/Src/LogManager.h | 2 - Source/Core/Common/Src/SysConf.cpp | 8 - Source/Core/Common/Src/SysConf.h | 2 - Source/Core/DolphinWX/Src/FrameAui.cpp | 9 +- Source/Core/DolphinWX/Src/LogWindow.cpp | 7 +- Source/Core/DolphinWX/Src/LogWindow.h | 2 +- Source/Core/DolphinWX/Src/Main.cpp | 485 ++++++++++++------------ 8 files changed, 256 insertions(+), 263 deletions(-) diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp index e613f2763d..2abf20b2f3 100644 --- a/Source/Core/Common/Src/LogManager.cpp +++ b/Source/Core/Common/Src/LogManager.cpp @@ -192,10 +192,6 @@ FileLogListener::FileLogListener(const char *filename) { setEnable(true); } -void FileLogListener::Reload() { - m_logfile = fopen(m_filename, "a+"); -} - FileLogListener::~FileLogListener() { free(m_filename); if (m_logfile) diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index eb5b7edff1..9b91e189de 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -42,8 +42,6 @@ public: FileLogListener(const char *filename); ~FileLogListener(); - void Reload(); - void Log(LogTypes::LOG_LEVELS, const char *msg); bool isValid() { diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp index 18a3669210..dbac407dc7 100644 --- a/Source/Core/Common/Src/SysConf.cpp +++ b/Source/Core/Common/Src/SysConf.cpp @@ -25,14 +25,6 @@ SysConf::SysConf() m_IsValid = true; } -void SysConf::Reload() -{ - if (m_IsValid) - return; - if (LoadFromFile(File::GetUserPath(F_WIISYSCONF_IDX))) - m_IsValid = true; -} - SysConf::~SysConf() { if (!m_IsValid) diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h index 5d7c50007e..c2db94fa3b 100644 --- a/Source/Core/Common/Src/SysConf.h +++ b/Source/Core/Common/Src/SysConf.h @@ -71,8 +71,6 @@ public: bool IsValid() { return m_IsValid; } - void Reload(); - template T GetData(const char* sectionName) { diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index 96dd8d8d9a..45da0a4716 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -105,7 +105,7 @@ void CFrame::ToggleLogWindow(bool bShow, int i) } else { - DoRemovePage(m_LogWindow); + DoRemovePage(m_LogWindow, bShow); } // Hide or Show the pane @@ -402,9 +402,10 @@ void CFrame::DoRemovePage(wxWindow * Win, bool _Hide) if (GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) { GetNotebookFromId(i)->RemovePage(GetNotebookFromId(i)->GetPageIndex(Win)); - // Reparent to avoid destruction if the notebook is closed and destroyed - if (!Win->IsBeingDeleted()) Win->Reparent(this); - if (_Hide) Win->Hide(); + if (_Hide) + Win->Hide(); + else + Win->Close(); } } } diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 512333a95b..0d1016b44f 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -53,7 +53,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxString &, const wx , Parent(parent) , m_LogAccess(true) , m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL) , m_LogSection(1) - , m_SJISConv(wxFONTENCODING_SHIFT_JIS) + , m_CSConv(wxConvLocal) { m_LogManager = LogManager::GetInstance(); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) @@ -156,12 +156,11 @@ CLogWindow::~CLogWindow() } m_LogTimer->Stop(); delete m_LogTimer; - - SaveSettings(); } void CLogWindow::OnClose(wxCloseEvent& event) { + SaveSettings(); wxGetApp().GetCFrame()->ToggleLogWindow(false); event.Skip(); } @@ -530,6 +529,6 @@ void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text) m_LogSection.Enter(); if (msgQueue.size() >= 100) msgQueue.pop(); - msgQueue.push(std::pair((u8)level, wxString(text, m_SJISConv))); + msgQueue.push(std::pair((u8)level, wxString(text, m_CSConv))); m_LogSection.Leave(); } diff --git a/Source/Core/DolphinWX/Src/LogWindow.h b/Source/Core/DolphinWX/Src/LogWindow.h index cde2e80aab..5c8bf9932c 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.h +++ b/Source/Core/DolphinWX/Src/LogWindow.h @@ -86,7 +86,7 @@ private: Common::CriticalSection m_LogSection; - wxCSConv m_SJISConv; + wxCSConv m_CSConv; DECLARE_EVENT_TABLE() diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index a8a9e600c0..3b47147185 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -52,10 +52,8 @@ IMPLEMENT_APP(DolphinApp) -#if defined(HAVE_WX) && HAVE_WX - #include - bool wxMsgAlert(const char*, const char*, bool, int); -#endif +#include +bool wxMsgAlert(const char*, const char*, bool, int); CFrame* main_frame = NULL; @@ -106,36 +104,139 @@ bool DolphinApp::OnInit() wxString padPluginFilename; wxString wiimotePluginFilename; - #if defined _DEBUG && defined _WIN32 - int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF; - _CrtSetDbgFlag(tmpflag); - #endif +#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" + }, + { + wxCMD_LINE_SWITCH, "l", "logger", "Opens The Logger" + }, + { + wxCMD_LINE_OPTION, "e", "elf", "Loads an elf file", + wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL + }, + { + 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, "P", "pad_plugin","Specify a pad 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") + }, + { + wxCMD_LINE_SWITCH, _("l"), _("logger"), wxT("Opens The Logger") + }, + { + wxCMD_LINE_OPTION, _("e"), _("elf"), wxT("Loads an elf file"), + wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL + }, + { + 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, _("P"), _("pad_plugin"), wxT("Specify a pad 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); - LogManager::Init(); - EventHandler::Init(); - SConfig::Init(); - CPluginManager::Init(); + if (parser.Parse() != 0) + { + return false; + } +#if wxCHECK_VERSION(2, 9, 0) + UseDebugger = parser.Found("debugger"); + UseLogger = parser.Found("logger"); + LoadElf = parser.Found("elf", &ElfFile); +#else + UseDebugger = parser.Found(_("debugger")); + UseLogger = parser.Found(_("logger")); + LoadElf = parser.Found(_("elf"), &ElfFile); +#endif + +#if wxCHECK_VERSION(2, 9, 0) + selectVideoPlugin = parser.Found("video_plugin", &videoPluginFilename); + selectAudioPlugin = parser.Found("audio_plugin", &audioPluginFilename); + selectPadPlugin = parser.Found("pad_plugin", &padPluginFilename); + selectWiimotePlugin = parser.Found("wiimote_plugin", &wiimotePluginFilename); +#else + selectVideoPlugin = parser.Found(_T("video_plugin"), &videoPluginFilename); + selectAudioPlugin = parser.Found(_T("audio_plugin"), &audioPluginFilename); + selectPadPlugin = parser.Found(_T("pad_plugin"), &padPluginFilename); + selectWiimotePlugin = parser.Found(_T("wiimote_plugin"), &wiimotePluginFilename); +#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 // Register message box handler -#if ! defined(_WIN32) && defined(HAVE_WX) && HAVE_WX - RegisterMsgAlertHandler(&wxMsgAlert); +#ifndef _WIN32 + RegisterMsgAlertHandler(&wxMsgAlert); #endif // "ExtendedTrace" looks freakin dangerous!!! - #ifdef _WIN32 - EXTENDEDTRACEINITIALIZE("."); - SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); - #endif - +#ifdef _WIN32 + EXTENDEDTRACEINITIALIZE("."); + SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); +#endif + // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlert("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" - "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" - "Sayonara!\n"); + "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" + "Sayonara!\n"); return false; } + #if ! defined(__APPLE__) && ! defined(__linux__) // Keep the user config dir free unless user wants to save the working dir if (!File::Exists((std::string(File::GetUserPath(D_CONFIG_IDX)) + "portable").c_str())) @@ -201,233 +302,141 @@ bool DolphinApp::OnInit() } #endif - // Parse command lines - #if wxUSE_CMDLINE_PARSER -#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" - }, - { - wxCMD_LINE_SWITCH, "l", "logger", "Opens The Logger" - }, - { - wxCMD_LINE_OPTION, "e", "elf", "Loads an elf file", - wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL - }, - { - 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, "P", "pad_plugin","Specify a pad 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") - }, - { - wxCMD_LINE_SWITCH, _("l"), _("logger"), wxT("Opens The Logger") - }, - { - wxCMD_LINE_OPTION, _("e"), _("elf"), wxT("Loads an elf file"), - wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL - }, - { - 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, _("P"), _("pad_plugin"), wxT("Specify a pad 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 - #if defined(__APPLE__) - // check to see if ~/Library/Application Support/Dolphin exists; if not, create it - char AppSupportDir[MAXPATHLEN]; - snprintf(AppSupportDir, sizeof(AppSupportDir), "%s/Library/Application Support", getenv("HOME")); - if (!File::Exists(AppSupportDir) || !File::IsDirectory(AppSupportDir)) - PanicAlert("Could not open ~/Library/Application Support"); +#ifdef __APPLE__ + // check to see if ~/Library/Application Support/Dolphin exists; if not, create it + char AppSupportDir[MAXPATHLEN]; + snprintf(AppSupportDir, sizeof(AppSupportDir), "%s/Library/Application Support", getenv("HOME")); + if (!File::Exists(AppSupportDir) || !File::IsDirectory(AppSupportDir)) + PanicAlert("Could not open ~/Library/Application Support"); - strlcat(AppSupportDir, "/Dolphin", sizeof(AppSupportDir)); - - if (!File::Exists(AppSupportDir)) - File::CreateDir(AppSupportDir); - - if (!File::IsDirectory(AppSupportDir)) - PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory"); - - chdir(AppSupportDir); + strlcat(AppSupportDir, "/Dolphin", sizeof(AppSupportDir)); - //create all necessary dir in user directory - if (!File::Exists(File::GetUserPath(D_CONFIG_IDX))) File::CreateDir(File::GetUserPath(D_CONFIG_IDX)); - if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); - if (!File::Exists(File::GetUserPath(D_WIISYSCONF_IDX))) File::CreateFullPath(File::GetUserPath(D_WIISYSCONF_IDX)); - if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); - if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); - if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); - if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); - if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); - if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); - if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); + if (!File::Exists(AppSupportDir)) + File::CreateDir(AppSupportDir); + + if (!File::IsDirectory(AppSupportDir)) + PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory"); + + chdir(AppSupportDir); + + //create all necessary dir in user directory + if (!File::Exists(File::GetUserPath(D_CONFIG_IDX))) + File::CreateDir(File::GetUserPath(D_CONFIG_IDX)); + if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); + if (!File::Exists(File::GetUserPath(D_WIISYSCONF_IDX))) + File::CreateFullPath(File::GetUserPath(D_WIISYSCONF_IDX)); + if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) + File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); + if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) + File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); + if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) + File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); + if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) + File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); + if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) + File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); + if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) + File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); + if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) + File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); + + //copy user wii shared2 SYSCONF if not exist + if (!File::Exists(File::GetUserPath(F_WIISYSCONF_IDX))) + File::Copy((File::GetBundleDirectory() + DIR_SEP + "Contents" + DIR_SEP + USERDATA_DIR + DIR_SEP + WII_SYSCONF_DIR + DIR_SEP + WII_SYSCONF).c_str(), + File::GetUserPath(F_WIISYSCONF_IDX)); + //TODO : if not exist copy game config dir in user dir and detect the revision to upgrade if necessary + //TODO : if not exist copy maps dir in user dir and detect revision to upgrade if necessary - //copy user wii shared2 SYSCONF if not exist - if (!File::Exists(File::GetUserPath(F_WIISYSCONF_IDX))) - File::Copy((File::GetBundleDirectory() + DIR_SEP + "Contents" + DIR_SEP + USERDATA_DIR + DIR_SEP + WII_SYSCONF_DIR + DIR_SEP + WII_SYSCONF).c_str(), - File::GetUserPath(F_WIISYSCONF_IDX)); - SConfig::GetInstance().m_SYSCONF->Reload(); - //TODO : if not exist copy game config dir in user dir and detect the revision to upgrade if necessary - //TODO : if not exist copy maps dir in user dir and detect revision to upgrade if necessary - #if !wxCHECK_VERSION(2, 9, 0) - // HACK: Get rid of bogus osx param - if (argc > 1 && wxString(argv[argc - 1]).StartsWith(_("-psn_"))) { - delete argv[argc-1]; - argv[argc-1] = NULL; - argc--; - } + // HACK: Get rid of bogus osx param + if (argc > 1 && wxString(argv[argc - 1]).StartsWith(_("-psn_"))) { + delete argv[argc-1]; + argv[argc-1] = NULL; + argc--; + } +#endif #endif - #endif #ifdef __linux__ - //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)); - SConfig::GetInstance().m_SYSCONF->Reload(); + //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))) File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); - if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); - if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); - if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); - if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); - if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); - if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); - if (!File::Exists(File::GetUserPath(D_LOGS_IDX))) { - File::CreateFullPath(File::GetUserPath(D_LOGS_IDX)); - LogManager::GetInstance()->getFileListener()->Reload(); - } - if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); + if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); + if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) + File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); + if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) + File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); + if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) + File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); + if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) + File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); + if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) + File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); + if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) + File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); + if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) + File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); #endif - // Gets the passed media files from command line - wxCmdLineParser parser(cmdLineDesc, argc, argv); + LogManager::Init(); + EventHandler::Init(); + SConfig::Init(); + CPluginManager::Init(); - // Get filenames from the command line - if (parser.Parse() != 0) - { - return false; - } -#if wxCHECK_VERSION(2, 9, 0) - UseDebugger = parser.Found("debugger"); - UseLogger = parser.Found("logger"); - LoadElf = parser.Found("elf", &ElfFile); -#else - UseDebugger = parser.Found(_("debugger")); - UseLogger = parser.Found(_("logger")); - LoadElf = parser.Found(_("elf"), &ElfFile); -#endif - if( LoadElf && ElfFile == wxEmptyString ) - PanicAlert("You did not specify a file name"); + if (selectVideoPlugin && videoPluginFilename != wxEmptyString) + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin = + std::string(videoPluginFilename.mb_str()); -#if wxCHECK_VERSION(2, 9, 0) - selectVideoPlugin = parser.Found("video_plugin", &videoPluginFilename); - selectAudioPlugin = parser.Found("audio_plugin", &audioPluginFilename); - selectPadPlugin = parser.Found("pad_plugin", &padPluginFilename); - selectWiimotePlugin = parser.Found("wiimote_plugin", &wiimotePluginFilename); -#else - selectVideoPlugin = parser.Found(_T("video_plugin"), &videoPluginFilename); - selectAudioPlugin = parser.Found(_T("audio_plugin"), &audioPluginFilename); - selectPadPlugin = parser.Found(_T("pad_plugin"), &padPluginFilename); - selectWiimotePlugin = parser.Found(_T("wiimote_plugin"), &wiimotePluginFilename); -#endif - // ============ - #endif + if (selectAudioPlugin && audioPluginFilename != wxEmptyString) + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin = + std::string(audioPluginFilename.mb_str()); - if (selectVideoPlugin && videoPluginFilename != wxEmptyString) - { - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin = std::string(videoPluginFilename.mb_str()); - } - if (selectAudioPlugin && audioPluginFilename != wxEmptyString) - { - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin = std::string(audioPluginFilename.mb_str()); - } - if (selectPadPlugin && padPluginFilename != wxEmptyString) - { - int k; - for(k=0;kStartGame(std::string(ElfFile.mb_str())); } - /* If we have selected Automatic Start, start the default ISO, or if no default - ISO exists, start the last loaded ISO */ + // If we have selected Automatic Start, start the default ISO, or if no default + // ISO exists, start the last loaded ISO else if (main_frame->g_pCodeWindow) { if (main_frame->g_pCodeWindow->AutomaticStart()) { if(!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty() - && File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter. - m_strDefaultGCM.c_str())) + && File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter. + m_strDefaultGCM.c_str())) { main_frame->StartGame(SConfig::GetInstance().m_LocalCoreStartupParameter. - m_strDefaultGCM); + m_strDefaultGCM); } else if(!SConfig::GetInstance().m_LastFilename.empty() - && File::Exists(SConfig::GetInstance().m_LastFilename.c_str())) + && File::Exists(SConfig::GetInstance().m_LastFilename.c_str())) { main_frame->StartGame(SConfig::GetInstance().m_LastFilename); } @@ -472,9 +481,11 @@ bool DolphinApp::OnInit() // Set main parent window SetTopWindow(main_frame); + #if defined HAVE_X11 && HAVE_X11 - XInitThreads(); + XInitThreads(); #endif + return true; } @@ -514,7 +525,6 @@ void Host_SysMessage(const char *fmt, ...) PanicAlert("%s", msg); } -#if defined HAVE_WX && HAVE_WX bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/) { return wxYES == wxMessageBox(wxString::FromAscii(text), @@ -671,4 +681,3 @@ void Host_SetWiiMoteConnectionState(int _State) main_frame->GetEventHandler()->AddPendingEvent(event); } -#endif // HAVE_WX