mirror of
https://github.com/4sval/FModel.git
synced 2026-04-25 07:21:54 -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;
|
Checking.WasFeatured = false;
|
||||||
SearchAthIteDefIcon(theItem);
|
SearchAthIteDefIcon(theItem);
|
||||||
}
|
}
|
||||||
if (featured)
|
else
|
||||||
{
|
{
|
||||||
if (theItem.DisplayAssetPath != null && theItem.DisplayAssetPath.AssetPathName.Contains("/Game/Catalog/DisplayAssets/"))
|
if (theItem.DisplayAssetPath != null && theItem.DisplayAssetPath.AssetPathName.Contains("/Game/Catalog/DisplayAssets/"))
|
||||||
{
|
{
|
||||||
|
|
@ -209,63 +209,54 @@ namespace FModel
|
||||||
/// <param name="catName"></param>
|
/// <param name="catName"></param>
|
||||||
private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
|
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;
|
Checking.WasFeatured = true;
|
||||||
|
if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk"))
|
||||||
string catalogFilePath;
|
|
||||||
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
|
||||||
{
|
{
|
||||||
catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
|
JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.')));
|
||||||
}
|
try
|
||||||
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('.')));
|
if (JohnWick.MyAsset.GetSerialized() != null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
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();
|
switch (catName)
|
||||||
var featuredId = FeaturedParser.FromJson(parsedJson);
|
|
||||||
for (int i = 0; i < featuredId.Length; i++)
|
|
||||||
{
|
{
|
||||||
switch (catName)
|
case "DA_Featured_Glider_ID_070_DarkViking":
|
||||||
{
|
case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
|
||||||
case "DA_Featured_Glider_ID_070_DarkViking":
|
if (featuredId[i].TileImage != null)
|
||||||
case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
|
{
|
||||||
if (featuredId[i].TileImage != null)
|
string textureFile = featuredId[i].TileImage.ResourceObject;
|
||||||
{
|
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||||
string textureFile = featuredId[i].TileImage.ResourceObject;
|
}
|
||||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
break;
|
||||||
}
|
default:
|
||||||
break;
|
if (featuredId[i].DetailsImage != null)
|
||||||
default:
|
{
|
||||||
if (featuredId[i].DetailsImage != null)
|
string textureFile = featuredId[i].DetailsImage.ResourceObject;
|
||||||
{
|
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
||||||
string textureFile = featuredId[i].DetailsImage.ResourceObject;
|
}
|
||||||
ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (JsonSerializationException)
|
}
|
||||||
{
|
catch (JsonSerializationException)
|
||||||
//do not crash when JsonSerialization does weird stuff
|
{
|
||||||
}
|
//do not crash when JsonSerialization does weird stuff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { GetItemIcon(theItem); }
|
else
|
||||||
|
GetItemIcon(theItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using csharp_wick;
|
using csharp_wick;
|
||||||
using FModel.Parser.RenderMat;
|
using FModel.Parser.RenderMat;
|
||||||
using FModel.Properties;
|
using FModel.Properties;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -109,28 +109,23 @@ namespace FModel
|
||||||
/// <returns> the path to the png image </returns>
|
/// <returns> the path to the png image </returns>
|
||||||
public static string AssetToTexture2D(string AssetName)
|
public static string AssetToTexture2D(string AssetName)
|
||||||
{
|
{
|
||||||
string textureFilePath;
|
string textureFilePath = (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
||||||
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
|
? ExtractAsset(ThePak.CurrentUsedPak, AssetName)
|
||||||
{
|
: ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName);
|
||||||
textureFilePath = ExtractAsset(ThePak.CurrentUsedPak, AssetName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string TexturePath = string.Empty;
|
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);
|
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 if (textureFilePath != null)
|
else
|
||||||
{
|
{
|
||||||
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)));
|
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)));
|
||||||
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png");
|
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png");
|
||||||
TexturePath = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
|
TexturePath = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TexturePath;
|
return TexturePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user