mirror of
https://github.com/4sval/FModel.git
synced 2026-03-22 01:34:37 -05:00
added check if pak is locked
fixed dynamic keys not being deleted fixed crash with loading paks and locres reverted searching for a featured icon
This commit is contained in:
parent
d960570ed2
commit
cd7835032c
|
|
@ -72,6 +72,10 @@ namespace FModel.Forms
|
|||
{
|
||||
DynamicKeysManager.serialize(txtBox.Text.Substring(2).ToUpper(), dCurrentUsedPak);
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicKeysManager.serialize("", dCurrentUsedPak);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,14 +115,11 @@ namespace FModel.Forms
|
|||
if (checkBox8.Checked == false)
|
||||
Properties.Settings.Default.loadFeaturedImage = false;
|
||||
|
||||
//LOCRES
|
||||
Properties.Settings.Default.IconLanguage = comboBox1.SelectedItem.ToString();
|
||||
LoadLocRes.LoadMySelectedLocRes(Properties.Settings.Default.IconLanguage);
|
||||
|
||||
Properties.Settings.Default.Save(); //SAVE
|
||||
|
||||
if (ThePak.AllpaksDictionary != null)
|
||||
{
|
||||
LoadLocRes.LoadMySelectedLocRes(Properties.Settings.Default.IconLanguage);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ namespace FModel
|
|||
/// </summary>
|
||||
/// <param name="thePaks"></param>
|
||||
/// <param name="index"></param>
|
||||
private void AddPaKs(IEnumerable<string> thePaks, int index)
|
||||
private void AddPaKs(string thePak)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
loadOneToolStripMenuItem.DropDownItems.Add(Path.GetFileName(thePaks.ElementAt(index)));
|
||||
loadOneToolStripMenuItem.DropDownItems.Add(thePak);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
@ -118,19 +118,23 @@ namespace FModel
|
|||
IEnumerable<string> yourPaKs = Directory.GetFiles(Settings.Default.PAKsPath).Where(x => x.EndsWith(".pak"));
|
||||
for (int i = 0; i < yourPaKs.Count(); i++)
|
||||
{
|
||||
AddPaKs(yourPaKs, i); //add to toolstrip
|
||||
|
||||
string arCurrentUsedPak = yourPaKs.ElementAt(i); //SET CURRENT PAK
|
||||
string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + Path.GetFileName(arCurrentUsedPak)); //SET CURRENT PAK GUID
|
||||
if (!Utilities.IsFileLocked(new System.IO.FileInfo(arCurrentUsedPak)))
|
||||
{
|
||||
string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + Path.GetFileName(arCurrentUsedPak)); //SET CURRENT PAK GUID
|
||||
|
||||
if (arCurrentUsedPakGuid == "0-0-0-0")
|
||||
{
|
||||
ThePak.mainPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid));
|
||||
}
|
||||
if (arCurrentUsedPakGuid != "0-0-0-0")
|
||||
{
|
||||
ThePak.dynamicPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid));
|
||||
if (arCurrentUsedPakGuid == "0-0-0-0")
|
||||
{
|
||||
ThePak.mainPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid));
|
||||
AddPaKs(Path.GetFileName(arCurrentUsedPak)); //add to toolstrip
|
||||
}
|
||||
if (arCurrentUsedPakGuid != "0-0-0-0")
|
||||
{
|
||||
ThePak.dynamicPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid));
|
||||
AddPaKs(Path.GetFileName(arCurrentUsedPak)); //add to toolstrip
|
||||
}
|
||||
}
|
||||
else { AppendText(Path.GetFileName(arCurrentUsedPak) + " is locked by another process.", Color.Red, true); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -273,6 +277,9 @@ namespace FModel
|
|||
private void RegisterPaKsinDict(ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ThePak.CurrentUsedPak = null;
|
||||
ThePak.CurrentUsedPakGuid = null;
|
||||
bool bMainKeyWorking = false;
|
||||
|
||||
for (int i = 0; i < ThePak.mainPaksList.Count; i++)
|
||||
{
|
||||
|
|
@ -292,6 +299,8 @@ namespace FModel
|
|||
string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray();
|
||||
if (CurrentUsedPakLines != null)
|
||||
{
|
||||
bMainKeyWorking = true;
|
||||
|
||||
JohnWick.MyKey = Settings.Default.AESKey;
|
||||
string mountPoint = JohnWick.MyExtractor.GetMountPoint();
|
||||
ThePak.PaksMountPoint.Add(ThePak.mainPaksList[i].thePak, mountPoint.Substring(9));
|
||||
|
|
@ -326,6 +335,8 @@ namespace FModel
|
|||
if (theSinglePak != null && ThePak.mainPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; }
|
||||
}
|
||||
}
|
||||
if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); }
|
||||
|
||||
if (theSinglePak != null) //IMPORTANT: IT STILLS LOAD THE DICTIONARY -> IT'S GONNA BE USEFUL FOR TRANSLATIONS
|
||||
{
|
||||
ThePak.CurrentUsedPak = theSinglePak.ClickedItem.Text;
|
||||
|
|
@ -337,7 +348,7 @@ namespace FModel
|
|||
{
|
||||
foreach (AESEntry s in DynamicKeysManager.AESEntries)
|
||||
{
|
||||
if (s.thePak == ThePak.CurrentUsedPak)
|
||||
if (s.thePak == ThePak.CurrentUsedPak && s.theKey.Length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -358,7 +369,7 @@ namespace FModel
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//do not crash
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -368,11 +379,8 @@ namespace FModel
|
|||
if (loadAllPaKs)
|
||||
{
|
||||
File.WriteAllText(App.DefaultOutputPath + "\\FortnitePAKs.txt", sb.ToString()); //File will always exist
|
||||
|
||||
ThePak.CurrentUsedPak = null;
|
||||
ThePak.CurrentUsedPakGuid = null;
|
||||
}
|
||||
LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage);
|
||||
|
||||
UpdateConsole("Building tree, please wait...", Color.FromArgb(255, 244, 132, 66), "Loading");
|
||||
}
|
||||
private void TreeParsePath(TreeNodeCollection nodeList, string path) //https://social.msdn.microsoft.com/Forums/en-US/c75c1804-6933-40ba-b17a-0e36ae8bcbb5/how-to-create-a-tree-view-with-full-paths?forum=csharplanguage
|
||||
|
|
|
|||
|
|
@ -209,11 +209,11 @@ namespace FModel
|
|||
/// <param name="catName"></param>
|
||||
private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
|
||||
{
|
||||
ThePak.CurrentUsedItem = catName;
|
||||
|
||||
string catalogFilePath;
|
||||
try
|
||||
if (ThePak.AllpaksDictionary.ContainsKey(catName))
|
||||
{
|
||||
ThePak.CurrentUsedItem = catName;
|
||||
|
||||
string catalogFilePath;
|
||||
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||
{
|
||||
catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
|
||||
|
|
@ -263,13 +263,9 @@ namespace FModel
|
|||
//do not crash when JsonSerialization does weird stuff
|
||||
}
|
||||
}
|
||||
else { GetItemIcon(theItem); } //Trails_ID_059_Sony2 smh :thinking:
|
||||
}
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
GetItemIcon(theItem);
|
||||
}
|
||||
else { GetItemIcon(theItem); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace FModel
|
||||
{
|
||||
static class LoadLocRes
|
||||
|
|
@ -30,12 +32,16 @@ namespace FModel
|
|||
|
||||
private static string getMyLocRes(string selectedLanguage)
|
||||
{
|
||||
string oldKey = JohnWick.MyKey;
|
||||
JohnWick.MyKey = Properties.Settings.Default.AESKey;
|
||||
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
|
||||
JohnWick.MyKey = oldKey;
|
||||
if (ThePak.AllpaksDictionary != null)
|
||||
{
|
||||
string oldKey = JohnWick.MyKey;
|
||||
JohnWick.MyKey = Properties.Settings.Default.AESKey;
|
||||
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
|
||||
JohnWick.MyKey = oldKey;
|
||||
|
||||
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
|
||||
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
|
||||
}
|
||||
else { return ""; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,5 +86,35 @@ namespace FModel
|
|||
File.Delete(App.DefaultOutputPath + "\\john-wick-parse_custom.exe");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this should tell me if i can read the file, to avoid crash when a pak is being written by the launcher
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsFileLocked(FileInfo file)
|
||||
{
|
||||
FileStream stream = null;
|
||||
try
|
||||
{
|
||||
stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
//the file is unavailable because it is:
|
||||
//still being written to
|
||||
//or being processed by another thread
|
||||
//or does not exist (has already been processed)
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
//file is not locked
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user