Migrate global init stuff into UICommon.

This avoids code duplication in a bunch of places .
I also moved the NVIDIA Optimus export into VideoCommon.
This commit is contained in:
Augustin Cavalier 2014-10-04 15:12:15 -04:00
parent 669a118063
commit 19109e2d01
12 changed files with 170 additions and 60 deletions

View File

@ -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)

View File

@ -3,6 +3,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
set(LIBS core
uicommon
${LZO}
${GTK2_LIBRARIES})

View File

@ -188,6 +188,9 @@
</ProjectReference>
<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>

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -0,0 +1,5 @@
set(SRCS UICommon.cpp)
set(LIBS common)
add_dolphin_library(uicommon "${SRCS}" "${LIBS}")

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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()

View File

@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiscIO", "Core\DiscIO\DiscI
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcxproj", "{6BBD47CF-91FD-4077-B676-8B76980178A9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UICommon", "Core\UICommon\UICommon.vcxproj", "{604C8368-F34A-4D55-82C8-CC92A0C13254}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoCommon", "Core\VideoCommon\VideoCommon.vcxproj", "{3DE9EE35-3E91-4F27-A014-2866AD8C3FE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Externals", "Externals", "{87ADDFF9-5768-4DA2-A33B-2477593D6677}"
@ -93,6 +95,10 @@ Global
{6BBD47CF-91FD-4077-B676-8B76980178A9}.Debug|x64.Build.0 = Debug|x64
{6BBD47CF-91FD-4077-B676-8B76980178A9}.Release|x64.ActiveCfg = Release|x64
{6BBD47CF-91FD-4077-B676-8B76980178A9}.Release|x64.Build.0 = Release|x64
{604C8368-F34A-4D55-82C8-CC92A0C13254}.Debug|x64.ActiveCfg = Debug|x64
{604C8368-F34A-4D55-82C8-CC92A0C13254}.Debug|x64.Build.0 = Debug|x64
{604C8368-F34A-4D55-82C8-CC92A0C13254}.Release|x64.ActiveCfg = Release|x64
{604C8368-F34A-4D55-82C8-CC92A0C13254}.Release|x64.Build.0 = Release|x64
{3DE9EE35-3E91-4F27-A014-2866AD8C3FE3}.Debug|x64.ActiveCfg = Debug|x64
{3DE9EE35-3E91-4F27-A014-2866AD8C3FE3}.Debug|x64.Build.0 = Debug|x64
{3DE9EE35-3E91-4F27-A014-2866AD8C3FE3}.Release|x64.ActiveCfg = Release|x64
@ -187,6 +193,7 @@ Global
{2E6C348C-C75C-4D94-8D1E-9C1FCBF3EFE4} = {15670B2E-CED6-4ED5-94CE-A00B1B2B5BA6}
{160BDC25-5626-4B0D-BDD8-2953D9777FB5} = {15670B2E-CED6-4ED5-94CE-A00B1B2B5BA6}
{6BBD47CF-91FD-4077-B676-8B76980178A9} = {15670B2E-CED6-4ED5-94CE-A00B1B2B5BA6}
{604C8368-F34A-4D55-82C8-CC92A0C13254} = {15670B2E-CED6-4ED5-94CE-A00B1B2B5BA6}
{3DE9EE35-3E91-4F27-A014-2866AD8C3FE3} = {15670B2E-CED6-4ED5-94CE-A00B1B2B5BA6}
{8ADA04D7-6DB1-4DA4-AB55-64FB12A0997B} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{AB993F38-C31D-4897-B139-A620C42BC565} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}