1- namespace ModAPI . Common
1+ using System . IO ;
2+
3+ namespace ModAPI . Common
24{
35 public enum GameVersionType
46 {
@@ -24,9 +26,9 @@ public enum GameVersionType
2426
2527 public static class GameVersion
2628 {
27-
2829
29- public static int [ ] ExecutableSizes = {
30+
31+ private static readonly int [ ] ExecutableSizes = {
3032 /* DISC*/ 24909584 ,
3133 /* ORIGIN */ 31347984 ,
3234 /* ORIGIN_P */ 24898224 ,
@@ -36,7 +38,7 @@ public static class GameVersion
3638 /* GOG_OCT24 */ 24895536 ,
3739 /* STEAM_OCT24 */ 25066744 } ;
3840
39- public static string [ ] VersionNames = {
41+ private static readonly string [ ] VersionNames = {
4042 "disk" ,
4143 "steam_patched" , // origin uses the steam_patched one
4244 "steam_patched" , // origin uses the steam_patched one
@@ -49,7 +51,7 @@ public static class GameVersion
4951 } ;
5052
5153 // Origin users download an alternative executable, so it uses a different name
52- public static string [ ] ExecutableNames = {
54+ private static readonly string [ ] ExecutableNames = {
5355 "SporeApp.exe" ,
5456 "SporeApp_ModAPIFix.exe" , // origin uses a different one
5557 "SporeApp_ModAPIFix.exe" , // origin uses a different one
@@ -70,39 +72,50 @@ public static bool RequiresModAPIFix(GameVersionType versionType)
7072
7173 public static GameVersionType DetectVersion ( string path )
7274 {
73- if ( path == null )
75+ if ( ! string . IsNullOrEmpty ( path ) )
7476 {
75- return GameVersionType . None ;
76- }
77- var length = new System . IO . FileInfo ( path ) . Length ;
77+ var length = new FileInfo ( path ) . Length ;
7878
79- for ( int i = 0 ; i < ExecutableSizes . Length ; i ++ )
80- {
81- if ( length == ExecutableSizes [ i ] )
79+ for ( int i = 0 ; i < ExecutableSizes . Length ; i ++ )
8280 {
83- return ( GameVersionType ) i ;
81+ if ( length == ExecutableSizes [ i ] )
82+ {
83+ return ( GameVersionType ) i ;
84+ }
8485 }
8586 }
8687
8788 return GameVersionType . None ;
8889 }
8990
91+ public static string GetVersionName ( GameVersionType type )
92+ {
93+ return VersionNames [ ( int ) type ] ;
94+ }
95+
96+ public static string GetExecutableFileName ( GameVersionType type )
97+ {
98+ return ExecutableNames [ ( int ) type ] ;
99+ }
100+
90101 public static string GetNewDLLName ( GameVersionType type )
91102 {
92103 if ( type == GameVersionType . Disc )
104+ {
93105 return "SporeModAPI.disk.dll" ;
94- else if ( ( type == GameVersionType . Origin ) ||
106+ }
107+ else if ( ( type == GameVersionType . Origin ) ||
95108 ( type == GameVersionType . Origin_Patched ) ||
96- ( type == GameVersionType . EA_Oct24 ) ||
97- ( type == GameVersionType . Steam_Patched ) ||
98- ( type == GameVersionType . GoG_Oct24 ) ||
109+ ( type == GameVersionType . EA_Oct24 ) ||
110+ ( type == GameVersionType . Steam_Patched ) ||
111+ ( type == GameVersionType . GoG_Oct24 ) ||
99112 ( type == GameVersionType . Steam_Oct24 ) )
113+ {
100114 return "SporeModAPI.march2017.dll" ;
115+ }
101116 else
102117 {
103- System . Windows . Forms . MessageBox . Show ( "Your current Spore game version is not compatible with this Launcher Kit version. If you downloaded the game from EA App, Steam, or GOG, please update to version 3.1.0.29 to proceed. If you're using a higher version of Spore, please see https://launcherkit.sporecommunity.com/support." , "Unsupported Game Version" ) ;
104- System . Diagnostics . Process . GetCurrentProcess ( ) . Kill ( ) ;
105- return string . Empty ;
118+ return null ;
106119 }
107120 }
108121 }
0 commit comments