Skip to content

Commit

Permalink
FModel 3.1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed May 25, 2020
1 parent a4f1cc2 commit e9de63b
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 36 deletions.
40 changes: 29 additions & 11 deletions FModel/Creator/BaseOffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,42 @@ public BaseOffer()

public BaseOffer(IUExport export) : this()
{
if (export.TryGetValue("DetailsImage", out var v1) && v1 is StructProperty s &&
s.Value is UObject typeImage && typeImage.TryGetValue("ResourceObject", out var v2) && v2 is ObjectProperty resourceObject)
if (export.GetExport<StructProperty>("DetailsImage", "TileImage") is StructProperty typeImage)
{
IconImage = Utils.GetObjectTexture(resourceObject);
if (typeImage.Value is UObject t && t.TryGetValue("ResourceObject", out var v) && v is ObjectProperty resourceObject)
{
IconImage = Utils.GetObjectTexture(resourceObject);
}
}

if (export.TryGetValue("Gradient", out var g) && g is StructProperty r && r.Value is UObject gradient)
if (export.GetExport<StructProperty>("Gradient") is StructProperty gradient)
{
if (gradient.TryGetValue("Start", out var s1) && s1 is StructProperty t1 && t1.Value is FLinearColor start &&
gradient.TryGetValue("Stop", out var s2) && s2 is StructProperty t2 && t2.Value is FLinearColor stop)
if (gradient.Value is UObject g &&
g.TryGetValue("Start", out var s1) && s1 is StructProperty t1 && t1.Value is FLinearColor start &&
g.TryGetValue("Stop", out var s2) && s2 is StructProperty t2 && t2.Value is FLinearColor stop)
{
RarityBackgroundColors = new SKColor[2] { SKColor.Parse(stop.Hex), SKColor.Parse(start.Hex) };
RarityBackgroundColors = new SKColor[2] { SKColor.Parse(start.Hex), SKColor.Parse(stop.Hex) };
}
}

if (export.TryGetValue("Background", out var b) && b is StructProperty a && a.Value is FLinearColor background)
RarityBorderColor = SKColor.Parse(background.Hex);
if (export.GetExport<StructProperty>("Background") is StructProperty background)
{
if (background.Value is FLinearColor b)
{
RarityBorderColor = SKColor.Parse(b.Hex);
}
}
}

public void Draw(SKCanvas c)
public void DrawBackground(SKCanvas c)
{
if (RarityBackgroundColors[0] == RarityBackgroundColors[1])
RarityBackgroundColors[0] = RarityBorderColor;

RarityBackgroundColors[0].ToHsl(out var _, out var _, out var l1);
RarityBackgroundColors[1].ToHsl(out var _, out var _, out var l2);
bool reverse = l1 > l2;

// border
c.DrawRect(new SKRect(0, 0, Size, Size),
new SKPaint
Expand All @@ -64,10 +79,13 @@ public void Draw(SKCanvas c)
Shader = SKShader.CreateRadialGradient(
new SKPoint(Size / 2, Size / 2),
Size / 5 * 4,
RarityBackgroundColors,
new SKColor[2] { reverse ? RarityBackgroundColors[0] : RarityBackgroundColors[1], reverse ? RarityBackgroundColors[1] : RarityBackgroundColors[0] },
SKShaderTileMode.Clamp)
});
}

