Fixed a bug when extracting rewards that do not exist (encrypted) in challenges.

This commit is contained in:
MaikyM 2019-09-18 12:54:56 -06:00
parent c1df41bc65
commit a655a07ff9
3 changed files with 22 additions and 7 deletions

View File

@ -76,10 +76,14 @@ namespace FModel
{
isSXBanner = true;
string textureFile = Path.GetFileName(assetPathName.Value<string>()).Substring(0, Path.GetFileName(assetPathName.Value<string>()).LastIndexOf('.'));
Image challengeIcon;
using (Bitmap bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile)))
Image challengeIcon = Resources.unknown512;
string textureAsset = JohnWick.AssetToTexture2D(textureFile);;
if (!string.IsNullOrEmpty(textureAsset))
{
challengeIcon = new Bitmap(bmpTemp);
using (var bmpTemp = new Bitmap(textureAsset))
{
challengeIcon = new Bitmap(bmpTemp);
}
}
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
@ -105,10 +109,14 @@ namespace FModel
if (assetPathName != null)
{
string textureFile = Path.GetFileName(assetPathName.Value<string>()).Substring(0, Path.GetFileName(assetPathName.Value<string>()).LastIndexOf('.'));
Image challengeIcon;
using (var bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile)))
Image challengeIcon = Resources.unknown512;
string textureAsset = JohnWick.AssetToTexture2D(textureFile);
if (!string.IsNullOrEmpty(textureAsset))
{
challengeIcon = new Bitmap(bmpTemp);
using (var bmpTemp = new Bitmap(textureAsset))
{
challengeIcon = new Bitmap(bmpTemp);
}
}
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));

View File

@ -79,7 +79,11 @@ namespace FModel
}
}
}
else
drawIcon();
}
else
drawIcon();
}
/// <summary>
@ -144,7 +148,7 @@ namespace FModel
private static void drawIcon()
{
Image itemIcon = null;
if (File.Exists(ItemIcon.ItemIconPath))
if (!string.IsNullOrEmpty(ItemIcon.ItemIconPath) && File.Exists(ItemIcon.ItemIconPath))
{
using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath))
{

View File

@ -72,6 +72,9 @@ namespace FModel
/// <returns> the path to the png image </returns>
public static string AssetToTexture2D(string AssetName)
{
if (!ThePak.AllpaksDictionary.ContainsKey(AssetName))
return string.Empty;
string textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName);
string TexturePath = string.Empty;
if (!string.IsNullOrEmpty(textureFilePath))