MapStructTypes dictionary UI

This commit is contained in:
LongerWarrior 2023-01-27 12:40:01 +02:00
parent e96a3b6d4d
commit 58d941c91c
8 changed files with 100 additions and 5 deletions

View File

@ -361,12 +361,44 @@ namespace FModel.Settings
{FGame.Hotta, null},
{FGame.eFootball, null}
};
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.PandaGame, null},
{FGame.Hotta, null},
{FGame.eFootball, null}
};
public IDictionary<FGame, Dictionary<string, bool>> OverridedOptions
{
get => _overridedOptions;
set => SetProperty(ref _overridedOptions, value);
}
public IDictionary<FGame, Dictionary<string, KeyValuePair<string, string>>> OverridedMapStructTypes
{
get => _overridedMapStructTypes;
set => SetProperty(ref _overridedMapStructTypes, value);
}
private IDictionary<FGame, FEndpoint[]> _customEndpoints = new Dictionary<FGame, FEndpoint[]>
{
{FGame.Unknown, new FEndpoint[]{new (), new ()}},

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using CUE4Parse.UE4.Versions;
using FModel.Creator;
@ -39,6 +39,7 @@ public class Version
[J] public int UeVer { get; private set; }
[J] public Dictionary<string, int> CustomVersions { get; private set; }
[J] public Dictionary<string, bool> Options { get; private set; }
[J] public Dictionary<string, KeyValuePair<string, string>> MapStructTypes { get; private set; }
}
[DebuggerDisplay("{" + nameof(Mode) + "}")]
@ -195,4 +196,4 @@ public class CommunityDesign
};
}
}
}
}

View File

@ -146,7 +146,8 @@ public class CUE4ParseViewModel : ViewModel
Game = Helper.IAmThePanda(parent) ? FGame.PandaGame : parent.ToEnum(FGame.Unknown);
var versions = new VersionContainer(UserSettings.Default.OverridedGame[Game], UserSettings.Default.OverridedPlatform,
customVersions: UserSettings.Default.OverridedCustomVersions[Game],
optionOverrides: UserSettings.Default.OverridedOptions[Game]);
optionOverrides: UserSettings.Default.OverridedOptions[Game],
mapStructTypesOverrides: UserSettings.Default.OverridedMapStructTypes[Game]);
switch (Game)
{
@ -178,7 +179,8 @@ public class CUE4ParseViewModel : ViewModel
{
versions = new VersionContainer(settings.OverridedGame, UserSettings.Default.OverridedPlatform,
customVersions: settings.OverridedCustomVersions,
optionOverrides: settings.OverridedOptions);
optionOverrides: settings.OverridedOptions,
mapStructTypesOverrides: settings.OverridedMapStructTypes);
goto default;
}
default:

View File

@ -29,6 +29,7 @@ public class GameSelectorViewModel : ViewModel
public EGame OverridedGame { get; set; }
public List<FCustomVersion> OverridedCustomVersions { get; set; }
public Dictionary<string, bool> OverridedOptions { get; set; }
public Dictionary<string, KeyValuePair<string, string>> OverridedMapStructTypes { get; set; }
public IList<CustomDirectory> CustomDirectories { get; set; }
}
@ -74,6 +75,7 @@ public class GameSelectorViewModel : ViewModel
OverridedGame = EGame.GAME_UE4_LATEST,
OverridedCustomVersions = null,
OverridedOptions = null,
OverridedMapStructTypes = null,
CustomDirectories = new List<CustomDirectory>()
};

View File

