Skip to content

Commit b732287

Browse files
committed
ModAPI.Common: remove unused forced paths in LauncherSettings.cs
1 parent d640267 commit b732287

File tree

4 files changed

+29
-115
lines changed

4 files changed

+29
-115
lines changed

ModAPI.Common/LauncherSettings.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,6 @@ public static class LauncherSettings
1313

1414
private static Dictionary<string, string> _dictionary = new Dictionary<string, string>();
1515

16-
public static string ForcedCoreSporeDataPath
17-
{
18-
get
19-
{
20-
string value = null;
21-
_dictionary.TryGetValue("ForcedCoreSporeDataPath", out value);
22-
return value;
23-
}
24-
}
25-
26-
/*public static string ForcedSporebinPath
27-
{
28-
get
29-
{
30-
string value = null;
31-
_dictionary.TryGetValue("ForcedSporebinPath", out value);
32-
return value;
33-
}
34-
}*/
35-
36-
public static string ForcedGalacticAdventuresDataPath
37-
{
38-
get
39-
{
40-
string value = null;
41-
_dictionary.TryGetValue("ForcedGalacticAdventuresDataPath", out value);
42-
return value;
43-
}
44-
}
45-
46-
public static string ForcedSporebinEP1Path
47-
{
48-
get
49-
{
50-
string value = null;
51-
_dictionary.TryGetValue("ForcedSporebinEP1Path", out value);
52-
return value;
53-
}
54-
}
55-
56-
public static string ForcedGalacticAdventuresSporeAppPath
57-
{
58-
get
59-
{
60-
string value = null;
61-
_dictionary.TryGetValue("ForcedGalacticAdventuresSporeAppPath", out value);
62-
return value;
63-
}
64-
}
65-
6616
public static string GamePath
6717
{
6818
get

ModAPI.Common/SporePath.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,19 @@ public static string MoveToData(Game game, string installationDirectory)
230230
{
231231
if (game == Game.Spore)
232232
{
233-
if (LauncherSettings.ForcedCoreSporeDataPath != null)
234-
return LauncherSettings.ForcedCoreSporeDataPath;
235-
else
236-
return Path.Combine(new string[] {installationDirectory, "Data"});
233+
return Path.Combine(new string[] {installationDirectory, "Data"});
237234
}
238235
else if (game == Game.GalacticAdventures)
239236
{
240-
if (LauncherSettings.ForcedGalacticAdventuresDataPath != null)
241-
return LauncherSettings.ForcedGalacticAdventuresDataPath;
237+
// Steam and GoG uses DataEP1
238+
string outputPath = Path.Combine(new string[] { installationDirectory, "DataEP1" });
239+
if (Directory.Exists(outputPath))
240+
{
241+
return outputPath;
242+
}
242243
else
243244
{
244-
// Steam and GoG uses DataEP1
245-
string outputPath = Path.Combine(new string[] { installationDirectory, "DataEP1" });
246-
if (Directory.Exists(outputPath))
247-
{
248-
return outputPath;
249-
}
250-
else
251-
{
252-
return Path.Combine(new string[] { installationDirectory, "Data" });
253-
}
245+
return Path.Combine(new string[] { installationDirectory, "Data" });
254246
}
255247
}
256248
else

Spore ModAPI Easy Installer/XmlInstallerWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public XmlInstallerWindow(string modName, bool configure, bool uninstall)
7070
//LauncherSettings.Load();
7171
installerWindows.Add(this);
7272

73-
if ((LauncherSettings.ForcedCoreSporeDataPath == null) && (!Directory.Exists(SporeDataPath)))
73+
if (!Directory.Exists(SporeDataPath))
7474
PathDialogs.ProcessSpore();
75-
if ((LauncherSettings.ForcedGalacticAdventuresDataPath == null) && (!Directory.Exists(GaDataPath)))
75+
if (!Directory.Exists(GaDataPath))
7676
PathDialogs.ProcessGalacticAdventures();
7777

7878
ModName = modName.Trim('"');

Spore ModAPI Launcher/Program.cs

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,59 +74,37 @@ void Execute()
7474
// We try a new approach for Steam users.
7575
// Before, we used Steam to launch the game and tried to find the new process and inject it.
7676
// However, when the injection happens the game already executed a bit, so mods fail.
77-
// Instead, we create a steam_appid.txt that allows us to execute SporeApp.exe directly
78-
79-
if (LauncherSettings.ForcedGalacticAdventuresSporeAppPath != null)
80-
this.ExecutablePath = LauncherSettings.ForcedGalacticAdventuresSporeAppPath;
81-
82-
if (LauncherSettings.ForcedSporebinEP1Path == null)
83-
{
84-
this.ProcessSporebinPath();
85-
}
86-
else
87-
{
88-
SporebinPath = LauncherSettings.ForcedSporebinEP1Path;
89-
}
77+
// Instead, we create a steam_appid.txt that allows us to execute SporeApp.exe directly
78+
SporebinPath = PathDialogs.ProcessGalacticAdventures();
9079

9180
// use the default path for now (we might have to use a different one for Origin)
92-
if (LauncherSettings.ForcedGalacticAdventuresSporeAppPath == null)
93-
{
94-
this.ExecutablePath = this.SporebinPath + "SporeApp.exe";
95-
96-
this.ProcessExecutableType();
97-
81+
this.ExecutablePath = this.SporebinPath + "SporeApp.exe";
82+
this.ProcessExecutableType();
9883

99-
if (this._executableType == GameVersionType.None)
100-
{
101-
// don't execute the game if the user closed the dialog
102-
return;
103-
}
104-
}
105-
else
84+
if (this._executableType == GameVersionType.None)
10685
{
107-
this._executableType = LauncherSettings.GameVersion;
86+
// don't execute the game if the user closed the dialog
87+
return;
10888
}
10989

11090
// get the correct executable path
111-
if (LauncherSettings.ForcedGalacticAdventuresSporeAppPath == null)
91+
this.ExecutablePath = this.SporebinPath + GameVersion.ExecutableNames[(int)this._executableType];
92+
if (!File.Exists(this.ExecutablePath))
11293
{
113-
this.ExecutablePath = this.SporebinPath + GameVersion.ExecutableNames[(int)this._executableType];
114-
if (!File.Exists(this.ExecutablePath))
94+
// the file might only not exist in Origin (since Origin users will use a different executable compatible with ModAPI)
95+
if (GameVersion.RequiresModAPIFix(this._executableType))
11596
{
116-
// the file might only not exist in Origin (since Origin users will use a different executable compatible with ModAPI)
117-
if (GameVersion.RequiresModAPIFix(this._executableType))
118-
{
119-
if (!HandleOriginUsers())
120-
{
121-
return;
122-
}
123-
}
124-
else
97+
if (!HandleOriginUsers())
12598
{
126-
throw new Exception(CommonStrings.GalacticAdventuresNotFound);
99+
return;
127100
}
128101
}
102+
else
103+
{
104+
throw new Exception(CommonStrings.GalacticAdventuresNotFound);
105+
}
129106
}
107+
130108

131109
// we must also check if the steam_api.dll doesn't exist (it's required for Origin users)
132110
if (GameVersion.RequiresModAPIFix(this._executableType) && !File.Exists(this.SporebinPath + "steam_api.dll"))
@@ -292,14 +270,8 @@ void CreateSporeProcess()
292270
i++;
293271
}
294272

295-
string currentSporebinPath = string.Empty;
296-
if (LauncherSettings.ForcedSporebinEP1Path != null)
297-
currentSporebinPath = LauncherSettings.ForcedSporebinEP1Path;
298-
else
299-
currentSporebinPath = this.SporebinPath;
300-
301273
if (!NativeMethods.CreateProcess(null, "\"" + this.ExecutablePath + "\" " + sb,
302-
IntPtr.Zero, IntPtr.Zero, false, NativeTypes.ProcessCreationFlags.CREATE_SUSPENDED, IntPtr.Zero, currentSporebinPath, ref this.StartupInfo, out this.ProcessInfo))
274+
IntPtr.Zero, IntPtr.Zero, false, NativeTypes.ProcessCreationFlags.CREATE_SUSPENDED, IntPtr.Zero, this.SporebinPath, ref this.StartupInfo, out this.ProcessInfo))
303275
{
304276
//throw new InjectException(Strings.ProcessNotStarted);
305277
int lastError = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

0 commit comments

Comments
 (0)