Skip to content

Commit

Permalink
Optimized stuff and disabled NKH until fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrenm3 authored and Gurrenm3 committed May 16, 2020
1 parent 5ffbf23 commit 6f9b5db
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Classes/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static string SetGameDir(string game)
path = Steam.GetGameDir(Steam.BMCAppID);
break;
}
if (path == "" || path == null)
if (!Guard.IsStringValid(path))
{
Log.Output("Failed to automatically find " + Settings.game.GameName);
MessageBox.Show("Failed to automatically find " + Settings.game.GameName + " . Please browse for the game's .exe file to set the game directory");
Expand Down
3 changes: 2 additions & 1 deletion Classes/JetReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ public void DoWork()
{
new Thread(() =>
{
Thread t1;
Thread t2 = new Thread(MakeMod);
t2.Start();
if (MainWindow.resetGameFiles)
{
Thread t1 = new Thread(Game.ResetGameFiles);
t1 = new Thread(Game.ResetGameFiles);
t1.Start();
t1.Join();
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/NKHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace TD_Loader.Classes
{
class NKHook
{
public static bool enableNKH = false;
public static string nkhDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NKHook5";
public static string nkhEXE = nkhDir + "\\NKHook5-Injector.exe";
public static string pathTowerLoadPlugin = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NKHook5\\Plugins\\NewTowerLoader.dll";
Expand Down Expand Up @@ -39,7 +40,7 @@ public static bool DoesNkhExist()
}
public static bool CanUseNKH()
{
if (Settings.game.GameName != "BTD5" || Settings.game == null)
if (!enableNKH || Settings.game.GameName != "BTD5" || Settings.game == null)
return false;

if (!DoesNkhExist())
Expand Down
6 changes: 3 additions & 3 deletions Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static void SaveGameFile()
{
settings.GameName = game.GameName;
settings.BTD5Version = game.GameVersion;
settings.BTD5Dir = game.GameDir;
settings.BTD5Dir = game.GameDir.Replace("\\\\", "\\");
settings.BTD5BackupDir = game.GameBackupDir;
settings.BTD5ModsDir = game.ModsDir;
settings.BTD5LoadedMods = game.LoadedMods;
Expand All @@ -143,7 +143,7 @@ public static void SaveGameFile()
{
settings.GameName = game.GameName;
settings.BTDBVersion = game.GameVersion;
settings.BTDBDir = game.GameDir;
settings.BTDBDir = game.GameDir.Replace("\\\\", "\\"); ;
settings.BTDBBackupDir = game.GameBackupDir;
settings.BTDBModsDir = game.ModsDir;
settings.BTDBLoadedMods = game.LoadedMods;
Expand All @@ -152,7 +152,7 @@ public static void SaveGameFile()
{
settings.GameName = game.GameName;
settings.BMCVersion = game.GameVersion;
settings.BMCDir = game.GameDir;
settings.BMCDir = game.GameDir.Replace("\\\\", "\\"); ;
settings.BMCBackupDir = game.GameBackupDir;
settings.BMCModsDir = game.ModsDir;
settings.BMCLoadedMods = game.LoadedMods;
Expand Down
2 changes: 2 additions & 0 deletions Classes/log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static void Print(string output, bool canRepeat, bool Notice)
if (!canRepeat && output == log.lastMessage)
return;

if (output == "input string is null" || output == "input string is empty")
return;

MainWindow.instance.OutputLog.Dispatcher.BeginInvoke((Action)(() =>
{
Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
VerticalAlignment="Top" Margin="-5,0,0,0" Background="{x:Null}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left"
VerticalAlignment="Bottom" Margin="0,0">
<CheckBox x:Name="ResetGameFiles_CB" Content="Reset Game Files" Foreground="White" FontSize="18" Click="ResetGameFiles_CB_Click" />
<CheckBox x:Name="ResetGameFiles_CB" Content="Reset Game Files" Foreground="White" FontSize="18" Click="ResetGameFiles_CB_Click" ToolTip="Check this to replace your game files with the backup when launching. Useful for switching between mods" />
<Button x:Name="Launch_Button" Margin="0,0" FontSize="25" Content="Launch" MinHeight="45" MinWidth="160" Background="#FF68C93A" Foreground="White" Click="Launch_Button_Clicked"/>
</StackPanel>

Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void CreatePluginsTab()
}
private void ShowHidePlugins()
{
if (Settings.game.GameName == "BTD5" && Settings.game != null)
if (NKHook.CanUseNKH() && Settings.game.GameName == "BTD5" && Settings.game != null)
{
Plugins_Tab.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { Plugins_Tab.Visibility = Visibility.Visible; }));
LaunchGrid.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { LaunchGrid.MinHeight = 195; }));
Expand Down
1 change: 1 addition & 0 deletions Mods_UserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void PopulateMods(string game)
return;

Mods_ListBox.Items.Clear();
SelectedMods_ListBox.Items.Clear();
modPaths = new List<string>();
modItems = new List<ModItem_UserControl>();
var mods = new DirectoryInfo(Settings.game.ModsDir).GetFiles("*.*");
Expand Down
3 changes: 3 additions & 0 deletions Plugins_UserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public Plugins_UserControl()
}
public void PopulateMods()
{
if (Settings.game.GameName != "BTD5")
return;

modPaths = new List<string>();
Plugins_ListBox.Items.Clear();
SelectedPlugins_ListBox.Items.Clear();
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,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("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]

0 comments on commit 6f9b5db

Please sign in to comment.