Skip to content

Commit

Permalink
and this is where problems begin
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Jun 14, 2023
1 parent a184a25 commit 011046a
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 557 deletions.
2 changes: 1 addition & 1 deletion FModel/Creator/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static SKBitmap GetBitmap(UMaterialInstanceConstant material)
public static SKBitmap GetB64Bitmap(string b64) => SKBitmap.Decode(new MemoryStream(Convert.FromBase64String(b64)) { Position = 0 });
public static SKBitmap GetBitmap(FSoftObjectPath softObjectPath) => GetBitmap(softObjectPath.AssetPathName.Text);
public static SKBitmap GetBitmap(string fullPath) => TryLoadObject(fullPath, out UTexture2D texture) ? GetBitmap(texture) : null;
public static SKBitmap GetBitmap(UTexture2D texture) => texture.IsVirtual ? null : texture.Decode(UserSettings.Default.OverridedPlatform);
public static SKBitmap GetBitmap(UTexture2D texture) => texture.IsVirtual ? null : texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform);
public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data);

public static SKBitmap ResizeWithRatio(this SKBitmap me, double width, double height)
Expand Down
90 changes: 90 additions & 0 deletions FModel/Settings/DirectorySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Versions;
using FModel.Framework;
using FModel.ViewModels;
using FModel.ViewModels.ApiEndpoints.Models;

namespace FModel.Settings;

public class DirectorySettings : ViewModel
{
private string _gameName;
public string GameName
{
get => _gameName;
set => SetProperty(ref _gameName, value);
}

private string _gameDirectory;
public string GameDirectory
{
get => _gameDirectory;
set => SetProperty(ref _gameDirectory, value);
}

private bool _isManual;
public bool IsManual
{
get => _isManual;
set => SetProperty(ref _isManual, value);
}

private EGame _ueVersion = EGame.GAME_UE4_LATEST;
public EGame UeVersion
{
get => _ueVersion;
set => SetProperty(ref _ueVersion, value);
}

private ETexturePlatform _texturePlatform = ETexturePlatform.DesktopMobile;
public ETexturePlatform TexturePlatform
{
get => _texturePlatform;
set => SetProperty(ref _texturePlatform, value);
}

private AesResponse _aesKeys;
public AesResponse AesKeys
{
get => _aesKeys;
set => SetProperty(ref _aesKeys, value);
}

private VersioningSettings _versioning = new ();
public VersioningSettings Versioning
{
get => _versioning;
set => SetProperty(ref _versioning, value);
}

private FEndpoint[] _endpoints = { new (), new () };
public FEndpoint[] Endpoints
{
get => _endpoints;
set => SetProperty(ref _endpoints, value);
}

private IList<CustomDirectory> _directories = new List<CustomDirectory>();
public IList<CustomDirectory> Directories
{
get => _directories;
set => SetProperty(ref _directories, value);
}

private bool Equals(DirectorySettings other)
{
return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion;
}

public override bool Equals(object obj)
{
return obj is DirectorySettings other && Equals(other);
}

public override int GetHashCode()
{
return HashCode.Combine(GameDirectory, (int) UeVersion);
}
}
211 changes: 24 additions & 187 deletions FModel/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static UserSettings()

public static void Save()
{
Default.PerDirectory[Default.CurrentDir.GameDirectory] = Default.CurrentDir;
File.WriteAllText(FilePath, JsonConvert.SerializeObject(Default, Formatting.Indented));
}

Expand All @@ -41,13 +42,9 @@ public static void Delete()
if (File.Exists(FilePath)) File.Delete(FilePath);
}

public static bool IsEndpointValid(FGame game, EEndpointType type, out FEndpoint endpoint)
public static bool IsEndpointValid(EEndpointType type, out FEndpoint endpoint)
{
endpoint = null;
if (!Default.CustomEndpoints.TryGetValue(game, out var endpoints))
return false;

endpoint = endpoints[(int) type];
endpoint = Default.CurrentDir.Endpoints[(int) type];
return endpoint.Overwrite || endpoint.IsValid;
}

Expand Down Expand Up @@ -100,7 +97,7 @@ public string ModelDirectory
set => SetProperty(ref _modelDirectory, value);
}

private string _gameDirectory;
private string _gameDirectory = string.Empty;
public string GameDirectory
{
get => _gameDirectory;
Expand Down Expand Up @@ -135,13 +132,6 @@ public GridLength AvalonImageSize
set => SetProperty(ref _avalonImageSize, value);
}

private IDictionary<FGame, AesResponse> _aesKeys = new Dictionary<FGame, AesResponse>();
public IDictionary<FGame, AesResponse> AesKeys
{
get => _aesKeys;
set => SetProperty(ref _aesKeys, value);
}

private string _audioDeviceId;
public string AudioDeviceId
{
Expand Down Expand Up @@ -233,177 +223,34 @@ public bool ReadScriptData
set => SetProperty(ref _readScriptData, value);
}

