-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFindModLoaderPath.targets
49 lines (42 loc) · 3.38 KB
/
FindModLoaderPath.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<Project>
<PropertyGroup>
<!-- Constants -->
<_GameName>Cobalt Core</_GameName>
<_GameSteamID>2179850</_GameSteamID>
<_ModLoaderName>Nickel</_ModLoaderName>
<!-- Remember user-provided settings -->
<HasUserModLoaderPath>false</HasUserModLoaderPath>
<HasUserModLoaderPath Condition="'$(ModLoaderPath)' != ''">true</HasUserModLoaderPath>
</PropertyGroup>
<!-- Trying to find the game path - needed if ModLoaderPath, GameDllPath or GameExePath is not set -->
<PropertyGroup Condition="$(OS) == 'Unix' OR $(OS) == 'OSX'">
<!-- Linux -->
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$(HOME)/.steam/steam/steamapps/common/$(_GameName)</_GamePath>
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/$(_GameName)</_GamePath>
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$(HOME)/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/$(_GameName)</_GamePath>
<!-- macOS (may be 'Unix' or 'OSX') -->
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/$(_GameName)/Contents/MacOS</_GamePath>
</PropertyGroup>
<PropertyGroup Condition="$(OS) == 'Windows_NT'">
<!-- Registry path -->
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App $(_GameSteamID)', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</_GamePath>
<!-- Derive from Steam library path -->
<_SteamLibraryPath>$([MSBuild]::GetRegistryValueFromView('HKEY_CURRENT_USER\SOFTWARE\Valve\Steam', 'SteamPath', null, RegistryView.Registry32))</_SteamLibraryPath>
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">$(_SteamLibraryPath)\steamapps\common\$(_GameName)</_GamePath>
<!-- Steam paths -->
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">C:\Program Files\Steam\steamapps\common\$(_GameName)</_GamePath>
<_GamePath Condition="'$(_GamePath)' == '' Or !Exists('$(_GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\$(_GameName)</_GamePath>
</PropertyGroup>
<!-- Trying to set ModLoaderPath based on the found game path -->
<PropertyGroup Condition="Exists('$(_GamePath)')">
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(_GamePath)\$(_ModLoaderName)</ModLoaderPath>
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(_GamePath)</ModLoaderPath>
</PropertyGroup>
<!-- Trying to set ModLoaderPath if it's still missing -->
<PropertyGroup>
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(USERPROFILE)\$(_ModLoaderName)</ModLoaderPath>
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(HOME)\$(_ModLoaderName)</ModLoaderPath>
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(USERPROFILE)\Downloads\$(_ModLoaderName)</ModLoaderPath>
<ModLoaderPath Condition="!'$(HasUserModLoaderPath)' And !Exists('$(ModLoaderPath)\$(_ModLoaderName).dll')">$(HOME)\Downloads\$(_ModLoaderName)</ModLoaderPath>
</PropertyGroup>
</Project>