Skip to content

Commit

Permalink
Merge pull request #1085 from waddlesplash/refactoring
Browse files Browse the repository at this point in the history
Migrate global init stuff into UICommon.
  • Loading branch information
lioncash committed Oct 6, 2014
2 parents af241c9 + 19109e2 commit 7c05d02
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 60 deletions.
1 change: 1 addition & 0 deletions Source/Core/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ add_subdirectory(Core)
add_subdirectory(DiscIO)
add_subdirectory(DolphinWX)
add_subdirectory(InputCommon)
add_subdirectory(UICommon)
add_subdirectory(VideoCommon)
add_subdirectory(VideoBackends)

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()

set(LIBS core
uicommon
${LZO}
${GTK2_LIBRARIES})

Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinWX/DolphinWX.vcxproj
Expand Up @@ -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>
Expand Down
46 changes: 5 additions & 41 deletions Source/Core/DolphinWX/Main.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -263,32 +256,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 =
Expand All @@ -307,8 +276,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;
Expand Down Expand Up @@ -451,10 +418,7 @@ void DolphinApp::OnEndSession(wxCloseEvent& event)
int DolphinApp::OnExit()
{
Core::Shutdown();
WiimoteReal::Shutdown();
VideoBackend::ClearList();
SConfig::Shutdown();
LogManager::Shutdown();
UICommon::Shutdown();

delete m_locale;

Expand Down
13 changes: 4 additions & 9 deletions Source/Core/DolphinWX/MainAndroid.cpp
Expand Up @@ -43,6 +43,8 @@
#include "DiscIO/Filesystem.h"
#include "DiscIO/VolumeCreator.h"

#include "UICommon/UICommon.h"

#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h"

Expand Down Expand Up @@ -360,21 +362,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);
}

Expand Down
14 changes: 4 additions & 10 deletions Source/Core/DolphinWX/MainNoGUI.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

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

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/UICommon/CMakeLists.txt
@@ -0,0 +1,5 @@
set(SRCS UICommon.cpp)

set(LIBS common)

add_dolphin_library(uicommon "${SRCS}" "${LIBS}")
64 changes: 64 additions & 0 deletions 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
15 changes: 15 additions & 0 deletions 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
54 changes: 54 additions & 0 deletions 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>
7 changes: 7 additions & 0 deletions Source/Core/VideoCommon/VideoBackendBase.cpp
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions Source/dolphin-emu.sln
Expand Up @@ -17,6 +17,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}"
Expand Down Expand Up @@ -99,6 +101,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
Expand Down Expand Up @@ -193,6 +199,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}
Expand Down

0 comments on commit 7c05d02

Please sign in to comment.