Skip to content

Commit

Permalink
Merge pull request #187 from iAmAsval/dev
Browse files Browse the repository at this point in the history
new map viewer, mesh support, other stuff
  • Loading branch information
4sval authored Jul 11, 2021
2 parents e5d7315 + d66b832 commit 7143844
Show file tree
Hide file tree
Showing 55 changed files with 1,693 additions and 512 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Artifact Generator
name: FModel Builder

on:
workflow_dispatch:
inputs:
appVersion:
description: 'FModel Version And Release Tag'
required: true
default: '4.0.X.X'

jobs:
build:
Expand All @@ -12,7 +17,6 @@ jobs:
uses: actions/checkout@v2
with:
submodules: 'true'
token: ${{ secrets.PAT_TOKEN }}

- name: .NET 5 Setup
uses: actions/setup-dotnet@v1
Expand All @@ -23,10 +27,19 @@ jobs:
run: dotnet restore FModel

- name: .NET Publish
run: dotnet publish FModel -c Release -f net5.0-windows -o "./FModel/bin/Publish/" -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:DebugType=None -p:GenerateDocumentationFile=false -p:DebugSymbols=false --no-self-contained -r win-x64
run: dotnet publish FModel -c Release -f net5.0-windows -o "./FModel/bin/Publish/" -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:DebugType=None -p:GenerateDocumentationFile=false -p:DebugSymbols=false -p:AssemblyVersion=${{ github.event.inputs.appVersion }} -p:FileVersion=${{ github.event.inputs.appVersion }} --no-self-contained -r win-x64

- name: EXE Upload
uses: actions/upload-artifact@v2
- name: ZIP File
uses: papeloto/action-zip@v1
with:
name: FModel
path: D:\a\FModel\FModel\FModel\bin\Publish\
files: ./FModel/bin/Publish/FModel.exe
dest: FModel.zip # will end up in working directory not the Publish folder