public void DrawImage(SKCanvas c)
{

This comment has been minimized.

Copy link
@DavidfromVietnam

DavidfromVietnam Jun 9, 2020

gfgfg

c.DrawBitmap(IconImage ?? FallbackImage, new SKRect(Margin, Margin, Size - Margin, Size - Margin),
new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true });
}
Expand Down
48 changes: 30 additions & 18 deletions FModel/Creator/Creator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,37 @@ public static bool TryDrawIcon(string assetPath, string exportType, IUExport exp
{
BaseIcon icon = new BaseIcon(export, exportType, ref assetName);
int height = icon.Size + icon.AdditionalSize;
using (var ret = new SKBitmap(icon.Size, height, SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var ret = new SKBitmap(icon.Size, height, SKColorType.Rgba8888, SKAlphaType.Premul))
using (var c = new SKCanvas(ret))
{
Rarity.DrawRarity(c, icon);
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
{
Rarity.DrawRarity(c, icon);
}

LargeSmallImage.DrawPreviewImage(c, icon);
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoText)

if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
{
Text.DrawBackground(c, icon);
Text.DrawDisplayName(c, icon);
Text.DrawDescription(c, icon);
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.Mini)
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoText)
{
if (!icon.ShortDescription.Equals(icon.DisplayName) && !icon.ShortDescription.Equals(icon.Description))
Text.DrawToBottom(c, icon, ETextSide.Left, icon.ShortDescription);
Text.DrawToBottom(c, icon, ETextSide.Right, icon.CosmeticSource);
Text.DrawBackground(c, icon);
Text.DrawDisplayName(c, icon);
Text.DrawDescription(c, icon);
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.Mini)
{
if (!icon.ShortDescription.Equals(icon.DisplayName) && !icon.ShortDescription.Equals(icon.Description))
Text.DrawToBottom(c, icon, ETextSide.Left, icon.ShortDescription);
Text.DrawToBottom(c, icon, ETextSide.Right, icon.CosmeticSource);
}
}
}
UserFacingFlag.DrawUserFacingFlags(c, icon);
UserFacingFlag.DrawUserFacingFlags(c, icon);