// <gameDirectory as string, settings>
// can't refactor to use this data layout for everything
// because it will wipe old user settings that relies on FGame
private IDictionary<string, GameSelectorViewModel.DetectedGame> _manualGames = new Dictionary<string, GameSelectorViewModel.DetectedGame>();
public IDictionary<string, GameSelectorViewModel.DetectedGame> ManualGames
private IDictionary<string, DirectorySettings> _perDirectory = new Dictionary<string, DirectorySettings>();
public IDictionary<string, DirectorySettings> PerDirectory
{
get => _manualGames;
set => SetProperty(ref _manualGames, value);
get => _perDirectory;
set => SetProperty(ref _perDirectory, value);
}

private ETexturePlatform _overridedPlatform = ETexturePlatform.DesktopMobile;
public ETexturePlatform OverridedPlatform
{
get => _overridedPlatform;
set => SetProperty(ref _overridedPlatform, value);
}

private IDictionary<FGame, string> _presets = new Dictionary<FGame, string>
{
{FGame.Unknown, Constants._NO_PRESET_TRIGGER},
{FGame.FortniteGame, Constants._NO_PRESET_TRIGGER},
{FGame.ShooterGame, Constants._NO_PRESET_TRIGGER},
{FGame.DeadByDaylight, Constants._NO_PRESET_TRIGGER},
{FGame.OakGame, Constants._NO_PRESET_TRIGGER},
{FGame.Dungeons, Constants._NO_PRESET_TRIGGER},
{FGame.WorldExplorers, Constants._NO_PRESET_TRIGGER},
{FGame.g3, Constants._NO_PRESET_TRIGGER},
{FGame.StateOfDecay2, Constants._NO_PRESET_TRIGGER},
{FGame.Prospect, Constants._NO_PRESET_TRIGGER},
{FGame.Indiana, Constants._NO_PRESET_TRIGGER},
{FGame.RogueCompany, Constants._NO_PRESET_TRIGGER},
{FGame.SwGame, Constants._NO_PRESET_TRIGGER},
{FGame.Platform, Constants._NO_PRESET_TRIGGER},
{FGame.BendGame, Constants._NO_PRESET_TRIGGER},
{FGame.TslGame, Constants._NO_PRESET_TRIGGER},
{FGame.PortalWars, Constants._NO_PRESET_TRIGGER},
{FGame.Gameface, Constants._NO_PRESET_TRIGGER},
{FGame.Athena, Constants._NO_PRESET_TRIGGER},
{FGame.MultiVersus, Constants._NO_PRESET_TRIGGER},
{FGame.Hotta, Constants._NO_PRESET_TRIGGER},
{FGame.eFootball, Constants._NO_PRESET_TRIGGER}
};
public IDictionary<FGame, string> Presets
{
get => _presets;
set => SetProperty(ref _presets, value);
}

private IDictionary<FGame, EGame> _overridedGame = new Dictionary<FGame, EGame>
{
{FGame.Unknown, EGame.GAME_UE4_LATEST},
{FGame.FortniteGame, EGame.GAME_UE5_2},
{FGame.ShooterGame, EGame.GAME_Valorant},
{FGame.DeadByDaylight, EGame.GAME_UE4_27},
{FGame.OakGame, EGame.GAME_Borderlands3},
{FGame.Dungeons, EGame.GAME_UE4_22},
{FGame.WorldExplorers, EGame.GAME_UE4_24},
{FGame.g3, EGame.GAME_UE4_22},
{FGame.StateOfDecay2, EGame.GAME_StateOfDecay2},
{FGame.Prospect, EGame.GAME_Splitgate},
{FGame.Indiana, EGame.GAME_UE4_21},
{FGame.RogueCompany, EGame.GAME_RogueCompany},
{FGame.SwGame, EGame.GAME_UE4_LATEST},
{FGame.Platform, EGame.GAME_UE4_26},
{FGame.BendGame, EGame.GAME_UE4_11},
{FGame.TslGame, EGame.GAME_PlayerUnknownsBattlegrounds},
{FGame.PortalWars, EGame.GAME_UE4_27},
{FGame.Gameface, EGame.GAME_GTATheTrilogyDefinitiveEdition},
{FGame.Athena, EGame.GAME_SeaOfThieves},
{FGame.MultiVersus, EGame.GAME_UE4_26},
{FGame.Hotta, EGame.GAME_TowerOfFantasy},
{FGame.eFootball, EGame.GAME_UE4_26}
};
public IDictionary<FGame, EGame> OverridedGame
{
get => _overridedGame;
set => SetProperty(ref _overridedGame, value);
}