- name: GIT Release
uses: marvinpinto/action-automatic-releases@latest
with:
title: "FModel v${{ github.event.inputs.appVersion }}"
automatic_release_tag: ${{ github.event.inputs.appVersion }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: FModel.zip
2 changes: 1 addition & 1 deletion CUE4Parse
Submodule CUE4Parse updated 180 files
6 changes: 6 additions & 0 deletions FModel/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ namespace FModel
/// </summary>
public partial class App
{
[DllImport("kernel32.dll")]
private static extern bool AttachConsole(int dwProcessId);

protected override void OnStartup(StartupEventArgs e)
{
#if DEBUG
AttachConsole(-1);
#endif
base.OnStartup(e);

try
Expand Down
39 changes: 1 addition & 38 deletions FModel/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reflection;
using System.Reflection;
using CUE4Parse.UE4.Objects.Core.Misc;

namespace FModel
Expand All @@ -23,41 +22,5 @@ public static class Constants

public const string _FN_LIVE_TRIGGER = "fortnite-live.manifest";
public const string _VAL_LIVE_TRIGGER = "valorant-live.manifest";

public static string GetRandomColor()
{
return _randomColors[_random.Next(0, 255)];
}

private static readonly Random _random = new(Environment.TickCount);
private static readonly string[] _randomColors =
{
"F44336", "FFEBEE", "FFCDD2", "EF9A9A", "E57373", "EF5350", "E53935", "D32F2F", "C62828", "B71C1C",
"FF8A80", "FF5252", "FF1744", "D50000", "FCE4EC", "F8BBD0", "F48FB1", "F06292", "EC407A", "E91E63",
"D81B60", "C2185B", "AD1457", "880E4F", "FF80AB", "FF4081", "F50057", "C51162", "F3E5F5", "E1BEE7",
"CE93D8", "BA68C8", "AB47BC", "9C27B0", "8E24AA", "7B1FA2", "6A1B9A", "4A148C", "EA80FC", "E040FB",
"D500F9", "AA00FF", "EDE7F6", "D1C4E9", "B39DDB", "9575CD", "7E57C2", "673AB7", "5E35B1", "512DA8",
"4527A0", "311B92", "B388FF", "7C4DFF", "651FFF", "6200EA", "E8EAF6", "C5CAE9", "9FA8DA", "7986CB",
"5C6BC0", "3F51B5", "3949AB", "303F9F", "283593", "1A237E", "8C9EFF", "536DFE", "3D5AFE", "304FFE",
"E3F2FD", "BBDEFB", "90CAF9", "64B5F6", "42A5F5", "2196F3", "1E88E5", "1976D2", "1565C0", "0D47A1",
"82B1FF", "448AFF", "2979FF", "2962FF", "E1F5FE", "B3E5FC", "81D4FA", "4FC3F7", "29B6F6", "03A9F4",
"039BE5", "0288D1", "0277BD", "01579B", "80D8FF", "40C4FF", "00B0FF", "0091EA", "E0F7FA", "B2EBF2",
"80DEEA", "4DD0E1", "26C6DA", "00BCD4", "00ACC1", "0097A7", "00838F", "006064", "84FFFF", "18FFFF",
"00E5FF", "00B8D4", "E0F2F1", "B2DFDB", "80CBC4", "4DB6AC", "26A69A", "009688", "00897B", "00796B",
"00695C", "004D40", "A7FFEB", "64FFDA", "1DE9B6", "00BFA5", "E8F5E9", "C8E6C9", "A5D6A7", "81C784",
"66BB6A", "4CAF50", "43A047", "388E3C", "2E7D32", "1B5E20", "B9F6CA", "69F0AE", "00E676", "00C853",
"F1F8E9", "DCEDC8", "C5E1A5", "AED581", "9CCC65", "8BC34A", "7CB342", "689F38", "558B2F", "33691E",
"CCFF90", "B2FF59", "76FF03", "64DD17", "F9FBE7", "F0F4C3", "E6EE9C", "DCE775", "D4E157", "CDDC39",
"C0CA33", "AFB42B", "9E9D24", "827717", "F4FF81", "EEFF41", "C6FF00", "AEEA00", "FFFDE7", "FFF9C4",
"FFF59D", "FFF176", "FFEE58", "FFEB3B", "FDD835", "FBC02D", "F9A825", "F57F17", "FFFF8D", "FFFF00",
"FFEA00", "FFD600", "FFF8E1", "FFECB3", "FFE082", "FFD54F", "FFCA28", "FFC107", "FFB300", "FFA000",
"FF8F00", "FF6F00", "FFE57F", "FFD740", "FFC400", "FFAB00", "FFF3E0", "FFE0B2", "FFCC80", "FFB74D",
"FFA726", "FF9800", "FB8C00", "F57C00", "EF6C00", "E65100", "FFD180", "FFAB40", "FF9100", "FF6D00",
"FBE9E7", "FFCCBC", "FFAB91", "FF8A65", "FF7043", "FF5722", "F4511E", "E64A19", "D84315", "BF360C",
"FF9E80", "FF6E40", "FF3D00", "DD2C00", "EFEBE9", "D7CCC8", "BCAAA4", "A1887F", "8D6E63", "795548",
"6D4C41", "5D4037", "4E342E", "3E2723", "FAFAFA", "F5F5F5", "EEEEEE", "E0E0E0", "BDBDBD", "9E9E9E",
"757575", "616161", "424242", "212121", "ECEFF1", "CFD8DC", "B0BEC5", "90A4AE", "78909C", "607D8B",
"546E7A", "455A64", "37474F", "263238", "000000",
};
}
}
6 changes: 3 additions & 3 deletions FModel/Creator/Bases/FN/BaseCommunity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private void CheckGameplayTags(FGameplayTagContainer gameplayTags)
if (_design.DrawSeason && gameplayTags.TryGetGameplayTag("Cosmetics.Filter.Season.", out var season))
_season = GetCosmeticSeason(season.Text, _design.DrawSeasonShort);

GetUserFacingFlags(gameplayTags.GetAllGameplayTags(
"Cosmetics.UserFacingFlags.", "Homebase.Class.", "NPC.CharacterType.Survivor.Defender."));
var triggers = _design.GameplayTags.DrawCustomOnly ? new[] {"Cosmetics.UserFacingFlags."} : new[] {"Cosmetics.UserFacingFlags.", "Homebase.Class.", "NPC.CharacterType.Survivor.Defender."};
GetUserFacingFlags(gameplayTags.GetAllGameplayTags(triggers));
}

