summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorAugustin Cavalier <waddlesplash@gmail.com>2014-10-04 15:12:15 -0400
committerAugustin Cavalier <waddlesplash@gmail.com>2014-10-05 20:47:37 -0400
commit19109e2d01d7bcbde51ba84f71fee1cfc751ec24 (patch)
treec2ef739cc452f25bc7ddefc1ad95357fac2f87ca /Source/Core
parent669a1180638cc803dae890e2f8616d7c7720780b (diff)
Migrate global init stuff into UICommon.
This avoids code duplication in a bunch of places . I also moved the NVIDIA Optimus export into VideoCommon.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/CMakeLists.txt1
-rw-r--r--Source/Core/DolphinWX/CMakeLists.txt1
-rw-r--r--Source/Core/DolphinWX/DolphinWX.vcxproj3
-rw-r--r--Source/Core/DolphinWX/Main.cpp46
-rw-r--r--Source/Core/DolphinWX/MainAndroid.cpp13
-rw-r--r--Source/Core/DolphinWX/MainNoGUI.cpp14
-rw-r--r--Source/Core/UICommon/CMakeLists.txt5
-rw-r--r--Source/Core/UICommon/UICommon.cpp64
-rw-r--r--Source/Core/UICommon/UICommon.h15
-rw-r--r--Source/Core/UICommon/UICommon.vcxproj54
-rw-r--r--Source/Core/VideoCommon/VideoBackendBase.cpp7
11 files changed, 163 insertions, 60 deletions
diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt
index 7b4042b604..b478a10100 100644
--- a/Source/Core/CMakeLists.txt
+++ b/Source/Core/CMakeLists.txt
@@ -4,5 +4,6 @@ add_subdirectory(Core)
add_subdirectory(DiscIO)
add_subdirectory(DolphinWX)
add_subdirectory(InputCommon)
+add_subdirectory(UICommon)
add_subdirectory(VideoCommon)
add_subdirectory(VideoBackends)
diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt
index 4b60118b48..8a007d0593 100644
--- a/Source/Core/DolphinWX/CMakeLists.txt
+++ b/Source/Core/DolphinWX/CMakeLists.txt
@@ -3,6 +3,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
set(LIBS core
+ uicommon
${LZO}
${GTK2_LIBRARIES})
diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj
index 90b6c8ce7b..69fa015d15 100644
--- a/Source/Core/DolphinWX/DolphinWX.vcxproj
+++ b/Source/Core/DolphinWX/DolphinWX.vcxproj
@@ -189,6 +189,9 @@
<ProjectReference Include="$(CoreDir)InputCommon\InputCommon.vcxproj">
<Project>{6bbd47cf-91fd-4077-b676-8b76980178a9}</Project>
</ProjectReference>
+ <ProjectReference Include="$(CoreDir)UICommon\UICommon.vcxproj">
+ <Project>{604C8368-F34A-4D55-82C8-CC92A0C13254}</Project>
+ </ProjectReference>
<ProjectReference Include="$(CoreDir)VideoBackends\D3D\D3D.vcxproj">
<Project>{96020103-4ba5-4fd2-b4aa-5b6d24492d4e}</Project>
</ProjectReference>
diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp
index 082a7544c4..c25b911de3 100644
--- a/Source/Core/DolphinWX/Main.cpp
+++ b/Source/Core/DolphinWX/Main.cpp
@@ -52,6 +52,8 @@
#include "DolphinWX/Debugger/CodeWindow.h"
#include "DolphinWX/Debugger/JitWindow.h"
+#include "UICommon/UICommon.h"
+
#include "VideoCommon/VideoBackendBase.h"
#if defined HAVE_X11 && HAVE_X11
@@ -83,15 +85,6 @@
class wxFrame;
-// Nvidia drivers >= v302 will check if the application exports a global
-// variable named NvOptimusEnablement to know if it should run the app in high
-// performance graphics mode or using the IGP.
-#ifdef WIN32
-extern "C" {
- __declspec(dllexport) DWORD NvOptimusEnablement = 1;
-}
-#endif
-
// ------------
// Main window
@@ -257,32 +250,8 @@ bool DolphinApp::OnInit()
}
#endif
- // Copy initial Wii NAND data from Sys to User.
- File::CopyDir(File::GetSysDirectory() + WII_USER_DIR DIR_SEP,
- File::GetUserPath(D_WIIUSER_IDX));
-
- File::CreateFullPath(File::GetUserPath(D_USER_IDX));
- File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
- File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
- File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
- File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
- File::CreateFullPath(File::GetUserPath(D_GAMESETTINGS_IDX));
- File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
- File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP);
- File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP);
- File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP);
- File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
- File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
- File::CreateFullPath(File::GetUserPath(D_MAPS_IDX));
- File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
- File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX));
- File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
- File::CreateFullPath(File::GetUserPath(D_THEMES_IDX));
-
- LogManager::Init();
- SConfig::Init();
- VideoBackend::PopulateList();
- WiimoteReal::LoadSettings();
+ UICommon::CreateDirectories();
+ UICommon::Init();
if (selectVideoBackend && videoBackendName != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend =
@@ -301,8 +270,6 @@ bool DolphinApp::OnInit()
// Enable the PNG image handler for screenshots
wxImage::AddHandler(new wxPNGHandler);
- SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
-
int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX;
int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY;
int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth;
@@ -445,10 +412,7 @@ void DolphinApp::OnEndSession(wxCloseEvent& event)
int DolphinApp::OnExit()
{
Core::Shutdown();
- WiimoteReal::Shutdown();
- VideoBackend::ClearList();
- SConfig::Shutdown();
- LogManager::Shutdown();
+ UICommon::Shutdown();
delete m_locale;
diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp
index 0f2c5eddce..3d226d5eef 100644
--- a/Source/Core/DolphinWX/MainAndroid.cpp
+++ b/Source/Core/DolphinWX/MainAndroid.cpp
@@ -43,6 +43,8 @@
#include "DiscIO/Filesystem.h"
#include "DiscIO/VolumeCreator.h"
+#include "UICommon/UICommon.h"
+
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h"
@@ -359,21 +361,14 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *
OSD::AddCallback(OSD::OSD_INIT, ButtonManager::Init);
OSD::AddCallback(OSD::OSD_SHUTDOWN, ButtonManager::Shutdown);
- LogManager::Init();
- SConfig::Init();
- VideoBackend::PopulateList();
- VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
- WiimoteReal::LoadSettings();
+ UICommon::Init();
// No use running the loop when booting fails
if ( BootManager::BootCore( g_filename.c_str() ) )
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();
- WiimoteReal::Shutdown();
- VideoBackend::ClearList();
- SConfig::Shutdown();
- LogManager::Shutdown();
+ UICommon::Shutdown();
ANativeWindow_release(surf);
}
diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp
index e000a5a9de..ebe1d97c30 100644
--- a/Source/Core/DolphinWX/MainNoGUI.cpp
+++ b/Source/Core/DolphinWX/MainNoGUI.cpp
@@ -22,6 +22,8 @@
#include "Core/HW/Wiimote.h"
#include "Core/PowerPC/PowerPC.h"
+#include "UICommon/UICommon.h"
+
#include "VideoCommon/VideoBackendBase.h"
static bool rendererHasFocus = true;
@@ -347,12 +349,7 @@ int main(int argc, char* argv[])
return 1;
}
- LogManager::Init();
- SConfig::Init();
- VideoBackend::PopulateList();
- VideoBackend::ActivateBackend(SConfig::GetInstance().
- m_LocalCoreStartupParameter.m_strVideoBackend);
- WiimoteReal::LoadSettings();
+ UICommon::Init();
platform->Init();
@@ -372,10 +369,7 @@ int main(int argc, char* argv[])
platform->Shutdown();
Core::Shutdown();
- WiimoteReal::Shutdown();
- VideoBackend::ClearList();
- SConfig::Shutdown();
- LogManager::Shutdown();
+ UICommon::Shutdown();
delete platform;
diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt
new file mode 100644
index 0000000000..59e9443da7
--- /dev/null
+++ b/Source/Core/UICommon/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(SRCS UICommon.cpp)
+
+set(LIBS common)
+
+add_dolphin_library(uicommon "${SRCS}" "${LIBS}")
diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp
new file mode 100644
index 0000000000..f54b1a9c76
--- /dev/null
+++ b/Source/Core/UICommon/UICommon.cpp
@@ -0,0 +1,64 @@
+// Copyright 2014 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Common/CommonPaths.h"
+#include "Common/FileUtil.h"
+#include "Common/Logging/LogManager.h"
+
+#include "Core/ConfigManager.h"
+#include "Core/HW/Wiimote.h"
+
+#include "UICommon/UICommon.h"
+
+#include "VideoCommon/VideoBackendBase.h"
+
+namespace UICommon
+{
+
+void Init()
+{
+ LogManager::Init();
+ SConfig::Init();
+ VideoBackend::PopulateList();
+ WiimoteReal::LoadSettings();
+
+ VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
+
+ SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
+}
+
+void Shutdown()
+{
+ WiimoteReal::Shutdown();
+ VideoBackend::ClearList();
+ SConfig::Shutdown();
+ LogManager::Shutdown();
+}
+
+void CreateDirectories()
+{
+ // Copy initial Wii NAND data from Sys to User.
+ File::CopyDir(File::GetSysDirectory() + WII_USER_DIR DIR_SEP,
+ File::GetUserPath(D_WIIUSER_IDX));
+
+ File::CreateFullPath(File::GetUserPath(D_USER_IDX));
+ File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
+ File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
+ File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
+ File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
+ File::CreateFullPath(File::GetUserPath(D_GAMESETTINGS_IDX));
+ File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
+ File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP);
+ File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP);
+ File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP);
+ File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
+ File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
+ File::CreateFullPath(File::GetUserPath(D_MAPS_IDX));
+ File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
+ File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX));
+ File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
+ File::CreateFullPath(File::GetUserPath(D_THEMES_IDX));
+}
+
+} // namespace UICommon
diff --git a/Source/Core/UICommon/UICommon.h b/Source/Core/UICommon/UICommon.h
new file mode 100644
index 0000000000..d177727986
--- /dev/null
+++ b/Source/Core/UICommon/UICommon.h
@@ -0,0 +1,15 @@
+// Copyright 2014 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+namespace UICommon
+{
+
+void Init();
+void Shutdown();
+
+void CreateDirectories();
+
+} // namespace UICommon
diff --git a/Source/Core/UICommon/UICommon.vcxproj b/Source/Core/UICommon/UICommon.vcxproj
new file mode 100644
index 0000000000..ca9a9e4dbc
--- /dev/null
+++ b/Source/Core/UICommon/UICommon.vcxproj
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{604C8368-F34A-4D55-82C8-CC92A0C13254}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
+ <UseDebugLibraries>true</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
+ <UseDebugLibraries>false</UseDebugLibraries>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\VSProps\Base.props" />
+ <Import Project="..\..\VSProps\PCHUse.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <ItemGroup>
+ <Text Include="CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(CoreDir)Core\Core.vcxproj">
+ <Project>{E54CF649-140E-4255-81A5-30A673C1FB36}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="UICommon.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="UICommon.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp
index a2d6d19845..817d917114 100644
--- a/Source/Core/VideoCommon/VideoBackendBase.cpp
+++ b/Source/Core/VideoCommon/VideoBackendBase.cpp
@@ -32,6 +32,13 @@ static bool IsGteVista()
return VerifyVersionInfo(&osvi, VER_MAJORVERSION, dwlConditionMask) != FALSE;
}
+
+// Nvidia drivers >= v302 will check if the application exports a global
+// variable named NvOptimusEnablement to know if it should run the app in high
+// performance graphics mode or using the IGP.
+extern "C" {
+__declspec(dllexport) DWORD NvOptimusEnablement = 1;
+}
#endif
void VideoBackend::PopulateList()