Skip to content

Commit

Permalink
TODO - Optimize search for Json mod for ns ver.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigSpice committed Jan 24, 2024
1 parent dc78b29 commit 92bacc9
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 40 deletions.
Binary file modified VTOL_2.0.0/.vs/ProjectEvaluation/vtol.metadata.v7.bin
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/ProjectEvaluation/vtol.projects.v7.bin
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/VTOL/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/VTOL/v17/fileList.bin
Binary file not shown.
60 changes: 31 additions & 29 deletions VTOL_2.0.0/Pages/Page_Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2436,14 +2436,16 @@ public void Launch_Northstar_()
public bool Check_Process_Running(string ProcessName)
{
Process[] pname = Process.GetProcessesByName(ProcessName);
if (pname.Length == 0)
{
return false;
}
else
if (pname.Length != 0)
{
GC.Collect();
return true;
}
pname = null;
GC.Collect();
return false;


}


Expand Down Expand Up @@ -4089,39 +4091,39 @@ private void Browse_Titanfall_Install_Click(object sender, RoutedEventArgs e)

private void EA_ORGIGIN_Client_Card_Loaded(object sender, RoutedEventArgs e)
{
if (Properties.Settings.Default.EA_APP_SUPPORT == true)
{
EA_ORGIGIN_Client_Card.Content = VTOL.Resources.Languages.Language.Page_Home_Page_Home_EAClientRunning;
BitmapImage bitmapx = new BitmapImage();
//if (Properties.Settings.Default.EA_APP_SUPPORT == true)
//{
// EA_ORGIGIN_Client_Card.Content = VTOL.Resources.Languages.Language.Page_Home_Page_Home_EAClientRunning;
// BitmapImage bitmapx = new BitmapImage();

bitmapx.BeginInit();
bitmapx.UriSource = new Uri(@"pack://application:,,,/Resources/Icons/EA.ico");
bitmapx.EndInit();
CLIENT_CARD_IMAGE.Source = bitmapx;
// bitmapx.BeginInit();
// bitmapx.UriSource = new Uri(@"pack://application:,,,/Resources/Icons/EA.ico");
// bitmapx.EndInit();
// CLIENT_CARD_IMAGE.Source = bitmapx;


}
else
{
BitmapImage bitmapy = new BitmapImage();
//}
//else
//{
// BitmapImage bitmapy = new BitmapImage();

bitmapy.BeginInit();
bitmapy.UriSource = new Uri(@"pack://application:,,,/Resources/Icons/Origin.ico");
bitmapy.EndInit();
CLIENT_CARD_IMAGE.Source = bitmapy;
// bitmapy.BeginInit();
// bitmapy.UriSource = new Uri(@"pack://application:,,,/Resources/Icons/Origin.ico");
// bitmapy.EndInit();
// CLIENT_CARD_IMAGE.Source = bitmapy;

EA_ORGIGIN_Client_Card.Content = VTOL.Resources.Languages.Language.Page_Home_OriginClientRunning;
// EA_ORGIGIN_Client_Card.Content = VTOL.Resources.Languages.Language.Page_Home_OriginClientRunning;


}
//}

BackgroundWorker worker_o = new BackgroundWorker();
worker_o.DoWork += (sender, e) =>
{
Check_EA_status();
};
//BackgroundWorker worker_o = new BackgroundWorker();
//worker_o.DoWork += (sender, e) =>
//{
// Check_EA_status();
//};

worker_o.RunWorkerAsync();
//worker_o.RunWorkerAsync();
}

private void Exit_BTN_Click(object sender, RoutedEventArgs e)
Expand Down
8 changes: 5 additions & 3 deletions VTOL_2.0.0/Pages/Page_Mods.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -459,10 +460,11 @@ public async Task Call_Mods_From_Folder()

System.IO.DirectoryInfo[] subDirs = null;
subDirs = rootDirs.GetDirectories().Concat(NS_Dirs.GetDirectories()).ToArray();



if (subDirs.Count() > 0)



if (subDirs.Count() > 0)
{
string Json_Path = FindFirstFile(User_Settings_Vars.NorthstarInstallLocation + @"R2Northstar\", "enabledmods.json");

Expand Down
68 changes: 60 additions & 8 deletions VTOL_2.0.0/Pages/Page_Thunderstore.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Runtime.ExceptionServices;
using System.Security.Policy;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -32,6 +33,7 @@
using System.Windows.Threading;
using System.Xml.Linq;
using Threading;
using VTOL.Titanfall2_Requisite.WeaponData.Default.AntiTitan;
using Windows.Foundation.Collections;
using static VTOL.MainWindow;
using static VTOL.Pages.Page_Mods;
Expand Down Expand Up @@ -1244,7 +1246,7 @@ static int versionCompare(string v1, string v2)
// part of version

int vnum1 = 0, vnum2 = 0;

if(v1 == null || v2 == null) { return 3; }
// loop until both string are
// processed

Expand Down Expand Up @@ -1311,10 +1313,42 @@ private void Compare_Mod_To_List(string modname, string Mod_version_current, Has
{



bool Northstar_flagged = false;
foreach (var item in list)
{

if (modname.Equals(@"Northstar") && Northstar_flagged == false)
{
if (String.Equals(item.Name.Split(".")[0], modname, StringComparison.OrdinalIgnoreCase))
{
string version = item.Version;
int result = versionCompare(version, Mod_version_current);
switch (result)
{
case 1:
res = "Re-Install";
bg = "#FFAD7F1A";
break;
case -1:
res = "Update";
bg = "#FF009817";

break;
case 0:
res = "Re-Install";
bg = "#FFAD7F1A";

break;
default:
res = "Install";
bg = "#FF005D42";

break;
}
label = res;
bg_color = bg;
Northstar_flagged = true;
}
}
if (String.Equals(item.Name, modname, StringComparison.OrdinalIgnoreCase))
{
string version = item.Version;
Expand Down Expand Up @@ -2944,26 +2978,44 @@ async Task Call_Mods_From_Folder_Lite()
System.IO.DirectoryInfo[] subDirs = null;
subDirs = rootDirs.GetDirectories().Concat(NS_Dirs.GetDirectories()).ToArray();


bool read_NS_version = true;
foreach (System.IO.DirectoryInfo dirInfo in subDirs)
{
string[] parts = dirInfo.Name.Split('-');
string name = dirInfo.Name;
string author = null;
string ver = null;

if (parts.Length > 1)
{
author = parts[0];
name = parts[1];
ver = parts[2];
}


Main.Current_Installed_Mods.Add(new GENERAL_MOD { Name = name, Version = ver, Author= author });
if (name.Contains("Northstar.") && dirInfo.Parent.Name.Equals(@"mods") && read_NS_version == true)
{
parts = null;
parts = dirInfo.Name.Split('.');
author = parts[0];
name = dirInfo.Name;
string json = File.ReadAllText(dirInfo.FullName + @"\mod.json");
// Parse the JSON
dynamic data = JsonConvert.DeserializeObject(json);

// Access the value
ver = data["Version"];
if (ver != null) { read_NS_version = false; }

}




Main.Current_Installed_Mods.Add(new GENERAL_MOD { Name = name, Version = ver, Author = author });
GC.Collect();

}
Main.loaded_mods = true;

}


Expand Down

0 comments on commit 92bacc9

Please sign in to comment.