// has more things to show
if (height > icon.Size)
{
Statistics.DrawStats(c, icon);
// has more things to show
if (height > icon.Size)
{
Statistics.DrawStats(c, icon);
}
}

Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
Expand All @@ -125,10 +133,14 @@ public static bool TryDrawIcon(string assetPath, string exportType, IUExport exp
case "FortMtxOfferData":
{
BaseOffer icon = new BaseOffer(export);
using (var ret = new SKBitmap(icon.Size, icon.Size, SKColorType.Rgba8888, SKAlphaType.Opaque))
using (var ret = new SKBitmap(icon.Size, icon.Size, SKColorType.Rgba8888, SKAlphaType.Premul))
using (var c = new SKCanvas(ret))
{
icon.Draw(c);
if ((EIconDesign)Properties.Settings.Default.AssetsIconDesign != EIconDesign.NoBackground)
{
icon.DrawBackground(c);
}
icon.DrawImage(c);

Watermark.DrawWatermark(c); // watermark should only be applied on icons with width = 512
ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
Expand Down
1 change: 1 addition & 0 deletions FModel/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public enum ELanguage : long
public enum EIconDesign : long
{
Default,
NoBackground,
NoText,
Mini,
Flat
Expand Down
8 changes: 5 additions & 3 deletions FModel/FModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<StartupObject>FModel.App</StartupObject>
<Authors>Asval</Authors>
<Company></Company>
<AssemblyVersion>3.1.0.3</AssemblyVersion>
<FileVersion>3.1.0.3</FileVersion>
<AssemblyVersion>3.1.0.4</AssemblyVersion>
<FileVersion>3.1.0.4</FileVersion>
<PackageIcon>FModel.ico</PackageIcon>
<PackageIconUrl />
<PackageProjectUrl>https://github.com/iAmAsval/FModel</PackageProjectUrl>
Expand Down Expand Up @@ -53,6 +53,7 @@
<None Remove="Resources\EIconDesign_Default.png" />
<None Remove="Resources\EIconDesign_Flat.png" />
<None Remove="Resources\EIconDesign_Mini.png" />
<None Remove="Resources\EIconDesign_NoBackground.png" />
<None Remove="Resources\EIconDesign_NoText.png" />
<None Remove="Resources\file-export.png" />
<None Remove="Resources\file-image.ico" />
Expand Down Expand Up @@ -122,7 +123,7 @@
<PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="CSCore" Version="1.2.1.2" />
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
<PackageReference Include="DotNetZip" Version="1.13.7" />
<PackageReference Include="DotNetZip" Version="1.13.8" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="3.8.1" />
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.1.11" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
Expand Down Expand Up @@ -156,6 +157,7 @@
<Resource Include="Resources\EIconDesign_Default.png" />
<Resource Include="Resources\EIconDesign_Flat.png" />
<Resource Include="Resources\EIconDesign_Mini.png" />
<Resource Include="Resources\EIconDesign_NoBackground.png" />
<Resource Include="Resources\EIconDesign_NoText.png" />
<Resource Include="Resources\file-export.png" />
<Resource Include="Resources\file-image.ico" />
Expand Down
19 changes: 19 additions & 0 deletions FModel/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions FModel/Properties/Resources.ar.resx
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,7 @@ It's now the most used free software to leak on Fortnite.</value>
<data name="UseFEnglish" xml:space="preserve">
<value>استخدم Fmodel باللغة الإنجليزية</value>
</data>
<data name="NoBackground" xml:space="preserve">
<value>أي خلفية</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FModel/Properties/Resources.de-DE.resx
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,7 @@ Jetzt ist es die am häufigsten genutzte freie Software um mit Fortnite zu leake
<data name="UseFEnglish" xml:space="preserve">
<value>FModel in Englisch benutzen</value>
</data>
<data name="NoBackground" xml:space="preserve">
<value>Kein Hintergrund</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FModel/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -862,4 +862,7 @@ C'est maintenant le logiciel gratuit le plus utilisé pour leak sur Fortnite.</v
<data name="UseFEnglish" xml:space="preserve">
<value>Utiliser FModel en Anglais</value>
</data>
<data name="NoBackground" xml:space="preserve">
<value>Pas de fond</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FModel/Properties/Resources.it-IT.resx
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,7 @@ Col tempo sono state aggiunte nuove funzioni e molti altri utenti hanno comincia
<data name="NoImageToCopy" xml:space="preserve">
<value>Al momento non ci sono immagini da copiare</value>
</data>
<data name="NoBackground" xml:space="preserve">
<value>Nessuno Sfondo</value>
</data>
</root>
6 changes: 6 additions & 0 deletions FModel/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,4 +1098,10 @@ It's now the most used free software to leak on Fortnite.</value>
<data name="UseFEnglish" xml:space="preserve">
<value>Use FModel in English</value>
</data>
<data name="NoBackground" xml:space="preserve">
<value>No Background</value>
</data>
<data name="EIconDesign_NoBackground" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\EIconDesign_NoBackground.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added FModel/Resources/EIconDesign_NoBackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions FModel/ViewModels/ComboBox/ComboBoxViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ static class ComboBoxVm
public static ObservableCollection<ComboBoxViewModel> designCbViewModel = new ObservableCollection<ComboBoxViewModel>
{
new ComboBoxViewModel { Id = 0, Content = Properties.Resources.Default, Property = EIconDesign.Default },
new ComboBoxViewModel { Id = 1, Content = Properties.Resources.NoText, Property = EIconDesign.NoText },
new ComboBoxViewModel { Id = 2, Content = Properties.Resources.Minimalist, Property = EIconDesign.Mini },
new ComboBoxViewModel { Id = 3, Content = Properties.Resources.Flat, Property = EIconDesign.Flat }
new ComboBoxViewModel { Id = 1, Content = Properties.Resources.NoBackground, Property = EIconDesign.NoBackground },
new ComboBoxViewModel { Id = 2, Content = Properties.Resources.NoText, Property = EIconDesign.NoText },
new ComboBoxViewModel { Id = 3, Content = Properties.Resources.Minimalist, Property = EIconDesign.Mini },
new ComboBoxViewModel { Id = 4, Content = Properties.Resources.Flat, Property = EIconDesign.Flat }
};

public static ObservableCollection<ComboBoxViewModel> gamesCbViewModel = new ObservableCollection<ComboBoxViewModel>();
Expand Down
2 changes: 1 addition & 1 deletion FModel/Windows/Settings/IconCreator.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void DrawPreview()
if (Designs_CbBox.HasItems && Designs_CbBox.SelectedIndex >= 0 && Designs_CbBox.SelectedItem is ComboBoxViewModel selectedItem)
{
using SKBitmap rarityBase = SKBitmap.Decode(Application.GetResourceStream(new Uri($"pack://application:,,,/Resources/EIconDesign_{(EIconDesign)selectedItem.Property}.png")).Stream);
using var ret = new SKBitmap(512, 512, SKColorType.Rgba8888, SKAlphaType.Opaque);
using var ret = new SKBitmap(512, 512, SKColorType.Rgba8888, SKAlphaType.Premul);
using var c = new SKCanvas(ret);
c.DrawBitmap(rarityBase, new SKRect(0, 0, 512, 512),
new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true });
Expand Down

0 comments on commit e9de63b

Please sign in to comment.