private IDictionary<FGame, List<FCustomVersion>> _overridedCustomVersions = new Dictionary<FGame, List<FCustomVersion>>
{
{FGame.Unknown, null},
{FGame.FortniteGame, null},
{FGame.ShooterGame, null},
{FGame.DeadByDaylight, null},
{FGame.OakGame, null},
{FGame.Dungeons, null},
{FGame.WorldExplorers, null},
{FGame.g3, null},
{FGame.StateOfDecay2, null},
{FGame.Prospect, null},
{FGame.Indiana, null},
{FGame.RogueCompany, null},
{FGame.SwGame, null},
{FGame.Platform, null},
{FGame.BendGame, null},
{FGame.TslGame, null},
{FGame.PortalWars, null},
{FGame.Gameface, null},
{FGame.Athena, null},
{FGame.MultiVersus, null},
{FGame.Hotta, null},
{FGame.eFootball, null}
};
public IDictionary<FGame, List<FCustomVersion>> OverridedCustomVersions
{
get => _overridedCustomVersions;
set => SetProperty(ref _overridedCustomVersions, value);
}

private IDictionary<FGame, Dictionary<string, bool>> _overridedOptions = new Dictionary<FGame, Dictionary<string, bool>>
{
{FGame.Unknown, null},
{FGame.FortniteGame, null},
{FGame.ShooterGame, null},
{FGame.DeadByDaylight, null},
{FGame.OakGame, null},
{FGame.Dungeons, null},
{FGame.WorldExplorers, null},
{FGame.g3, null},
{FGame.StateOfDecay2, null},
{FGame.Prospect, null},
{FGame.Indiana, null},
{FGame.RogueCompany, null},
{FGame.SwGame, null},
{FGame.Platform, null},
{FGame.BendGame, null},
{FGame.TslGame, null},
{FGame.PortalWars, null},
{FGame.Gameface, null},
{FGame.Athena, null},
{FGame.MultiVersus, null},
{FGame.Hotta, null},
{FGame.eFootball, null}
};
public DirectorySettings CurrentDir { get; set; }

private IDictionary<FGame, Dictionary<string, KeyValuePair<string, string>>> _overridedMapStructTypes = new Dictionary<FGame, Dictionary<string, KeyValuePair<string, string>>>
{
{FGame.Unknown, null},
{FGame.FortniteGame, null},
{FGame.ShooterGame, null},
{FGame.DeadByDaylight, null},
{FGame.OakGame, null},
{FGame.Dungeons, null},
{FGame.WorldExplorers, null},
{FGame.g3, null},
{FGame.StateOfDecay2, null},
{FGame.Prospect, null},
{FGame.Indiana, null},
{FGame.RogueCompany, null},
{FGame.SwGame, null},
{FGame.Platform, null},
{FGame.BendGame, null},
{FGame.TslGame, null},
{FGame.PortalWars, null},
{FGame.Gameface, null},
{FGame.Athena, null},
{FGame.MultiVersus, null},
{FGame.Hotta, null},
{FGame.eFootball, null}
};
public IDictionary<FGame, Dictionary<string, bool>> OverridedOptions
/// <summary>
/// TO DELETEEEEEEEEEEEEE
/// </summary>

private IDictionary<FGame, AesResponse> _aesKeys = new Dictionary<FGame, AesResponse>();
public IDictionary<FGame, AesResponse> AesKeys
{
get => _overridedOptions;
set => SetProperty(ref _overridedOptions, value);
get => _aesKeys;
set => SetProperty(ref _aesKeys, value);
}

public IDictionary<FGame, Dictionary<string, KeyValuePair<string, string>>> OverridedMapStructTypes
// <gameDirectory as string, settings>
// can't refactor to use this data layout for everything
// because it will wipe old user settings that relies on FGame
private IDictionary<string, GameSelectorViewModel.DetectedGame> _manualGames = new Dictionary<string, GameSelectorViewModel.DetectedGame>();
public IDictionary<string, GameSelectorViewModel.DetectedGame> ManualGames
{
get => _overridedMapStructTypes;
set => SetProperty(ref _overridedMapStructTypes, value);
get => _manualGames;
set => SetProperty(ref _manualGames, value);
}

private IDictionary<FGame, FEndpoint[]> _customEndpoints = new Dictionary<FGame, FEndpoint[]>
Expand Down Expand Up @@ -437,11 +284,6 @@ public IDictionary<FGame, Dictionary<string, KeyValuePair<string, string>>> Over
{FGame.Hotta, new FEndpoint[]{new (), new ()}},
{FGame.eFootball, new FEndpoint[]{new (), new ()}}
};
public IDictionary<FGame, FEndpoint[]> CustomEndpoints
{
get => _customEndpoints;
set => SetProperty(ref _customEndpoints, value);
}

private IDictionary<FGame, IList<CustomDirectory>> _customDirectories = new Dictionary<FGame, IList<CustomDirectory>>
{
Expand Down Expand Up @@ -515,11 +357,6 @@ public IDictionary<FGame, FEndpoint[]> CustomEndpoints
{FGame.Hotta, new List<CustomDirectory>()},
{FGame.eFootball, new List<CustomDirectory>()}
};
public IDictionary<FGame, IList<CustomDirectory>> CustomDirectories
{
get => _customDirectories;
set => SetProperty(ref _customDirectories, value);
}

private DateTime _lastAesReload = DateTime.Today.AddDays(-1);
public DateTime LastAesReload
Expand Down
Loading

0 comments on commit 011046a

Please sign in to comment.