@ -76,6 +76,13 @@ public class SettingsViewModel : ViewModel
set => SetProperty(ref _selectedOptions, value);
}
private Dictionary<string, KeyValuePair<string, string>> _selectedMapStructTypes;
public Dictionary<string, KeyValuePair<string, string>> SelectedMapStructTypes
{
get => _selectedMapStructTypes;
set => SetProperty(ref _selectedMapStructTypes, value);
}
private FEndpoint _aesEndpoint;
public FEndpoint AesEndpoint
{
@ -192,6 +199,7 @@ public class SettingsViewModel : ViewModel
private EGame _ueGameSnapshot;
private List<FCustomVersion> _customVersionsSnapshot;
private Dictionary<string, bool> _optionsSnapshot;
private Dictionary<string, KeyValuePair<string, string>> _mapStructTypesSnapshot;
private ELanguage _assetLanguageSnapshot;
private ECompressedAudio _compressedAudioSnapshot;
private EIconStyle _cosmeticStyleSnapshot;
@ -225,12 +233,14 @@ public class SettingsViewModel : ViewModel
_ueGameSnapshot = settings.OverridedGame;
_customVersionsSnapshot = settings.OverridedCustomVersions;
_optionsSnapshot = settings.OverridedOptions;
_mapStructTypesSnapshot = settings.OverridedMapStructTypes;
}
else
{
_ueGameSnapshot = UserSettings.Default.OverridedGame[_game];
_customVersionsSnapshot = UserSettings.Default.OverridedCustomVersions[_game];
_optionsSnapshot = UserSettings.Default.OverridedOptions[_game];
_mapStructTypesSnapshot = UserSettings.Default.OverridedMapStructTypes[_game];
}
if (UserSettings.Default.CustomEndpoints.TryGetValue(_game, out var endpoints))
@ -259,6 +269,7 @@ public class SettingsViewModel : ViewModel
SelectedUeGame = _ueGameSnapshot;
SelectedCustomVersions = _customVersionsSnapshot;
SelectedOptions = _optionsSnapshot;
SelectedMapStructTypes = _mapStructTypesSnapshot;
SelectedAssetLanguage = _assetLanguageSnapshot;
SelectedCompressedAudio = _compressedAudioSnapshot;
SelectedCosmeticStyle = _cosmeticStyleSnapshot;
@ -317,6 +328,12 @@ public class SettingsViewModel : ViewModel
{
SelectedOptions[k] = v;
}
SelectedMapStructTypes = new Dictionary<string, KeyValuePair<string, string>>();
foreach (var (k, v) in version.MapStructTypes)
{
SelectedMapStructTypes[k] = v;
}
}
public void ResetPreset()
@ -324,6 +341,7 @@ public class SettingsViewModel : ViewModel
SelectedUeGame = _ueGameSnapshot;
SelectedCustomVersions = _customVersionsSnapshot;
SelectedOptions = _optionsSnapshot;
SelectedMapStructTypes = _mapStructTypesSnapshot;
}
public bool Save(out List<SettingsOut> whatShouldIDo)
@ -340,6 +358,7 @@ public class SettingsViewModel : ViewModel
if (_ueGameSnapshot != SelectedUeGame || _customVersionsSnapshot != SelectedCustomVersions ||
_uePlatformSnapshot != SelectedUePlatform || _optionsSnapshot != SelectedOptions || // combobox
_mapStructTypesSnapshot != SelectedMapStructTypes ||
_outputSnapshot != UserSettings.Default.OutputDirectory || // textbox
_rawDataSnapshot != UserSettings.Default.RawDataDirectory || // textbox
_propertiesSnapshot != UserSettings.Default.PropertiesDirectory || // textbox
@ -357,12 +376,14 @@ public class SettingsViewModel : ViewModel
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedGame = SelectedUeGame;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedCustomVersions = SelectedCustomVersions;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedOptions = SelectedOptions;
UserSettings.Default.ManualGames[UserSettings.Default.GameDirectory].OverridedMapStructTypes = SelectedMapStructTypes;
}
else
{
UserSettings.Default.OverridedGame[_game] = SelectedUeGame;
UserSettings.Default.OverridedCustomVersions[_game] = SelectedCustomVersions;
UserSettings.Default.OverridedOptions[_game] = SelectedOptions;
UserSettings.Default.OverridedMapStructTypes[_game] = SelectedMapStructTypes;
}
UserSettings.Default.AssetLanguage = SelectedAssetLanguage;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
@ -16,15 +16,18 @@ public partial class DictionaryEditor
private readonly bool _enableElements;
private readonly List<FCustomVersion> _defaultCustomVersions;
private readonly Dictionary<string, bool> _defaultOptions;
private readonly Dictionary<string, KeyValuePair<string, string>> _defaultMapStructTypes;
public List<FCustomVersion> CustomVersions { get; private set; }
public Dictionary<string, bool> Options { get; private set; }
public Dictionary<string, KeyValuePair<string, string>> MapStructTypes { get; private set; }
public DictionaryEditor(string title, bool enableElements)
{
_enableElements = enableElements;
_defaultCustomVersions = new List<FCustomVersion> { new() { Key = new FGuid(), Version = 0 } };
_defaultOptions = new Dictionary<string, bool> { { "key1", true }, { "key2", false } };
_defaultMapStructTypes = new Dictionary<string, KeyValuePair<string, string>> { { "MapName", new KeyValuePair<string, string>("KeyType", "ValueType") } };
InitializeComponent();
@ -49,6 +52,14 @@ public partial class DictionaryEditor
};
}
public DictionaryEditor(Dictionary<string, KeyValuePair<string, string>> options, string title, bool enableElements) : this(title, enableElements)
{
MyAvalonEditor.Document = new TextDocument
{
Text = JsonConvert.SerializeObject(options ?? _defaultMapStructTypes, Formatting.Indented)
};
}
private void OnClick(object sender, RoutedEventArgs e)
{
if (!_enableElements)
@ -74,6 +85,12 @@ public partial class DictionaryEditor
DialogResult = true;
Close();
break;
case "MapStructTypes":
MapStructTypes = JsonConvert.DeserializeObject<Dictionary<string, KeyValuePair<string, string>>>(MyAvalonEditor.Document.Text);
// DialogResult = !Options.SequenceEqual(_defaultOptions);
DialogResult = true;
Close();
break;
default:
throw new NotImplementedException();
}
@ -100,6 +117,10 @@ public partial class DictionaryEditor
{
Text = JsonConvert.SerializeObject(_defaultOptions, Formatting.Indented)
},
"MapStructTypes" => new TextDocument
{
Text = JsonConvert.SerializeObject(_defaultMapStructTypes, Formatting.Indented)
},
_ => throw new NotImplementedException()
};
}

View File

@ -186,10 +186,13 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="AES" Click="OpenAesEndpoint" />
<Button Grid.Column="2" Content="Mapping" Click="OpenMappingEndpoint" />
<Button Grid.Column="4" Content="MapStructTypes" Click="OpenMapStructTypes" />
</Grid>
<TextBlock Grid.Row="13" Grid.Column="0" Text="AES Reload at Launch" VerticalAlignment="Center" Margin="0 0 0 5"

View File

@ -183,6 +183,19 @@ public partial class SettingsView
_applicationView.SettingsView.SelectedOptions = editor.Options;
}
private void OpenMapStructTypes(object sender, RoutedEventArgs e)
{
var editor = new DictionaryEditor(
_applicationView.SettingsView.SelectedMapStructTypes,
"MapStructTypes",
_applicationView.SettingsView.EnableElements);
var result = editor.ShowDialog();
if (!result.HasValue || !result.Value)
return;
_applicationView.SettingsView.SelectedMapStructTypes = editor.MapStructTypes;
}
private void OpenAesEndpoint(object sender, RoutedEventArgs e)
{
var editor = new EndpointEditor(