mirror of
https://github.com/4sval/FModel.git
synced 2026-03-22 01:34:37 -05:00
Fixed the Featured image when loading a ONE Pak & code optimization.
This commit is contained in:
parent
3836772201
commit
a080bd2dac
|
|
@ -28,7 +28,7 @@ namespace FModel
|
|||
Checking.WasFeatured = false;
|
||||
SearchAthIteDefIcon(theItem);
|
||||
}
|
||||
if (featured)
|
||||
else
|
||||
{
|
||||
if (theItem.DisplayAssetPath != null && theItem.DisplayAssetPath.AssetPathName.Contains("/Game/Catalog/DisplayAssets/"))
|
||||
{
|
||||
|
|
@ -209,63 +209,54 @@ namespace FModel
|
|||
/// <param name="catName"></param>
|
||||
private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
|
||||
{
|
||||
if (ThePak.AllpaksDictionary.ContainsKey(catName))
|
||||
ThePak.CurrentUsedItem = catName;
|
||||
string catalogFilePath = (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||
? catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName)
|
||||
: catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName);
|
||||
|
||||
if (catalogFilePath != null)
|
||||
{
|
||||
ThePak.CurrentUsedItem = catName;
|
||||
|
||||
string catalogFilePath;
|
||||
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||
Checking.WasFeatured = true;
|
||||
if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk"))
|
||||
{
|
||||
catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
|
||||
}
|
||||
else
|
||||
{
|
||||
catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName);
|
||||
}
|
||||
|
||||
if (catalogFilePath != null)
|
||||
{
|
||||
Checking.WasFeatured = true;
|
||||
if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk"))
|
||||
JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.')));
|
||||
try
|
||||
{
|
||||
JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.')));
|
||||
try
|
||||
if (JohnWick.MyAsset.GetSerialized() != null)
|
||||
{
|
||||
if (JohnWick.MyAsset.GetSerialized() != null)
|
||||
string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
|
||||
var featuredId = FeaturedParser.FromJson(parsedJson);
|
||||
for (int i = 0; i < featuredId.Length; i++)
|
||||
{
|
||||
string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
|
||||
var featuredId = FeaturedParser.FromJson(parsedJson);
|
||||
for (int i = 0; i < featuredId.Length; i++)
|
||||
switch (catName)
|
||||
{
|
||||
switch (catName)
|
||||
{
|
||||
case "DA_Featured_Glider_ID_070_DarkViking":
|
||||
case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
|
||||
if (featuredId[i].TileImage != null)
|
||||
{
|
||||
string textureFile = featuredId[i].TileImage.ResourceObject;
|
||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (featuredId[i].DetailsImage != null)
|
||||
{
|
||||
string textureFile = featuredId[i].DetailsImage.ResourceObject;
|
||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "DA_Featured_Glider_ID_070_DarkViking":
|
||||
case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
|
||||
if (featuredId[i].TileImage != null)
|
||||
{
|
||||
string textureFile = featuredId[i].TileImage.ResourceObject;
|
||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (featuredId[i].DetailsImage != null)
|
||||
{
|
||||
string textureFile = featuredId[i].DetailsImage.ResourceObject;
|
||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
//do not crash when JsonSerialization does weird stuff
|
||||
}
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
//do not crash when JsonSerialization does weird stuff
|
||||
}
|
||||
}
|
||||
}
|
||||
else { GetItemIcon(theItem); }
|
||||
else
|
||||
GetItemIcon(theItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using csharp_wick;
|
||||
using csharp_wick;
|
||||
using FModel.Parser.RenderMat;
|
||||
using FModel.Properties;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -109,28 +109,23 @@ namespace FModel
|
|||
/// <returns> the path to the png image </returns>
|
||||
public static string AssetToTexture2D(string AssetName)
|
||||
{
|
||||
string textureFilePath;
|
||||
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||
{
|
||||
textureFilePath = ExtractAsset(ThePak.CurrentUsedPak, AssetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName);
|
||||
}
|
||||
|
||||
string textureFilePath = (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||
? ExtractAsset(ThePak.CurrentUsedPak, AssetName)
|
||||
: ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName);
|
||||
|
||||
string TexturePath = string.Empty;
|
||||
if (textureFilePath != null && (textureFilePath.Contains("MI_UI_FeaturedRenderSwitch_") || textureFilePath.Contains("M_UI_ChallengeTile_PCB") || textureFilePath.Contains("Wraps\\FeaturedMaterials\\") || textureFilePath.Contains("M-Wraps-StreetDemon")))
|
||||
if (!string.IsNullOrEmpty(textureFilePath))
|
||||
{
|
||||
return GetRenderSwitchMaterialTexture(textureFilePath);
|
||||
}
|
||||
else if (textureFilePath != null)
|
||||
{
|
||||
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)));
|
||||
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png");
|
||||
TexturePath = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
|
||||
if ((textureFilePath.Contains("MI_UI_FeaturedRenderSwitch_") || textureFilePath.Contains("M_UI_ChallengeTile_PCB") || textureFilePath.Contains("Wraps\\FeaturedMaterials\\") || textureFilePath.Contains("M-Wraps-StreetDemon")))
|
||||
return GetRenderSwitchMaterialTexture(textureFilePath);
|
||||
else
|
||||
{
|
||||
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)));
|
||||
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png");
|
||||
TexturePath = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
return TexturePath;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user