Skip to content

Commit

Permalink
Modnix 2.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheep-y committed Feb 19, 2021
2 parents a646083 + 4e1f947 commit 59b9130
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 28 deletions.
31 changes: 14 additions & 17 deletions Injector/Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,7 @@ private static string FindGameVersion1 ( MethodDefinition method ) { try {
var op = code.OpCode.ToString();
if ( ! op.StartsWith( "ldc.i4" ) ) continue;
if ( ldcCount >= 2 ) return "ERR too many vers";

var ver = 0;
if ( code.Operand is int num ) ver = num;
else if ( code.Operand is sbyte num2 ) ver = num2;
else if ( code.OpCode.Code.Equals( Code.Ldc_I4_M1 ) ) ver = -1;
else ver = int.Parse( op.Substring( 7 ) );

version[ ldcCount ] = ver;
version[ ldcCount ] = ParseI4Param( code );
++ldcCount;
}
if ( ldcCount < 2 ) return "ERR too few vers";
Expand All @@ -539,24 +532,28 @@ private static string FindGameVersion2 ( MethodDefinition method ) { try {
foreach ( var code in method.Body.Instructions ) {
var op = code.OpCode.ToString();
if ( ! op.StartsWith( "ldc.i4" ) ) continue;
if ( ldcCount > 7 ) return "ERR too many vers";

var ver = 0;
if ( code.Operand is int num ) ver = num;
else if ( code.Operand is sbyte num2 ) ver = num2;
else if ( code.OpCode.Code.Equals( Code.Ldc_I4_M1 ) ) ver = -1;
else ver = int.Parse( op.Substring( 7 ) );
var ver = ParseI4Param( code );
switch ( ldcCount ) {
case 0 : version[ 0 ] = ver; break;
case 1 : version[ 1 ] = ver; break;
case 2 : version[ 0 ] = ver; break;
case 4 : version[ 1 ] = ver; break;
case 6 : version[ 2 ] = ver; break;
}
++ldcCount;
}
if ( ldcCount <= 7 ) return "ERR too few vers";
return version[0].ToString() + '.' + version[1] + '.' + version[2];
if ( ldcCount == 2 ) return version[0].ToString() + '.' + version[1] + ".0"; // 1.10 Orryx
if ( ldcCount == 8 ) return version[0].ToString() + '.' + version[1] + '.' + version[2]; // Up till 1.9.3 Polaris
return $"ERR opcode {ldcCount} <> 2 or 8";
} catch ( Exception e ) {
return $"ERR {e.GetType()}";
} }

private static int ParseI4Param ( Instruction code ) {
if ( code.Operand is int num ) return num;
if ( code.Operand is sbyte num2 ) return num2;
if ( code.OpCode.Code.Equals( Code.Ldc_I4_M1 ) ) return -1;
return int.Parse( code.OpCode.ToString().Substring( 7 ) );
}
}
}
4 changes: 2 additions & 2 deletions Injector/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "2.5.3.0" )]
[assembly: AssemblyFileVersion( "2.5.3.0" )]
[assembly: AssemblyVersion( "2.5.7.0" )]
[assembly: AssemblyFileVersion( "2.5.7.0" )]
26 changes: 23 additions & 3 deletions MainGUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public partial class AppControl : Application {
internal const string MOD_LOG = "ModnixLoader.log";
internal const string GAME_LOG = "Console.log";
internal const string EPIC_DIR = ".egstore";
internal const string GOGG_DLL = "Galaxy64.dll";

private string[] UNSAFE_DLL = new string[] { AppRes.LOADER, AppRes.INJECTOR, AppRes.CECI_DLL, AppRes.HARM_DLL, JBA_DLL, PAST, PAST_DL1, PAST_DL2, DOOR_DLL, DOOR_CNF };
internal readonly string ModFolder = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments ), MOD_PATH );
Expand Down Expand Up @@ -357,8 +358,11 @@ private bool FoundGame ( out string gamePath ) { try {
private string SearchRegistry () { try {
Log( "Checking Steam registry" );
using ( RegistryKey steam = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\WOW6432Node\\Valve\\Steam" ) ) {
var path = Path.Combine( steam?.GetValue( "InstallPath" )?.ToString(), "steamapps", "common", "Phoenix Point" );
if ( IsGamePath( path ) ) return path;
var path = steam?.GetValue( "InstallPath" )?.ToString();
if ( path != null ) {
path = Path.Combine( path, "steamapps", "common", "Phoenix Point" );
if ( IsGamePath( path ) ) return path;
}
}
Log( "Checking Steam App Uninstall registry" );
using ( RegistryKey steamPP = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 839770" ) ) {
Expand Down Expand Up @@ -407,6 +411,20 @@ internal void LaunchGame ( string type ) { try {
Log( "Launching through Epic Games" );
Process.Start( Settings.EgsCommand ?? "com.epicgames.launcher://apps/Iris?action=launch", Settings.EgsParameter );
return;
} else if ( CurrentGame.GameType == "gog" ) {
Log( "Launching through Gog Galaxy" );
var launcher = Settings.GogExe;
var param = ( Settings.GogParameter ?? "/gameId=1795581746 /command=runGame /path=\"%GAME_PATH%\"" )
.Replace( "%GAME_PATH%", Path.Combine( CurrentGame.GameDir, GAME_EXE ).Replace( "\"", "\"\"" ) );
if ( string.IsNullOrWhiteSpace( launcher ) )
using ( RegistryKey reg = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\Wow6432Node\\GOG.com\\GalaxyClient\\paths" ) )
launcher = Path.Combine( reg?.GetValue( "client" )?.ToString(), "GalaxyClient.exe" );
var path = File.Exists( launcher ) ? launcher : "C:/Program Files (x86)/GOG Galaxy/GalaxyClient.exe".FixSlash();
if ( File.Exists( path ) )
Process.Start( path, param );
else
MessageBox.Show( "Not found: " + launcher, "Error", MessageBoxButton.OK, MessageBoxImage.Error );
return;
} else {
Log( "Launching through Steam" );
Process.Start( Settings.SteamCommand ?? "steam://rungameid/839770" );
Expand Down Expand Up @@ -860,7 +878,9 @@ internal string Status {
internal string GameType { get {
if ( Directory.Exists( Path.Combine( GameDir, AppControl.EPIC_DIR ) ) )
return "epic";
return "offline";
else if ( File.Exists( Path.Combine( GameDir, AppControl.GOGG_DLL ) ) )
return "gog";
return "unknown";
} }

internal string RunInjector ( string param ) {
Expand Down
3 changes: 3 additions & 0 deletions MainGUI/MainGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@
<Resource Include="Resources\img\console.png" />
<Resource Include="Resources\img\cross.png" />
<Resource Include="Resources\img\discord.png" />
<Resource Include="Resources\img\epic.png" />
<Resource Include="Resources\img\eraser.png" />
<Resource Include="Resources\img\floppy.png" />
<Resource Include="Resources\img\folder.png" />
<Resource Include="Resources\img\gear.png" />
<Resource Include="Resources\img\gears.png" />
<Resource Include="Resources\img\gog.png" />
<Resource Include="Resources\img\info.png" />
<Resource Include="Resources\img\log_file.png" />
<Resource Include="Resources\img\modder.png" />
Expand All @@ -142,6 +144,7 @@
<Resource Include="Resources\img\redo.png" />
<Resource Include="Resources\img\reload.png" />
<Resource Include="Resources\img\snapshot.png" />
<Resource Include="Resources\img\steam.png" />
<Resource Include="Resources\img\twitter.png" />
<Resource Include="Resources\img\uncheck.png" />
<Resource Include="Resources\img\undo.png" />
Expand Down
2 changes: 1 addition & 1 deletion MainGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</Grid.ColumnDefinitions>
<Button x:Name="ButtonRunOnline" Padding="10,5" Click="ButtonOnline_Click" IsEnabled="False" TabIndex="400">
<StackPanel Orientation="Horizontal">
<Image Source="Resources/img/phoenix_point.png" Width="16" Margin="0,0,5,0"/>
<Image Source="Resources/img/phoenix_point.png" Width="16" Margin="0,0,5,0" Name="IconRunOnline"/>
<AccessText Text="_Launch"/>
</StackPanel>
</Button>
Expand Down
9 changes: 8 additions & 1 deletion MainGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void RefreshAppButtons () { try {

RefreshConfButtions();

ButtonAddMod.IsEnabled = SharedGui.CanModify && Directory.Exists( App.ModFolder );
ButtonAddMod.IsEnabled = SharedGui.CanModify;
ButtonModDir.IsEnabled = Directory.Exists( App.ModFolder );
ButtonRefreshMod.IsEnabled = Directory.Exists( App.ModFolder ) && ! SharedGui.IsAppWorking;

Expand Down Expand Up @@ -311,6 +311,7 @@ public void Prompt ( AppAction action, PromptFlag flags = PromptFlag.NONE, Excep
private void RefreshGameInfo () { try {
Log( "Refreshing game info" );
var p = new Paragraph( new Bold( new Run( "Phoenix Point" ) ) );
var img = "phoenix_point.png";
if ( SharedGui.IsGameFound ) {
if ( SharedGui.GameVer != null )
p.Inlines.Add( $"\tVer {SharedGui.GameVer}" );
Expand All @@ -320,8 +321,14 @@ private void RefreshGameInfo () { try {
p.Inlines.Add( "\r" );
p.Inlines.Add( txt );
}
switch ( App.CurrentGame.GameType ) {
case "epic" : img = "epic.png"; break;
case "gog" : img = "gog.png"; break;
default : img = "steam.png"; break;
}
} else
p.Inlines.Add( new Run( "\rGame not found" ){ Foreground = Brushes.Red } );
IconRunOnline.Source = new BitmapImage( new Uri( $"/Resources/img/{img}", UriKind.Relative ) );
RichGameInfo.Document.Replace( p );
} catch ( Exception ex ) { Log( ex ); } }

Expand Down
4 changes: 2 additions & 2 deletions MainGUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "2.5.6.0" )]
[assembly: AssemblyFileVersion( "2.5.6.0" )]
[assembly: AssemblyVersion( "2.5.7.0" )]
[assembly: AssemblyFileVersion( "2.5.7.0" )]
[assembly: NeutralResourcesLanguage( "en" ) ]
7 changes: 7 additions & 0 deletions MainGUI/Resources/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Modnix Changelog

# Version 2.5.7, 2021-02-19

* New: Support GOG Galaxy online launch. Thanks mad2342 for helping with detection.
* New: Detect Phoenix Point 1.10 Orryx version.
* Fix: Fix game path detection error when Steam is not installed for current user.
* Fix: Make sure Add Mods button is enabled on non-standard installation path.

# Version 2.5.6, 2021-01-25

* New: Identify and disable Modnix 3 mod packs.
Expand Down
Binary file added MainGUI/Resources/img/epic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MainGUI/Resources/img/gog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MainGUI/Resources/img/steam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ModLoader/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class LoaderSettings {
public double WindowHeight = -1;
public string OfflineParameter = "";
public string SteamCommand = "steam://rungameid/839770";
public string GogExe = null;
public string GogParameter = "/gameId=1795581746 /command=runGame /path=\"%GAME_PATH%\"";
public string EgsCommand = "com.epicgames.launcher://apps/Iris?action=launch";
public string EgsParameter = "";
// For mod loader, set by manager
Expand Down
4 changes: 2 additions & 2 deletions ModLoader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "2.5.6.0" )]
[assembly: AssemblyFileVersion( "2.5.6.0" )]
[assembly: AssemblyVersion( "2.5.7.0" )]
[assembly: AssemblyFileVersion( "2.5.7.0" )]

0 comments on commit 59b9130

Please sign in to comment.