private string GetCosmeticSet(string setName, bool bShort)
Expand Down Expand Up @@ -290,7 +290,7 @@ private void DrawToBottom(SKCanvas c, FontDesign font, string text)

private void DrawUserFacingFlags(SKCanvas c, bool customOnly)
{
if (UserFacingFlags == null || UserFacingFlags.Length < 1) return;
if (UserFacingFlags == null || UserFacingFlags.Count < 1) return;
if (customOnly)
{
c.DrawBitmap(_design.GameplayTags.Custom, 0, 0, ImagePaint);
Expand Down
18 changes: 9 additions & 9 deletions FModel/Creator/Bases/FN/BaseIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BaseIcon : UCreator
public SKBitmap SeriesBackground { get; protected set; }
protected string ShortDescription { get; set; }
protected string CosmeticSource { get; set; }
protected SKBitmap[] UserFacingFlags { get; set; }
protected Dictionary<string, SKBitmap> UserFacingFlags { get; set; }

public BaseIcon(UObject uObject, EIconStyle style) : base(uObject, style)
{
Expand Down Expand Up @@ -269,24 +269,24 @@ protected void GetUserFacingFlags(IList<string> userFacingFlags)
if (!itemCategories.TryGetValue(out FStructFallback[] tertiaryCategories, "TertiaryCategories"))
return;

UserFacingFlags = new SKBitmap[userFacingFlags.Count];
for (var i = 0; i < UserFacingFlags.Length; i++)
UserFacingFlags = new Dictionary<string, SKBitmap>(userFacingFlags.Count);
foreach (var flag in userFacingFlags)
{
if (userFacingFlags[i].Equals("Cosmetics.UserFacingFlags.HasUpgradeQuests", StringComparison.OrdinalIgnoreCase))
if (flag.Equals("Cosmetics.UserFacingFlags.HasUpgradeQuests", StringComparison.OrdinalIgnoreCase))
{
if (Object.ExportType.Equals("AthenaPetCarrierItemDefinition", StringComparison.OrdinalIgnoreCase))
UserFacingFlags[i] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Pets-64.png"))?.Stream);
else UserFacingFlags[i] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Quests-64.png"))?.Stream);
UserFacingFlags[flag] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Pets-64.png"))?.Stream);
else UserFacingFlags[flag] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Quests-64.png"))?.Stream);
}
else
{
foreach (var category in tertiaryCategories)
{
if (category.TryGetValue(out FGameplayTagContainer tagContainer, "TagContainer") && tagContainer.TryGetGameplayTag(userFacingFlags[i], out _) &&
if (category.TryGetValue(out FGameplayTagContainer tagContainer, "TagContainer") && tagContainer.TryGetGameplayTag(flag, out _) &&
category.TryGetValue(out FStructFallback categoryBrush, "CategoryBrush") && categoryBrush.TryGetValue(out FStructFallback brushXxs, "Brush_XXS") &&
brushXxs.TryGetValue(out FPackageIndex resourceObject, "ResourceObject") && Utils.TryGetPackageIndexExport(resourceObject, out UTexture2D texture))
{
UserFacingFlags[i] = Utils.GetBitmap(texture);
UserFacingFlags[flag] = Utils.GetBitmap(texture);
}
}
}
Expand All @@ -299,7 +299,7 @@ private void DrawUserFacingFlags(SKCanvas c)

const int size = 25;
var x = Margin * (int) 2.5;
foreach (var flag in UserFacingFlags)
foreach (var flag in UserFacingFlags.Values)
{
if (flag == null) continue;

Expand Down
4 changes: 4 additions & 0 deletions FModel/Creator/Bases/FN/BaseMaterialInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public override void ParseForInfo()
{
if (Object is not UMaterialInstanceConstant material) return;

texture_finding:
foreach (var textureParameter in material.TextureParameterValues) // get texture from base material
{
if (textureParameter.ParameterValue is not UTexture2D texture || Preview != null) continue;
Expand All @@ -45,6 +46,9 @@ public override void ParseForInfo()
if (material == null) return;
}

if (Preview == null)
goto texture_finding;

foreach (var vectorParameter in material.VectorParameterValues)
{
if (vectorParameter.ParameterValue == null) continue;
Expand Down
4 changes: 2 additions & 2 deletions FModel/Creator/Bases/FN/BaseQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public override void ParseForInfo()
}
else if (!_unauthorizedReward.Contains(name.Text))
{
_reward = new Reward(quantity, primaryAssetName);
_reward = new Reward(quantity, $"{name}:{primaryAssetName}");
}
}
}
Expand Down Expand Up @@ -256,4 +256,4 @@ private void DrawTexts(SKCanvas c, int y)
_reward.DrawQuest(c, new SKRect(Height, outY + 25, Width - 20, y + Height - 25));
}
}
}
}
111 changes: 51 additions & 60 deletions FModel/Creator/Bases/FN/BaseSeason.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CUE4Parse.UE4.Assets.Exports;
using CUE4Parse.UE4.Assets.Objects;
using CUE4Parse.UE4.Objects.Core.i18N;
Expand All @@ -10,10 +10,17 @@

namespace FModel.Creator.Bases.FN
{
public class Page
{
public int LevelsNeededForUnlock;
public int RewardsNeededForUnlock;
public Reward[] RewardEntryList;
}

public class BaseSeason : UCreator
{
private Reward _firstWinReward;
private Dictionary<int, List<Reward>> _bookXpSchedule;
private Page[] _bookXpSchedule;
private const int _headerHeight = 150;
// keep the list because rewards are ordered by least to most important
// we only care about the most but we also have filters so we can't just take the last reward
Expand All @@ -27,8 +34,8 @@ public BaseSeason(UObject uObject, EIconStyle style) : base(uObject, style)

public override void ParseForInfo()
{
_bookXpSchedule = new Dictionary<int, List<Reward>>();

_bookXpSchedule = Array.Empty<Page>();
if (Object.TryGetValue(out FText displayName, "DisplayName"))
DisplayName = displayName.Text.ToUpperInvariant();

Expand All @@ -45,56 +52,48 @@ public override void ParseForInfo()
}
}

var freeLevels = Array.Empty<FStructFallback>();
var paidLevels = Array.Empty<FStructFallback>();
if (Object.TryGetValue(out FPackageIndex[] additionalSeasonData, "AdditionalSeasonData") &&
additionalSeasonData.Length > 0 && Utils.TryGetPackageIndexExport(additionalSeasonData[0], out UObject data) &&
data.TryGetValue(out FStructFallback battlePassXpScheduleFree, "BattlePassXpScheduleFree") &&
battlePassXpScheduleFree.TryGetValue(out freeLevels, "Levels") &&
data.TryGetValue(out FStructFallback battlePassXpSchedulePaid, "BattlePassXpSchedulePaid") &&
battlePassXpSchedulePaid.TryGetValue(out paidLevels, "Levels"))
if (Object.TryGetValue(out FPackageIndex[] additionalSeasonData, "AdditionalSeasonData"))
{
// we got them boys
}
else if (Object.TryGetValue(out FStructFallback bookXpScheduleFree, "BookXpScheduleFree") &&
bookXpScheduleFree.TryGetValue(out freeLevels, "Levels") &&
Object.TryGetValue(out FStructFallback bookXpSchedulePaid, "BookXpSchedulePaid") &&
bookXpSchedulePaid.TryGetValue(out paidLevels, "Levels"))
{
// we got them boys
}

for (var i = 0; i < freeLevels.Length; i++)
{
_bookXpSchedule[i] = new List<Reward>();
if (!freeLevels[i].TryGetValue(out rewards, "Rewards")) continue;

foreach (var reward in rewards)
foreach (var data in additionalSeasonData)
{
if (!reward.TryGetValue(out FSoftObjectPath itemDefinition, "ItemDefinition") ||
itemDefinition.AssetPathName.Text.Contains("/Items/Tokens/") ||
!Utils.TryLoadObject(itemDefinition.AssetPathName.Text, out UObject uObject)) continue;

_bookXpSchedule[i].Add(new Reward(uObject));
break;
}
}

for (var i = 0; i < paidLevels.Length; i++)
{
if (!paidLevels[i].TryGetValue(out rewards, "Rewards")) continue;
if (!Utils.TryGetPackageIndexExport(data, out UObject packageIndex) ||
!packageIndex.TryGetValue(out FStructFallback[] pageList, "PageList")) continue;

var i = 0;
_bookXpSchedule = new Page[pageList.Length];
foreach (var page in pageList)
{
if (!page.TryGetValue(out int levelsNeededForUnlock, "LevelsNeededForUnlock") ||
!page.TryGetValue(out int rewardsNeededForUnlock, "RewardsNeededForUnlock") ||
!page.TryGetValue(out FPackageIndex[] rewardEntryList, "RewardEntryList"))
continue;

var p = new Page
{
LevelsNeededForUnlock = levelsNeededForUnlock,
RewardsNeededForUnlock = rewardsNeededForUnlock,
RewardEntryList = new Reward[rewardEntryList.Length]
};

for (var j = 0; j < p.RewardEntryList.Length; j++)
{
if (!Utils.TryGetPackageIndexExport(rewardEntryList[j], out packageIndex) ||
!packageIndex.TryGetValue(out FStructFallback battlePassOffer, "BattlePassOffer") ||
!battlePassOffer.TryGetValue(out FStructFallback rewardItem, "RewardItem") ||
!rewardItem.TryGetValue(out FSoftObjectPath itemDefinition, "ItemDefinition") ||
!Utils.TryLoadObject(itemDefinition.AssetPathName.Text, out UObject uObject)) continue;

p.RewardEntryList[j] = new Reward(uObject);
}

_bookXpSchedule[i++] = p;
}

foreach (var reward in rewards)
{
if (!reward.TryGetValue(out FSoftObjectPath itemDefinition, "ItemDefinition") ||
!Utils.TryLoadObject(itemDefinition.AssetPathName.Text, out UObject uObject)) continue;

_bookXpSchedule[i].Add(new Reward(uObject));
break;
}
}

Height += 100 * _bookXpSchedule.Count / 10;
Height += 100 * _bookXpSchedule.Sum(x => x.RewardEntryList.Length) / _bookXpSchedule.Length;
}

public override SKImage Draw()
Expand Down Expand Up @@ -151,23 +150,15 @@ private void DrawBookSchedule(SKCanvas c)
{
var x = 20;
var y = _headerHeight + 50;
foreach (var (index, reward) in _bookXpSchedule)
foreach (var page in _bookXpSchedule)
{
if (index == 0 || reward.Count == 0 || !reward[0].HasReward())
continue;

c.DrawText(index.ToString(), new SKPoint(x + _DEFAULT_AREA_SIZE / 2, y - 5), _bookPaint);
reward[0].DrawSeason(c, x, y, _DEFAULT_AREA_SIZE);

if (index != 1 && index % 10 == 0)
{
y += _DEFAULT_AREA_SIZE + 20;
x = 20;
}
else
foreach (var reward in page.RewardEntryList)
{
reward.DrawSeason(c, x, y, _DEFAULT_AREA_SIZE);
x += _DEFAULT_AREA_SIZE + 20;
}
y += _DEFAULT_AREA_SIZE + 20;
x = 20;
}
}
}
Expand Down
Loading

0 comments on commit 7143844

Please sign in to comment.