From d07be619c6376351e5ab8680a68030182f77600d Mon Sep 17 00:00:00 2001 From: And42 Date: Mon, 7 Sep 2020 11:44:05 +0300 Subject: [PATCH 01/33] Added new predefined pack tags --- .../PredefinedTagToStringConverter.cs | 98 ++++++- .../Code/Enums/BonusType.cs | 3 +- .../Code/Enums/FileType.cs | 23 +- .../Code/Enums/PredefinedPackTag.cs | 31 ++- .../Code/Implementations/FileConverter.cs | 17 +- .../Code/Implementations/PackProcessor.cs | 3 + .../ModifiedFileTemplateSelector.cs | 51 ++-- .../Code/Utils/PackUtils.cs | 10 +- .../ViewModels/ConverterWindowViewModel.cs | 8 +- .../Code/ViewModels/PackCreationViewModel.cs | 79 ++++-- .../Pages/PackCreation/PackCreationStep1.xaml | 2 +- .../Localizations/StringResources.Designer.cs | 258 +++++++++++++++++- .../Localizations/StringResources.resx | 88 +++++- .../Localizations/StringResources.ru-RU.resx | 88 +++++- 14 files changed, 644 insertions(+), 115 deletions(-) diff --git a/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs b/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs index c962efe..a3d6674 100644 --- a/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs @@ -12,7 +12,38 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { return (value as PredefinedPackTag?) switch { - PredefinedPackTag.Animated => StringResources.PredefinedPackTagAnimated, + PredefinedPackTag.TexturesAnimated => StringResources.PredefinedPackTagTexturesAnimated, + PredefinedPackTag.TexturesWeapons => StringResources.PredefinedPackTagTexturesWeapons, + PredefinedPackTag.TexturesTools => StringResources.PredefinedPackTagTexturesTools, + PredefinedPackTag.TexturesVanity => StringResources.PredefinedPackTagTexturesVanity, + PredefinedPackTag.TexturesArmor => StringResources.PredefinedPackTagTexturesArmor, + PredefinedPackTag.TexturesPets => StringResources.PredefinedPackTagTexturesPets, + PredefinedPackTag.TexturesBosses => StringResources.PredefinedPackTagTexturesBosses, + PredefinedPackTag.TexturesMobs => StringResources.PredefinedPackTagTexturesMobs, + PredefinedPackTag.TexturesNpc => StringResources.PredefinedPackTagTexturesNpc, + PredefinedPackTag.TexturesBlocks => StringResources.PredefinedPackTagTexturesBlocks, + PredefinedPackTag.TexturesOther => StringResources.PredefinedPackTagTexturesOther, + PredefinedPackTag.MapsBuildings => StringResources.PredefinedPackTagMapsBuildings, + PredefinedPackTag.MapsAdventure => StringResources.PredefinedPackTagMapsAdventure, + PredefinedPackTag.MapsSurvival => StringResources.PredefinedPackTagMapsSurvival, + PredefinedPackTag.MapsOther => StringResources.PredefinedPackTagMapsOther, + PredefinedPackTag.CharactersCombat => StringResources.PredefinedPackTagCharactersCombat, + PredefinedPackTag.CharactersAppearance => StringResources.PredefinedPackTagCharactersAppearance, + PredefinedPackTag.CharactersOther => StringResources.PredefinedPackTagCharactersOther, + PredefinedPackTag.GuiAnimated => StringResources.PredefinedPackTagGuiAnimated, + PredefinedPackTag.GuiInventory => StringResources.PredefinedPackTagGuiInventory, + PredefinedPackTag.GuiHealthOrMana => StringResources.PredefinedPackTagGuiHealthOrMana, + PredefinedPackTag.GuiGeneral => StringResources.PredefinedPackTagGuiGeneral, + PredefinedPackTag.GuiOther => StringResources.PredefinedPackTagGuiOther, + PredefinedPackTag.AudioBiomsOrLocation => StringResources.PredefinedPackTagAudioBiomsOrLocations, + PredefinedPackTag.AudioBosses => StringResources.PredefinedPackTagAudioBosses, + PredefinedPackTag.AudioEvents => StringResources.PredefinedPackTagAudioEvents, + PredefinedPackTag.AudioSounds => StringResources.PredefinedPackTagAudioSounds, + PredefinedPackTag.AudioOther => StringResources.PredefinedPackTagAudioOther, + PredefinedPackTag.FontsAnimated => StringResources.PredefinedPackTagFontsAnimated, + PredefinedPackTag.LastEnumElement => throw new ArgumentException( + (1 / (29 / (int) PredefinedPackTag.LastEnumElement)).ToString() + ), _ => null }; } @@ -20,9 +51,70 @@ public object Convert(object value, Type targetType, object parameter, CultureIn public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var val = value as string; + if (val == null) + return null; - if (val == StringResources.PredefinedPackTagAnimated) - return PredefinedPackTag.Animated; +#pragma warning disable 219 + const int _ = 1 / (29 / (int) PredefinedPackTag.LastEnumElement); +#pragma warning restore 219 + if (val == StringResources.PredefinedPackTagTexturesAnimated) + return PredefinedPackTag.TexturesAnimated; + if (val == StringResources.PredefinedPackTagTexturesWeapons) + return PredefinedPackTag.TexturesWeapons; + if (val == StringResources.PredefinedPackTagTexturesTools) + return PredefinedPackTag.TexturesTools; + if (val == StringResources.PredefinedPackTagTexturesVanity) + return PredefinedPackTag.TexturesVanity; + if (val == StringResources.PredefinedPackTagTexturesArmor) + return PredefinedPackTag.TexturesArmor; + if (val == StringResources.PredefinedPackTagTexturesPets) + return PredefinedPackTag.TexturesPets; + if (val == StringResources.PredefinedPackTagTexturesBosses) + return PredefinedPackTag.AudioBosses; + if (val == StringResources.PredefinedPackTagTexturesMobs) + return PredefinedPackTag.TexturesMobs; + if (val == StringResources.PredefinedPackTagTexturesNpc) + return PredefinedPackTag.TexturesNpc; + if (val == StringResources.PredefinedPackTagTexturesBlocks) + return PredefinedPackTag.TexturesBlocks; + if (val == StringResources.PredefinedPackTagTexturesOther) + return PredefinedPackTag.TexturesOther; + if (val == StringResources.PredefinedPackTagMapsBuildings) + return PredefinedPackTag.MapsBuildings; + if (val == StringResources.PredefinedPackTagMapsAdventure) + return PredefinedPackTag.MapsAdventure; + if (val == StringResources.PredefinedPackTagMapsSurvival) + return PredefinedPackTag.MapsSurvival; + if (val == StringResources.PredefinedPackTagMapsOther) + return PredefinedPackTag.MapsOther; + if (val == StringResources.PredefinedPackTagCharactersCombat) + return PredefinedPackTag.CharactersCombat; + if (val == StringResources.PredefinedPackTagCharactersAppearance) + return PredefinedPackTag.CharactersAppearance; + if (val == StringResources.PredefinedPackTagCharactersOther) + return PredefinedPackTag.CharactersOther; + if (val == StringResources.PredefinedPackTagGuiAnimated) + return PredefinedPackTag.GuiAnimated; + if (val == StringResources.PredefinedPackTagGuiInventory) + return PredefinedPackTag.GuiInventory; + if (val == StringResources.PredefinedPackTagGuiHealthOrMana) + return PredefinedPackTag.GuiHealthOrMana; + if (val == StringResources.PredefinedPackTagGuiGeneral) + return PredefinedPackTag.GuiGeneral; + if (val == StringResources.PredefinedPackTagGuiOther) + return PredefinedPackTag.GuiOther; + if (val == StringResources.PredefinedPackTagAudioBiomsOrLocations) + return PredefinedPackTag.AudioBiomsOrLocation; + if (val == StringResources.PredefinedPackTagAudioBosses) + return PredefinedPackTag.AudioBosses; + if (val == StringResources.PredefinedPackTagAudioEvents) + return PredefinedPackTag.AudioEvents; + if (val == StringResources.PredefinedPackTagAudioSounds) + return PredefinedPackTag.AudioSounds; + if (val == StringResources.PredefinedPackTagAudioOther) + return PredefinedPackTag.AudioOther; + if (val == StringResources.PredefinedPackTagFontsAnimated) + return PredefinedPackTag.FontsAnimated; return null; } } diff --git a/TerrLauncherPackCreator/Code/Enums/BonusType.cs b/TerrLauncherPackCreator/Code/Enums/BonusType.cs index ec01c4f..fd2b80b 100644 --- a/TerrLauncherPackCreator/Code/Enums/BonusType.cs +++ b/TerrLauncherPackCreator/Code/Enums/BonusType.cs @@ -2,6 +2,7 @@ { public enum BonusType { - OldVersionOwners = 0 + OldVersionOwners = 0, + LastEnumElement } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Enums/FileType.cs b/TerrLauncherPackCreator/Code/Enums/FileType.cs index 78d0f76..5084b80 100644 --- a/TerrLauncherPackCreator/Code/Enums/FileType.cs +++ b/TerrLauncherPackCreator/Code/Enums/FileType.cs @@ -2,20 +2,13 @@ { public enum FileType { - Texture, - Map, - Character, - Gui, - Translation, - Font, - Audio - } -} - -namespace TerrLauncherPackCreator.Code.Utils -{ - public static partial class PackUtils - { - public const int TotalFileTypes = 7; + Texture = 0, + Map = 1, + Character = 2, + Gui = 3, + Translation = 4, + Font = 5, + Audio = 6, + LastEnumElement } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs b/TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs index a32ec65..5657a55 100644 --- a/TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs +++ b/TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs @@ -2,6 +2,35 @@ { public enum PredefinedPackTag { - Animated = 0 + TexturesAnimated = 0, + TexturesWeapons = 1, + TexturesTools = 2, + TexturesVanity = 3, + TexturesArmor = 4, + TexturesPets = 5, + TexturesBosses = 6, + TexturesMobs = 7, + TexturesNpc = 8, + TexturesBlocks = 9, + TexturesOther = 10, + MapsBuildings = 11, + MapsAdventure = 12, + MapsSurvival = 13, + MapsOther = 14, + CharactersCombat = 15, + CharactersAppearance = 16, + CharactersOther = 17, + GuiAnimated = 18, + GuiInventory = 19, + GuiHealthOrMana = 20, + GuiGeneral = 21, + GuiOther = 22, + AudioBiomsOrLocation = 23, + AudioBosses = 24, + AudioEvents = 25, + AudioSounds = 26, + AudioOther = 27, + FontsAnimated = 28, + LastEnumElement } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs b/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs index 8c630f4..ce57860 100644 --- a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs +++ b/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs @@ -49,12 +49,6 @@ [CanBeNull] string configFile if (!File.Exists(targetFile)) throw new FileNotFoundException("File not found", targetFile); - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - // config IPackFileInfo fileInfo = null; if (configFile != null && File.Exists(configFile)) @@ -69,6 +63,9 @@ [CanBeNull] string configFile FileType.Translation => JsonConvert.DeserializeObject(configText), FileType.Font => JsonConvert.DeserializeObject(configText), FileType.Audio => JsonConvert.DeserializeObject(configText), + FileType.LastEnumElement => throw new ArgumentException( + (1 / (7 / (int) FileType.LastEnumElement)).ToString() + ), _ => throw new ArgumentOutOfRangeException() }; if (fileType == FileType.Texture && packStructureVersion < 15) @@ -79,12 +76,6 @@ [CanBeNull] string configFile } } - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - // file string sourceFile; switch (fileType) @@ -101,6 +92,8 @@ [CanBeNull] string configFile File.Copy(targetFile, uniqueFile, overwrite: false); sourceFile = uniqueFile; break; + case FileType.LastEnumElement: + throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); default: throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); } diff --git a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs index 021f7a4..95b25c8 100644 --- a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs +++ b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs @@ -227,6 +227,9 @@ private void SavePackModelInternal(PackModel packModel, string filePath) AuthorJson json = AuthorModelToJson(author, ref authorFileIndex, out bool copyIcon, out fileExtension); authorsMappings.Add((copyIcon ? author.icon : null, copyIcon ? $"{authorFileIndex - 1}{fileExtension}" : null, json)); } +#pragma warning disable 219 + const int _ = 1 / (1 / (int) BonusType.LastEnumElement); +#pragma warning restore 219 var packSettingsJson = new PackSettings( packStructureVersion: packModel.PackStructureVersion, title: packModel.Title, diff --git a/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs b/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs index 69518e1..5c9187b 100644 --- a/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs +++ b/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs @@ -1,8 +1,8 @@ using System.Diagnostics; using System.Windows; using System.Windows.Controls; +using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Models; -using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.TemplateSelectors { @@ -16,42 +16,25 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai var previewItem = (ModifiedFileModel) item; var containerUi = (FrameworkElement) container; - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - +#pragma warning disable 219 + const int _ = 1 / (7 / (int) FileType.LastEnumElement); +#pragma warning restore 219 + string resourceName; if (previewItem.IsDragDropTarget) resourceName = "ModifiedFileDropTargetDataTemplate"; - else switch (item) - { - case ModifiedTextureModel _: - resourceName = "ModifiedTextureTemplate"; - break; - case ModifiedGuiModel _: - resourceName = "ModifiedGuiTemplate"; - break; - case ModifiedFontModel _: - resourceName = "ModifiedFontTemplate"; - break; - case ModifiedMapModel _: - resourceName = "ModifiedMapTemplate"; - break; - case ModifiedCharacterModel _: - resourceName = "ModifiedCharacterTemplate"; - break; - case ModifiedTranslationModel _: - resourceName = "ModifiedTranslationTemplate"; - break; - case ModifiedAudioModel _: - resourceName = "ModifiedAudioTemplate"; - break; - default: - resourceName = "ModifiedFileDataTemplate"; - break; - } + else + resourceName = item switch + { + ModifiedTextureModel _ => "ModifiedTextureTemplate", + ModifiedGuiModel _ => "ModifiedGuiTemplate", + ModifiedFontModel _ => "ModifiedFontTemplate", + ModifiedMapModel _ => "ModifiedMapTemplate", + ModifiedCharacterModel _ => "ModifiedCharacterTemplate", + ModifiedTranslationModel _ => "ModifiedTranslationTemplate", + ModifiedAudioModel _ => "ModifiedAudioTemplate", + _ => "ModifiedFileDataTemplate" + }; return (DataTemplate) containerUi.FindResource(resourceName); } diff --git a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs b/TerrLauncherPackCreator/Code/Utils/PackUtils.cs index 6d1af87..d22cd17 100644 --- a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/PackUtils.cs @@ -6,7 +6,7 @@ namespace TerrLauncherPackCreator.Code.Utils { - public static partial class PackUtils + public static class PackUtils { public const int DefaultAuthorIconHeight = 70; public const string PacksExtension = ".tl"; @@ -22,11 +22,9 @@ public static partial class PackUtils static PackUtils() { - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / TotalFileTypes) + - 1 / (TotalFileTypes / fileTypesHandled); - } +#pragma warning disable 219 + const int _ = 1 / (7 / (int) FileType.LastEnumElement); +#pragma warning restore 219 PacksInfo = new[] { diff --git a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs index 5c6e799..951dbba 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs @@ -115,12 +115,6 @@ private async void DropConvertedFilesCommand_Execute(string[] files) string resultFileName = Path.GetFileNameWithoutExtension(file); if (fileInfo != null) { - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - switch (CurrentFileType) { case FileType.Texture: @@ -151,6 +145,8 @@ private async void DropConvertedFilesCommand_Execute(string[] files) var audioInfo = (AudioFileInfo) fileInfo; resultFileName = audioInfo.EntryName; break; + case FileType.LastEnumElement: + throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); default: throw new ArgumentOutOfRangeException(); } diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index cff6b7e..9dc8b7d 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -28,9 +28,39 @@ public class PackCreationViewModel : ViewModelBase public const int LatestPackStructureVersion = 16; private static readonly ISet IconExtensions = new HashSet {".png", ".gif"}; private static readonly ISet PreviewExtensions = new HashSet {".jpg", ".png", ".gif"}; - private static readonly ISet AllPredefinedTags = new HashSet - { - PredefinedPackTag.Animated + // ReSharper disable once UnusedMember.Local + private const int _ = 1 / (29 / (int) PredefinedPackTag.LastEnumElement); + private static readonly IReadOnlyList AllPredefinedTags = new [] + { + PredefinedPackTag.TexturesAnimated, + PredefinedPackTag.TexturesWeapons, + PredefinedPackTag.TexturesTools, + PredefinedPackTag.TexturesVanity, + PredefinedPackTag.TexturesArmor, + PredefinedPackTag.TexturesPets, + PredefinedPackTag.TexturesBosses, + PredefinedPackTag.TexturesMobs, + PredefinedPackTag.TexturesNpc, + PredefinedPackTag.TexturesBlocks, + PredefinedPackTag.TexturesOther, + PredefinedPackTag.MapsBuildings, + PredefinedPackTag.MapsAdventure, + PredefinedPackTag.MapsSurvival, + PredefinedPackTag.MapsOther, + PredefinedPackTag.CharactersCombat, + PredefinedPackTag.CharactersAppearance, + PredefinedPackTag.CharactersOther, + PredefinedPackTag.GuiAnimated, + PredefinedPackTag.GuiInventory, + PredefinedPackTag.GuiHealthOrMana, + PredefinedPackTag.GuiGeneral, + PredefinedPackTag.GuiOther, + PredefinedPackTag.AudioBiomsOrLocation, + PredefinedPackTag.AudioBosses, + PredefinedPackTag.AudioEvents, + PredefinedPackTag.AudioSounds, + PredefinedPackTag.AudioOther, + PredefinedPackTag.FontsAnimated, }; [NotNull] private readonly IPackProcessor _packProcessor; @@ -78,10 +108,10 @@ public int Version public IReadOnlyList RemainedPredefinedTags => AllPredefinedTags.Except(PredefinedTags).ToList(); - public bool IsPredefindTagsPopupOpen + public bool IsPredefinedTagsPopupOpen { - get => _isPredefindTagsPopupOpen; - set => SetProperty(ref _isPredefindTagsPopupOpen, value); + get => _isPredefinedTagsPopupOpen; + set => SetProperty(ref _isPredefinedTagsPopupOpen, value); } public bool IsBonusPack @@ -110,7 +140,7 @@ public bool IsBonusPack private string _descriptionEnglish; private Guid _guid; private int _version; - private bool _isPredefindTagsPopupOpen; + private bool _isPredefinedTagsPopupOpen; private bool _isBonusPack; #endregion @@ -317,13 +347,13 @@ private bool AddPredefinedTagCanExecute() private void AddPredefinedTagExecuted() { - IsPredefindTagsPopupOpen = true; + IsPredefinedTagsPopupOpen = !IsPredefinedTagsPopupOpen; } private void AddSelectedTagExecuted(PredefinedPackTag tag) { PredefinedTags.Add(tag); - IsPredefindTagsPopupOpen = false; + IsPredefinedTagsPopupOpen = false; } private bool RemovePredefinedTagCanExecute(PredefinedPackTag _) @@ -424,12 +454,12 @@ private void DeleteModifiedItemCommand_Execute(ModifiedFileModel file) private bool SaveResourceCommand_CanExecute([NotNull] ModifiedFileModel file) { +#pragma warning disable 219 { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); + const int _ = 1 / (7 / (int) FileType.LastEnumElement); } - +#pragma warning restore 219 + return !Working && !file.IsDragDropTarget && ( file is ModifiedTextureModel || file is ModifiedGuiModel || @@ -443,11 +473,11 @@ private void SaveResourceCommand_Execute([NotNull] ModifiedFileModel file) if (string.IsNullOrEmpty(file.FilePath) || !File.Exists(file.FilePath)) return; +#pragma warning disable 219 { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); + const int _ = 1 / (7 / (int) FileType.LastEnumElement); } +#pragma warning restore 219 string extension = file switch { @@ -562,12 +592,6 @@ private PackModel GeneratePackModel() .Where(it => !it.modified.IsDragDropTarget) .Select(it => { - { - const int fileTypesHandled = 7; - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - IPackFileInfo fileInfo; switch (it.FilesType) { @@ -631,6 +655,8 @@ private PackModel GeneratePackModel() : $"{audioModel.Prefix}/{audioModel.Name}" ); break; + case FileType.LastEnumElement: + throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); default: throw new ArgumentOutOfRangeException(); } @@ -706,13 +732,6 @@ private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) [NotNull] private static ModifiedFileModel FileToModel(FileType fileType, [NotNull] string filePath, [CanBeNull] IPackFileInfo fileInfo) { - { - const int fileTypesHandled = 7; - // ReSharper disable once UnusedVariable - const int _ = 1 / (fileTypesHandled / PackUtils.TotalFileTypes) + - 1 / (PackUtils.TotalFileTypes / fileTypesHandled); - } - switch (fileType) { case FileType.Texture: @@ -804,6 +823,8 @@ private static ModifiedFileModel FileToModel(FileType fileType, [NotNull] string return model; } + case FileType.LastEnumElement: + throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); default: throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); } diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml index 60f57a0..4e95f59 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml @@ -152,7 +152,7 @@ VerticalAlignment="Center"/> - /// Looks up a localized string similar to Animated. + /// Looks up a localized string similar to Audio: Bioms or locations. + /// + public static string PredefinedPackTagAudioBiomsOrLocations { + get { + return ResourceManager.GetString("PredefinedPackTagAudioBiomsOrLocations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Audio: Bosses. + /// + public static string PredefinedPackTagAudioBosses { + get { + return ResourceManager.GetString("PredefinedPackTagAudioBosses", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Audio: Events. + /// + public static string PredefinedPackTagAudioEvents { + get { + return ResourceManager.GetString("PredefinedPackTagAudioEvents", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Audio: Other. + /// + public static string PredefinedPackTagAudioOther { + get { + return ResourceManager.GetString("PredefinedPackTagAudioOther", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Audio: Sounds. + /// + public static string PredefinedPackTagAudioSounds { + get { + return ResourceManager.GetString("PredefinedPackTagAudioSounds", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Characters: Appearance. + /// + public static string PredefinedPackTagCharactersAppearance { + get { + return ResourceManager.GetString("PredefinedPackTagCharactersAppearance", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Characters: Combat. + /// + public static string PredefinedPackTagCharactersCombat { + get { + return ResourceManager.GetString("PredefinedPackTagCharactersCombat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Characters: Other. + /// + public static string PredefinedPackTagCharactersOther { + get { + return ResourceManager.GetString("PredefinedPackTagCharactersOther", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fonts: Animated. + /// + public static string PredefinedPackTagFontsAnimated { + get { + return ResourceManager.GetString("PredefinedPackTagFontsAnimated", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gui: Animated. + /// + public static string PredefinedPackTagGuiAnimated { + get { + return ResourceManager.GetString("PredefinedPackTagGuiAnimated", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gui: General. + /// + public static string PredefinedPackTagGuiGeneral { + get { + return ResourceManager.GetString("PredefinedPackTagGuiGeneral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gui: Health or mana. + /// + public static string PredefinedPackTagGuiHealthOrMana { + get { + return ResourceManager.GetString("PredefinedPackTagGuiHealthOrMana", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gui: Inventory. + /// + public static string PredefinedPackTagGuiInventory { + get { + return ResourceManager.GetString("PredefinedPackTagGuiInventory", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gui: Other. + /// + public static string PredefinedPackTagGuiOther { + get { + return ResourceManager.GetString("PredefinedPackTagGuiOther", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Maps: Adventure. + /// + public static string PredefinedPackTagMapsAdventure { + get { + return ResourceManager.GetString("PredefinedPackTagMapsAdventure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Maps: Buildings. + /// + public static string PredefinedPackTagMapsBuildings { + get { + return ResourceManager.GetString("PredefinedPackTagMapsBuildings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Maps: Other. + /// + public static string PredefinedPackTagMapsOther { + get { + return ResourceManager.GetString("PredefinedPackTagMapsOther", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Maps: Survival. + /// + public static string PredefinedPackTagMapsSurvival { + get { + return ResourceManager.GetString("PredefinedPackTagMapsSurvival", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Animated. + /// + public static string PredefinedPackTagTexturesAnimated { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesAnimated", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Armor. + /// + public static string PredefinedPackTagTexturesArmor { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesArmor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Blocks. + /// + public static string PredefinedPackTagTexturesBlocks { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesBlocks", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Bosses. + /// + public static string PredefinedPackTagTexturesBosses { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesBosses", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Mobs. + /// + public static string PredefinedPackTagTexturesMobs { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesMobs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Npc. + /// + public static string PredefinedPackTagTexturesNpc { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesNpc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Other. + /// + public static string PredefinedPackTagTexturesOther { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesOther", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Pets. + /// + public static string PredefinedPackTagTexturesPets { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesPets", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Tools. + /// + public static string PredefinedPackTagTexturesTools { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesTools", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Vanity. + /// + public static string PredefinedPackTagTexturesVanity { + get { + return ResourceManager.GetString("PredefinedPackTagTexturesVanity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Textures: Weapons. /// - public static string PredefinedPackTagAnimated { + public static string PredefinedPackTagTexturesWeapons { get { - return ResourceManager.GetString("PredefinedPackTagAnimated", resourceCulture); + return ResourceManager.GetString("PredefinedPackTagTexturesWeapons", resourceCulture); } } diff --git a/TerrLauncherPackCreator/Resources/Localizations/StringResources.resx b/TerrLauncherPackCreator/Resources/Localizations/StringResources.resx index 4deae78..507db53 100644 --- a/TerrLauncherPackCreator/Resources/Localizations/StringResources.resx +++ b/TerrLauncherPackCreator/Resources/Localizations/StringResources.resx @@ -351,8 +351,92 @@ Can't save application settings: - - Animated + + Textures: Animated + + + Textures: Weapons + + + Textures: Tools + + + Textures: Vanity + + + Textures: Armor + + + Textures: Pets + + + Textures: Bosses + + + Textures: Mobs + + + Textures: Npc + + + Textures: Blocks + + + Textures: Other + + + Maps: Buildings + + + Maps: Adventure + + + Maps: Survival + + + Maps: Other + + + Characters: Combat + + + Characters: Appearance + + + Characters: Other + + + Gui: Animated + + + Gui: Inventory + + + Gui: Health or mana + + + Gui: General + + + Gui: Other + + + Audio: Bioms or locations + + + Audio: Bosses + + + Audio: Events + + + Audio: Sounds + + + Audio: Other + + + Fonts: Animated Add tag diff --git a/TerrLauncherPackCreator/Resources/Localizations/StringResources.ru-RU.resx b/TerrLauncherPackCreator/Resources/Localizations/StringResources.ru-RU.resx index b027c9c..41a37ac 100644 --- a/TerrLauncherPackCreator/Resources/Localizations/StringResources.ru-RU.resx +++ b/TerrLauncherPackCreator/Resources/Localizations/StringResources.ru-RU.resx @@ -345,8 +345,8 @@ Не удалось сохранить настройки: - - Анимированный + + Текстуры: Анимированные Добавить тег @@ -378,4 +378,88 @@ Высота иконки: + + Аудио: Биомы или локации + + + Аудио: Боссы + + + Аудио: События + + + Аудио: Другое + + + Аудио: Звуки + + + Персонажи: Внешний вид + + + Персонажи: Боевые + + + Персонажи: Другое + + + Шрифты: Анимированные + + + Интерфейс: Анимированный + + + Интерфейс: Общее + + + Интерфейс: Жизни или мана + + + Интерфейс: Инвентарь + + + Интерфейс: Другое + + + Карты: Прохождение + + + Карты: Постройки + + + Карты: Другое + + + Карты: Выживание + + + Текстуры: Броня + + + Текстуры: Блоки + + + Текстуры: Боссы + + + Текстуры: Мобы + + + Текстуры: Нпс + + + Текстуры: Другое + + + Текстуры: Питомцы + + + Текстуры: Инструменты + + + Текстуры: Костюмы + + + Текстуры: Оружие + \ No newline at end of file From 2eb5d406943cead146fb0492ca0270f37408b98d Mon Sep 17 00:00:00 2001 From: And42 Date: Mon, 7 Sep 2020 17:10:17 +0300 Subject: [PATCH 02/33] Fixed pack settings deserialization --- TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs index 37597bb..9bb9c12 100644 --- a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs +++ b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs @@ -21,7 +21,7 @@ public static PackSettings Deserialize([NotNull] string json) int packStructureVersion = jsonObject["packStructureVersion"]?.ToObject() ?? 0; while (packStructureVersion < PackCreationViewModel.LatestPackStructureVersion) { - if (packStructureVersion < 15) + if (packStructureVersion <= 15) { var authors = jsonObject["authors"]?.ToObject(); if (authors != null) From 3338f7d3f8eed245530e8454e3917c0e0933de95 Mon Sep 17 00:00:00 2001 From: And42 Date: Mon, 7 Sep 2020 17:10:52 +0300 Subject: [PATCH 03/33] Pack structure version changed: 16 > 17 --- TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs | 3 ++- .../Code/ViewModels/PackCreationViewModel.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs index 9bb9c12..17c2c20 100644 --- a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs +++ b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs @@ -19,6 +19,7 @@ public static PackSettings Deserialize([NotNull] string json) { JObject jsonObject = JObject.Parse(json); int packStructureVersion = jsonObject["packStructureVersion"]?.ToObject() ?? 0; + const int _ = 1 / (17 / PackCreationViewModel.LatestPackStructureVersion); while (packStructureVersion < PackCreationViewModel.LatestPackStructureVersion) { if (packStructureVersion <= 15) @@ -36,7 +37,7 @@ public static PackSettings Deserialize([NotNull] string json) } else { - throw new Exception("Can't handle structure version: " + packStructureVersion); + packStructureVersion = 17; } } diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 9dc8b7d..4553a13 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -25,7 +25,7 @@ namespace TerrLauncherPackCreator.Code.ViewModels { public class PackCreationViewModel : ViewModelBase { - public const int LatestPackStructureVersion = 16; + public const int LatestPackStructureVersion = 17; private static readonly ISet IconExtensions = new HashSet {".png", ".gif"}; private static readonly ISet PreviewExtensions = new HashSet {".jpg", ".png", ".gif"}; // ReSharper disable once UnusedMember.Local From 471f2877f3c987c7eb4f7a4a2749578456c5d8a6 Mon Sep 17 00:00:00 2001 From: And42 Date: Mon, 7 Sep 2020 17:11:40 +0300 Subject: [PATCH 04/33] Pack creator version changed: 1.22.1 > 1.23 --- TerrLauncherPackCreator/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TerrLauncherPackCreator/Properties/AssemblyInfo.cs b/TerrLauncherPackCreator/Properties/AssemblyInfo.cs index 7a121d8..6d8a0bc 100644 --- a/TerrLauncherPackCreator/Properties/AssemblyInfo.cs +++ b/TerrLauncherPackCreator/Properties/AssemblyInfo.cs @@ -50,7 +50,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.22.1.0")] -[assembly: AssemblyFileVersion("1.22.1.0")] +[assembly: AssemblyVersion("1.23.0.0")] +[assembly: AssemblyFileVersion("1.23.0.0")] [assembly: NeutralResourcesLanguage("en")] From adfd09d177a9b84a11b9ba7065901bff30ba9f84 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 3 Feb 2021 19:09:30 +0300 Subject: [PATCH 05/33] PackageReference migration --- CommonLibrary/CommonLibrary.csproj | 7 +- CommonLibrary/packages.config | 4 - .../TerrLauncherPackCreator.csproj | 88 ++++++------------- TerrLauncherPackCreator/packages.config | 14 --- .../TerrLauncherPackCreatorTests.csproj | 34 +++---- TerrLauncherPackCreatorTests/packages.config | 6 -- .../TerrLauncherPackCreatorUpdater.csproj | 33 +++---- .../packages.config | 8 -- 8 files changed, 54 insertions(+), 140 deletions(-) delete mode 100644 CommonLibrary/packages.config delete mode 100644 TerrLauncherPackCreator/packages.config delete mode 100644 TerrLauncherPackCreatorTests/packages.config delete mode 100644 TerrLauncherPackCreatorUpdater/packages.config diff --git a/CommonLibrary/CommonLibrary.csproj b/CommonLibrary/CommonLibrary.csproj index 13ec0b8..277f11a 100644 --- a/CommonLibrary/CommonLibrary.csproj +++ b/CommonLibrary/CommonLibrary.csproj @@ -31,9 +31,6 @@ 4 - - ..\packages\JetBrains.Annotations.2020.1.0\lib\net20\JetBrains.Annotations.dll - @@ -61,7 +58,9 @@ - + + 2020.1.0 + \ No newline at end of file diff --git a/CommonLibrary/packages.config b/CommonLibrary/packages.config deleted file mode 100644 index 0dfab75..0000000 --- a/CommonLibrary/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index 18da316..b9545a5 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -1,7 +1,5 @@  - - Debug @@ -43,37 +41,14 @@ Resources\Images\app.ico - - ..\packages\AdonisUI.1.15.0\lib\net45\AdonisUI.dll - True - - - ..\packages\AdonisUI.ClassicTheme.1.15.0\lib\net45\AdonisUI.ClassicTheme.dll - True - - - ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll - - - ..\packages\DotNetZip.1.13.8\lib\net40\DotNetZip.dll - - - ..\packages\JetBrains.Annotations.2020.1.0\lib\net20\JetBrains.Annotations.dll - False Libraries\MVVM_Tools.dll - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll - 4.0 @@ -81,29 +56,6 @@ - - ..\packages\XamlAnimatedGif.1.2.2\lib\net45\XamlAnimatedGif.dll - - - ..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.dll - True - - - ..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll - True - - - ..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll - True - - - ..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll - True - - - ..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.Toolkit.dll - True - @@ -291,7 +243,6 @@ PreserveNewest - @@ -329,15 +280,34 @@ - + + + 1.15.0 + + + 4.1.0 + + + 1.13.8 + + + 3.8.1 + + + 2020.1.0 + + + 12.0.3 + + + 2.1.1 + + + 4.5.0 + + + 1.2.2 + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreator/packages.config b/TerrLauncherPackCreator/packages.config deleted file mode 100644 index b5b76ef..0000000 --- a/TerrLauncherPackCreator/packages.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj b/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj index f5f3175..e3756c9 100644 --- a/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj +++ b/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj @@ -1,6 +1,5 @@  - Debug AnyCPU @@ -38,41 +37,30 @@ 4 - - ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll - - - - Designer - - {7645e727-d062-4e3e-a1d9-1c13bbdfd80b} TerrLauncherPackCreator + + + 2.1.1 + + + 2.1.1 + + + 4.5.0 + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorTests/packages.config b/TerrLauncherPackCreatorTests/packages.config deleted file mode 100644 index b5d714f..0000000 --- a/TerrLauncherPackCreatorTests/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index efd1e04..1d320b3 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -1,7 +1,5 @@  - - Debug @@ -39,19 +37,9 @@ 4 - - ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll - - - ..\packages\DotNetZip.1.13.8\lib\net40\DotNetZip.dll - - - ..\packages\Microsoft.Expression.Drawing.3.0.0\lib\net45\Microsoft.Expression.Drawing.dll - True - False Libraries\MVVM_Tools.dll @@ -110,7 +98,6 @@ - @@ -143,14 +130,16 @@ True + + + 1.13.8 + + + 3.0.0 + + + 2.1.1 + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorUpdater/packages.config b/TerrLauncherPackCreatorUpdater/packages.config deleted file mode 100644 index 762e9db..0000000 --- a/TerrLauncherPackCreatorUpdater/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From d2664e1583e4413acb3df71b92cf2e6ce852310b Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 13:04:32 +0300 Subject: [PATCH 06/33] Updated to Net5.0 --- CommonLibrary/CommonLibrary.csproj | 90 ++-- CommonLibrary/Properties/AssemblyInfo.cs | 35 -- TerrLauncherPackCreator/App.config | 6 - TerrLauncherPackCreator/App.xaml | 14 +- TerrLauncherPackCreator/App.xaml.cs | 4 + TerrLauncherPackCreator/AssemblyInfo.cs | 10 + TerrLauncherPackCreator/FodyWeavers.xml | 4 - TerrLauncherPackCreator/FodyWeavers.xsd | 111 ----- .../Properties/AssemblyInfo.cs | 56 --- .../TerrLauncherPackCreator.csproj | 397 ++++-------------- TerrLauncherPackCreatorUpdater/App.config | 6 - .../AssemblyInfo.cs | 10 + .../FodyWeavers.xml | 4 - .../Properties/AssemblyInfo.cs | 53 --- .../TerrLauncherPackCreatorUpdater.csproj | 182 ++------ 15 files changed, 176 insertions(+), 806 deletions(-) delete mode 100644 CommonLibrary/Properties/AssemblyInfo.cs delete mode 100644 TerrLauncherPackCreator/App.config create mode 100644 TerrLauncherPackCreator/AssemblyInfo.cs delete mode 100644 TerrLauncherPackCreator/FodyWeavers.xml delete mode 100644 TerrLauncherPackCreator/FodyWeavers.xsd delete mode 100644 TerrLauncherPackCreator/Properties/AssemblyInfo.cs delete mode 100644 TerrLauncherPackCreatorUpdater/App.config create mode 100644 TerrLauncherPackCreatorUpdater/AssemblyInfo.cs delete mode 100644 TerrLauncherPackCreatorUpdater/FodyWeavers.xml delete mode 100644 TerrLauncherPackCreatorUpdater/Properties/AssemblyInfo.cs diff --git a/CommonLibrary/CommonLibrary.csproj b/CommonLibrary/CommonLibrary.csproj index 277f11a..654f7bf 100644 --- a/CommonLibrary/CommonLibrary.csproj +++ b/CommonLibrary/CommonLibrary.csproj @@ -1,66 +1,24 @@ - - - - - Debug - AnyCPU - {C963037D-1C4B-4387-BF22-5E15444DF3F5} - Library - Properties - CommonLibrary - CommonLibrary - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - True - True - StringResources.resx - - - - - ResXFileCodeGenerator - StringResources.Designer.cs - - - - - 2020.1.0 - - - - \ No newline at end of file + + + + net5.0-windows + true + CommonLibrary + CommonLibrary + + + + + + ResXFileCodeGenerator + StringResources.Designer.cs + + + + + + 2020.3.0 + + + + diff --git a/CommonLibrary/Properties/AssemblyInfo.cs b/CommonLibrary/Properties/AssemblyInfo.cs deleted file mode 100644 index 01e657f..0000000 --- a/CommonLibrary/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("CommonLibrary")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CommonLibrary")] -[assembly: AssemblyCopyright("© Andrey Skobtsov, 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c963037d-1c4b-4387-bf22-5e15444df3f5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TerrLauncherPackCreator/App.config b/TerrLauncherPackCreator/App.config deleted file mode 100644 index 731f6de..0000000 --- a/TerrLauncherPackCreator/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreator/App.xaml b/TerrLauncherPackCreator/App.xaml index 9a0ab23..1519f3a 100644 --- a/TerrLauncherPackCreator/App.xaml +++ b/TerrLauncherPackCreator/App.xaml @@ -4,16 +4,16 @@ xmlns:templateSelectors="clr-namespace:TerrLauncherPackCreator.Code.TemplateSelectors" ShutdownMode="OnLastWindowClose"> - - + + - + - - - + + + - + \ No newline at end of file diff --git a/TerrLauncherPackCreator/App.xaml.cs b/TerrLauncherPackCreator/App.xaml.cs index 1f8545d..13a889a 100644 --- a/TerrLauncherPackCreator/App.xaml.cs +++ b/TerrLauncherPackCreator/App.xaml.cs @@ -1,7 +1,11 @@ using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; using System.Diagnostics; using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; diff --git a/TerrLauncherPackCreator/AssemblyInfo.cs b/TerrLauncherPackCreator/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/TerrLauncherPackCreator/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/TerrLauncherPackCreator/FodyWeavers.xml b/TerrLauncherPackCreator/FodyWeavers.xml deleted file mode 100644 index a5dcf04..0000000 --- a/TerrLauncherPackCreator/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreator/FodyWeavers.xsd b/TerrLauncherPackCreator/FodyWeavers.xsd deleted file mode 100644 index 44a5374..0000000 --- a/TerrLauncherPackCreator/FodyWeavers.xsd +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks - - - - - A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. - - - - - A list of unmanaged 32 bit assembly names to include, delimited with line breaks. - - - - - A list of unmanaged 64 bit assembly names to include, delimited with line breaks. - - - - - The order of preloaded assemblies, delimited with line breaks. - - - - - - This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. - - - - - Controls if .pdbs for reference assemblies are also embedded. - - - - - Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. - - - - - As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. - - - - - Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. - - - - - Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. - - - - - A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | - - - - - A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. - - - - - A list of unmanaged 32 bit assembly names to include, delimited with |. - - - - - A list of unmanaged 64 bit assembly names to include, delimited with |. - - - - - The order of preloaded assemblies, delimited with |. - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreator/Properties/AssemblyInfo.cs b/TerrLauncherPackCreator/Properties/AssemblyInfo.cs deleted file mode 100644 index 6d8a0bc..0000000 --- a/TerrLauncherPackCreator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TerrLauncherPackCreator")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TerrLauncherPackCreator")] -[assembly: AssemblyCopyright("© Andrey Skobtsov, 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.23.0.0")] -[assembly: AssemblyFileVersion("1.23.0.0")] -[assembly: NeutralResourcesLanguage("en")] - diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index b9545a5..871982f 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -1,313 +1,84 @@ - - - - - Debug - AnyCPU - {7645E727-D062-4E3E-A1D9-1C13BBDFD80B} - WinExe - TerrLauncherPackCreator - TerrLauncherPackCreator - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - true - 8 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - Resources\Images\app.ico - - - - - - False - Libraries\MVVM_Tools.dll - - - - - - 4.0 - - - - - - - - MSBuild:Compile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DragAndDropImage.xaml - - - DragAndDropImageBytes.xaml - - - PackCreationStep4.xaml - - - AuthorEditorWindow.xaml - - - ConverterWindow.xaml - - - PackStartupWindow.xaml - - - MSBuild:Compile - - - - - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - - - - - - - - - - - - - - PageNavigationNumberButton.xaml - - - PackCreationStep5.xaml - - - PackCreationStep3.xaml - - - PackCreationStep2.xaml - - - PackCreationStep1.xaml - - - True - True - StringResources.resx - - - - - MainWindow.xaml - Code - - - MSBuild:Compile - - - - - Code - - - - - - - - PreserveNewest - - - PreserveNewest - - - - - {c963037d-1c4b-4387-bf22-5e15444df3f5} - CommonLibrary - - - - - PublicResXFileCodeGenerator - StringResources.Designer.cs - Designer - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - 1.15.0 - - - 4.1.0 - - - 1.13.8 - - - 3.8.1 - - - 2020.1.0 - - - 12.0.3 - - - 2.1.1 - - - 4.5.0 - - - 1.2.2 - - - - \ No newline at end of file + + + + WinExe + net5.0-windows + true + TerrLauncherPackCreator + TerrLauncherPackCreator + + 1.23.0.0 + 1.23.0.0 + en + + + + + + + + + + + + + + PublicResXFileCodeGenerator + StringResources.Designer.cs + + + + + + 1.17.0 + + + 1.17.0 + + + 1.15.0 + + + 4.0.2 + + + 2020.3.0 + + + 12.0.3 + + + 1.2.3 + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + Libraries\MVVM_Tools.dll + + + + + + + + diff --git a/TerrLauncherPackCreatorUpdater/App.config b/TerrLauncherPackCreatorUpdater/App.config deleted file mode 100644 index 731f6de..0000000 --- a/TerrLauncherPackCreatorUpdater/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorUpdater/AssemblyInfo.cs b/TerrLauncherPackCreatorUpdater/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/TerrLauncherPackCreatorUpdater/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/TerrLauncherPackCreatorUpdater/FodyWeavers.xml b/TerrLauncherPackCreatorUpdater/FodyWeavers.xml deleted file mode 100644 index a5dcf04..0000000 --- a/TerrLauncherPackCreatorUpdater/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/TerrLauncherPackCreatorUpdater/Properties/AssemblyInfo.cs b/TerrLauncherPackCreatorUpdater/Properties/AssemblyInfo.cs deleted file mode 100644 index 1814263..0000000 --- a/TerrLauncherPackCreatorUpdater/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TerrLauncherPackCreatorUpdater")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TerrLauncherPackCreatorUpdater")] -[assembly: AssemblyCopyright("© Andrey Skobtsov, 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.1.0")] -[assembly: AssemblyFileVersion("1.3.1.0")] diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index 1d320b3..666ad7e 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -1,145 +1,37 @@ - - - - - Debug - AnyCPU - {D9CB589C-D3BC-4B09-AC6D-0AA95BAB993E} - WinExe - TerrLauncherPackCreatorUpdater - updater - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - False - Libraries\MVVM_Tools.dll - - - - - 4.0 - - - - - - - - MSBuild:Compile - - - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - - - CircleProgress.xaml - - - True - True - StringResources.resx - - - UpdaterWindow.xaml - Code - - - - - Code - - - - - - - - - - - - - {c963037d-1c4b-4387-bf22-5e15444df3f5} - CommonLibrary - - - - - - - - - - ResXFileCodeGenerator - StringResources.Designer.cs - - - - - {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} - 1 - 0 - 0 - tlbimp - False - True - - - - - 1.13.8 - - - 3.0.0 - - - 2.1.1 - - - - \ No newline at end of file + + + + WinExe + net5.0-windows + true + updater + TerrLauncherPackCreatorUpdater + + TerrLauncherPackCreatorUpdater + 1.3.1.0 + 1.3.1.0 + + + + + + + + + + + + + + ResXFileCodeGenerator + StringResources.Designer.cs + + + + + + 1.15.0 + + + + From 14cfd2437a8e020be39e11c71ca17e5c6595dc87 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 13:08:00 +0300 Subject: [PATCH 07/33] CommonLibrary nullable option --- CommonLibrary/CommonLibrary.csproj | 7 +------ CommonLibrary/CommonUtils/ApplicationDataUtils.cs | 5 +---- CommonLibrary/CommonUtils/CollectionUtils.cs | 4 +--- CommonLibrary/CommonUtils/IOUtils.cs | 10 ++++------ 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/CommonLibrary/CommonLibrary.csproj b/CommonLibrary/CommonLibrary.csproj index 654f7bf..f2325eb 100644 --- a/CommonLibrary/CommonLibrary.csproj +++ b/CommonLibrary/CommonLibrary.csproj @@ -6,6 +6,7 @@ CommonLibrary CommonLibrary + enable @@ -15,10 +16,4 @@ - - - 2020.3.0 - - - diff --git a/CommonLibrary/CommonUtils/ApplicationDataUtils.cs b/CommonLibrary/CommonUtils/ApplicationDataUtils.cs index 8200efc..90a3689 100644 --- a/CommonLibrary/CommonUtils/ApplicationDataUtils.cs +++ b/CommonLibrary/CommonUtils/ApplicationDataUtils.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using JetBrains.Annotations; namespace CommonLibrary.CommonUtils { @@ -24,8 +23,7 @@ static ApplicationDataUtils() PathToSessionTempFolder = Path.Combine(PathToRootFolder, "SessionTemp"); } - [NotNull] - public static string GenerateNonExistentFilePath([CanBeNull] string extension = null) + public static string GenerateNonExistentFilePath(string? extension = null) { string filePath; do @@ -36,7 +34,6 @@ public static string GenerateNonExistentFilePath([CanBeNull] string extension = return filePath; } - [NotNull] public static string GenerateNonExistentDirPath() { string dirPath; diff --git a/CommonLibrary/CommonUtils/CollectionUtils.cs b/CommonLibrary/CommonUtils/CollectionUtils.cs index 8f4ff27..7addbae 100644 --- a/CommonLibrary/CommonUtils/CollectionUtils.cs +++ b/CommonLibrary/CommonUtils/CollectionUtils.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using JetBrains.Annotations; namespace CommonLibrary.CommonUtils { @@ -26,8 +25,7 @@ public static int IndexOf(this IEnumerable items, T item) return -1; } - [NotNull] - public static TOutput[] ConvertAll([NotNull] this TInput[] array, [NotNull] Converter converter) + public static TOutput[] ConvertAll(this TInput[] array, Converter converter) { return Array.ConvertAll(array, converter); } diff --git a/CommonLibrary/CommonUtils/IOUtils.cs b/CommonLibrary/CommonUtils/IOUtils.cs index 895686b..6b467c8 100644 --- a/CommonLibrary/CommonUtils/IOUtils.cs +++ b/CommonLibrary/CommonUtils/IOUtils.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Threading; -using JetBrains.Annotations; namespace CommonLibrary.CommonUtils { @@ -34,21 +33,20 @@ public static void TryDeleteDirectory(string dirPath, int triesCount, int triesS TryAction(() => Directory.Delete(dirPath, true), triesCount, triesSleepMs); } - public static void EnsureDirExists([NotNull] string dir) + public static void EnsureDirExists(string dir) { if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); } - public static void EnsureParentDirExists([NotNull] string filePath) + public static void EnsureParentDirExists(string filePath) { - string parentDir = Path.GetDirectoryName(filePath); + string? parentDir = Path.GetDirectoryName(filePath); if (parentDir != null) EnsureDirExists(parentDir); } - [NotNull] - public static string ChooseLighterFileAndDeleteSecond([NotNull] string first, [NotNull] string second) + public static string ChooseLighterFileAndDeleteSecond(string first, string second) { if (new FileInfo(first).Length > new FileInfo(second).Length) return second; From 8f0860a02576394e458012481ab4ff3713a3da39 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 14:56:39 +0300 Subject: [PATCH 08/33] TerrLauncherPackCreator nullable option --- .../Code/Converters/BytesToStream.cs | 3 +- .../Code/Converters/ColorToBrushConverter.cs | 4 +- .../Code/Implementations/FileConverter.cs | 23 ++++---- .../Code/Implementations/ImageInfo.cs | 7 +-- .../Code/Implementations/PackProcessor.cs | 52 ++++++++++--------- .../Code/Implementations/TempDirsProvider.cs | 5 +- .../Code/Implementations/ValuesProvider.cs | 7 +-- .../Code/Interfaces/IFileConverter.cs | 17 +++--- .../Code/Interfaces/IPackProcessor.cs | 4 +- .../Code/Interfaces/ITempDirsProvider.cs | 5 +- .../Code/Json/AppSettingsJson.cs | 6 +-- .../Code/Json/AuthorsJson.cs | 22 +++----- .../Code/Json/CharacterFileInfo.cs | 6 +-- .../Code/Json/MapFileInfo.cs | 6 +-- .../Code/Json/TL/PackSettings.cs | 37 ++++++------- .../Code/Json/TranslationFileInfo.cs | 6 +-- .../Code/MarkupExtensions/BooleanExtension.cs | 4 -- .../Code/Models/AuthorItemModel.cs | 27 ++++------ .../Code/Models/ModifiedAudioModel.cs | 14 ++--- .../Code/Models/ModifiedCharacterModel.cs | 3 +- .../Code/Models/ModifiedFileModel.cs | 5 +- .../Code/Models/ModifiedFilesGroupModel.cs | 6 +-- .../Code/Models/ModifiedFontModel.cs | 14 ++--- .../Code/Models/ModifiedGuiModel.cs | 14 ++--- .../Code/Models/ModifiedMapModel.cs | 9 ++-- .../Code/Models/ModifiedTextureModel.cs | 15 ++---- .../Code/Models/ModifiedTranslationModel.cs | 6 +-- .../Code/Models/PackModel.cs | 21 +++----- .../Code/Models/PreviewItemModel.cs | 12 ++--- .../Code/Utils/AppUtils.cs | 4 +- .../Code/Utils/BitmapUtils.cs | 10 ++-- .../Code/Utils/DragDropUtils.cs | 15 +++--- .../Code/Utils/ImageUtils.cs | 13 ++--- .../Code/Utils/JsonUtils.cs | 4 +- .../Code/Utils/PackUtils.cs | 6 --- TerrLauncherPackCreator/Code/Utils/Paths.cs | 10 ---- .../Code/Utils/ProcessUtils.cs | 3 +- .../Code/Utils/SafeFileSystemUtils.cs | 5 +- .../ViewModels/AuthorEditorWindowViewModel.cs | 18 ++----- .../ViewModels/ConverterWindowViewModel.cs | 8 +-- .../Code/ViewModels/MainWindowViewModel.cs | 10 +--- .../Code/ViewModels/PackCreationViewModel.cs | 23 ++++---- .../ViewModels/PackStartupWindowViewModel.cs | 18 ++----- .../Code/ViewModels/ViewModelBase.cs | 6 +-- .../TerrLauncherPackCreator.csproj | 4 +- .../Windows/AuthorEditorWindow.xaml.cs | 8 ++- 46 files changed, 179 insertions(+), 346 deletions(-) diff --git a/TerrLauncherPackCreator/Code/Converters/BytesToStream.cs b/TerrLauncherPackCreator/Code/Converters/BytesToStream.cs index e502597..cf2bb34 100644 --- a/TerrLauncherPackCreator/Code/Converters/BytesToStream.cs +++ b/TerrLauncherPackCreator/Code/Converters/BytesToStream.cs @@ -1,13 +1,12 @@ using System.Globalization; using System.IO; -using JetBrains.Annotations; using MVVM_Tools.Code.Classes; namespace TerrLauncherPackCreator.Code.Converters { public class BytesToStream : ConverterBase { - public override Stream ConvertInternal([CanBeNull] byte[] value, object parameter, CultureInfo culture) + public override Stream? ConvertInternal(byte[]? value, object parameter, CultureInfo culture) { return value == null ? null : new MemoryStream(value); } diff --git a/TerrLauncherPackCreator/Code/Converters/ColorToBrushConverter.cs b/TerrLauncherPackCreator/Code/Converters/ColorToBrushConverter.cs index f3d3732..9a3d753 100644 --- a/TerrLauncherPackCreator/Code/Converters/ColorToBrushConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/ColorToBrushConverter.cs @@ -1,14 +1,12 @@ using System.Globalization; using System.Windows.Media; -using JetBrains.Annotations; using MVVM_Tools.Code.Classes; namespace TerrLauncherPackCreator.Code.Converters { public class ColorToBrushConverter : ConverterBase { - [CanBeNull] - private SolidColorBrush _latestBrush; + private SolidColorBrush? _latestBrush; public override SolidColorBrush ConvertInternal(Color value, object parameter, CultureInfo culture) { diff --git a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs b/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs index ce57860..ce38fe0 100644 --- a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs +++ b/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs @@ -2,22 +2,19 @@ using System.IO; using System.Threading.Tasks; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Json; -using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Implementations { public class FileConverter : IFileConverter { - [NotNull] - public async Task<(string convertedFile, string configFile)> ConvertToTarget( + public async Task<(string convertedFile, string? configFile)> ConvertToTarget( FileType fileType, - [NotNull] string sourceFile, - [CanBeNull] IPackFileInfo fileInfo + string sourceFile, + IPackFileInfo? fileInfo ) { if (!File.Exists(sourceFile)) @@ -27,10 +24,10 @@ [CanBeNull] IPackFileInfo fileInfo IOUtils.EnsureParentDirExists(targetFile); // config - string configFile = null; + string? configFile = null; if (fileInfo != null) { configFile = ApplicationDataUtils.GenerateNonExistentFilePath(); - File.WriteAllText(configFile, JsonConvert.SerializeObject(fileInfo, Formatting.Indented)); + await File.WriteAllTextAsync(configFile, JsonConvert.SerializeObject(fileInfo, Formatting.Indented)); } // file @@ -39,21 +36,21 @@ [CanBeNull] IPackFileInfo fileInfo return (targetFile, configFile); } - public async Task<(string sourceFile, IPackFileInfo fileInfo)> ConvertToSource( + public async Task<(string sourceFile, IPackFileInfo? fileInfo)> ConvertToSource( int packStructureVersion, FileType fileType, - [NotNull] string targetFile, - [CanBeNull] string configFile + string targetFile, + string? configFile ) { if (!File.Exists(targetFile)) throw new FileNotFoundException("File not found", targetFile); // config - IPackFileInfo fileInfo = null; + IPackFileInfo? fileInfo = null; if (configFile != null && File.Exists(configFile)) { - string configText = File.ReadAllText(configFile); + string configText = await File.ReadAllTextAsync(configFile); fileInfo = fileType switch { FileType.Texture => JsonConvert.DeserializeObject(configText), diff --git a/TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs b/TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs index a9109f4..b610d2b 100644 --- a/TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs +++ b/TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs @@ -1,6 +1,4 @@ -using JetBrains.Annotations; - -namespace TerrLauncherPackCreator.Code.Implementations { +namespace TerrLauncherPackCreator.Code.Implementations { public class ImageInfo { public enum ImageType { @@ -8,11 +6,10 @@ public enum ImageType { Gif = 1 } - [NotNull] public byte[] Bytes { get; } public ImageType Type { get; } - public ImageInfo([NotNull] byte[] bytes, ImageType type) { + public ImageInfo(byte[] bytes, ImageType type) { Bytes = bytes; Type = type; } diff --git a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs index 95b25c8..55d0e14 100644 --- a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs +++ b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -7,7 +8,6 @@ using System.Windows.Media; using CommonLibrary.CommonUtils; using Ionic.Zip; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Json.TL; @@ -23,24 +23,24 @@ public class PackProcessor : IPackProcessor private const int PackProcessingTries = 20; private const int PackProcessingSleepMs = 500; - public event Action PackLoadingStarted; + public event Action? PackLoadingStarted; - public event Action<(string filePath, PackModel loadedPack, Exception error)> PackLoaded; + public event Action<(string filePath, PackModel loadedPack, Exception? error)>? PackLoaded; - public event Action<(PackModel pack, string targetFilePath)> PackSavingStarted; + public event Action<(PackModel pack, string targetFilePath)>? PackSavingStarted; - public event Action<(PackModel pack, string targetFilePath, Exception error)> PackSaved; + public event Action<(PackModel pack, string targetFilePath, Exception? error)>? PackSaved; - private readonly IProgressManager _loadProgressManager; - private readonly IProgressManager _saveProgressManager; + private readonly IProgressManager? _loadProgressManager; + private readonly IProgressManager? _saveProgressManager; private readonly IFileConverter _fileConverter; private readonly object _loadingLock = new object(); private readonly object _savingLock = new object(); public PackProcessor( - IProgressManager loadProgressManager, - IProgressManager saveProgressManager, + IProgressManager? loadProgressManager, + IProgressManager? saveProgressManager, IFileConverter fileConverter ) { @@ -107,6 +107,7 @@ private void OnPackLoadingStarted(string item) { lock (_loadingLock) { + Debug.Assert(_loadProgressManager != null, nameof(_loadProgressManager) + " != null"); _loadProgressManager.RemainingFilesCount++; } } @@ -115,6 +116,7 @@ private void OnPackLoaded((string filePath, PackModel loadedPack, Exception erro { lock (_loadingLock) { + Debug.Assert(_loadProgressManager != null, nameof(_loadProgressManager) + " != null"); _loadProgressManager.RemainingFilesCount--; } } @@ -123,6 +125,7 @@ private void OnPackSavingStarted((PackModel pack, string targetFilePath) item) { lock (_savingLock) { + Debug.Assert(_saveProgressManager != null, nameof(_saveProgressManager) + " != null"); _saveProgressManager.RemainingFilesCount++; } } @@ -131,6 +134,7 @@ private void OnPackSaved((PackModel pack, string targetFilePath, Exception error { lock (_savingLock) { + Debug.Assert(_saveProgressManager != null, nameof(_saveProgressManager) + " != null"); _saveProgressManager.RemainingFilesCount--; } } @@ -149,10 +153,10 @@ private async Task LoadPackModelInternal(string filePath) string packAuthorsFolder = Path.Combine(targetFolderPath, "Authors"); string packModifiedFilesFolder = Path.Combine(targetFolderPath, "Modified"); - string packSettingsText = File.ReadAllText(packSettingsFile, Encoding.UTF8); + string packSettingsText = await File.ReadAllTextAsync(packSettingsFile, Encoding.UTF8); PackSettings packSettings = PackSettings.Processor.Deserialize(packSettingsText); - string packIconFile = null; + string? packIconFile = null; if (File.Exists(packIconGif)) packIconFile = packIconGif; else if (File.Exists(packIconPng)) @@ -165,7 +169,7 @@ private async Task LoadPackModelInternal(string filePath) ? Directory.EnumerateFiles(packPreviewsFolder) .Where(it => PreviewExtensions.Contains(Path.GetExtension(it))) .ToArray() - : new string[0]; + : Array.Empty(); string[] modifiedFileExts = PackUtils.PacksInfo.Select(it => it.convertedFilesExt).ToArray(); string[] modifiedFilesPaths = @@ -173,7 +177,7 @@ private async Task LoadPackModelInternal(string filePath) ? Directory.EnumerateFiles(packModifiedFilesFolder) .Where(it => modifiedFileExts.Contains(Path.GetExtension(it))) .ToArray() - : new string[0]; + : Array.Empty(); var authors = packSettings.Authors? .ConvertAll(it => JsonToAuthorModel(it, packAuthorsFolder)) @@ -182,7 +186,7 @@ private async Task LoadPackModelInternal(string filePath) var modifiedFiles = new List(); foreach (string modifiedFile in modifiedFilesPaths) { - string configFile = Path.ChangeExtension(modifiedFile, PackUtils.PackFileConfigExtension); + string? configFile = Path.ChangeExtension(modifiedFile, PackUtils.PackFileConfigExtension); if (!File.Exists(configFile)) { configFile = null; } @@ -220,7 +224,7 @@ private async Task LoadPackModelInternal(string filePath) private void SavePackModelInternal(PackModel packModel, string filePath) { - var authorsMappings = new List<(ImageInfo sourceFile, string targetFile, AuthorJson json)>(); + var authorsMappings = new List<(ImageInfo? sourceFile, string? targetFile, AuthorJson json)>(); int authorFileIndex = 1; foreach (var author in packModel.Authors) { string fileExtension; @@ -334,19 +338,18 @@ private void SavePackModelInternal(PackModel packModel, string filePath) } } - [NotNull] private static AuthorJson AuthorModelToJson( (string name, Color? color, string link, ImageInfo icon, int iconHeight) author, ref int authorFileIndex, out bool copyIcon, - [CanBeNull] out string fileExtension + out string? fileExtension ) { string name = author.name ?? string.Empty; string color = author.color?.ToString(); string link = author.link ?? string.Empty; - string icon = null; + string? icon = null; fileExtension = null; if (author.icon != null) { string extension = author.icon.Type switch @@ -375,13 +378,13 @@ [CanBeNull] out string fileExtension ); } - private static (string name, Color? color, string link, ImageInfo icon, int iconHeight) StringToAuthorModel(string author, string authorIconsDir) + private static (string? name, Color? color, string? link, ImageInfo? icon, int iconHeight) StringToAuthorModel(string author, string authorIconsDir) { string[] parts = author.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries); - string name = null; + string? name = null; Color? color = null; - string link = null; - ImageInfo icon = null; + string? link = null; + ImageInfo? icon = null; foreach (string part in parts) { @@ -420,14 +423,13 @@ private static (string name, Color? color, string link, ImageInfo icon, int icon ); } - private static Color ParseAuthorColor([NotNull] string color) + private static Color ParseAuthorColor(string color) { // ReSharper disable once PossibleNullReferenceException return (Color) ColorConverter.ConvertFromString(color); } - [CanBeNull] - private static ImageInfo ParseAuthorIcon([NotNull] string iconPath) + private static ImageInfo? ParseAuthorIcon(string iconPath) { if (!File.Exists(iconPath)) return null; diff --git a/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs b/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs index ae81f8f..b4fc95e 100644 --- a/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs +++ b/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs @@ -1,16 +1,14 @@ using System.IO; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Implementations { public class TempDirsProvider : ITempDirsProvider { - [NotNull] private readonly string _initialDir; - public TempDirsProvider([NotNull] string initialDir) + public TempDirsProvider(string initialDir) { if (!Directory.Exists(initialDir)) Directory.CreateDirectory(initialDir); @@ -18,7 +16,6 @@ public TempDirsProvider([NotNull] string initialDir) _initialDir = initialDir; } - [NotNull] public string GetNewDir() { for (int i = 1;; i++) diff --git a/TerrLauncherPackCreator/Code/Implementations/ValuesProvider.cs b/TerrLauncherPackCreator/Code/Implementations/ValuesProvider.cs index 39bdbc5..4f6f158 100644 --- a/TerrLauncherPackCreator/Code/Implementations/ValuesProvider.cs +++ b/TerrLauncherPackCreator/Code/Implementations/ValuesProvider.cs @@ -1,14 +1,11 @@ -using JetBrains.Annotations; -using TerrLauncherPackCreator.Code.Json; +using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Implementations { public static class ValuesProvider { - [NotNull] public static AppSettingsJson AppSettings => _appSettings ??= AppUtils.LoadAppSettings(); - [CanBeNull] - private static AppSettingsJson _appSettings; + private static AppSettingsJson? _appSettings; } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs b/TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs index 866e7c9..9e70077 100644 --- a/TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs +++ b/TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs @@ -1,24 +1,21 @@ using System.Threading.Tasks; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Enums; namespace TerrLauncherPackCreator.Code.Interfaces { public interface IFileConverter { - [NotNull] - Task<(string convertedFile, string configFile)> ConvertToTarget( + Task<(string convertedFile, string? configFile)> ConvertToTarget( FileType fileType, - [NotNull] string sourceFile, - [CanBeNull] IPackFileInfo fileInfo + string sourceFile, + IPackFileInfo? fileInfo ); - - [NotNull] - Task<(string sourceFile, IPackFileInfo fileInfo)> ConvertToSource( + + Task<(string sourceFile, IPackFileInfo? fileInfo)> ConvertToSource( int packStructureVersion, FileType fileType, - [NotNull] string targetFile, - [CanBeNull] string configFile + string targetFile, + string? configFile ); } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs b/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs index 43d34db..24af0c6 100644 --- a/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs +++ b/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs @@ -5,9 +5,9 @@ namespace TerrLauncherPackCreator.Code.Interfaces { public interface IPackProcessor { - event Action<(string filePath, PackModel loadedPack, Exception error)> PackLoaded; + event Action<(string filePath, PackModel loadedPack, Exception? error)> PackLoaded; - event Action<(PackModel pack, string targetFilePath, Exception error)> PackSaved; + event Action<(PackModel pack, string targetFilePath, Exception? error)> PackSaved; void LoadPackFromFile(string filePath); diff --git a/TerrLauncherPackCreator/Code/Interfaces/ITempDirsProvider.cs b/TerrLauncherPackCreator/Code/Interfaces/ITempDirsProvider.cs index 9fa2bbe..af50863 100644 --- a/TerrLauncherPackCreator/Code/Interfaces/ITempDirsProvider.cs +++ b/TerrLauncherPackCreator/Code/Interfaces/ITempDirsProvider.cs @@ -1,10 +1,7 @@ -using JetBrains.Annotations; - -namespace TerrLauncherPackCreator.Code.Interfaces +namespace TerrLauncherPackCreator.Code.Interfaces { public interface ITempDirsProvider { - [NotNull] string GetNewDir(); void DeleteAll(); diff --git a/TerrLauncherPackCreator/Code/Json/AppSettingsJson.cs b/TerrLauncherPackCreator/Code/Json/AppSettingsJson.cs index a1d32a1..94c8758 100644 --- a/TerrLauncherPackCreator/Code/Json/AppSettingsJson.cs +++ b/TerrLauncherPackCreator/Code/Json/AppSettingsJson.cs @@ -1,11 +1,9 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace TerrLauncherPackCreator.Code.Json { public class AppSettingsJson { - [NotNull] [JsonProperty("app_language", Required = Required.Always)] public string AppLanguage { get; set; } @@ -23,7 +21,7 @@ public AppSettingsJson() } public AppSettingsJson( - [NotNull] string appLanguage, + string appLanguage, int mainWindowWidth, int mainWindowHeight ) diff --git a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs index e4055bb..d26d149 100644 --- a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs +++ b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Windows.Media; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TerrLauncherPackCreator.Code.Implementations; @@ -13,8 +12,7 @@ public class AuthorsJson { public static class Processor { - [NotNull] - public static AuthorsJson Deserialize([NotNull] string json) { + public static AuthorsJson Deserialize(string json) { JObject fileJson = JObject.Parse(json); int fileVersion = fileJson["version"]?.ToObject() ?? 0; bool updatePerformed = false; @@ -28,7 +26,7 @@ public static AuthorsJson Deserialize([NotNull] string json) { { foreach (var author in authors) { - byte[] iconBytes = author["icon"]?.ToObject(); + byte[]? iconBytes = author["icon"]?.ToObject(); if (iconBytes != null) { author["icon"] = JObject.FromObject(new @@ -62,8 +60,7 @@ public static AuthorsJson Deserialize([NotNull] string json) { : JsonConvert.DeserializeObject(json); } - [NotNull] - public static string Serialize([NotNull] AuthorsJson model) { + public static string Serialize(AuthorsJson model) { return JsonUtils.Serialize(model); } } @@ -73,9 +70,8 @@ public static string Serialize([NotNull] AuthorsJson model) { [JsonProperty("version")] public int Version { get; set; } - [CanBeNull] [JsonProperty("authors")] - public List Authors { get; set; } + public List? Authors { get; set; } public static AuthorsJson CreateLatest() { return new AuthorsJson { @@ -105,21 +101,17 @@ ImageInfo.ImageType type } } - [CanBeNull] [JsonProperty("name")] - public string Name { get; set; } + public string? Name { get; set; } - [CanBeNull] [JsonProperty("color")] public Color? Color { get; set; } - [CanBeNull] [JsonProperty("link")] - public string Link { get; set; } + public string? Link { get; set; } - [CanBeNull] [JsonProperty("icon")] - public IconJson Icon { get; set; } + public IconJson? Icon { get; set; } [JsonProperty("icon_height")] public int IconHeight { get; set; } = PackUtils.DefaultAuthorIconHeight; diff --git a/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs b/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs index 2469d2e..50c820b 100644 --- a/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs +++ b/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs @@ -1,12 +1,10 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Json { public class CharacterFileInfo : IPackFileInfo { - [NotNull] [JsonProperty("result_file_name", Required = Required.Always)] public string ResultFileName { get; set; } @@ -15,7 +13,7 @@ public CharacterFileInfo() ResultFileName = string.Empty; } - public CharacterFileInfo([NotNull] string resultFileName) + public CharacterFileInfo(string resultFileName) { ResultFileName = resultFileName; } diff --git a/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs b/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs index 1d53690..211ffb3 100644 --- a/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs +++ b/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs @@ -1,12 +1,10 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Json { public class MapFileInfo : IPackFileInfo { - [NotNull] [JsonProperty("result_file_name", Required = Required.Always)] public string ResultFileName { get; set; } @@ -15,7 +13,7 @@ public MapFileInfo() ResultFileName = string.Empty; } - public MapFileInfo([NotNull] string resultFileName) + public MapFileInfo(string resultFileName) { ResultFileName = resultFileName; } diff --git a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs index 17c2c20..a5f36fc 100644 --- a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs +++ b/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TerrLauncherPackCreator.Code.Enums; @@ -14,8 +13,7 @@ public class PackSettings { public static class Processor { - [NotNull] - public static PackSettings Deserialize([NotNull] string json) + public static PackSettings Deserialize(string json) { JObject jsonObject = JObject.Parse(json); int packStructureVersion = jsonObject["packStructureVersion"]?.ToObject() ?? 0; @@ -44,18 +42,17 @@ public static PackSettings Deserialize([NotNull] string json) return jsonObject.ToObject() ?? throw new Exception("Can't parse json"); } - [NotNull] - public static string Serialize([NotNull] PackSettings settings) + public static string Serialize(PackSettings settings) { return JsonUtils.Serialize(settings); } private static AuthorJson StringToAuthorJson(string author) { - string name = null; - string color = null; - string link = null; - string file = null; + string? name = null; + string? color = null; + string? link = null; + string? file = null; string[] parts = author.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) @@ -101,13 +98,11 @@ private static AuthorJson StringToAuthorJson(string author) [JsonProperty("title")] public string Title { get; set; } - [CanBeNull] [JsonProperty("descriptionEnglish")] - public string DescriptionEnglish { get; set; } + public string? DescriptionEnglish { get; set; } - [CanBeNull] [JsonProperty("descriptionRussian")] - public string DescriptionRussian { get; set; } + public string? DescriptionRussian { get; set; } [JsonProperty("version")] public int Version { get; set; } @@ -115,13 +110,11 @@ private static AuthorJson StringToAuthorJson(string author) [JsonProperty("guid")] public Guid Guid { get; set; } - [CanBeNull] [JsonProperty("authors")] - public List Authors { get; set; } + public List? Authors { get; set; } - [CanBeNull] [JsonProperty("predefined_tags")] - public List PredefinedTags { get; set; } + public List? PredefinedTags { get; set; } [JsonProperty("is_bonus")] public bool IsBonus { get; set; } @@ -133,13 +126,13 @@ public PackSettings() {} public PackSettings( int packStructureVersion, - [CanBeNull] string title, - [CanBeNull] string descriptionEnglish, - [CanBeNull] string descriptionRussian, + string title, + string? descriptionEnglish, + string? descriptionRussian, int version, Guid guid, - [CanBeNull] List authors, - [CanBeNull] List predefinedTags, + List? authors, + List? predefinedTags, bool isBonus, BonusType bonusType ) diff --git a/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs b/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs index fc96303..3a1e037 100644 --- a/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs +++ b/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs @@ -1,12 +1,10 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Json { public class TranslationFileInfo : IPackFileInfo { - [NotNull] [JsonProperty("language", Required = Required.Always)] public string Language { get; set; } @@ -15,7 +13,7 @@ public TranslationFileInfo() Language = string.Empty; } - public TranslationFileInfo([NotNull] string language) + public TranslationFileInfo(string language) { Language = language; } diff --git a/TerrLauncherPackCreator/Code/MarkupExtensions/BooleanExtension.cs b/TerrLauncherPackCreator/Code/MarkupExtensions/BooleanExtension.cs index 91e167f..49eb5b0 100644 --- a/TerrLauncherPackCreator/Code/MarkupExtensions/BooleanExtension.cs +++ b/TerrLauncherPackCreator/Code/MarkupExtensions/BooleanExtension.cs @@ -1,17 +1,13 @@ using System; using System.Windows.Markup; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.MarkupExtensions { public class BooleanExtension : MarkupExtension { - [NotNull] private static readonly object FalseObject = false; - [NotNull] private static readonly object TrueObject = true; - [NotNull] private readonly object _value; public BooleanExtension(bool value) diff --git a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs index 1b23bca..2ebdac8 100644 --- a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs +++ b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs @@ -1,5 +1,4 @@ using System.Windows.Media; -using JetBrains.Annotations; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Utils; @@ -10,29 +9,25 @@ namespace TerrLauncherPackCreator.Code.Models { public class AuthorItemModel : ViewModelBase { - [CanBeNull] - public ImageInfo Image + public ImageInfo? Image { get => _image; set => SetProperty(ref _image, value); } - [CanBeNull] - public string Name + public string? Name { get => _name; set => SetProperty(ref _name, value); } - [CanBeNull] public Color? Color { get => _color; set => SetProperty(ref _color, value); } - [CanBeNull] - public string Link + public string? Link { get => _link; set => SetProperty(ref _link, value); @@ -46,10 +41,10 @@ public int IconHeight public IActionCommand EditAuthorCommand { get; } - [CanBeNull] private ImageInfo _image; - [CanBeNull] private string _name; - [CanBeNull] private Color? _color; - [CanBeNull] private string _link; + private ImageInfo? _image; + private string? _name; + private Color? _color; + private string? _link; private int _iconHeight; public AuthorItemModel(): this( @@ -61,10 +56,10 @@ public AuthorItemModel(): this( ) {} public AuthorItemModel( - [CanBeNull] string name, - [CanBeNull] Color? color, - [CanBeNull] ImageInfo image, - [CanBeNull] string link, + string? name, + Color? color, + ImageInfo? image, + string? link, int iconHeight ) { diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedAudioModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedAudioModel.cs index 5f782b3..735402c 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedAudioModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedAudioModel.cs @@ -1,31 +1,27 @@ using System.Collections.ObjectModel; using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedAudioModel : ModifiedFileModel { - [CanBeNull] - public string Prefix + public string? Prefix { get => _prefix; set => SetProperty(ref _prefix, value); } - private string _prefix; + private string? _prefix; - [CanBeNull] - public string Name + public string? Name { get => _name; set => SetProperty(ref _name, value); } - private string _name; + private string? _name; - [NotNull] public ObservableCollection CommonPrefixes { get; } - public ModifiedAudioModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedAudioModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _name = Path.GetFileNameWithoutExtension(filePath); CommonPrefixes = new ObservableCollection diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedCharacterModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedCharacterModel.cs index 42bd9ac..771eaf7 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedCharacterModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedCharacterModel.cs @@ -1,5 +1,4 @@ using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Models { @@ -12,7 +11,7 @@ public string ResultFileName } private string _resultFileName; - public ModifiedCharacterModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedCharacterModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _resultFileName = Path.GetFileNameWithoutExtension(filePath); } diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedFileModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedFileModel.cs index b2a8b3e..b3281e5 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedFileModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedFileModel.cs @@ -1,18 +1,15 @@ using System.IO; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.ViewModels; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedFileModel : ViewModelBase { - [NotNull] public string FilePath { get; } - [NotNull] public string FileExtension { get; } public bool IsDragDropTarget { get; } - public ModifiedFileModel([NotNull] string filePath, bool isDragDropTarget) + public ModifiedFileModel(string filePath, bool isDragDropTarget) { FilePath = filePath; FileExtension = Path.GetExtension(filePath); diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs index 5128a8a..5479c8b 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs @@ -1,5 +1,4 @@ using System.Collections.ObjectModel; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.ViewModels; @@ -7,18 +6,15 @@ namespace TerrLauncherPackCreator.Code.Models { public class ModifiedFilesGroupModel : ViewModelBase { - [NotNull] public string Title { get; } - [NotNull] public string FilesExtension { get; } public FileType FilesType { get; } - [NotNull] public ObservableCollection ModifiedFiles { get; } = new ObservableCollection(); - public ModifiedFilesGroupModel([NotNull] string title, [NotNull] string filesExtension, FileType filesType) + public ModifiedFilesGroupModel(string title, string filesExtension, FileType filesType) { Title = title; FilesExtension = filesExtension; diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedFontModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedFontModel.cs index 91299b5..2a1c06f 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedFontModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedFontModel.cs @@ -1,31 +1,27 @@ using System.Collections.ObjectModel; using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedFontModel : ModifiedFileModel { - [CanBeNull] - public string Prefix + public string? Prefix { get => _prefix; set => SetProperty(ref _prefix, value); } - private string _prefix; + private string? _prefix; - [CanBeNull] - public string Name + public string? Name { get => _name; set => SetProperty(ref _name, value); } - private string _name; + private string? _name; - [NotNull] public ObservableCollection CommonPrefixes { get; } - public ModifiedFontModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedFontModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _name = Path.GetFileNameWithoutExtension(filePath); CommonPrefixes = new ObservableCollection diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedGuiModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedGuiModel.cs index 5610824..d2742ed 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedGuiModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedGuiModel.cs @@ -1,31 +1,27 @@ using System.Collections.ObjectModel; using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedGuiModel : ModifiedFileModel { - [CanBeNull] - public string Prefix + public string? Prefix { get => _prefix; set => SetProperty(ref _prefix, value); } - private string _prefix; + private string? _prefix; - [CanBeNull] - public string Name + public string? Name { get => _name; set => SetProperty(ref _name, value); } - private string _name; + private string? _name; - [NotNull] public ObservableCollection CommonPrefixes { get; } - public ModifiedGuiModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedGuiModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _name = Path.GetFileNameWithoutExtension(filePath); CommonPrefixes = new ObservableCollection diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedMapModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedMapModel.cs index 4541e45..31f2028 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedMapModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedMapModel.cs @@ -1,20 +1,17 @@ using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedMapModel : ModifiedFileModel { - [CanBeNull] - public string ResultFileName + public string? ResultFileName { get => _resultFileName; set => SetProperty(ref _resultFileName, value); } - [CanBeNull] - private string _resultFileName; + private string? _resultFileName; - public ModifiedMapModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedMapModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _resultFileName = Path.GetFileNameWithoutExtension(filePath); } diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs index 38eb970..cb73f4c 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using JetBrains.Annotations; using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Models @@ -15,21 +14,19 @@ public TextureType CurrentTextureType } private TextureType _currentTextureType; - [CanBeNull] - public string Prefix + public string? Prefix { get => _prefix; set => SetProperty(ref _prefix, value); } - private string _prefix; + private string? _prefix; - [CanBeNull] - public string Name + public string? Name { get => _name; set => SetProperty(ref _name, value); } - private string _name; + private string? _name; public int ElementId { @@ -80,13 +77,11 @@ public bool ApplyOriginalSize } private bool _applyOriginalSize; - [NotNull] public ObservableCollection CommonPrefixes { get; } - [NotNull] public IReadOnlyList TextureTypes { get; } - public ModifiedTextureModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedTextureModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { _name = Path.GetFileNameWithoutExtension(filePath); _currentTextureType = TextureType.General; diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs index 7382102..e92ce09 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs @@ -1,24 +1,20 @@ using System.Collections.Generic; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Models { public class ModifiedTranslationModel : ModifiedFileModel { - [NotNull] public string CurrentLanguage { get => _currentLanguage; set => SetProperty(ref _currentLanguage, value); } - [NotNull] private string _currentLanguage; - [NotNull] public IReadOnlyList ShortLanguages { get; } - public ModifiedTranslationModel([NotNull] string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) + public ModifiedTranslationModel(string filePath, bool isDragDropTarget) : base(filePath, isDragDropTarget) { ShortLanguages = PackUtils.TranslationLanguages; _currentLanguage = ShortLanguages[0]; diff --git a/TerrLauncherPackCreator/Code/Models/PackModel.cs b/TerrLauncherPackCreator/Code/Models/PackModel.cs index fd6489b..f21b4f9 100644 --- a/TerrLauncherPackCreator/Code/Models/PackModel.cs +++ b/TerrLauncherPackCreator/Code/Models/PackModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Windows.Media; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Interfaces; @@ -12,17 +11,15 @@ public class PackModel { public class ModifiedFileInfo { - [CanBeNull] - public IPackFileInfo Config { get; } + public IPackFileInfo? Config { get; } - [NotNull] public string FilePath { get; } public FileType FileType { get; } public ModifiedFileInfo( - [CanBeNull] IPackFileInfo config, - [NotNull] string filePath, + IPackFileInfo? config, + string filePath, FileType fileType ) { @@ -33,9 +30,9 @@ FileType fileType } public PackModel( - [NotNull] (string name, Color? color, string link, ImageInfo icon, int iconHeight)[] authors, - [NotNull] string[] previewsPaths, - [NotNull] ModifiedFileInfo[] modifiedFiles, + (string name, Color? color, string link, ImageInfo icon, int iconHeight)[] authors, + string[] previewsPaths, + ModifiedFileInfo[] modifiedFiles, int packStructureVersion, string iconFilePath, string title, @@ -44,7 +41,7 @@ public PackModel( Guid guid, int version, bool isBonusPack, - [NotNull] List predefinedTags + List predefinedTags ) { Authors = authors; @@ -77,16 +74,12 @@ [NotNull] List predefinedTags public bool IsBonusPack { get; } - [NotNull] public List PredefinedTags { get; } - [NotNull] public (string name, Color? color, string link, ImageInfo icon, int iconHeight)[] Authors { get; } - [NotNull] public string[] PreviewsPaths { get; } - [NotNull] public ModifiedFileInfo[] ModifiedFiles { get; } } } diff --git a/TerrLauncherPackCreator/Code/Models/PreviewItemModel.cs b/TerrLauncherPackCreator/Code/Models/PreviewItemModel.cs index ec84904..bbeefaa 100644 --- a/TerrLauncherPackCreator/Code/Models/PreviewItemModel.cs +++ b/TerrLauncherPackCreator/Code/Models/PreviewItemModel.cs @@ -4,20 +4,16 @@ using System.Diagnostics; using System.Drawing; using System.IO; -using JetBrains.Annotations; using MVVM_Tools.Code.Classes; namespace TerrLauncherPackCreator.Code.Models { public class PreviewItemModel : BindableBase { - [NotNull] private static readonly ISet CroppableFileExtensions = new HashSet {".png", ".jpg"}; - [CanBeNull] - public Uri ImageUri { get; } - [CanBeNull] - public string FilePath { get; } + public Uri? ImageUri { get; } + public string? FilePath { get; } public bool IsDragDropTarget { get; } public bool IsCroppingEnabled @@ -99,7 +95,7 @@ public double ImageHeightDp private readonly int _imageWidthPx; private readonly int _imageHeightPx; - public PreviewItemModel([CanBeNull] string filePath, bool isDragDropTarget) + public PreviewItemModel(string? filePath, bool isDragDropTarget) { ImageUri = filePath != null ? new Uri(filePath) : null; FilePath = filePath; @@ -121,7 +117,7 @@ public PreviewItemModel([CanBeNull] string filePath, bool isDragDropTarget) PropertyChanged += OnPropertyChanged; } - public static PreviewItemModel FromImageFile([NotNull] string filePath) + public static PreviewItemModel FromImageFile(string filePath) { return new PreviewItemModel(filePath, false); } diff --git a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs index 02b4ce1..96fd333 100644 --- a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs @@ -1,7 +1,6 @@ using System; using System.IO; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Resources.Localizations; @@ -10,7 +9,6 @@ namespace TerrLauncherPackCreator.Code.Utils { public static class AppUtils { - [NotNull] public static AppSettingsJson LoadAppSettings() { if (!File.Exists(Paths.AppSettingsFile)) @@ -29,7 +27,7 @@ public static AppSettingsJson LoadAppSettings() } } - public static void SaveAppSettings([NotNull] AppSettingsJson settings) + public static void SaveAppSettings(AppSettingsJson settings) { IOUtils.EnsureParentDirExists(Paths.AppSettingsFile); File.WriteAllText( diff --git a/TerrLauncherPackCreator/Code/Utils/BitmapUtils.cs b/TerrLauncherPackCreator/Code/Utils/BitmapUtils.cs index bf76ef1..2426c5f 100644 --- a/TerrLauncherPackCreator/Code/Utils/BitmapUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/BitmapUtils.cs @@ -1,10 +1,8 @@ -using System; -using System.Drawing; +using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Windows; using System.Windows.Media.Imaging; -using JetBrains.Annotations; using Point = System.Drawing.Point; namespace TerrLauncherPackCreator.Code.Utils @@ -22,8 +20,7 @@ public static Bitmap ToBitmap(this BitmapSource source) return bmp; } - [NotNull] - public static BitmapSource ToBitmapSource([NotNull] this Bitmap bitmap) + public static BitmapSource ToBitmapSource(this Bitmap bitmap) { using (var stream = new MemoryStream()) { @@ -32,8 +29,7 @@ public static BitmapSource ToBitmapSource([NotNull] this Bitmap bitmap) } } - [NotNull] - public static BitmapSource ToBitmapSource([NotNull] this Stream stream) { + public static BitmapSource ToBitmapSource(this Stream stream) { stream.Position = 0; BitmapImage result = new BitmapImage(); result.BeginInit(); diff --git a/TerrLauncherPackCreator/Code/Utils/DragDropUtils.cs b/TerrLauncherPackCreator/Code/Utils/DragDropUtils.cs index fcfc51e..b51b194 100644 --- a/TerrLauncherPackCreator/Code/Utils/DragDropUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/DragDropUtils.cs @@ -1,14 +1,13 @@ using System; using System.Windows; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Utils { public static class DragDropUtils { public static void HandleDrag( - [NotNull] DragEventArgs eventArgs, - [NotNull] Predicate areFilesValid, + DragEventArgs eventArgs, + Predicate areFilesValid, DragDropEffects validEffect ) { @@ -20,7 +19,7 @@ DragDropEffects validEffect return; } - var files = (string[]) eventArgs.Data.GetData(DataFormats.FileDrop); + var files = (string[]?) eventArgs.Data.GetData(DataFormats.FileDrop); if (files != null && areFilesValid(files)) eventArgs.Effects = validEffect; else @@ -28,9 +27,9 @@ DragDropEffects validEffect } public static void HandleDrop( - [NotNull] DragEventArgs eventArgs, - [NotNull] Predicate areFilesValid, - [NotNull] Action handleValidFiles + DragEventArgs eventArgs, + Predicate areFilesValid, + Action handleValidFiles ) { eventArgs.Handled = true; @@ -38,7 +37,7 @@ [NotNull] Action handleValidFiles if (!eventArgs.Data.GetDataPresent(DataFormats.FileDrop)) return; - var files = (string[]) eventArgs.Data.GetData(DataFormats.FileDrop); + var files = (string[]?) eventArgs.Data.GetData(DataFormats.FileDrop); if (files != null && areFilesValid(files)) handleValidFiles(files); } diff --git a/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs b/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs index 6bcc490..c411e80 100644 --- a/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs @@ -2,15 +2,13 @@ using System.Drawing.Imaging; using System.IO; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using WebPWrapper; namespace TerrLauncherPackCreator.Code.Utils { public static class ImageUtils { - [NotNull] - public static string ConvertWebPToTempPngFile([NotNull] string webPPath) + public static string ConvertWebPToTempPngFile(string webPPath) { string tempIcon = ApplicationDataUtils.GenerateNonExistentFilePath(extension: ".png"); IOUtils.EnsureParentDirExists(tempIcon); @@ -19,23 +17,20 @@ public static string ConvertWebPToTempPngFile([NotNull] string webPPath) return tempIcon; } - [NotNull] - public static string ConvertImageToTempWebPFile([NotNull] string imagePath, bool lossless) + public static string ConvertImageToTempWebPFile(string imagePath, bool lossless) { using (var imageBitmap = new Bitmap(imagePath)) return ConvertImageToTempWebPFile(imageBitmap, lossless); } - [NotNull] - public static string ConvertImageToTempWebPFile([NotNull] byte[] imageBytes, bool lossless) + public static string ConvertImageToTempWebPFile(byte[] imageBytes, bool lossless) { using (var imageMemory = new MemoryStream(imageBytes)) using (var imageBitmap = new Bitmap(imageMemory)) return ConvertImageToTempWebPFile(imageBitmap, lossless); } - [NotNull] - public static string ConvertImageToTempWebPFile([NotNull] Bitmap imageBitmap, bool lossless) + public static string ConvertImageToTempWebPFile(Bitmap imageBitmap, bool lossless) { string tempIcon = ApplicationDataUtils.GenerateNonExistentFilePath(extension: ".webp"); IOUtils.EnsureParentDirExists(tempIcon); diff --git a/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs b/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs index 84c39f2..6d14252 100644 --- a/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs @@ -1,15 +1,13 @@ using System.Globalization; using System.IO; using System.Text; -using JetBrains.Annotations; using Newtonsoft.Json; namespace TerrLauncherPackCreator.Code.Utils { public static class JsonUtils { - [NotNull] - public static string Serialize([NotNull] T value) + public static string Serialize(T value) { StringBuilder sb = new StringBuilder(256); StringWriter sw = new StringWriter(sb, CultureInfo.InvariantCulture); diff --git a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs b/TerrLauncherPackCreator/Code/Utils/PackUtils.cs index d22cd17..2d4e75b 100644 --- a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/PackUtils.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using JetBrains.Annotations; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Resources.Localizations; @@ -13,11 +12,8 @@ public static class PackUtils public const string PacksActualExtension = ".zip"; public const string PackFileConfigExtension = ".json"; - [NotNull] public static IReadOnlyList<(FileType fileType, string initialFilesExt, string convertedFilesExt, string title)> PacksInfo { get; } - [NotNull] public static IReadOnlyList TranslationLanguages { get; } - [NotNull] public static IReadOnlyList TranslationLanguageTitles { get; } static PackUtils() @@ -40,13 +36,11 @@ static PackUtils() TranslationLanguageTitles = new[] { "English", "Deutsch", "Italiano", "Français", "Español", "Русский", "Português brasileiro" }; } - [NotNull] public static string GetInitialFilesExt(FileType fileType) { return PacksInfo.First(it => it.fileType == fileType).initialFilesExt; } - [NotNull] public static string GetConvertedFilesExt(FileType fileType) { return PacksInfo.First(it => it.fileType == fileType).convertedFilesExt; diff --git a/TerrLauncherPackCreator/Code/Utils/Paths.cs b/TerrLauncherPackCreator/Code/Utils/Paths.cs index 25b60db..5dfd836 100644 --- a/TerrLauncherPackCreator/Code/Utils/Paths.cs +++ b/TerrLauncherPackCreator/Code/Utils/Paths.cs @@ -1,32 +1,22 @@ using System.IO; using System.Reflection; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Utils { public static class Paths { #if DEBUG - [NotNull] public static readonly string ExeDir = Path.GetFullPath(Path.Combine( Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "..", "Release" )); #else - [NotNull] public static readonly string ExeDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); #endif - [NotNull] public static readonly string DataDir = Path.Combine(ExeDir, "data"); - - [NotNull] public static readonly string TempDir = Path.Combine(ExeDir, "temp"); - - [NotNull] public static readonly string AuthorsFile = Path.Combine(DataDir, "authors.json"); - - [NotNull] public static readonly string AppSettingsFile = Path.Combine(DataDir, "appSettings.json"); } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs b/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs index 81aa809..42ba34d 100644 --- a/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs @@ -2,13 +2,12 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Utils { public static class ProcessUtils { - public static async Task WaitForExitAsync([NotNull] this Process process, CancellationToken cancellationToken = default) + public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default) { var tcs = new TaskCompletionSource(); diff --git a/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs b/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs index 5d609ab..d8cd24e 100644 --- a/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs @@ -1,17 +1,16 @@ using System.IO; -using JetBrains.Annotations; namespace TerrLauncherPackCreator.Code.Utils { public static class SafeFileSystemUtils { - public static void DeleteFile([NotNull] string file) + public static void DeleteFile(string file) { if (File.Exists(file)) File.Delete(file); } - public static void DeleteDir([NotNull] string dir) + public static void DeleteDir(string dir) { if (Directory.Exists(dir)) Directory.Delete(dir, true); diff --git a/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs index 4e4b943..9ddd324 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Json; @@ -16,32 +15,25 @@ namespace TerrLauncherPackCreator.Code.ViewModels { public class AuthorEditorWindowViewModel : ViewModelBase { - [NotNull] public AuthorItemModel EditableAuthor { get; } - [NotNull] public IActionCommand DropAuthorImageCommand { get; } - [NotNull] public IActionCommand DeleteSavedAuthor { get; } - [NotNull] public IActionCommand SaveAuthor { get; } - [NotNull] public ObservableCollection SavedAuthors { get; } - [CanBeNull] - public AuthorJson SelectedSavedAuthor + public AuthorJson? SelectedSavedAuthor { get => _selectedSavedAuthor; set => SetProperty(ref _selectedSavedAuthor, value); } - [CanBeNull] - private AuthorJson _selectedSavedAuthor; + private AuthorJson? _selectedSavedAuthor; public AuthorEditorWindowViewModel( - [NotNull] AuthorItemModel editableAuthor + AuthorItemModel editableAuthor ) { EditableAuthor = editableAuthor; @@ -82,7 +74,7 @@ private void SaveAuthor_Execute() WriteAuthorsToFile(); } - private void DropAuthorImage_Execute([NotNull] string iconPath) { + private void DropAuthorImage_Execute(string iconPath) { ImageInfo.ImageType imageType; switch (Path.GetExtension(iconPath)) { case ".png": @@ -98,7 +90,7 @@ private void DropAuthorImage_Execute([NotNull] string iconPath) { EditableAuthor.Image = new ImageInfo(File.ReadAllBytes(iconPath), imageType); } - private void DeleteSavedAuthor_Execute([CanBeNull] AuthorJson obj) + private void DeleteSavedAuthor_Execute(AuthorJson? obj) { if (obj == null) return; diff --git a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs index 951dbba..0e3033b 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Windows; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Implementations; @@ -22,20 +21,15 @@ public FileType CurrentFileType set => SetProperty(ref _currentFileType, value); } - [NotNull] public string SourceFilesExtension => PackUtils.GetInitialFilesExt(CurrentFileType); - [NotNull] public string ConvertedFilesExtension => PackUtils.GetConvertedFilesExt(CurrentFileType); public FileType[] FileTypes { get; } = PackUtils.PacksInfo.Select(it => it.fileType).ToArray(); - [NotNull] private readonly IFileConverter _fileConverter = new FileConverter(); private FileType _currentFileType = FileType.Texture; - [NotNull] public IActionCommand DropSourceFilesCommand { get; } - [NotNull] public IActionCommand DropConvertedFiledCommand { get; } public ConverterWindowViewModel() @@ -100,7 +94,7 @@ private async void DropConvertedFilesCommand_Execute(string[] files) string resultsDir = Path.Combine(Path.GetDirectoryName(file), "source_files"); IOUtils.EnsureDirExists(resultsDir); - string config = Path.ChangeExtension(file, PackUtils.PackFileConfigExtension); + string? config = Path.ChangeExtension(file, PackUtils.PackFileConfigExtension); if (!File.Exists(config)) config = null; diff --git a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs index 7171f77..51d97e9 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs @@ -6,7 +6,6 @@ using System.Windows.Controls; using CommonLibrary; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Interfaces; @@ -107,27 +106,20 @@ public int CurrentStep public double InitialWindowWidth { get; } public double InitialWindowHeight { get; } - [NotNull] public Page[] StepsPages { get; } - [NotNull] public IProgressManager LoadProgressManager { get; } - [NotNull] public IProgressManager SaveProgressManager { get; } - [NotNull] public IFileConverter FileConverter { get; } - [NotNull] public ObservableCollection ProgressManagers { get; } - [NotNull] public IPackProcessor PackProcessor { get; } - [NotNull] public ITempDirsProvider TempDirsProvider { get; } public IActionCommand GoToPreviousStepCommand { get; } public IActionCommand GoToNextStepCommand { get; } public MainWindowViewModel( - [CanBeNull] Action restartApp + Action? restartApp ) { // ReSharper disable once UnreachableCode diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 4553a13..4eb5cfa 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -11,7 +11,6 @@ using System.Windows; using System.Windows.Media.Imaging; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using Microsoft.Win32; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Enums; @@ -63,7 +62,7 @@ public class PackCreationViewModel : ViewModelBase PredefinedPackTag.FontsAnimated, }; - [NotNull] private readonly IPackProcessor _packProcessor; + private readonly IPackProcessor _packProcessor; #region Properties @@ -121,13 +120,13 @@ public bool IsBonusPack } // Step 2 - [NotNull] public ObservableCollection Previews { get; } + public ObservableCollection Previews { get; } // Step 3 - [NotNull] public ObservableCollection ModifiedFileGroups { get; } + public ObservableCollection ModifiedFileGroups { get; } // Step 4 - [NotNull] public ObservableCollection Authors { get; } + public ObservableCollection Authors { get; } #endregion @@ -168,8 +167,7 @@ public bool IsBonusPack public IActionCommand DeleteAuthorCommand { get; } // Step 5 - [CanBeNull] - private readonly Action _restartApp; + private readonly Action? _restartApp; public IActionCommand ExportPackCommand { get; } public IActionCommand RestartSequenceCommand { get; } @@ -185,8 +183,8 @@ public PackCreationViewModel() : this(null, null) } public PackCreationViewModel( - [NotNull] IPackProcessor packProcessor, - [CanBeNull] Action restartApp + IPackProcessor packProcessor, + Action? restartApp ) { _packProcessor = packProcessor; @@ -452,7 +450,7 @@ private void DeleteModifiedItemCommand_Execute(ModifiedFileModel file) Debug.WriteLine($"Can't delete modified file: {file}"); } - private bool SaveResourceCommand_CanExecute([NotNull] ModifiedFileModel file) + private bool SaveResourceCommand_CanExecute(ModifiedFileModel file) { #pragma warning disable 219 { @@ -468,7 +466,7 @@ file is ModifiedAudioModel ); } - private void SaveResourceCommand_Execute([NotNull] ModifiedFileModel file) + private void SaveResourceCommand_Execute(ModifiedFileModel file) { if (string.IsNullOrEmpty(file.FilePath) || !File.Exists(file.FilePath)) return; @@ -729,8 +727,7 @@ private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) } } - [NotNull] - private static ModifiedFileModel FileToModel(FileType fileType, [NotNull] string filePath, [CanBeNull] IPackFileInfo fileInfo) + private static ModifiedFileModel FileToModel(FileType fileType, string filePath, IPackFileInfo? fileInfo) { switch (fileType) { diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs index 33aed67..4da1239 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using CommonLibrary; using CommonLibrary.CommonUtils; -using JetBrains.Annotations; using Microsoft.Win32; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Interfaces; @@ -18,12 +17,9 @@ namespace TerrLauncherPackCreator.Code.ViewModels { public class PackStartupWindowViewModel : ViewModelBase { - [NotNull] private readonly IAttachedWindowManipulator _attachedWindowManipulator; - [NotNull] private readonly AppSettingsJson _appSettings; - [NotNull] public string CurrentLanguage => Thread.CurrentThread.CurrentUICulture.Name; public bool EnglishLanguageActive => CurrentLanguage == "en-US"; public bool RussianLanguageActive => CurrentLanguage == "ru-RU"; @@ -33,23 +29,17 @@ public class PackStartupWindowViewModel : ViewModelBase (Color) ColorConverter.ConvertFromString(CommonConstants.IsPreview ? "#ef5350" : "#66bb6a") ); - [CanBeNull] - public Action RecreateWindow { get; set; } + public Action? RecreateWindow { get; set; } - [NotNull] public IActionCommand CreateNewPackCommand { get; } - [NotNull] public IActionCommand ChooseExistingPackCommand { get; } - [NotNull] public IActionCommand LaunchConverterCommand { get; } - [NotNull] public IActionCommand SwitchToEnglishCommand { get; } - [NotNull] public IActionCommand SwitchToRussianCommand { get; } public PackStartupWindowViewModel( - [NotNull] IAttachedWindowManipulator attachedWindowManipulator, - [NotNull] AppSettingsJson appSettings + IAttachedWindowManipulator attachedWindowManipulator, + AppSettingsJson appSettings ) { _attachedWindowManipulator = attachedWindowManipulator; @@ -102,7 +92,7 @@ private void LaunchConverterCommand_Execute() _attachedWindowManipulator.Close(); } - private void SwitchLanguageTo([NotNull] string language) + private void SwitchLanguageTo(string language) { if (Thread.CurrentThread.CurrentUICulture.Name == language) return; diff --git a/TerrLauncherPackCreator/Code/ViewModels/ViewModelBase.cs b/TerrLauncherPackCreator/Code/ViewModels/ViewModelBase.cs index 9fea6f6..f32af9d 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ViewModelBase.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ViewModelBase.cs @@ -1,5 +1,4 @@ using System; -using JetBrains.Annotations; using MVVM_Tools.Code.Classes; namespace TerrLauncherPackCreator.Code.ViewModels @@ -18,10 +17,9 @@ public bool Working private class WorkingDisposable : IDisposable { - [CanBeNull] - private ViewModelBase _viewModelBase; + private ViewModelBase? _viewModelBase; - public WorkingDisposable([NotNull] ViewModelBase viewModel) + public WorkingDisposable(ViewModelBase viewModel) { _viewModelBase = viewModel; viewModel.Working = true; diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index 871982f..8eb9ca8 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -10,6 +10,7 @@ 1.23.0.0 1.23.0.0 en + enable @@ -41,9 +42,6 @@ 4.0.2 - - 2020.3.0 - 12.0.3 diff --git a/TerrLauncherPackCreator/Windows/AuthorEditorWindow.xaml.cs b/TerrLauncherPackCreator/Windows/AuthorEditorWindow.xaml.cs index f8cea2b..7a5c0f2 100644 --- a/TerrLauncherPackCreator/Windows/AuthorEditorWindow.xaml.cs +++ b/TerrLauncherPackCreator/Windows/AuthorEditorWindow.xaml.cs @@ -1,5 +1,4 @@ -using JetBrains.Annotations; -using TerrLauncherPackCreator.Code.Models; +using TerrLauncherPackCreator.Code.Models; using TerrLauncherPackCreator.Code.ViewModels; namespace TerrLauncherPackCreator.Windows @@ -7,7 +6,7 @@ namespace TerrLauncherPackCreator.Windows public partial class AuthorEditorWindow { public AuthorEditorWindow( - [NotNull] AuthorItemModel authorModel + AuthorItemModel authorModel ) { InitializeComponent(); @@ -17,8 +16,7 @@ [NotNull] AuthorItemModel authorModel public AuthorEditorWindowViewModel ViewModel { - get => DataContext as AuthorEditorWindowViewModel; - set => DataContext = value; + init => DataContext = value; } } } From 5c5e2274f5653e8d370937218b7d2c28dce5f0b3 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 15:04:17 +0300 Subject: [PATCH 09/33] Tests moved to Net 5 --- .../Properties/AssemblyInfo.cs | 19 ---- .../TerrLauncherPackCreatorTests.csproj | 92 ++++++------------- 2 files changed, 26 insertions(+), 85 deletions(-) delete mode 100644 TerrLauncherPackCreatorTests/Properties/AssemblyInfo.cs diff --git a/TerrLauncherPackCreatorTests/Properties/AssemblyInfo.cs b/TerrLauncherPackCreatorTests/Properties/AssemblyInfo.cs deleted file mode 100644 index fe2f30b..0000000 --- a/TerrLauncherPackCreatorTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("TerrLauncherPackCreatorTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TerrLauncherPackCreatorTests")] -[assembly: AssemblyCopyright("© Andrey Skobtsov, 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("ac241444-0a7d-4696-9477-efa4b3d2835b")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj b/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj index e3756c9..d345307 100644 --- a/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj +++ b/TerrLauncherPackCreatorTests/TerrLauncherPackCreatorTests.csproj @@ -1,66 +1,26 @@ - - - - Debug - AnyCPU - {AC241444-0A7D-4696-9477-EFA4B3D2835B} - Library - Properties - TerrLauncherPackCreatorTests - TerrLauncherPackCreatorTests - v4.6.1 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - {7645e727-d062-4e3e-a1d9-1c13bbdfd80b} - TerrLauncherPackCreator - - - - - 2.1.1 - - - 2.1.1 - - - 4.5.0 - - - - - \ No newline at end of file + + + + net5.0-windows + TerrLauncherPackCreatorTests + TerrLauncherPackCreatorTests + + + + + + 16.8.3 + + + 2.1.2 + + + 2.1.2 + + + + + + + + From 1f6ec3fea127c8c874387b3b1a2c6df677903a0b Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 15:22:59 +0300 Subject: [PATCH 10/33] Updated Pack updated references --- TerrLauncherPackCreatorUpdater/App.xaml.cs | 2 +- .../TerrLauncherPackCreatorUpdater.csproj | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/TerrLauncherPackCreatorUpdater/App.xaml.cs b/TerrLauncherPackCreatorUpdater/App.xaml.cs index fa7fad7..6eb1220 100644 --- a/TerrLauncherPackCreatorUpdater/App.xaml.cs +++ b/TerrLauncherPackCreatorUpdater/App.xaml.cs @@ -85,7 +85,7 @@ private static void CreateShortcut() { var shell = new WshShell(); - IWshShortcut shortcut = shell.CreateShortcut( + IWshShortcut shortcut = (IWshShortcut) shell.CreateShortcut( Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, "TerrLauncherPackCreator.lnk" diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index 666ad7e..f73ab35 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -12,6 +12,17 @@ 1.3.1.0 + + + tlbimp + 0 + 1 + f935dc20-1cf0-11d0-adb9-00c04fd58a0b + 0 + false + + + @@ -32,6 +43,19 @@ 1.15.0 + + 1.0.0 + + + + + + + + + + Libraries\MVVM_Tools.dll + From ac15ea795c9fa4ca8e7d2ae4ef3a9097330085a8 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 15:33:14 +0300 Subject: [PATCH 11/33] Pack updater nullability option --- .../Implementations/DownloadSpeedEvaluator.cs | 49 ++++++++++++------- .../Code/ViewModels/UpdaterWindowViewModel.cs | 27 +++++----- .../TerrLauncherPackCreatorUpdater.csproj | 1 + .../Windows/UpdaterWindow.xaml.cs | 4 +- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/TerrLauncherPackCreatorUpdater/Code/Implementations/DownloadSpeedEvaluator.cs b/TerrLauncherPackCreatorUpdater/Code/Implementations/DownloadSpeedEvaluator.cs index ef56497..0060f5d 100644 --- a/TerrLauncherPackCreatorUpdater/Code/Implementations/DownloadSpeedEvaluator.cs +++ b/TerrLauncherPackCreatorUpdater/Code/Implementations/DownloadSpeedEvaluator.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Net; using System.Threading; @@ -9,32 +8,32 @@ internal class DownloadSpeedEvaluator : IDisposable { public delegate void SpeedMeasured(long speedBytesPerSecond); - private readonly object _updateLock = new object(); + private readonly object _updateLock = new(); - private WebClient _webClient; - private SpeedMeasured _onSpeedMeasured; - private Timer _updateTimer; + private Resources? _resources; private DateTime? _lastUpdateTime; private long _lastUpdateDownloadedBytes; private long _currentSpeed; - [SuppressMessage("ReSharper", "JoinNullCheckWithUsage")] - public DownloadSpeedEvaluator(WebClient webClient, int updatePeriosMs, SpeedMeasured onSpeedMeasured) + public DownloadSpeedEvaluator( + WebClient webClient, + int updatePeriodMs, + SpeedMeasured onSpeedMeasured + ) { if (webClient == null) throw new ArgumentNullException(nameof(webClient)); - if (updatePeriosMs < 1) - throw new ArgumentOutOfRangeException(nameof(updatePeriosMs)); + if (updatePeriodMs < 1) + throw new ArgumentOutOfRangeException(nameof(updatePeriodMs)); if (onSpeedMeasured == null) throw new ArgumentNullException(nameof(onSpeedMeasured)); - _webClient = webClient; - _onSpeedMeasured = onSpeedMeasured; + webClient.DownloadProgressChanged += WebClientOnDownloadProgressChanged; + var updateTimer = new Timer(_ => _resources?.OnSpeedMeasured(_currentSpeed), null, 0, updatePeriodMs); - _webClient.DownloadProgressChanged += WebClientOnDownloadProgressChanged; - _updateTimer = new Timer(state => _onSpeedMeasured(_currentSpeed), null, 0, updatePeriosMs); + _resources = new Resources(webClient, onSpeedMeasured, updateTimer); } private void WebClientOnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) @@ -60,15 +59,27 @@ private void WebClientOnDownloadProgressChanged(object sender, DownloadProgressC public void Dispose() { - if (_webClient == null) + if (_resources == null) return; - _webClient.DownloadProgressChanged -= WebClientOnDownloadProgressChanged; - _updateTimer.Dispose(); + _resources.WebClient.DownloadProgressChanged -= WebClientOnDownloadProgressChanged; + _resources.UpdateTimer.Dispose(); - _webClient = null; - _onSpeedMeasured = null; - _updateTimer = null; + _resources = null; + } + + private class Resources + { + public readonly WebClient WebClient; + public readonly SpeedMeasured OnSpeedMeasured; + public readonly Timer UpdateTimer; + + public Resources(WebClient webClient, SpeedMeasured onSpeedMeasured, Timer updateTimer) + { + WebClient = webClient; + OnSpeedMeasured = onSpeedMeasured; + UpdateTimer = updateTimer; + } } } } diff --git a/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs b/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs index e93c9a2..67a9d57 100644 --- a/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs +++ b/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs @@ -30,8 +30,8 @@ public long SpeedInBytes private readonly TaskbarItemInfo _taskbarItemInfo; - private DownloadSpeedEvaluator _downloadSpeedEvaluator; - private WebClient _webClient; + private readonly DownloadSpeedEvaluator _downloadSpeedEvaluator; + private readonly WebClient _webClient; private bool _started; #region backing fields @@ -42,9 +42,18 @@ public long SpeedInBytes public UpdaterWindowViewModel(TaskbarItemInfo taskbarItemInfo) { _taskbarItemInfo = taskbarItemInfo ?? throw new ArgumentNullException(nameof(taskbarItemInfo)); - _taskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; + _webClient = new WebClient(); + _webClient.DownloadProgressChanged += WebClientOnDownloadProgressChanged; + _webClient.DownloadDataCompleted += WebClientOnDownloadDataCompleted; + + _downloadSpeedEvaluator = new DownloadSpeedEvaluator( + webClient: _webClient, + updatePeriodMs: 1000, + onSpeedMeasured: speed => SpeedInBytes = speed + ); + PropertyChanged += OnPropertyChanged; } @@ -55,13 +64,6 @@ public void StartLoading() _started = true; - _webClient = new WebClient(); - - _webClient.DownloadProgressChanged += WebClientOnDownloadProgressChanged; - _webClient.DownloadDataCompleted += WebClientOnDownloadDataCompleted; - - _downloadSpeedEvaluator = new DownloadSpeedEvaluator(_webClient, 1000, speed => SpeedInBytes = speed); - _webClient.DownloadDataAsync(new Uri(CommonConstants.LatestVersionZipUrl)); } @@ -95,9 +97,6 @@ private void WebClientOnDownloadDataCompleted(object sender, DownloadDataComplet _webClient.DownloadDataCompleted -= WebClientOnDownloadDataCompleted; _webClient.Dispose(); - _downloadSpeedEvaluator = null; - _webClient = null; - using (var memoryStream = new MemoryStream(e.Result)) using (var zip = ZipFile.Read(memoryStream)) { @@ -112,7 +111,7 @@ private void WebClientOnDownloadDataCompleted(object sender, DownloadDataComplet Environment.Exit(0); } - private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) + private void OnPropertyChanged(object? sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index f73ab35..2ba411b 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -10,6 +10,7 @@ TerrLauncherPackCreatorUpdater 1.3.1.0 1.3.1.0 + enable diff --git a/TerrLauncherPackCreatorUpdater/Windows/UpdaterWindow.xaml.cs b/TerrLauncherPackCreatorUpdater/Windows/UpdaterWindow.xaml.cs index 90daa53..024d872 100644 --- a/TerrLauncherPackCreatorUpdater/Windows/UpdaterWindow.xaml.cs +++ b/TerrLauncherPackCreatorUpdater/Windows/UpdaterWindow.xaml.cs @@ -10,8 +10,8 @@ public partial class UpdaterWindow { public UpdaterWindowViewModel ViewModel { - get => DataContext as UpdaterWindowViewModel; - set => DataContext = value; + get => DataContext as UpdaterWindowViewModel ?? throw new InvalidOperationException(); + init => DataContext = value; } public UpdaterWindow() From 40da70cf20fbbdb46700cd3eb991834e87a48fa9 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 16:08:49 +0300 Subject: [PATCH 12/33] C# 9 changes --- .../AttachedWindowManipulator.cs | 4 +- .../Code/Implementations/PackProcessor.cs | 80 +++++++-------- .../Code/Interfaces/IPackProcessor.cs | 2 +- .../Code/Models/PackModel.cs | 98 +++++-------------- .../Code/ViewModels/PackCreationViewModel.cs | 52 +++++----- 5 files changed, 99 insertions(+), 137 deletions(-) diff --git a/TerrLauncherPackCreator/Code/Implementations/AttachedWindowManipulator.cs b/TerrLauncherPackCreator/Code/Implementations/AttachedWindowManipulator.cs index ac157ba..be91b55 100644 --- a/TerrLauncherPackCreator/Code/Implementations/AttachedWindowManipulator.cs +++ b/TerrLauncherPackCreator/Code/Implementations/AttachedWindowManipulator.cs @@ -6,7 +6,7 @@ namespace TerrLauncherPackCreator.Code.Implementations { public class AttachedWindowManipulator : IAttachedWindowManipulator { - private Window _window; + private Window? _window; public AttachedWindowManipulator(Window window) { @@ -17,7 +17,7 @@ public void Close() { CheckWindowNull(); - _window.Close(); + _window!.Close(); _window = null; } diff --git a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs index 55d0e14..ca27845 100644 --- a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs +++ b/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs @@ -25,7 +25,7 @@ public class PackProcessor : IPackProcessor public event Action? PackLoadingStarted; - public event Action<(string filePath, PackModel loadedPack, Exception? error)>? PackLoaded; + public event Action<(string filePath, PackModel? loadedPack, Exception? error)>? PackLoaded; public event Action<(PackModel pack, string targetFilePath)>? PackSavingStarted; @@ -35,8 +35,8 @@ public class PackProcessor : IPackProcessor private readonly IProgressManager? _saveProgressManager; private readonly IFileConverter _fileConverter; - private readonly object _loadingLock = new object(); - private readonly object _savingLock = new object(); + private readonly object _loadingLock = new(); + private readonly object _savingLock = new(); public PackProcessor( IProgressManager? loadProgressManager, @@ -112,7 +112,7 @@ private void OnPackLoadingStarted(string item) } } - private void OnPackLoaded((string filePath, PackModel loadedPack, Exception error) item) + private void OnPackLoaded((string filePath, PackModel? loadedPack, Exception? error) item) { lock (_loadingLock) { @@ -130,7 +130,7 @@ private void OnPackSavingStarted((PackModel pack, string targetFilePath) item) } } - private void OnPackSaved((PackModel pack, string targetFilePath, Exception error) item) + private void OnPackSaved((PackModel pack, string targetFilePath, Exception? error) item) { lock (_savingLock) { @@ -183,7 +183,7 @@ private async Task LoadPackModelInternal(string filePath) .ConvertAll(it => JsonToAuthorModel(it, packAuthorsFolder)) .ToArray(); - var modifiedFiles = new List(); + var modifiedFiles = new List(); foreach (string modifiedFile in modifiedFilesPaths) { string? configFile = Path.ChangeExtension(modifiedFile, PackUtils.PackFileConfigExtension); @@ -199,26 +199,26 @@ private async Task LoadPackModelInternal(string filePath) targetFile: modifiedFile, configFile: configFile ); - modifiedFiles.Add(new PackModel.ModifiedFileInfo( - config: fileInfo, - filePath: sourceFile, - fileType: fileType + modifiedFiles.Add(new PackModel.ModifiedFile( + Config: fileInfo, + FilePath: sourceFile, + FileType: fileType )); } - + return new PackModel( - authors: authors ?? Array.Empty<(string name, Color? color, string link, ImageInfo icon, int iconHeight)>(), - previewsPaths: previewsPaths, - modifiedFiles: modifiedFiles.ToArray(), - packStructureVersion: packSettings.PackStructureVersion, - iconFilePath: packIconFile, - title: packSettings.Title, - descriptionRussian: packSettings.DescriptionRussian, - descriptionEnglish: packSettings.DescriptionEnglish, - guid: packSettings.Guid, - version: packSettings.Version, - isBonusPack: packSettings.IsBonus, - predefinedTags: packSettings.PredefinedTags?.ToList() ?? new List(0) + Authors: authors ?? Array.Empty(), + PreviewsPaths: previewsPaths, + ModifiedFiles: modifiedFiles.ToArray(), + PackStructureVersion: packSettings.PackStructureVersion, + IconFilePath: packIconFile, + Title: packSettings.Title, + DescriptionRussian: packSettings.DescriptionRussian, + DescriptionEnglish: packSettings.DescriptionEnglish, + Guid: packSettings.Guid, + Version: packSettings.Version, + IsBonusPack: packSettings.IsBonus, + PredefinedTags: packSettings.PredefinedTags?.ToList() ?? new List(0) ); } @@ -229,7 +229,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) foreach (var author in packModel.Authors) { string fileExtension; AuthorJson json = AuthorModelToJson(author, ref authorFileIndex, out bool copyIcon, out fileExtension); - authorsMappings.Add((copyIcon ? author.icon : null, copyIcon ? $"{authorFileIndex - 1}{fileExtension}" : null, json)); + authorsMappings.Add((copyIcon ? author.Icon : null, copyIcon ? $"{authorFileIndex - 1}{fileExtension}" : null, json)); } #pragma warning disable 219 const int _ = 1 / (1 / (int) BonusType.LastEnumElement); @@ -323,7 +323,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) } int fileIndex = 1; - foreach (PackModel.ModifiedFileInfo modifiedFile in packModel.ModifiedFiles) { + foreach (PackModel.ModifiedFile modifiedFile in packModel.ModifiedFiles) { var (convertedFile, configFile) = _fileConverter.ConvertToTarget(modifiedFile.FileType, modifiedFile.FilePath, modifiedFile.Config).GetAwaiter().GetResult(); string fileExt = PackUtils.GetConvertedFilesExt(modifiedFile.FileType); string fileName = fileIndex.ToString(); @@ -339,24 +339,24 @@ private void SavePackModelInternal(PackModel packModel, string filePath) } private static AuthorJson AuthorModelToJson( - (string name, Color? color, string link, ImageInfo icon, int iconHeight) author, + PackModel.Author author, ref int authorFileIndex, out bool copyIcon, out string? fileExtension ) { - string name = author.name ?? string.Empty; - string color = author.color?.ToString(); - string link = author.link ?? string.Empty; + string name = author.Name ?? string.Empty; + string color = author.Color?.ToString(); + string link = author.Link ?? string.Empty; string? icon = null; fileExtension = null; - if (author.icon != null) { - string extension = author.icon.Type switch + if (author.Icon != null) { + string extension = author.Icon.Type switch { ImageInfo.ImageType.Png => ".png", ImageInfo.ImageType.Gif => ".gif", - _ => throw new ArgumentOutOfRangeException(nameof(author.icon.Type), author.icon.Type, @"Unknown type") + _ => throw new ArgumentOutOfRangeException(nameof(author.Icon.Type), author.Icon.Type, @"Unknown type") }; fileExtension = extension; @@ -374,7 +374,7 @@ out string? fileExtension color: color, file: icon, link: link, - iconHeight: author.iconHeight + iconHeight: author.IconHeight ); } @@ -412,14 +412,14 @@ private static (string? name, Color? color, string? link, ImageInfo? icon, int i return (name, color, link, icon, PackUtils.DefaultAuthorIconHeight); } - private static (string name, Color? color, string link, ImageInfo icon, int iconHeight) JsonToAuthorModel(AuthorJson author, string authorIconsDir) + private static PackModel.Author JsonToAuthorModel(AuthorJson author, string authorIconsDir) { - return ( - author.Name, - ParseAuthorColor(author.Color), - author.Link, - author.File == null ? null : ParseAuthorIcon(Path.Combine(authorIconsDir, author.File)), - author.IconHeight + return new( + Name: author.Name, + Color: ParseAuthorColor(author.Color), + Link: author.Link, + Icon: author.File == null ? null : ParseAuthorIcon(Path.Combine(authorIconsDir, author.File)), + IconHeight: author.IconHeight ); } diff --git a/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs b/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs index 24af0c6..f6e3678 100644 --- a/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs +++ b/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs @@ -5,7 +5,7 @@ namespace TerrLauncherPackCreator.Code.Interfaces { public interface IPackProcessor { - event Action<(string filePath, PackModel loadedPack, Exception? error)> PackLoaded; + event Action<(string filePath, PackModel? loadedPack, Exception? error)> PackLoaded; event Action<(PackModel pack, string targetFilePath, Exception? error)> PackSaved; diff --git a/TerrLauncherPackCreator/Code/Models/PackModel.cs b/TerrLauncherPackCreator/Code/Models/PackModel.cs index f21b4f9..92d14eb 100644 --- a/TerrLauncherPackCreator/Code/Models/PackModel.cs +++ b/TerrLauncherPackCreator/Code/Models/PackModel.cs @@ -7,79 +7,33 @@ namespace TerrLauncherPackCreator.Code.Models { - public class PackModel + public record PackModel( + int PackStructureVersion, + string IconFilePath, + string Title, + string DescriptionRussian, + string DescriptionEnglish, + Guid Guid, + int Version, + bool IsBonusPack, + IReadOnlyList PredefinedTags, + IReadOnlyList Authors, + IReadOnlyList PreviewsPaths, + IReadOnlyList ModifiedFiles + ) { - public class ModifiedFileInfo - { - public IPackFileInfo? Config { get; } - - public string FilePath { get; } - - public FileType FileType { get; } - - public ModifiedFileInfo( - IPackFileInfo? config, - string filePath, - FileType fileType - ) - { - Config = config; - FilePath = filePath; - FileType = fileType; - } - } - - public PackModel( - (string name, Color? color, string link, ImageInfo icon, int iconHeight)[] authors, - string[] previewsPaths, - ModifiedFileInfo[] modifiedFiles, - int packStructureVersion, - string iconFilePath, - string title, - string descriptionRussian, - string descriptionEnglish, - Guid guid, - int version, - bool isBonusPack, - List predefinedTags - ) - { - Authors = authors; - PreviewsPaths = previewsPaths; - ModifiedFiles = modifiedFiles; - PackStructureVersion = packStructureVersion; - IconFilePath = iconFilePath; - Title = title; - DescriptionRussian = descriptionRussian; - DescriptionEnglish = descriptionEnglish; - Guid = guid; - Version = version; - IsBonusPack = isBonusPack; - PredefinedTags = predefinedTags; - } - - public int PackStructureVersion { get; } + public record Author( + string Name, + Color? Color, + string Link, + ImageInfo Icon, + int IconHeight + ); - public string IconFilePath { get; } - - public string Title { get; } - - public string DescriptionRussian { get; } - - public string DescriptionEnglish { get; } - - public Guid Guid { get; } - - public int Version { get; } - - public bool IsBonusPack { get; } - - public List PredefinedTags { get; } - - public (string name, Color? color, string link, ImageInfo icon, int iconHeight)[] Authors { get; } - - public string[] PreviewsPaths { get; } - - public ModifiedFileInfo[] ModifiedFiles { get; } + public record ModifiedFile( + IPackFileInfo? Config, + string FilePath, + FileType FileType + ); } } diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 4eb5cfa..298d020 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -298,11 +298,11 @@ public void InitFromPackModel(PackModel packModel) foreach (var author in packModel.Authors) { Authors.Add(new AuthorItemModel( - name: author.name, - color: author.color, - image: author.icon, - link: author.link, - iconHeight: author.iconHeight + name: author.Name, + color: author.Color, + image: author.Icon, + link: author.Link, + iconHeight: author.IconHeight )); } @@ -556,9 +556,17 @@ private bool RestartSequenceCommand_CanExecute() private PackModel GeneratePackModel() { - return new PackModel( - authors: Authors.Select(author => (author.Name, author.Color, author.Link, author.Image, author.IconHeight)).ToArray(), - previewsPaths: Previews.Where(it => !it.IsDragDropTarget) + return new( + Authors: Authors.Select(author => + new PackModel.Author( + Name: author.Name, + Color: author.Color, + Link: author.Link, + Icon: author.Image, + IconHeight: author.IconHeight + ) + ).ToArray(), + PreviewsPaths: Previews.Where(it => !it.IsDragDropTarget) .Select(it => { if (string.IsNullOrEmpty(it.FilePath)) @@ -586,7 +594,7 @@ private PackModel GeneratePackModel() } }) .ToArray(), - modifiedFiles: ModifiedFileGroups.SelectMany(it => it.ModifiedFiles.Select(modified => (it.FilesType, modified))) + ModifiedFiles: ModifiedFileGroups.SelectMany(it => it.ModifiedFiles.Select(modified => (it.FilesType, modified))) .Where(it => !it.modified.IsDragDropTarget) .Select(it => { @@ -659,24 +667,24 @@ private PackModel GeneratePackModel() throw new ArgumentOutOfRangeException(); } - var info = new PackModel.ModifiedFileInfo( - config: fileInfo, - filePath: it.modified.FilePath, - fileType: it.FilesType + var info = new PackModel.ModifiedFile( + Config: fileInfo, + FilePath: it.modified.FilePath, + FileType: it.FilesType ); return info; }) .ToArray(), - packStructureVersion: LatestPackStructureVersion, - iconFilePath: IconFilePath, - title: Title, - descriptionRussian: DescriptionRussian, - descriptionEnglish: DescriptionEnglish, - guid: Guid, - version: Version, - isBonusPack: IsBonusPack, - predefinedTags: PredefinedTags.ToList() + PackStructureVersion: LatestPackStructureVersion, + IconFilePath: IconFilePath, + Title: Title, + DescriptionRussian: DescriptionRussian, + DescriptionEnglish: DescriptionEnglish, + Guid: Guid, + Version: Version, + IsBonusPack: IsBonusPack, + PredefinedTags: PredefinedTags.ToList() ); } From d3d62a7455938bd0275362e070b538fea483a8db Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 18:13:59 +0300 Subject: [PATCH 13/33] Moved some classes to CrossPlatform library --- CommonLibrary/CommonUtils/ColorUtils.cs | 15 +++ .../Code/Enums/BonusType.cs | 0 .../Code/Enums/FileType.cs | 0 .../Code/Enums/PredefinedPackTag.cs | 0 .../Code/Implementations/ImageInfo.cs | 0 .../Code/Implementations/PackProcessor.cs | 94 +++++++------------ .../Code/Interfaces/IFileConverter.cs | 0 .../Code/Interfaces/IImageConverter.cs | 9 ++ .../Code/Interfaces/IPackFileInfo.cs | 0 .../Code/Interfaces/IPackProcessor.cs | 0 .../Code/Interfaces/IProgressManager.cs | 0 .../Code/Interfaces/ISessionHelper.cs | 7 ++ CrossPlatform/Code/Interfaces/IZipHelper.cs | 7 ++ .../Code/Json/TL/AuthorJson.cs | 16 ++-- .../Code/Json/TL/PackSettings.cs | 9 +- .../Code/Models/PackModel.cs | 4 +- .../Code/Utils}/CollectionUtils.cs | 0 .../Code/Utils}/IOUtils.cs | 0 .../Code/Utils/JsonUtils.cs | 6 +- .../Code/Utils/PackUtils.cs | 30 +++--- CrossPlatform/CrossPlatform.csproj | 22 +++++ TerrLauncherPackCreator.sln | 6 ++ .../Code/Implementations/ImageConverter.cs | 23 +++++ .../Code/Implementations/SessionHelper.cs | 13 +++ .../Code/Implementations/ZipHelper.cs | 14 +++ .../Code/Models/AuthorItemModel.cs | 16 ++-- .../ViewModels/ConverterWindowViewModel.cs | 4 +- .../Code/ViewModels/MainWindowViewModel.cs | 6 +- .../Code/ViewModels/PackCreationViewModel.cs | 36 ++++--- .../Pages/PackCreation/PackCreationStep1.xaml | 2 +- .../TerrLauncherPackCreator.csproj | 1 + .../Tests/Code/Utils/PackUtilsTests.cs | 16 +--- .../TerrLauncherPackCreatorUpdater.csproj | 1 + 33 files changed, 232 insertions(+), 125 deletions(-) create mode 100644 CommonLibrary/CommonUtils/ColorUtils.cs rename {TerrLauncherPackCreator => CrossPlatform}/Code/Enums/BonusType.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Enums/FileType.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Enums/PredefinedPackTag.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Implementations/ImageInfo.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Implementations/PackProcessor.cs (85%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Interfaces/IFileConverter.cs (100%) create mode 100644 CrossPlatform/Code/Interfaces/IImageConverter.cs rename {TerrLauncherPackCreator => CrossPlatform}/Code/Interfaces/IPackFileInfo.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Interfaces/IPackProcessor.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Interfaces/IProgressManager.cs (100%) create mode 100644 CrossPlatform/Code/Interfaces/ISessionHelper.cs create mode 100644 CrossPlatform/Code/Interfaces/IZipHelper.cs rename {TerrLauncherPackCreator => CrossPlatform}/Code/Json/TL/AuthorJson.cs (71%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Json/TL/PackSettings.cs (94%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Models/PackModel.cs (94%) rename {CommonLibrary/CommonUtils => CrossPlatform/Code/Utils}/CollectionUtils.cs (100%) rename {CommonLibrary/CommonUtils => CrossPlatform/Code/Utils}/IOUtils.cs (100%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Utils/JsonUtils.cs (74%) rename {TerrLauncherPackCreator => CrossPlatform}/Code/Utils/PackUtils.cs (54%) create mode 100644 CrossPlatform/CrossPlatform.csproj create mode 100644 TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs create mode 100644 TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs create mode 100644 TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs diff --git a/CommonLibrary/CommonUtils/ColorUtils.cs b/CommonLibrary/CommonUtils/ColorUtils.cs new file mode 100644 index 0000000..b31ba4f --- /dev/null +++ b/CommonLibrary/CommonUtils/ColorUtils.cs @@ -0,0 +1,15 @@ +namespace CommonLibrary.CommonUtils +{ + public static class ColorUtils + { + public static System.Windows.Media.Color ToMediaColor(this in System.Drawing.Color color) + { + return System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); + } + + public static System.Drawing.Color ToDrawingColor(this in System.Windows.Media.Color color) + { + return System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B); + } + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Enums/BonusType.cs b/CrossPlatform/Code/Enums/BonusType.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Enums/BonusType.cs rename to CrossPlatform/Code/Enums/BonusType.cs diff --git a/TerrLauncherPackCreator/Code/Enums/FileType.cs b/CrossPlatform/Code/Enums/FileType.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Enums/FileType.cs rename to CrossPlatform/Code/Enums/FileType.cs diff --git a/TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs b/CrossPlatform/Code/Enums/PredefinedPackTag.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Enums/PredefinedPackTag.cs rename to CrossPlatform/Code/Enums/PredefinedPackTag.cs diff --git a/TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs b/CrossPlatform/Code/Implementations/ImageInfo.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Implementations/ImageInfo.cs rename to CrossPlatform/Code/Implementations/ImageInfo.cs diff --git a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs b/CrossPlatform/Code/Implementations/PackProcessor.cs similarity index 85% rename from TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs rename to CrossPlatform/Code/Implementations/PackProcessor.cs index ca27845..99d340f 100644 --- a/TerrLauncherPackCreator/Code/Implementations/PackProcessor.cs +++ b/CrossPlatform/Code/Implementations/PackProcessor.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Windows.Media; using CommonLibrary.CommonUtils; using Ionic.Zip; using TerrLauncherPackCreator.Code.Enums; @@ -34,6 +34,8 @@ public class PackProcessor : IPackProcessor private readonly IProgressManager? _loadProgressManager; private readonly IProgressManager? _saveProgressManager; private readonly IFileConverter _fileConverter; + private readonly ISessionHelper _sessionHelper; + private readonly IImageConverter _imageConverter; private readonly object _loadingLock = new(); private readonly object _savingLock = new(); @@ -41,12 +43,16 @@ public class PackProcessor : IPackProcessor public PackProcessor( IProgressManager? loadProgressManager, IProgressManager? saveProgressManager, - IFileConverter fileConverter + IFileConverter fileConverter, + ISessionHelper sessionHelper, + IImageConverter imageConverter ) { _loadProgressManager = loadProgressManager; _saveProgressManager = saveProgressManager; _fileConverter = fileConverter; + _sessionHelper = sessionHelper; + _imageConverter = imageConverter; if (loadProgressManager != null) { @@ -141,7 +147,7 @@ private void OnPackSaved((PackModel pack, string targetFilePath, Exception? erro private async Task LoadPackModelInternal(string filePath) { - string targetFolderPath = ApplicationDataUtils.GenerateNonExistentDirPath(); + string targetFolderPath = _sessionHelper.GenerateNonExistentDirPath(); using (var zip = ZipFile.Read(filePath)) zip.ExtractAll(targetFolderPath); @@ -162,7 +168,7 @@ private async Task LoadPackModelInternal(string filePath) else if (File.Exists(packIconPng)) packIconFile = packIconPng; else if (File.Exists(packIconWebP)) - packIconFile = ImageUtils.ConvertWebPToTempPngFile(packIconWebP); + packIconFile = _imageConverter.ConvertWebPToTempPngFile(packIconWebP); string[] previewsPaths = Directory.Exists(packPreviewsFolder) @@ -171,7 +177,7 @@ private async Task LoadPackModelInternal(string filePath) .ToArray() : Array.Empty(); - string[] modifiedFileExts = PackUtils.PacksInfo.Select(it => it.convertedFilesExt).ToArray(); + string[] modifiedFileExts = PackUtils.PacksInfo.Select(it => it.ConvertedFilesExt).ToArray(); string[] modifiedFilesPaths = Directory.Exists(packModifiedFilesFolder) ? Directory.EnumerateFiles(packModifiedFilesFolder) @@ -192,7 +198,7 @@ private async Task LoadPackModelInternal(string filePath) } string fileExt = Path.GetExtension(modifiedFile); - FileType fileType = PackUtils.PacksInfo.First(it => it.convertedFilesExt == fileExt).fileType; + FileType fileType = PackUtils.PacksInfo.First(it => it.ConvertedFilesExt == fileExt).FileType; var (sourceFile, fileInfo) = await _fileConverter.ConvertToSource( packStructureVersion: packSettings.PackStructureVersion, fileType: fileType, @@ -211,10 +217,10 @@ private async Task LoadPackModelInternal(string filePath) PreviewsPaths: previewsPaths, ModifiedFiles: modifiedFiles.ToArray(), PackStructureVersion: packSettings.PackStructureVersion, - IconFilePath: packIconFile, + IconFilePath: packIconFile ?? string.Empty, Title: packSettings.Title, - DescriptionRussian: packSettings.DescriptionRussian, - DescriptionEnglish: packSettings.DescriptionEnglish, + DescriptionRussian: packSettings.DescriptionRussian ?? string.Empty, + DescriptionEnglish: packSettings.DescriptionEnglish ?? string.Empty, Guid: packSettings.Guid, Version: packSettings.Version, IsBonusPack: packSettings.IsBonus, @@ -227,7 +233,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) var authorsMappings = new List<(ImageInfo? sourceFile, string? targetFile, AuthorJson json)>(); int authorFileIndex = 1; foreach (var author in packModel.Authors) { - string fileExtension; + string? fileExtension; AuthorJson json = AuthorModelToJson(author, ref authorFileIndex, out bool copyIcon, out fileExtension); authorsMappings.Add((copyIcon ? author.Icon : null, copyIcon ? $"{authorFileIndex - 1}{fileExtension}" : null, json)); } @@ -260,7 +266,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) ? packModel.IconFilePath : IOUtils.ChooseLighterFileAndDeleteSecond( packModel.IconFilePath, - ImageUtils.ConvertImageToTempWebPFile(packModel.IconFilePath, lossless: true) + _imageConverter.ConvertImageToTempWebPFile(packModel.IconFilePath, lossless: true) ); zip.AddFile(targetPath).FileName = $"Icon{Path.GetExtension(targetPath)}"; } @@ -277,7 +283,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) } else { - string webPImage = ImageUtils.ConvertImageToTempWebPFile(sourceFile.Bytes, lossless: true); + string webPImage = _imageConverter.ConvertImageToTempWebPFile(sourceFile.Bytes, lossless: true); if (new FileInfo(webPImage).Length < sourceFile.Bytes.Length) { json.File = Path.ChangeExtension(targetFile, ".webp"); @@ -313,7 +319,7 @@ private void SavePackModelInternal(PackModel packModel, string filePath) { targetPath = IOUtils.ChooseLighterFileAndDeleteSecond( previewPath, - ImageUtils.ConvertImageToTempWebPFile(previewPath, lossless: false) + _imageConverter.ConvertImageToTempWebPFile(previewPath, lossless: false) ); } @@ -345,9 +351,9 @@ private static AuthorJson AuthorModelToJson( out string? fileExtension ) { - string name = author.Name ?? string.Empty; - string color = author.Color?.ToString(); - string link = author.Link ?? string.Empty; + string name = author.Name; + string? color = author.Color == null ? null : AuthorColorToString(author.Color.Value); + string link = author.Link; string? icon = null; fileExtension = null; @@ -378,58 +384,28 @@ out string? fileExtension ); } - private static (string? name, Color? color, string? link, ImageInfo? icon, int iconHeight) StringToAuthorModel(string author, string authorIconsDir) - { - string[] parts = author.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries); - string? name = null; - Color? color = null; - string? link = null; - ImageInfo? icon = null; - - foreach (string part in parts) - { - string[] keyValue = part.Split('='); - if (keyValue.Length != 2) - continue; - - switch (keyValue[0]) - { - case "name": - name = keyValue[1]; - break; - case "color": - color = ParseAuthorColor(keyValue[1]); - break; - case "link": - link = keyValue[1]; - break; - case "file": - icon = ParseAuthorIcon(Path.Combine(authorIconsDir, keyValue[1])); - break; - } - } - - return (name, color, link, icon, PackUtils.DefaultAuthorIconHeight); - } - - private static PackModel.Author JsonToAuthorModel(AuthorJson author, string authorIconsDir) + private PackModel.Author JsonToAuthorModel(AuthorJson author, string authorIconsDir) { return new( - Name: author.Name, - Color: ParseAuthorColor(author.Color), - Link: author.Link, + Name: author.Name ?? string.Empty, + Color: author.Color == null ? null : AuthorColorFromString(author.Color), + Link: author.Link ?? string.Empty, Icon: author.File == null ? null : ParseAuthorIcon(Path.Combine(authorIconsDir, author.File)), IconHeight: author.IconHeight ); } - private static Color ParseAuthorColor(string color) + private static Color AuthorColorFromString(string color) + { + return ColorTranslator.FromHtml(color); + } + + private static string AuthorColorToString(Color color) { - // ReSharper disable once PossibleNullReferenceException - return (Color) ColorConverter.ConvertFromString(color); + return ColorTranslator.ToHtml(color); } - private static ImageInfo? ParseAuthorIcon(string iconPath) + private ImageInfo? ParseAuthorIcon(string iconPath) { if (!File.Exists(iconPath)) return null; @@ -444,7 +420,7 @@ private static Color ParseAuthorColor(string color) break; case ".webp": iconType = ImageInfo.ImageType.Png; - iconPath = ImageUtils.ConvertWebPToTempPngFile(iconPath); + iconPath = _imageConverter.ConvertWebPToTempPngFile(iconPath); break; default: throw new ArgumentOutOfRangeException(nameof(iconPath), iconPath, @"Unknown extension"); diff --git a/TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs b/CrossPlatform/Code/Interfaces/IFileConverter.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Interfaces/IFileConverter.cs rename to CrossPlatform/Code/Interfaces/IFileConverter.cs diff --git a/CrossPlatform/Code/Interfaces/IImageConverter.cs b/CrossPlatform/Code/Interfaces/IImageConverter.cs new file mode 100644 index 0000000..3f0b2d8 --- /dev/null +++ b/CrossPlatform/Code/Interfaces/IImageConverter.cs @@ -0,0 +1,9 @@ +namespace TerrLauncherPackCreator.Code.Interfaces +{ + public interface IImageConverter + { + string ConvertWebPToTempPngFile(string webPPath); + string ConvertImageToTempWebPFile(string imagePath, bool lossless); + string ConvertImageToTempWebPFile(byte[] imageBytes, bool lossless); + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Interfaces/IPackFileInfo.cs b/CrossPlatform/Code/Interfaces/IPackFileInfo.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Interfaces/IPackFileInfo.cs rename to CrossPlatform/Code/Interfaces/IPackFileInfo.cs diff --git a/TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs b/CrossPlatform/Code/Interfaces/IPackProcessor.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Interfaces/IPackProcessor.cs rename to CrossPlatform/Code/Interfaces/IPackProcessor.cs diff --git a/TerrLauncherPackCreator/Code/Interfaces/IProgressManager.cs b/CrossPlatform/Code/Interfaces/IProgressManager.cs similarity index 100% rename from TerrLauncherPackCreator/Code/Interfaces/IProgressManager.cs rename to CrossPlatform/Code/Interfaces/IProgressManager.cs diff --git a/CrossPlatform/Code/Interfaces/ISessionHelper.cs b/CrossPlatform/Code/Interfaces/ISessionHelper.cs new file mode 100644 index 0000000..30936fb --- /dev/null +++ b/CrossPlatform/Code/Interfaces/ISessionHelper.cs @@ -0,0 +1,7 @@ +namespace TerrLauncherPackCreator.Code.Interfaces +{ + public interface ISessionHelper + { + string GenerateNonExistentDirPath(); + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Interfaces/IZipHelper.cs b/CrossPlatform/Code/Interfaces/IZipHelper.cs new file mode 100644 index 0000000..723c1db --- /dev/null +++ b/CrossPlatform/Code/Interfaces/IZipHelper.cs @@ -0,0 +1,7 @@ +namespace TerrLauncherPackCreator.Code.Interfaces +{ + public interface IZipHelper + { + void Extract(string inputZipPath, string targetDirectory); + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/TL/AuthorJson.cs b/CrossPlatform/Code/Json/TL/AuthorJson.cs similarity index 71% rename from TerrLauncherPackCreator/Code/Json/TL/AuthorJson.cs rename to CrossPlatform/Code/Json/TL/AuthorJson.cs index 918d668..0c20bcf 100644 --- a/TerrLauncherPackCreator/Code/Json/TL/AuthorJson.cs +++ b/CrossPlatform/Code/Json/TL/AuthorJson.cs @@ -6,16 +6,16 @@ namespace TerrLauncherPackCreator.Code.Json.TL public class AuthorJson { [JsonProperty("name")] - public string Name { get; set; } + public string? Name { get; set; } [JsonProperty("color")] - public string Color { get; set; } + public string? Color { get; set; } [JsonProperty("file")] - public string File { get; set; } + public string? File { get; set; } [JsonProperty("link")] - public string Link { get; set; } + public string? Link { get; set; } [JsonProperty("icon_height")] public int IconHeight { get; set; } = PackUtils.DefaultAuthorIconHeight; @@ -23,10 +23,10 @@ public class AuthorJson public AuthorJson() {} public AuthorJson( - string name, - string color, - string file, - string link, + string? name, + string? color, + string? file, + string? link, int iconHeight ) { diff --git a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs b/CrossPlatform/Code/Json/TL/PackSettings.cs similarity index 94% rename from TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs rename to CrossPlatform/Code/Json/TL/PackSettings.cs index a5f36fc..2a3d594 100644 --- a/TerrLauncherPackCreator/Code/Json/TL/PackSettings.cs +++ b/CrossPlatform/Code/Json/TL/PackSettings.cs @@ -5,7 +5,6 @@ using Newtonsoft.Json.Linq; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Utils; -using TerrLauncherPackCreator.Code.ViewModels; namespace TerrLauncherPackCreator.Code.Json.TL { @@ -17,8 +16,8 @@ public static PackSettings Deserialize(string json) { JObject jsonObject = JObject.Parse(json); int packStructureVersion = jsonObject["packStructureVersion"]?.ToObject() ?? 0; - const int _ = 1 / (17 / PackCreationViewModel.LatestPackStructureVersion); - while (packStructureVersion < PackCreationViewModel.LatestPackStructureVersion) + const int _ = 1 / (17 / PackUtils.LatestPackStructureVersion); + while (packStructureVersion < PackUtils.LatestPackStructureVersion) { if (packStructureVersion <= 15) { @@ -96,8 +95,8 @@ private static AuthorJson StringToAuthorJson(string author) public int PackStructureVersion { get; set; } [JsonProperty("title")] - public string Title { get; set; } - + public string Title { get; set; } = null!; + [JsonProperty("descriptionEnglish")] public string? DescriptionEnglish { get; set; } diff --git a/TerrLauncherPackCreator/Code/Models/PackModel.cs b/CrossPlatform/Code/Models/PackModel.cs similarity index 94% rename from TerrLauncherPackCreator/Code/Models/PackModel.cs rename to CrossPlatform/Code/Models/PackModel.cs index 92d14eb..e8d3c45 100644 --- a/TerrLauncherPackCreator/Code/Models/PackModel.cs +++ b/CrossPlatform/Code/Models/PackModel.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Windows.Media; +using System.Drawing; using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Interfaces; @@ -26,7 +26,7 @@ public record Author( string Name, Color? Color, string Link, - ImageInfo Icon, + ImageInfo? Icon, int IconHeight ); diff --git a/CommonLibrary/CommonUtils/CollectionUtils.cs b/CrossPlatform/Code/Utils/CollectionUtils.cs similarity index 100% rename from CommonLibrary/CommonUtils/CollectionUtils.cs rename to CrossPlatform/Code/Utils/CollectionUtils.cs diff --git a/CommonLibrary/CommonUtils/IOUtils.cs b/CrossPlatform/Code/Utils/IOUtils.cs similarity index 100% rename from CommonLibrary/CommonUtils/IOUtils.cs rename to CrossPlatform/Code/Utils/IOUtils.cs diff --git a/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs b/CrossPlatform/Code/Utils/JsonUtils.cs similarity index 74% rename from TerrLauncherPackCreator/Code/Utils/JsonUtils.cs rename to CrossPlatform/Code/Utils/JsonUtils.cs index 6d14252..5a869d2 100644 --- a/TerrLauncherPackCreator/Code/Utils/JsonUtils.cs +++ b/CrossPlatform/Code/Utils/JsonUtils.cs @@ -9,11 +9,11 @@ public static class JsonUtils { public static string Serialize(T value) { - StringBuilder sb = new StringBuilder(256); - StringWriter sw = new StringWriter(sb, CultureInfo.InvariantCulture); + StringBuilder sb = new(256); + StringWriter sw = new(sb, CultureInfo.InvariantCulture); var jsonSerializer = JsonSerializer.CreateDefault(); - using (JsonTextWriter jsonWriter = new JsonTextWriter(sw)) + using (JsonTextWriter jsonWriter = new(sw)) { jsonWriter.Formatting = Formatting.Indented; jsonWriter.IndentChar = ' '; diff --git a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs b/CrossPlatform/Code/Utils/PackUtils.cs similarity index 54% rename from TerrLauncherPackCreator/Code/Utils/PackUtils.cs rename to CrossPlatform/Code/Utils/PackUtils.cs index 2d4e75b..7e9899f 100644 --- a/TerrLauncherPackCreator/Code/Utils/PackUtils.cs +++ b/CrossPlatform/Code/Utils/PackUtils.cs @@ -1,18 +1,24 @@ using System.Collections.Generic; using System.Linq; using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Resources.Localizations; namespace TerrLauncherPackCreator.Code.Utils { public static class PackUtils { + public record PackInfo( + FileType FileType, + string InitialFilesExt, + string ConvertedFilesExt + ); + + public const int LatestPackStructureVersion = 17; public const int DefaultAuthorIconHeight = 70; public const string PacksExtension = ".tl"; public const string PacksActualExtension = ".zip"; public const string PackFileConfigExtension = ".json"; - public static IReadOnlyList<(FileType fileType, string initialFilesExt, string convertedFilesExt, string title)> PacksInfo { get; } + public static IReadOnlyList PacksInfo { get; } public static IReadOnlyList TranslationLanguages { get; } public static IReadOnlyList TranslationLanguageTitles { get; } @@ -22,15 +28,15 @@ static PackUtils() const int _ = 1 / (7 / (int) FileType.LastEnumElement); #pragma warning restore 219 - PacksInfo = new[] + PacksInfo = new PackInfo[] { - (FileType.Texture, ".png", ".texture", StringResources.PackTypeTextures), - (FileType.Map, ".wld", ".world", StringResources.PackTypeMaps), - (FileType.Character, ".plr", ".character", StringResources.PackTypeCharacters), - (FileType.Gui, ".png", ".gui", StringResources.PackTypeGui), - (FileType.Translation, ".json", ".translation", StringResources.PackTypeTranslations), - (FileType.Font, ".png", ".font", StringResources.PackTypeFonts), - (FileType.Audio, ".mp3", ".audio", StringResources.PackTypeAudio) + new(FileType.Texture, ".png", ".texture"), + new(FileType.Map, ".wld", ".world"), + new(FileType.Character, ".plr", ".character"), + new(FileType.Gui, ".png", ".gui"), + new(FileType.Translation, ".json", ".translation"), + new(FileType.Font, ".png", ".font"), + new(FileType.Audio, ".mp3", ".audio") }; TranslationLanguages = new[] { "en-US", "de-DE", "it-IT", "fr-FR", "es-ES", "ru-RU", "pt-BR", /*"zh-Hans", "pl-PL", "ja-JP"*/ }; TranslationLanguageTitles = new[] { "English", "Deutsch", "Italiano", "Français", "Español", "Русский", "Português brasileiro" }; @@ -38,12 +44,12 @@ static PackUtils() public static string GetInitialFilesExt(FileType fileType) { - return PacksInfo.First(it => it.fileType == fileType).initialFilesExt; + return PacksInfo.First(it => it.FileType == fileType).InitialFilesExt; } public static string GetConvertedFilesExt(FileType fileType) { - return PacksInfo.First(it => it.fileType == fileType).convertedFilesExt; + return PacksInfo.First(it => it.FileType == fileType).ConvertedFilesExt; } } } diff --git a/CrossPlatform/CrossPlatform.csproj b/CrossPlatform/CrossPlatform.csproj new file mode 100644 index 0000000..55a18af --- /dev/null +++ b/CrossPlatform/CrossPlatform.csproj @@ -0,0 +1,22 @@ + + + + net5.0 + enable + + + + + + + + + + 1.15.0 + + + 12.0.3 + + + + diff --git a/TerrLauncherPackCreator.sln b/TerrLauncherPackCreator.sln index de3eb9a..27b5c81 100644 --- a/TerrLauncherPackCreator.sln +++ b/TerrLauncherPackCreator.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrLauncherPackCreatorUpda EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonLibrary", "CommonLibrary\CommonLibrary.csproj", "{C963037D-1C4B-4387-BF22-5E15444DF3F5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossPlatform", "CrossPlatform\CrossPlatform.csproj", "{BDC7145D-F429-4D3A-9A55-5390F8633526}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {C963037D-1C4B-4387-BF22-5E15444DF3F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {C963037D-1C4B-4387-BF22-5E15444DF3F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {C963037D-1C4B-4387-BF22-5E15444DF3F5}.Release|Any CPU.Build.0 = Release|Any CPU + {BDC7145D-F429-4D3A-9A55-5390F8633526}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDC7145D-F429-4D3A-9A55-5390F8633526}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDC7145D-F429-4D3A-9A55-5390F8633526}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDC7145D-F429-4D3A-9A55-5390F8633526}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs new file mode 100644 index 0000000..f78739a --- /dev/null +++ b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs @@ -0,0 +1,23 @@ +using TerrLauncherPackCreator.Code.Interfaces; +using TerrLauncherPackCreator.Code.Utils; + +namespace TerrLauncherPackCreator.Code.Implementations +{ + public class ImageConverter : IImageConverter + { + public string ConvertWebPToTempPngFile(string webPPath) + { + return ImageUtils.ConvertWebPToTempPngFile(webPPath); + } + + public string ConvertImageToTempWebPFile(string imagePath, bool lossless) + { + return ImageUtils.ConvertImageToTempWebPFile(imagePath, lossless); + } + + public string ConvertImageToTempWebPFile(byte[] imageBytes, bool lossless) + { + return ImageUtils.ConvertImageToTempWebPFile(imageBytes, lossless); + } + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs new file mode 100644 index 0000000..b9e68e7 --- /dev/null +++ b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs @@ -0,0 +1,13 @@ +using CommonLibrary.CommonUtils; +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Implementations +{ + public class SessionHelper : ISessionHelper + { + public string GenerateNonExistentDirPath() + { + return ApplicationDataUtils.GenerateNonExistentDirPath(); + } + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs b/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs new file mode 100644 index 0000000..e2a7851 --- /dev/null +++ b/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs @@ -0,0 +1,14 @@ +using Ionic.Zip; +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Implementations +{ + public class ZipHelper : IZipHelper + { + public void Extract(string inputZipPath, string targetDirectory) + { + using (var zip = ZipFile.Read(inputZipPath)) + zip.ExtractAll(targetDirectory); + } + } +} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs index 2ebdac8..d86ffb0 100644 --- a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs +++ b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs @@ -15,7 +15,7 @@ public ImageInfo? Image set => SetProperty(ref _image, value); } - public string? Name + public string Name { get => _name; set => SetProperty(ref _name, value); @@ -27,7 +27,7 @@ public Color? Color set => SetProperty(ref _color, value); } - public string? Link + public string Link { get => _link; set => SetProperty(ref _link, value); @@ -42,24 +42,24 @@ public int IconHeight public IActionCommand EditAuthorCommand { get; } private ImageInfo? _image; - private string? _name; + private string _name; private Color? _color; - private string? _link; + private string _link; private int _iconHeight; public AuthorItemModel(): this( - name: null, + name: string.Empty, color: null, image: null, - link: null, + link: string.Empty, iconHeight: PackUtils.DefaultAuthorIconHeight ) {} public AuthorItemModel( - string? name, + string name, Color? color, ImageInfo? image, - string? link, + string link, int iconHeight ) { diff --git a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs index 0e3033b..808c8fe 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs @@ -24,7 +24,7 @@ public FileType CurrentFileType public string SourceFilesExtension => PackUtils.GetInitialFilesExt(CurrentFileType); public string ConvertedFilesExtension => PackUtils.GetConvertedFilesExt(CurrentFileType); - public FileType[] FileTypes { get; } = PackUtils.PacksInfo.Select(it => it.fileType).ToArray(); + public FileType[] FileTypes { get; } = PackUtils.PacksInfo.Select(it => it.FileType).ToArray(); private readonly IFileConverter _fileConverter = new FileConverter(); private FileType _currentFileType = FileType.Texture; @@ -99,7 +99,7 @@ private async void DropConvertedFilesCommand_Execute(string[] files) config = null; var (convertedFile, fileInfo) = await _fileConverter.ConvertToSource( - packStructureVersion: PackCreationViewModel.LatestPackStructureVersion, + packStructureVersion: PackUtils.LatestPackStructureVersion, fileType: CurrentFileType, targetFile: file, configFile: config diff --git a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs index 51d97e9..c89c5ae 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs @@ -123,7 +123,7 @@ public MainWindowViewModel( ) { // ReSharper disable once UnreachableCode - WindowTitle = Assembly.GetEntryAssembly().GetName().Name + (CommonConstants.IsPreview ? " (Preview)" : ""); + WindowTitle = Assembly.GetEntryAssembly()?.GetName().Name + (CommonConstants.IsPreview ? " (Preview)" : ""); _currentStep = 1; InitialWindowWidth = ValuesProvider.AppSettings.MainWindowWidth; InitialWindowHeight = ValuesProvider.AppSettings.MainWindowHeight; @@ -144,7 +144,9 @@ public MainWindowViewModel( PackProcessor = new PackProcessor( LoadProgressManager, SaveProgressManager, - FileConverter + FileConverter, + new SessionHelper(), + new ImageConverter() ); TempDirsProvider = new TempDirsProvider(Paths.TempDir); TempDirsProvider.DeleteAll(); diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 298d020..72dd635 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -24,7 +24,6 @@ namespace TerrLauncherPackCreator.Code.ViewModels { public class PackCreationViewModel : ViewModelBase { - public const int LatestPackStructureVersion = 17; private static readonly ISet IconExtensions = new HashSet {".png", ".gif"}; private static readonly ISet PreviewExtensions = new HashSet {".jpg", ".png", ".gif"}; // ReSharper disable once UnusedMember.Local @@ -297,13 +296,15 @@ public void InitFromPackModel(PackModel packModel) foreach (var author in packModel.Authors) { - Authors.Add(new AuthorItemModel( - name: author.Name, - color: author.Color, - image: author.Icon, - link: author.Link, - iconHeight: author.IconHeight - )); + Authors.Add( + new AuthorItemModel( + name: author.Name, + color: author.Color?.ToMediaColor(), + image: author.Icon, + link: author.Link, + iconHeight: author.IconHeight + ) + ); } previewItems.ForEach(Previews.Add); @@ -560,7 +561,7 @@ private PackModel GeneratePackModel() Authors: Authors.Select(author => new PackModel.Author( Name: author.Name, - Color: author.Color, + Color: author.Color?.ToDrawingColor(), Link: author.Link, Icon: author.Image, IconHeight: author.IconHeight @@ -676,7 +677,7 @@ private PackModel GeneratePackModel() return info; }) .ToArray(), - PackStructureVersion: LatestPackStructureVersion, + PackStructureVersion: PackUtils.LatestPackStructureVersion, IconFilePath: IconFilePath, Title: Title, DescriptionRussian: DescriptionRussian, @@ -696,8 +697,21 @@ private void ResetCollections() PredefinedTags.Clear(); Previews.Add(new PreviewItemModel(filePath: null, isDragDropTarget: true)); - foreach ((FileType fileType, string initialFilesExt, string _, string title) in PackUtils.PacksInfo) + foreach ((FileType fileType, string initialFilesExt, string _) in PackUtils.PacksInfo) { + // ReSharper disable once LocalVariableHidesMember + const int _ = 1 / (7 / (int) FileType.LastEnumElement); + + string title = fileType switch { + FileType.Texture => StringResources.PackTypeTextures, + FileType.Map => StringResources.PackTypeMaps, + FileType.Character => StringResources.PackTypeCharacters, + FileType.Gui => StringResources.PackTypeGui, + FileType.Translation => StringResources.PackTypeTranslations, + FileType.Font => StringResources.PackTypeFonts, + FileType.Audio => StringResources.PackTypeAudio, + _ => throw new ArgumentOutOfRangeException() + }; var group = new ModifiedFilesGroupModel(title, initialFilesExt, fileType); group.ModifiedFiles.Add(new ModifiedFileModel(filePath: "drop_target" + initialFilesExt, isDragDropTarget: true)); diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml index 4e95f59..53daed4 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml @@ -7,7 +7,7 @@ xmlns:localizations="clr-namespace:TerrLauncherPackCreator.Resources.Localizations" xmlns:viewModels="clr-namespace:TerrLauncherPackCreator.Code.ViewModels" xmlns:controls="clr-namespace:TerrLauncherPackCreator.Controls" - xmlns:enums="clr-namespace:TerrLauncherPackCreator.Code.Enums" + xmlns:enums="clr-namespace:TerrLauncherPackCreator.Code.Enums;assembly=CrossPlatform" xmlns:packCreation="clr-namespace:TerrLauncherPackCreator.Pages.PackCreation" mc:Ignorable="d" diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index 8eb9ca8..3f8f624 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -77,6 +77,7 @@ + diff --git a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs index cf09243..60508d0 100644 --- a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs +++ b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs @@ -19,7 +19,7 @@ public void PacksInfo_NotNull() [TestMethod] public void PacksInfo_PackTypesValid() { - FileType[] packTypes = PackUtils.PacksInfo.Select(it => it.fileType).ToArray(); + FileType[] packTypes = PackUtils.PacksInfo.Select(it => it.FileType).ToArray(); Assert.IsTrue(packTypes.All(type => Enum.IsDefined(typeof(FileType), type))); } @@ -27,26 +27,18 @@ public void PacksInfo_PackTypesValid() [TestMethod] public void PacksInfo_PackTypesUnique() { - FileType[] packTypes = PackUtils.PacksInfo.Select(it => it.fileType).ToArray(); + FileType[] packTypes = PackUtils.PacksInfo.Select(it => it.FileType).ToArray(); var packTypesSet = new HashSet(packTypes); Assert.IsTrue(packTypes.Length == packTypesSet.Count); } - [TestMethod] - public void PacksInfo_PackTitlesNotEmpty() - { - string[] titles = PackUtils.PacksInfo.Select(it => it.title).ToArray(); - - Assert.IsTrue(titles.All(title => !string.IsNullOrWhiteSpace(title))); - } - [TestMethod] public void PacksInfo_PackInitialFilesExtensionsWithDot() { foreach (var item in PackUtils.PacksInfo) { - string packExt = item.initialFilesExt; + string packExt = item.InitialFilesExt; Assert.IsTrue(packExt[0] == '.' && packExt.Count(ch => ch == '.') == 1); } } @@ -57,7 +49,7 @@ public void PacksInfo_PackConvertedFilesExtensionsWithDot() Assert.IsTrue(PackUtils.PacksExtension[0] == '.' && PackUtils.PacksExtension.Count(ch => ch == '.') == 1); foreach (var item in PackUtils.PacksInfo) { - string packFilesExt = item.convertedFilesExt; + string packFilesExt = item.ConvertedFilesExt; Assert.IsTrue(packFilesExt[0] == '.' && packFilesExt.Count(ch => ch == '.') == 1); } } diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index 2ba411b..4bebd87 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -51,6 +51,7 @@ + From e4fba5f106585edd17020bcdd74729aef5b53644 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 20:06:39 +0300 Subject: [PATCH 14/33] Moved some classes to CrossPlatform library v2 --- CrossPlatform/Code/FileInfos/AudioFileInfo.cs | 9 + .../Code/FileInfos/CharacterFileInfo.cs | 8 + CrossPlatform/Code/FileInfos/FontFileInfo.cs | 8 + CrossPlatform/Code/FileInfos/GuiFileInfo.cs | 30 ++ CrossPlatform/Code/FileInfos/MapFileInfo.cs | 8 + .../Code/FileInfos/TextureFileInfo.cs | 27 ++ .../Code/FileInfos/TranslationFileInfo.cs | 8 + .../Code/Implementations/FileConverter.cs | 290 ++++++++++++++++++ .../Code/Interfaces/ISessionHelper.cs | 2 + .../Code/Json/FileInfos/AudioFileInfoJson.cs | 11 + .../Json/FileInfos/CharacterFileInfoJson.cs | 10 + .../Code/Json/FileInfos/FontFileInfoJson.cs | 10 + .../Code/Json/FileInfos/GuiFileInfoJson.cs | 5 + .../Code/Json/FileInfos/MapFileInfoJson.cs | 10 + .../Json/FileInfos/TextureFileInfoJson.cs | 35 +++ .../Json/FileInfos/TranslationFileInfoJson.cs | 11 + CrossPlatform/CrossPlatform.csproj | 4 - .../Code/Implementations/FileConverter.cs | 101 ------ .../Code/Implementations/SessionHelper.cs | 9 + .../Code/Implementations/ZipHelper.cs | 14 - .../Code/Json/AudioFileInfo.cs | 18 -- .../Code/Json/CharacterFileInfo.cs | 21 -- .../Code/Json/FontFileInfo.cs | 18 -- .../Code/Json/GuiFileInfo.cs | 4 - .../Code/Json/MapFileInfo.cs | 21 -- .../Code/Json/TextureFileInfo.cs | 45 --- .../Code/Json/TranslationFileInfo.cs | 21 -- .../ViewModels/ConverterWindowViewModel.cs | 2 +- .../Code/ViewModels/MainWindowViewModel.cs | 4 +- .../Code/ViewModels/PackCreationViewModel.cs | 60 ++-- .../Pages/PackCreation/PackCreationStep3.xaml | 2 +- 31 files changed, 528 insertions(+), 298 deletions(-) create mode 100644 CrossPlatform/Code/FileInfos/AudioFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/CharacterFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/FontFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/GuiFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/MapFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/TextureFileInfo.cs create mode 100644 CrossPlatform/Code/FileInfos/TranslationFileInfo.cs create mode 100644 CrossPlatform/Code/Implementations/FileConverter.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/AudioFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/CharacterFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/FontFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/GuiFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/MapFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs create mode 100644 CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs delete mode 100644 TerrLauncherPackCreator/Code/Implementations/FileConverter.cs delete mode 100644 TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/AudioFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/FontFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/GuiFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/MapFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/TextureFileInfo.cs delete mode 100644 TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs diff --git a/CrossPlatform/Code/FileInfos/AudioFileInfo.cs b/CrossPlatform/Code/FileInfos/AudioFileInfo.cs new file mode 100644 index 0000000..9e7b6ec --- /dev/null +++ b/CrossPlatform/Code/FileInfos/AudioFileInfo.cs @@ -0,0 +1,9 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json +{ + + public record AudioFileInfo( + string EntryName + ) : IPackFileInfo; +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs b/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs new file mode 100644 index 0000000..9f3e49f --- /dev/null +++ b/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs @@ -0,0 +1,8 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json +{ + public record CharacterFileInfo( + string ResultFileName + ) : IPackFileInfo; +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/FontFileInfo.cs b/CrossPlatform/Code/FileInfos/FontFileInfo.cs new file mode 100644 index 0000000..78818ea --- /dev/null +++ b/CrossPlatform/Code/FileInfos/FontFileInfo.cs @@ -0,0 +1,8 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json { + + public record FontFileInfo( + string EntryName + ) : IPackFileInfo; +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/GuiFileInfo.cs b/CrossPlatform/Code/FileInfos/GuiFileInfo.cs new file mode 100644 index 0000000..ba8fa68 --- /dev/null +++ b/CrossPlatform/Code/FileInfos/GuiFileInfo.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; + +namespace TerrLauncherPackCreator.Code.Json { + + public record GuiFileInfo : TextureFileInfo + { + [SuppressMessage("ReSharper", "InconsistentNaming")] + public GuiFileInfo( + TextureType Type, + string EntryName, + int ElementId, + bool Animated, + bool AnimateInGui, + int NumberOfVerticalFrames, + int NumberOfHorizontalFrames, + int MillisecondsPerFrame, + bool ApplyOriginalSize + ) : base( + Type, + EntryName, + ElementId, + Animated, + AnimateInGui, + NumberOfVerticalFrames, + NumberOfHorizontalFrames, + MillisecondsPerFrame, + ApplyOriginalSize + ) { } + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/MapFileInfo.cs b/CrossPlatform/Code/FileInfos/MapFileInfo.cs new file mode 100644 index 0000000..2f4f92b --- /dev/null +++ b/CrossPlatform/Code/FileInfos/MapFileInfo.cs @@ -0,0 +1,8 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json +{ + public record MapFileInfo( + string ResultFileName + ) : IPackFileInfo; +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/TextureFileInfo.cs b/CrossPlatform/Code/FileInfos/TextureFileInfo.cs new file mode 100644 index 0000000..2f62d0c --- /dev/null +++ b/CrossPlatform/Code/FileInfos/TextureFileInfo.cs @@ -0,0 +1,27 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json +{ + public record TextureFileInfo( + TextureFileInfo.TextureType Type, + string EntryName, + int ElementId, + bool Animated, + bool AnimateInGui, + int NumberOfVerticalFrames, + int NumberOfHorizontalFrames, + int MillisecondsPerFrame, + bool ApplyOriginalSize + ) : IPackFileInfo + { + public enum TextureType + { + General = 0, + ItemDeprecated = 1, + NpcDeprecated = 2, + BuffDeprecated = 3, + ExtraDeprecated = 4, + Item = 5 + } + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs b/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs new file mode 100644 index 0000000..f1d6b09 --- /dev/null +++ b/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs @@ -0,0 +1,8 @@ +using TerrLauncherPackCreator.Code.Interfaces; + +namespace TerrLauncherPackCreator.Code.Json +{ + public record TranslationFileInfo( + string Language + ) : IPackFileInfo; +} \ No newline at end of file diff --git a/CrossPlatform/Code/Implementations/FileConverter.cs b/CrossPlatform/Code/Implementations/FileConverter.cs new file mode 100644 index 0000000..9331ff2 --- /dev/null +++ b/CrossPlatform/Code/Implementations/FileConverter.cs @@ -0,0 +1,290 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Json.FileInfos; +using Newtonsoft.Json; +using TerrLauncherPackCreator.Code.Enums; +using TerrLauncherPackCreator.Code.Interfaces; +using TerrLauncherPackCreator.Code.Json; +using AudioFileInfo = TerrLauncherPackCreator.Code.Json.AudioFileInfo; + +namespace TerrLauncherPackCreator.Code.Implementations +{ + public class FileConverter : IFileConverter + { + private readonly ISessionHelper _sessionHelper; + + public FileConverter( + ISessionHelper sessionHelper + ) + { + _sessionHelper = sessionHelper; + } + + public async Task<(string convertedFile, string? configFile)> ConvertToTarget( + FileType fileType, + string sourceFile, + IPackFileInfo? fileInfo + ) + { + if (!File.Exists(sourceFile)) + throw new FileNotFoundException("File not found", sourceFile); + + string targetFile = _sessionHelper.GenerateNonExistentFilePath(); + IOUtils.EnsureParentDirExists(targetFile); + + // config + string? configFile = null; + if (fileInfo != null) { + configFile = _sessionHelper.GenerateNonExistentFilePath(); + await File.WriteAllTextAsync( + configFile, + fileType switch + { + FileType.Texture => SerializeFileInfo((TextureFileInfo) fileInfo), + FileType.Map => SerializeFileInfo((MapFileInfo) fileInfo), + FileType.Character => SerializeFileInfo((CharacterFileInfo) fileInfo), + FileType.Gui => SerializeFileInfo((GuiFileInfo) fileInfo), + FileType.Translation => SerializeFileInfo((TranslationFileInfo) fileInfo), + FileType.Font => SerializeFileInfo((FontFileInfo) fileInfo), + FileType.Audio => SerializeFileInfo((AudioFileInfo) fileInfo), + _ => throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null) + } + ); + } + + // file + File.Copy(sourceFile, targetFile, overwrite: false); + + return (targetFile, configFile); + } + + public async Task<(string sourceFile, IPackFileInfo? fileInfo)> ConvertToSource( + int packStructureVersion, + FileType fileType, + string targetFile, + string? configFile + ) + { + if (!File.Exists(targetFile)) + throw new FileNotFoundException("File not found", targetFile); + + // config + IPackFileInfo? fileInfo = null; + if (configFile != null && File.Exists(configFile)) + { + string configText = await File.ReadAllTextAsync(configFile); + fileInfo = fileType switch + { + FileType.Texture => DeserializeTextureFileInfo(configText), + FileType.Map => DeserializeMapFileInfo(configText), + FileType.Character => DeserializeCharacterFileInfo(configText), + FileType.Gui => DeserializeGuiFileInfo(configText), + FileType.Translation => DeserializeTranslationFileInfo(configText), + FileType.Font => DeserializeFontFileInfo(configText), + FileType.Audio => DeserializeAudioFileInfo(configText), + FileType.LastEnumElement => throw new ArgumentException( + (1 / (7 / (int) FileType.LastEnumElement)).ToString() + ), + _ => throw new ArgumentOutOfRangeException() + }; + if (fileType == FileType.Texture && packStructureVersion < 15) + { + var textureConfig = (TextureFileInfo) fileInfo; + if (textureConfig.Type == TextureFileInfo.TextureType.General) + fileInfo = textureConfig with { Animated = false }; + } + } + + // file + string sourceFile; + switch (fileType) + { + case FileType.Texture: + case FileType.Map: + case FileType.Character: + case FileType.Gui: + case FileType.Translation: + case FileType.Font: + case FileType.Audio: + string uniqueFile = _sessionHelper.GenerateNonExistentFilePath(); + IOUtils.EnsureParentDirExists(uniqueFile); + File.Copy(targetFile, uniqueFile, overwrite: false); + sourceFile = uniqueFile; + break; + case FileType.LastEnumElement: + throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); + default: + throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); + } + + return (sourceFile, fileInfo); + } + + private static TextureFileInfo DeserializeTextureFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new TextureFileInfo( + Type: json.Type, + EntryName: json.EntryName ?? string.Empty, + ElementId: json.ElementId ?? 0, + Animated: json.Animated ?? false, + AnimateInGui: json.AnimateInGui ?? true, + NumberOfVerticalFrames: json.NumberOfVerticalFrames ?? 1, + NumberOfHorizontalFrames: json.NumberOfHorizontalFrames ?? 1, + MillisecondsPerFrame: json.MillisecondsPerFrame ?? 100, + ApplyOriginalSize: json.ApplyOriginalSize ?? true + ); + } + + private static MapFileInfo DeserializeMapFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new MapFileInfo( + ResultFileName: json.ResultFileName + ); + } + + private static CharacterFileInfo DeserializeCharacterFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new CharacterFileInfo( + ResultFileName: json.ResultFileName + ); + } + + private static TextureFileInfo DeserializeGuiFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new GuiFileInfo( + Type: json.Type, + EntryName: json.EntryName ?? string.Empty, + ElementId: json.ElementId ?? 0, + Animated: json.Animated ?? false, + AnimateInGui: json.AnimateInGui ?? true, + NumberOfVerticalFrames: json.NumberOfVerticalFrames ?? 1, + NumberOfHorizontalFrames: json.NumberOfHorizontalFrames ?? 1, + MillisecondsPerFrame: json.MillisecondsPerFrame ?? 100, + ApplyOriginalSize: json.ApplyOriginalSize ?? true + ); + } + + private static TranslationFileInfo DeserializeTranslationFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new TranslationFileInfo( + Language: json.Language + ); + } + + private static FontFileInfo DeserializeFontFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new FontFileInfo( + EntryName: json.EntryName ?? string.Empty + ); + } + + private static AudioFileInfo DeserializeAudioFileInfo(string text) + { + var json = JsonConvert.DeserializeObject(text); + return new AudioFileInfo( + EntryName: json.EntryName + ); + } + + public static string SerializeFileInfo(TextureFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new TextureFileInfoJson + { + Type = fileInfo.Type, + EntryName = fileInfo.EntryName, + ElementId = fileInfo.ElementId, + Animated = fileInfo.Animated, + AnimateInGui = fileInfo.AnimateInGui, + NumberOfVerticalFrames = fileInfo.NumberOfVerticalFrames, + NumberOfHorizontalFrames = fileInfo.NumberOfHorizontalFrames, + MillisecondsPerFrame = fileInfo.MillisecondsPerFrame, + ApplyOriginalSize = fileInfo.ApplyOriginalSize + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(MapFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new MapFileInfoJson + { + ResultFileName = fileInfo.ResultFileName + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(CharacterFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new CharacterFileInfoJson + { + ResultFileName = fileInfo.ResultFileName + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(GuiFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new GuiFileInfoJson + { + Type = fileInfo.Type, + EntryName = fileInfo.EntryName, + ElementId = fileInfo.ElementId, + Animated = fileInfo.Animated, + AnimateInGui = fileInfo.AnimateInGui, + NumberOfVerticalFrames = fileInfo.NumberOfVerticalFrames, + NumberOfHorizontalFrames = fileInfo.NumberOfHorizontalFrames, + MillisecondsPerFrame = fileInfo.MillisecondsPerFrame, + ApplyOriginalSize = fileInfo.ApplyOriginalSize + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(TranslationFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new TranslationFileInfoJson + { + Language = fileInfo.Language + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(FontFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new FontFileInfoJson + { + EntryName = fileInfo.EntryName + }, + Formatting.Indented + ); + } + + public static string SerializeFileInfo(AudioFileInfo fileInfo) + { + return JsonConvert.SerializeObject( + new AudioFileInfoJson + { + EntryName = fileInfo.EntryName + }, + Formatting.Indented + ); + } + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Interfaces/ISessionHelper.cs b/CrossPlatform/Code/Interfaces/ISessionHelper.cs index 30936fb..d11801c 100644 --- a/CrossPlatform/Code/Interfaces/ISessionHelper.cs +++ b/CrossPlatform/Code/Interfaces/ISessionHelper.cs @@ -3,5 +3,7 @@ public interface ISessionHelper { string GenerateNonExistentDirPath(); + + string GenerateNonExistentFilePath(string? extension = null); } } \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/AudioFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/AudioFileInfoJson.cs new file mode 100644 index 0000000..597d8bc --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/AudioFileInfoJson.cs @@ -0,0 +1,11 @@ +using Newtonsoft.Json; + +namespace CrossPlatform.Code.Json.FileInfos +{ + + internal class AudioFileInfoJson + { + [JsonProperty("entry_name", Required = Required.Always)] + public string EntryName = null!; + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/CharacterFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/CharacterFileInfoJson.cs new file mode 100644 index 0000000..3f2d97d --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/CharacterFileInfoJson.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace CrossPlatform.Code.Json.FileInfos +{ + internal class CharacterFileInfoJson + { + [JsonProperty("result_file_name", Required = Required.Always)] + public string ResultFileName = null!; + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/FontFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/FontFileInfoJson.cs new file mode 100644 index 0000000..be54d5e --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/FontFileInfoJson.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace CrossPlatform.Code.Json.FileInfos { + + internal class FontFileInfoJson + { + [JsonProperty("entry_name")] + public string? EntryName { get; set; } + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/GuiFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/GuiFileInfoJson.cs new file mode 100644 index 0000000..655295b --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/GuiFileInfoJson.cs @@ -0,0 +1,5 @@ +namespace CrossPlatform.Code.Json.FileInfos +{ + + internal class GuiFileInfoJson : TextureFileInfoJson {} +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/MapFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/MapFileInfoJson.cs new file mode 100644 index 0000000..37f14c2 --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/MapFileInfoJson.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace CrossPlatform.Code.Json.FileInfos +{ + internal class MapFileInfoJson + { + [JsonProperty("result_file_name", Required = Required.Always)] + public string ResultFileName = null!; + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs new file mode 100644 index 0000000..10dde4a --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using TerrLauncherPackCreator.Code.Json; + +namespace CrossPlatform.Code.Json.FileInfos +{ + internal class TextureFileInfoJson + { + [JsonProperty("type", Required = Required.Always)] + public TextureFileInfo.TextureType Type; + + [JsonProperty("entry_name")] + public string? EntryName; + + [JsonProperty("element_id")] + public int? ElementId; + + [JsonProperty("animated")] + public bool? Animated; + + [JsonProperty("animate_in_gui")] + public bool? AnimateInGui; + + [JsonProperty("number_of_vertical_frames")] + public int? NumberOfVerticalFrames; + + [JsonProperty("number_of_horizontal_frames")] + public int? NumberOfHorizontalFrames; + + [JsonProperty("milliseconds_per_frame")] + public int? MillisecondsPerFrame; + + [JsonProperty("apply_original_size")] + public bool? ApplyOriginalSize; + } +} \ No newline at end of file diff --git a/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs new file mode 100644 index 0000000..3de8de2 --- /dev/null +++ b/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs @@ -0,0 +1,11 @@ +using Newtonsoft.Json; +using TerrLauncherPackCreator.Code.Interfaces; + +namespace CrossPlatform.Code.Json.FileInfos +{ + internal class TranslationFileInfoJson : IPackFileInfo + { + [JsonProperty("language", Required = Required.Always)] + public string Language = null!; + } +} \ No newline at end of file diff --git a/CrossPlatform/CrossPlatform.csproj b/CrossPlatform/CrossPlatform.csproj index 55a18af..de190bf 100644 --- a/CrossPlatform/CrossPlatform.csproj +++ b/CrossPlatform/CrossPlatform.csproj @@ -6,10 +6,6 @@ - - - - 1.15.0 diff --git a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs b/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs deleted file mode 100644 index ce38fe0..0000000 --- a/TerrLauncherPackCreator/Code/Implementations/FileConverter.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; -using CommonLibrary.CommonUtils; -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Code.Interfaces; -using TerrLauncherPackCreator.Code.Json; - -namespace TerrLauncherPackCreator.Code.Implementations -{ - public class FileConverter : IFileConverter - { - public async Task<(string convertedFile, string? configFile)> ConvertToTarget( - FileType fileType, - string sourceFile, - IPackFileInfo? fileInfo - ) - { - if (!File.Exists(sourceFile)) - throw new FileNotFoundException("File not found", sourceFile); - - string targetFile = ApplicationDataUtils.GenerateNonExistentFilePath(); - IOUtils.EnsureParentDirExists(targetFile); - - // config - string? configFile = null; - if (fileInfo != null) { - configFile = ApplicationDataUtils.GenerateNonExistentFilePath(); - await File.WriteAllTextAsync(configFile, JsonConvert.SerializeObject(fileInfo, Formatting.Indented)); - } - - // file - File.Copy(sourceFile, targetFile, overwrite: false); - - return (targetFile, configFile); - } - - public async Task<(string sourceFile, IPackFileInfo? fileInfo)> ConvertToSource( - int packStructureVersion, - FileType fileType, - string targetFile, - string? configFile - ) - { - if (!File.Exists(targetFile)) - throw new FileNotFoundException("File not found", targetFile); - - // config - IPackFileInfo? fileInfo = null; - if (configFile != null && File.Exists(configFile)) - { - string configText = await File.ReadAllTextAsync(configFile); - fileInfo = fileType switch - { - FileType.Texture => JsonConvert.DeserializeObject(configText), - FileType.Map => JsonConvert.DeserializeObject(configText), - FileType.Character => JsonConvert.DeserializeObject(configText), - FileType.Gui => JsonConvert.DeserializeObject(configText), - FileType.Translation => JsonConvert.DeserializeObject(configText), - FileType.Font => JsonConvert.DeserializeObject(configText), - FileType.Audio => JsonConvert.DeserializeObject(configText), - FileType.LastEnumElement => throw new ArgumentException( - (1 / (7 / (int) FileType.LastEnumElement)).ToString() - ), - _ => throw new ArgumentOutOfRangeException() - }; - if (fileType == FileType.Texture && packStructureVersion < 15) - { - var textureConfig = (TextureFileInfo) fileInfo; - if (textureConfig.Type == TextureFileInfo.TextureType.General) - textureConfig.Animated = false; - } - } - - // file - string sourceFile; - switch (fileType) - { - case FileType.Texture: - case FileType.Map: - case FileType.Character: - case FileType.Gui: - case FileType.Translation: - case FileType.Font: - case FileType.Audio: - string uniqueFile = ApplicationDataUtils.GenerateNonExistentFilePath(); - IOUtils.EnsureParentDirExists(uniqueFile); - File.Copy(targetFile, uniqueFile, overwrite: false); - sourceFile = uniqueFile; - break; - case FileType.LastEnumElement: - throw new ArgumentException((1 / (7 / (int) FileType.LastEnumElement)).ToString()); - default: - throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); - } - - return (sourceFile, fileInfo); - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs index b9e68e7..3e36000 100644 --- a/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs +++ b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs @@ -5,9 +5,18 @@ namespace TerrLauncherPackCreator.Code.Implementations { public class SessionHelper : ISessionHelper { + public static readonly SessionHelper Instance = new(); + + private SessionHelper() {} + public string GenerateNonExistentDirPath() { return ApplicationDataUtils.GenerateNonExistentDirPath(); } + + public string GenerateNonExistentFilePath(string? extension = null) + { + return ApplicationDataUtils.GenerateNonExistentFilePath(); + } } } \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs b/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs deleted file mode 100644 index e2a7851..0000000 --- a/TerrLauncherPackCreator/Code/Implementations/ZipHelper.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Ionic.Zip; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Implementations -{ - public class ZipHelper : IZipHelper - { - public void Extract(string inputZipPath, string targetDirectory) - { - using (var zip = ZipFile.Read(inputZipPath)) - zip.ExtractAll(targetDirectory); - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/AudioFileInfo.cs b/TerrLauncherPackCreator/Code/Json/AudioFileInfo.cs deleted file mode 100644 index 0c8e11c..0000000 --- a/TerrLauncherPackCreator/Code/Json/AudioFileInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json { - - public class AudioFileInfo : IPackFileInfo - { - [JsonProperty("entry_name")] - public string EntryName { get; set; } - - public AudioFileInfo() {} - - public AudioFileInfo(string entryName) - { - EntryName = entryName; - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs b/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs deleted file mode 100644 index 50c820b..0000000 --- a/TerrLauncherPackCreator/Code/Json/CharacterFileInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json -{ - public class CharacterFileInfo : IPackFileInfo - { - [JsonProperty("result_file_name", Required = Required.Always)] - public string ResultFileName { get; set; } - - public CharacterFileInfo() - { - ResultFileName = string.Empty; - } - - public CharacterFileInfo(string resultFileName) - { - ResultFileName = resultFileName; - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/FontFileInfo.cs b/TerrLauncherPackCreator/Code/Json/FontFileInfo.cs deleted file mode 100644 index bc3b87d..0000000 --- a/TerrLauncherPackCreator/Code/Json/FontFileInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json { - - public class FontFileInfo : IPackFileInfo - { - [JsonProperty("entry_name")] - public string EntryName { get; set; } - - public FontFileInfo() {} - - public FontFileInfo(string entryName) - { - EntryName = entryName; - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/GuiFileInfo.cs b/TerrLauncherPackCreator/Code/Json/GuiFileInfo.cs deleted file mode 100644 index 8e3cc98..0000000 --- a/TerrLauncherPackCreator/Code/Json/GuiFileInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace TerrLauncherPackCreator.Code.Json { - - public class GuiFileInfo : TextureFileInfo {} -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs b/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs deleted file mode 100644 index 211ffb3..0000000 --- a/TerrLauncherPackCreator/Code/Json/MapFileInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json -{ - public class MapFileInfo : IPackFileInfo - { - [JsonProperty("result_file_name", Required = Required.Always)] - public string ResultFileName { get; set; } - - public MapFileInfo() - { - ResultFileName = string.Empty; - } - - public MapFileInfo(string resultFileName) - { - ResultFileName = resultFileName; - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/TextureFileInfo.cs b/TerrLauncherPackCreator/Code/Json/TextureFileInfo.cs deleted file mode 100644 index 86d0231..0000000 --- a/TerrLauncherPackCreator/Code/Json/TextureFileInfo.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json -{ - public class TextureFileInfo : IPackFileInfo - { - public enum TextureType - { - General = 0, - ItemDeprecated = 1, - NpcDeprecated = 2, - BuffDeprecated = 3, - ExtraDeprecated = 4, - Item = 5 - } - - [JsonProperty("type")] - public TextureType Type { get; set; } - - [JsonProperty("entry_name")] - public string EntryName { get; set; } - - [JsonProperty("element_id")] - public int ElementId { get; set; } - - [JsonProperty("animated")] - public bool Animated { get; set; } - - [JsonProperty("animate_in_gui")] - public bool AnimateInGui { get; set; } = true; - - [JsonProperty("number_of_vertical_frames")] - public int NumberOfVerticalFrames { get; set; } = 1; - - [JsonProperty("number_of_horizontal_frames")] - public int NumberOfHorizontalFrames { get; set; } = 1; - - [JsonProperty("milliseconds_per_frame")] - public int MillisecondsPerFrame { get; set; } = 100; - - [JsonProperty("apply_original_size")] - public bool ApplyOriginalSize { get; set; } = true; - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs b/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs deleted file mode 100644 index 3a1e037..0000000 --- a/TerrLauncherPackCreator/Code/Json/TranslationFileInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; - -namespace TerrLauncherPackCreator.Code.Json -{ - public class TranslationFileInfo : IPackFileInfo - { - [JsonProperty("language", Required = Required.Always)] - public string Language { get; set; } - - public TranslationFileInfo() - { - Language = string.Empty; - } - - public TranslationFileInfo(string language) - { - Language = language; - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs index 808c8fe..9335f2b 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs @@ -26,7 +26,7 @@ public FileType CurrentFileType public FileType[] FileTypes { get; } = PackUtils.PacksInfo.Select(it => it.FileType).ToArray(); - private readonly IFileConverter _fileConverter = new FileConverter(); + private readonly IFileConverter _fileConverter = new FileConverter(SessionHelper.Instance); private FileType _currentFileType = FileType.Texture; public IActionCommand DropSourceFilesCommand { get; } diff --git a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs index c89c5ae..6395912 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs @@ -139,13 +139,13 @@ public MainWindowViewModel( LoadProgressManager = new ProgressManager {Text = StringResources.LoadingProgressStep}; SaveProgressManager = new ProgressManager {Text = StringResources.SavingProcessStep}; - FileConverter = new FileConverter(); + FileConverter = new FileConverter(SessionHelper.Instance); PackProcessor = new PackProcessor( LoadProgressManager, SaveProgressManager, FileConverter, - new SessionHelper(), + SessionHelper.Instance, new ImageConverter() ); TempDirsProvider = new TempDirsProvider(Paths.TempDir); diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 72dd635..adfe9b5 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -174,7 +174,7 @@ public bool IsBonusPack // ReSharper disable once UnusedMember.Global // ReSharper disable AssignNullToNotNullAttribute - public PackCreationViewModel() : this(null, null) + public PackCreationViewModel() : this(null!, null) // ReSharper restore AssignNullToNotNullAttribute { if (!DesignerUtils.IsInDesignMode()) @@ -604,61 +604,67 @@ private PackModel GeneratePackModel() { case FileType.Texture: var textureModel = (ModifiedTextureModel) it.modified; - fileInfo = new TextureFileInfo - { - Type = textureModel.CurrentTextureType, - Animated = textureModel.Animated, - AnimateInGui = textureModel.AnimateInGui, - EntryName = string.IsNullOrEmpty(textureModel.Prefix) - ? textureModel.Name + fileInfo = new TextureFileInfo( + Type: textureModel.CurrentTextureType, + Animated: textureModel.Animated, + AnimateInGui: textureModel.AnimateInGui, + EntryName: string.IsNullOrEmpty(textureModel.Prefix) + ? textureModel.Name ?? string.Empty : $"{textureModel.Prefix}/{textureModel.Name}", - ElementId = textureModel.ElementId, - MillisecondsPerFrame = textureModel.MillisecondsPerFrame, - NumberOfVerticalFrames = textureModel.NumberOfVerticalFrames, - NumberOfHorizontalFrames = textureModel.NumberOfHorizontalFrames, - ApplyOriginalSize = textureModel.ApplyOriginalSize - }; + ElementId: textureModel.ElementId, + MillisecondsPerFrame: textureModel.MillisecondsPerFrame, + NumberOfVerticalFrames: textureModel.NumberOfVerticalFrames, + NumberOfHorizontalFrames: textureModel.NumberOfHorizontalFrames, + ApplyOriginalSize: textureModel.ApplyOriginalSize + ); break; case FileType.Map: var mapModel = (ModifiedMapModel) it.modified; fileInfo = new MapFileInfo( - resultFileName: mapModel.ResultFileName ?? string.Empty + ResultFileName: mapModel.ResultFileName ?? string.Empty ); break; case FileType.Character: var characterModel = (ModifiedCharacterModel) it.modified; fileInfo = new CharacterFileInfo( - resultFileName: characterModel.ResultFileName + ResultFileName: characterModel.ResultFileName ); break; case FileType.Gui: var guiModel = (ModifiedGuiModel) it.modified; - fileInfo = new GuiFileInfo - { - EntryName = string.IsNullOrEmpty(guiModel.Prefix) - ? guiModel.Name - : $"{guiModel.Prefix}/{guiModel.Name}" - }; + fileInfo = new GuiFileInfo( + Type: TextureFileInfo.TextureType.General, + EntryName: string.IsNullOrEmpty(guiModel.Prefix) + ? guiModel.Name ?? string.Empty + : $"{guiModel.Prefix}/{guiModel.Name}", + ElementId: 0, + Animated: false, + AnimateInGui: false, + NumberOfVerticalFrames: 1, + NumberOfHorizontalFrames: 1, + MillisecondsPerFrame: 0, + ApplyOriginalSize: true + ); break; case FileType.Translation: var translationModel = (ModifiedTranslationModel) it.modified; fileInfo = new TranslationFileInfo( - language: translationModel.CurrentLanguage + Language: translationModel.CurrentLanguage ); break; case FileType.Font: var fontModel = (ModifiedFontModel) it.modified; fileInfo = new FontFileInfo( - entryName: string.IsNullOrEmpty(fontModel.Prefix) - ? fontModel.Name + EntryName: string.IsNullOrEmpty(fontModel.Prefix) + ? fontModel.Name ?? string.Empty : $"{fontModel.Prefix}/{fontModel.Name}" ); break; case FileType.Audio: var audioModel = (ModifiedAudioModel) it.modified; fileInfo = new AudioFileInfo( - entryName: string.IsNullOrEmpty(audioModel.Prefix) - ? audioModel.Name + EntryName: string.IsNullOrEmpty(audioModel.Prefix) + ? audioModel.Name ?? string.Empty : $"{audioModel.Prefix}/{audioModel.Name}" ); break; diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml index b5f1933..82ede80 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml @@ -7,7 +7,7 @@ xmlns:localizations="clr-namespace:TerrLauncherPackCreator.Resources.Localizations" xmlns:viewModels="clr-namespace:TerrLauncherPackCreator.Code.ViewModels" xmlns:models="clr-namespace:TerrLauncherPackCreator.Code.Models" - xmlns:json="clr-namespace:TerrLauncherPackCreator.Code.Json" + xmlns:json="clr-namespace:TerrLauncherPackCreator.Code.Json;assembly=CrossPlatform" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:me="clr-namespace:TerrLauncherPackCreator.Code.MarkupExtensions" mc:Ignorable="d" From b3a0873963e8984f16efa15884b18b6db3475883 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 20:08:03 +0300 Subject: [PATCH 15/33] Adjusted CrossPlatform library namespaces --- CrossPlatform/Code/Enums/BonusType.cs | 2 +- CrossPlatform/Code/Enums/FileType.cs | 2 +- CrossPlatform/Code/Enums/PredefinedPackTag.cs | 2 +- CrossPlatform/Code/FileInfos/AudioFileInfo.cs | 4 ++-- .../Code/FileInfos/CharacterFileInfo.cs | 4 ++-- CrossPlatform/Code/FileInfos/FontFileInfo.cs | 4 ++-- CrossPlatform/Code/FileInfos/GuiFileInfo.cs | 2 +- CrossPlatform/Code/FileInfos/MapFileInfo.cs | 4 ++-- CrossPlatform/Code/FileInfos/TextureFileInfo.cs | 4 ++-- .../Code/FileInfos/TranslationFileInfo.cs | 4 ++-- .../Code/Implementations/FileConverter.cs | 12 ++++++------ CrossPlatform/Code/Implementations/ImageInfo.cs | 2 +- .../Code/Implementations/PackProcessor.cs | 17 ++++++++--------- CrossPlatform/Code/Interfaces/IFileConverter.cs | 4 ++-- .../Code/Interfaces/IImageConverter.cs | 2 +- CrossPlatform/Code/Interfaces/IPackFileInfo.cs | 2 +- CrossPlatform/Code/Interfaces/IPackProcessor.cs | 4 ++-- .../Code/Interfaces/IProgressManager.cs | 2 +- CrossPlatform/Code/Interfaces/ISessionHelper.cs | 2 +- CrossPlatform/Code/Interfaces/IZipHelper.cs | 2 +- .../Code/Json/FileInfos/TextureFileInfoJson.cs | 4 ++-- .../Json/FileInfos/TranslationFileInfoJson.cs | 4 ++-- CrossPlatform/Code/Json/TL/AuthorJson.cs | 6 +++--- CrossPlatform/Code/Json/TL/PackSettings.cs | 7 +++---- CrossPlatform/Code/Models/PackModel.cs | 8 ++++---- CrossPlatform/Code/Utils/CollectionUtils.cs | 2 +- CrossPlatform/Code/Utils/IOUtils.cs | 2 +- CrossPlatform/Code/Utils/JsonUtils.cs | 2 +- CrossPlatform/Code/Utils/PackUtils.cs | 4 ++-- .../PredefinedTagToStringConverter.cs | 2 +- .../Converters/StatusBarVisibilityConverter.cs | 1 + ...TextureModeToEditingPanelEnabledConverter.cs | 2 +- .../TextureModelToAnimateInGuiVisibility.cs | 2 +- .../TextureModelToHorizontalFramesVisibility.cs | 2 +- .../TextureModelToVerticalFramesVisibility.cs | 2 +- .../Converters/TextureTypeToStringConverter.cs | 2 +- .../TranslationShortToLongConverter.cs | 1 + .../Code/Implementations/ImageConverter.cs | 3 ++- .../Code/Implementations/SessionHelper.cs | 1 + .../Code/Implementations/TempDirsProvider.cs | 1 + .../Code/Json/AuthorsJson.cs | 2 ++ .../Code/Models/AuthorItemModel.cs | 2 ++ .../Code/Models/ModifiedFilesGroupModel.cs | 2 +- .../Code/Models/ModifiedTextureModel.cs | 2 +- .../Code/Models/ModifiedTranslationModel.cs | 1 + .../ModifiedFileTemplateSelector.cs | 2 +- TerrLauncherPackCreator/Code/Utils/AppUtils.cs | 1 + .../Code/Utils/ImageUtils.cs | 1 + .../ViewModels/AuthorEditorWindowViewModel.cs | 2 ++ .../Code/ViewModels/ConverterWindowViewModel.cs | 6 +++++- .../Code/ViewModels/MainWindowViewModel.cs | 2 ++ .../Code/ViewModels/PackCreationViewModel.cs | 6 +++++- .../ViewModels/PackStartupWindowViewModel.cs | 1 + .../Pages/PackCreation/PackCreationStep1.xaml | 2 +- .../PackCreation/PackCreationStep1.xaml.cs | 2 +- .../Pages/PackCreation/PackCreationStep3.xaml | 7 ++++--- .../Tests/Code/Utils/PackUtilsTests.cs | 3 ++- TerrLauncherPackCreatorUpdater/App.xaml.cs | 1 + 58 files changed, 105 insertions(+), 79 deletions(-) diff --git a/CrossPlatform/Code/Enums/BonusType.cs b/CrossPlatform/Code/Enums/BonusType.cs index fd2b80b..5a9873a 100644 --- a/CrossPlatform/Code/Enums/BonusType.cs +++ b/CrossPlatform/Code/Enums/BonusType.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Enums +namespace CrossPlatform.Code.Enums { public enum BonusType { diff --git a/CrossPlatform/Code/Enums/FileType.cs b/CrossPlatform/Code/Enums/FileType.cs index 5084b80..402e2c2 100644 --- a/CrossPlatform/Code/Enums/FileType.cs +++ b/CrossPlatform/Code/Enums/FileType.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Enums +namespace CrossPlatform.Code.Enums { public enum FileType { diff --git a/CrossPlatform/Code/Enums/PredefinedPackTag.cs b/CrossPlatform/Code/Enums/PredefinedPackTag.cs index 5657a55..02dbd42 100644 --- a/CrossPlatform/Code/Enums/PredefinedPackTag.cs +++ b/CrossPlatform/Code/Enums/PredefinedPackTag.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Enums +namespace CrossPlatform.Code.Enums { public enum PredefinedPackTag { diff --git a/CrossPlatform/Code/FileInfos/AudioFileInfo.cs b/CrossPlatform/Code/FileInfos/AudioFileInfo.cs index 9e7b6ec..d0f0d1d 100644 --- a/CrossPlatform/Code/FileInfos/AudioFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/AudioFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json +namespace CrossPlatform.Code.FileInfos { public record AudioFileInfo( diff --git a/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs b/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs index 9f3e49f..3bf646e 100644 --- a/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/CharacterFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json +namespace CrossPlatform.Code.FileInfos { public record CharacterFileInfo( string ResultFileName diff --git a/CrossPlatform/Code/FileInfos/FontFileInfo.cs b/CrossPlatform/Code/FileInfos/FontFileInfo.cs index 78818ea..850448b 100644 --- a/CrossPlatform/Code/FileInfos/FontFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/FontFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json { +namespace CrossPlatform.Code.FileInfos { public record FontFileInfo( string EntryName diff --git a/CrossPlatform/Code/FileInfos/GuiFileInfo.cs b/CrossPlatform/Code/FileInfos/GuiFileInfo.cs index ba8fa68..abacd67 100644 --- a/CrossPlatform/Code/FileInfos/GuiFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/GuiFileInfo.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace TerrLauncherPackCreator.Code.Json { +namespace CrossPlatform.Code.FileInfos { public record GuiFileInfo : TextureFileInfo { diff --git a/CrossPlatform/Code/FileInfos/MapFileInfo.cs b/CrossPlatform/Code/FileInfos/MapFileInfo.cs index 2f4f92b..d24cbea 100644 --- a/CrossPlatform/Code/FileInfos/MapFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/MapFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json +namespace CrossPlatform.Code.FileInfos { public record MapFileInfo( string ResultFileName diff --git a/CrossPlatform/Code/FileInfos/TextureFileInfo.cs b/CrossPlatform/Code/FileInfos/TextureFileInfo.cs index 2f62d0c..a0e86a9 100644 --- a/CrossPlatform/Code/FileInfos/TextureFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/TextureFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json +namespace CrossPlatform.Code.FileInfos { public record TextureFileInfo( TextureFileInfo.TextureType Type, diff --git a/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs b/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs index f1d6b09..c06b3cb 100644 --- a/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs +++ b/CrossPlatform/Code/FileInfos/TranslationFileInfo.cs @@ -1,6 +1,6 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Json +namespace CrossPlatform.Code.FileInfos { public record TranslationFileInfo( string Language diff --git a/CrossPlatform/Code/Implementations/FileConverter.cs b/CrossPlatform/Code/Implementations/FileConverter.cs index 9331ff2..3af2f0c 100644 --- a/CrossPlatform/Code/Implementations/FileConverter.cs +++ b/CrossPlatform/Code/Implementations/FileConverter.cs @@ -1,15 +1,15 @@ using System; using System.IO; using System.Threading.Tasks; -using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.FileInfos; +using CrossPlatform.Code.Interfaces; using CrossPlatform.Code.Json.FileInfos; +using CrossPlatform.Code.Utils; using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Code.Interfaces; -using TerrLauncherPackCreator.Code.Json; -using AudioFileInfo = TerrLauncherPackCreator.Code.Json.AudioFileInfo; +using AudioFileInfo = CrossPlatform.Code.FileInfos.AudioFileInfo; -namespace TerrLauncherPackCreator.Code.Implementations +namespace CrossPlatform.Code.Implementations { public class FileConverter : IFileConverter { diff --git a/CrossPlatform/Code/Implementations/ImageInfo.cs b/CrossPlatform/Code/Implementations/ImageInfo.cs index b610d2b..b08f79b 100644 --- a/CrossPlatform/Code/Implementations/ImageInfo.cs +++ b/CrossPlatform/Code/Implementations/ImageInfo.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Implementations { +namespace CrossPlatform.Code.Implementations { public class ImageInfo { public enum ImageType { diff --git a/CrossPlatform/Code/Implementations/PackProcessor.cs b/CrossPlatform/Code/Implementations/PackProcessor.cs index 99d340f..60de472 100644 --- a/CrossPlatform/Code/Implementations/PackProcessor.cs +++ b/CrossPlatform/Code/Implementations/PackProcessor.cs @@ -6,16 +6,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.Interfaces; +using CrossPlatform.Code.Json.TL; +using CrossPlatform.Code.Models; +using CrossPlatform.Code.Utils; using Ionic.Zip; -using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Code.Interfaces; -using TerrLauncherPackCreator.Code.Json.TL; -using TerrLauncherPackCreator.Code.Models; -using TerrLauncherPackCreator.Code.Utils; -using AuthorJson = TerrLauncherPackCreator.Code.Json.TL.AuthorJson; - -namespace TerrLauncherPackCreator.Code.Implementations +using AuthorJson = CrossPlatform.Code.Json.TL.AuthorJson; + +namespace CrossPlatform.Code.Implementations { public class PackProcessor : IPackProcessor { diff --git a/CrossPlatform/Code/Interfaces/IFileConverter.cs b/CrossPlatform/Code/Interfaces/IFileConverter.cs index 9e70077..faf6ac1 100644 --- a/CrossPlatform/Code/Interfaces/IFileConverter.cs +++ b/CrossPlatform/Code/Interfaces/IFileConverter.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface IFileConverter { diff --git a/CrossPlatform/Code/Interfaces/IImageConverter.cs b/CrossPlatform/Code/Interfaces/IImageConverter.cs index 3f0b2d8..8b95303 100644 --- a/CrossPlatform/Code/Interfaces/IImageConverter.cs +++ b/CrossPlatform/Code/Interfaces/IImageConverter.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface IImageConverter { diff --git a/CrossPlatform/Code/Interfaces/IPackFileInfo.cs b/CrossPlatform/Code/Interfaces/IPackFileInfo.cs index e4a8d61..772e57d 100644 --- a/CrossPlatform/Code/Interfaces/IPackFileInfo.cs +++ b/CrossPlatform/Code/Interfaces/IPackFileInfo.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Interfaces { +namespace CrossPlatform.Code.Interfaces { public interface IPackFileInfo {} } \ No newline at end of file diff --git a/CrossPlatform/Code/Interfaces/IPackProcessor.cs b/CrossPlatform/Code/Interfaces/IPackProcessor.cs index f6e3678..e862cae 100644 --- a/CrossPlatform/Code/Interfaces/IPackProcessor.cs +++ b/CrossPlatform/Code/Interfaces/IPackProcessor.cs @@ -1,7 +1,7 @@ using System; -using TerrLauncherPackCreator.Code.Models; +using CrossPlatform.Code.Models; -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface IPackProcessor { diff --git a/CrossPlatform/Code/Interfaces/IProgressManager.cs b/CrossPlatform/Code/Interfaces/IProgressManager.cs index 166e2a4..e450c40 100644 --- a/CrossPlatform/Code/Interfaces/IProgressManager.cs +++ b/CrossPlatform/Code/Interfaces/IProgressManager.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface IProgressManager { diff --git a/CrossPlatform/Code/Interfaces/ISessionHelper.cs b/CrossPlatform/Code/Interfaces/ISessionHelper.cs index d11801c..807bf6e 100644 --- a/CrossPlatform/Code/Interfaces/ISessionHelper.cs +++ b/CrossPlatform/Code/Interfaces/ISessionHelper.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface ISessionHelper { diff --git a/CrossPlatform/Code/Interfaces/IZipHelper.cs b/CrossPlatform/Code/Interfaces/IZipHelper.cs index 723c1db..0328d1f 100644 --- a/CrossPlatform/Code/Interfaces/IZipHelper.cs +++ b/CrossPlatform/Code/Interfaces/IZipHelper.cs @@ -1,4 +1,4 @@ -namespace TerrLauncherPackCreator.Code.Interfaces +namespace CrossPlatform.Code.Interfaces { public interface IZipHelper { diff --git a/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs index 10dde4a..1b68593 100644 --- a/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs +++ b/CrossPlatform/Code/Json/FileInfos/TextureFileInfoJson.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Json; +using CrossPlatform.Code.FileInfos; +using Newtonsoft.Json; namespace CrossPlatform.Code.Json.FileInfos { diff --git a/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs b/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs index 3de8de2..ad3e024 100644 --- a/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs +++ b/CrossPlatform/Code/Json/FileInfos/TranslationFileInfoJson.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; +using Newtonsoft.Json; namespace CrossPlatform.Code.Json.FileInfos { diff --git a/CrossPlatform/Code/Json/TL/AuthorJson.cs b/CrossPlatform/Code/Json/TL/AuthorJson.cs index 0c20bcf..bc22fef 100644 --- a/CrossPlatform/Code/Json/TL/AuthorJson.cs +++ b/CrossPlatform/Code/Json/TL/AuthorJson.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using TerrLauncherPackCreator.Code.Utils; +using CrossPlatform.Code.Utils; +using Newtonsoft.Json; -namespace TerrLauncherPackCreator.Code.Json.TL +namespace CrossPlatform.Code.Json.TL { public class AuthorJson { diff --git a/CrossPlatform/Code/Json/TL/PackSettings.cs b/CrossPlatform/Code/Json/TL/PackSettings.cs index 2a3d594..340b06b 100644 --- a/CrossPlatform/Code/Json/TL/PackSettings.cs +++ b/CrossPlatform/Code/Json/TL/PackSettings.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; -using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Code.Utils; -namespace TerrLauncherPackCreator.Code.Json.TL +namespace CrossPlatform.Code.Json.TL { public class PackSettings { diff --git a/CrossPlatform/Code/Models/PackModel.cs b/CrossPlatform/Code/Models/PackModel.cs index e8d3c45..f9ad156 100644 --- a/CrossPlatform/Code/Models/PackModel.cs +++ b/CrossPlatform/Code/Models/PackModel.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Drawing; -using TerrLauncherPackCreator.Code.Enums; -using TerrLauncherPackCreator.Code.Implementations; -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Interfaces; -namespace TerrLauncherPackCreator.Code.Models +namespace CrossPlatform.Code.Models { public record PackModel( int PackStructureVersion, diff --git a/CrossPlatform/Code/Utils/CollectionUtils.cs b/CrossPlatform/Code/Utils/CollectionUtils.cs index 7addbae..8491a26 100644 --- a/CrossPlatform/Code/Utils/CollectionUtils.cs +++ b/CrossPlatform/Code/Utils/CollectionUtils.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace CommonLibrary.CommonUtils +namespace CrossPlatform.Code.Utils { public static class CollectionUtils { diff --git a/CrossPlatform/Code/Utils/IOUtils.cs b/CrossPlatform/Code/Utils/IOUtils.cs index 6b467c8..a41418c 100644 --- a/CrossPlatform/Code/Utils/IOUtils.cs +++ b/CrossPlatform/Code/Utils/IOUtils.cs @@ -2,7 +2,7 @@ using System.IO; using System.Threading; -namespace CommonLibrary.CommonUtils +namespace CrossPlatform.Code.Utils { // ReSharper disable once InconsistentNaming public static class IOUtils diff --git a/CrossPlatform/Code/Utils/JsonUtils.cs b/CrossPlatform/Code/Utils/JsonUtils.cs index 5a869d2..e339045 100644 --- a/CrossPlatform/Code/Utils/JsonUtils.cs +++ b/CrossPlatform/Code/Utils/JsonUtils.cs @@ -3,7 +3,7 @@ using System.Text; using Newtonsoft.Json; -namespace TerrLauncherPackCreator.Code.Utils +namespace CrossPlatform.Code.Utils { public static class JsonUtils { diff --git a/CrossPlatform/Code/Utils/PackUtils.cs b/CrossPlatform/Code/Utils/PackUtils.cs index 7e9899f..d1f8356 100644 --- a/CrossPlatform/Code/Utils/PackUtils.cs +++ b/CrossPlatform/Code/Utils/PackUtils.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; -namespace TerrLauncherPackCreator.Code.Utils +namespace CrossPlatform.Code.Utils { public static class PackUtils { diff --git a/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs b/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs index a3d6674..cadedac 100644 --- a/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/PredefinedTagToStringConverter.cs @@ -1,7 +1,7 @@ using System; using System.Globalization; using System.Windows.Data; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; using TerrLauncherPackCreator.Resources.Localizations; namespace TerrLauncherPackCreator.Code.Converters diff --git a/TerrLauncherPackCreator/Code/Converters/StatusBarVisibilityConverter.cs b/TerrLauncherPackCreator/Code/Converters/StatusBarVisibilityConverter.cs index f1d21a4..afe5174 100644 --- a/TerrLauncherPackCreator/Code/Converters/StatusBarVisibilityConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/StatusBarVisibilityConverter.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Linq; using System.Windows; +using CrossPlatform.Code.Interfaces; using MVVM_Tools.Code.Classes; using TerrLauncherPackCreator.Code.Interfaces; diff --git a/TerrLauncherPackCreator/Code/Converters/TextureModeToEditingPanelEnabledConverter.cs b/TerrLauncherPackCreator/Code/Converters/TextureModeToEditingPanelEnabledConverter.cs index 5776cc5..d159f71 100644 --- a/TerrLauncherPackCreator/Code/Converters/TextureModeToEditingPanelEnabledConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/TextureModeToEditingPanelEnabledConverter.cs @@ -2,7 +2,7 @@ using System.Diagnostics; using System.Globalization; using System.Windows.Data; -using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; +using TextureType = CrossPlatform.Code.FileInfos.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Converters { diff --git a/TerrLauncherPackCreator/Code/Converters/TextureModelToAnimateInGuiVisibility.cs b/TerrLauncherPackCreator/Code/Converters/TextureModelToAnimateInGuiVisibility.cs index 191ff36..2d4bd09 100644 --- a/TerrLauncherPackCreator/Code/Converters/TextureModelToAnimateInGuiVisibility.cs +++ b/TerrLauncherPackCreator/Code/Converters/TextureModelToAnimateInGuiVisibility.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.Windows; using System.Windows.Data; -using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; +using TextureType = CrossPlatform.Code.FileInfos.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Converters { diff --git a/TerrLauncherPackCreator/Code/Converters/TextureModelToHorizontalFramesVisibility.cs b/TerrLauncherPackCreator/Code/Converters/TextureModelToHorizontalFramesVisibility.cs index b4c248c..bf17655 100644 --- a/TerrLauncherPackCreator/Code/Converters/TextureModelToHorizontalFramesVisibility.cs +++ b/TerrLauncherPackCreator/Code/Converters/TextureModelToHorizontalFramesVisibility.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.Windows; using System.Windows.Data; -using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; +using TextureType = CrossPlatform.Code.FileInfos.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Converters { diff --git a/TerrLauncherPackCreator/Code/Converters/TextureModelToVerticalFramesVisibility.cs b/TerrLauncherPackCreator/Code/Converters/TextureModelToVerticalFramesVisibility.cs index a0f09ed..1884d41 100644 --- a/TerrLauncherPackCreator/Code/Converters/TextureModelToVerticalFramesVisibility.cs +++ b/TerrLauncherPackCreator/Code/Converters/TextureModelToVerticalFramesVisibility.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.Windows; using System.Windows.Data; -using static TerrLauncherPackCreator.Code.Json.TextureFileInfo; +using static CrossPlatform.Code.FileInfos.TextureFileInfo; namespace TerrLauncherPackCreator.Code.Converters { diff --git a/TerrLauncherPackCreator/Code/Converters/TextureTypeToStringConverter.cs b/TerrLauncherPackCreator/Code/Converters/TextureTypeToStringConverter.cs index c7d4a55..667c260 100644 --- a/TerrLauncherPackCreator/Code/Converters/TextureTypeToStringConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/TextureTypeToStringConverter.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Windows.Data; using TerrLauncherPackCreator.Resources.Localizations; -using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; +using TextureType = CrossPlatform.Code.FileInfos.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Converters { diff --git a/TerrLauncherPackCreator/Code/Converters/TranslationShortToLongConverter.cs b/TerrLauncherPackCreator/Code/Converters/TranslationShortToLongConverter.cs index 6e64120..5143031 100644 --- a/TerrLauncherPackCreator/Code/Converters/TranslationShortToLongConverter.cs +++ b/TerrLauncherPackCreator/Code/Converters/TranslationShortToLongConverter.cs @@ -1,5 +1,6 @@ using System.Globalization; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using MVVM_Tools.Code.Classes; using TerrLauncherPackCreator.Code.Utils; diff --git a/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs index f78739a..39868fd 100644 --- a/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs +++ b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs @@ -1,4 +1,5 @@ -using TerrLauncherPackCreator.Code.Interfaces; +using CrossPlatform.Code.Interfaces; +using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Implementations diff --git a/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs index 3e36000..effb52c 100644 --- a/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs +++ b/TerrLauncherPackCreator/Code/Implementations/SessionHelper.cs @@ -1,4 +1,5 @@ using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Interfaces; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Implementations diff --git a/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs b/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs index b4fc95e..7d70597 100644 --- a/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs +++ b/TerrLauncherPackCreator/Code/Implementations/TempDirsProvider.cs @@ -1,5 +1,6 @@ using System.IO; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using TerrLauncherPackCreator.Code.Interfaces; namespace TerrLauncherPackCreator.Code.Implementations diff --git a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs index d26d149..3414e64 100644 --- a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs +++ b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Windows.Media; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TerrLauncherPackCreator.Code.Implementations; diff --git a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs index d86ffb0..31f8da1 100644 --- a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs +++ b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs @@ -1,4 +1,6 @@ using System.Windows.Media; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Utils; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Utils; diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs index 5479c8b..1345542 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedFilesGroupModel.cs @@ -1,5 +1,5 @@ using System.Collections.ObjectModel; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; using TerrLauncherPackCreator.Code.ViewModels; namespace TerrLauncherPackCreator.Code.Models diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs index cb73f4c..3327f35 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedTextureModel.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using TextureType = TerrLauncherPackCreator.Code.Json.TextureFileInfo.TextureType; +using TextureType = CrossPlatform.Code.FileInfos.TextureFileInfo.TextureType; namespace TerrLauncherPackCreator.Code.Models { diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs index e92ce09..e846c6c 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CrossPlatform.Code.Utils; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Models diff --git a/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs b/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs index 5c9187b..a5440b4 100644 --- a/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs +++ b/TerrLauncherPackCreator/Code/TemplateSelectors/ModifiedFileTemplateSelector.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Windows; using System.Windows.Controls; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; using TerrLauncherPackCreator.Code.Models; namespace TerrLauncherPackCreator.Code.TemplateSelectors diff --git a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs index 96fd333..e941328 100644 --- a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs @@ -1,6 +1,7 @@ using System; using System.IO; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Resources.Localizations; diff --git a/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs b/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs index c411e80..2384feb 100644 --- a/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/ImageUtils.cs @@ -2,6 +2,7 @@ using System.Drawing.Imaging; using System.IO; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using WebPWrapper; namespace TerrLauncherPackCreator.Code.Utils diff --git a/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs index 9ddd324..800e90f 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/AuthorEditorWindowViewModel.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Text; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Utils; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Json; diff --git a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs index 9335f2b..bb3ffe6 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/ConverterWindowViewModel.cs @@ -4,8 +4,12 @@ using System.Linq; using System.Windows; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.FileInfos; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Interfaces; +using CrossPlatform.Code.Utils; using MVVM_Tools.Code.Commands; -using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Json; diff --git a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs index 6395912..2ec596a 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/MainWindowViewModel.cs @@ -6,6 +6,8 @@ using System.Windows.Controls; using CommonLibrary; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Implementations; +using CrossPlatform.Code.Interfaces; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.Interfaces; diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index adfe9b5..53f44ff 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -11,9 +11,13 @@ using System.Windows; using System.Windows.Media.Imaging; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.FileInfos; +using CrossPlatform.Code.Interfaces; +using CrossPlatform.Code.Models; +using CrossPlatform.Code.Utils; using Microsoft.Win32; using MVVM_Tools.Code.Commands; -using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Code.Models; diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs index 4da1239..b031f13 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackStartupWindowViewModel.cs @@ -5,6 +5,7 @@ using System.Windows.Media; using CommonLibrary; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using Microsoft.Win32; using MVVM_Tools.Code.Commands; using TerrLauncherPackCreator.Code.Interfaces; diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml index 53daed4..7b09ef7 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml @@ -7,8 +7,8 @@ xmlns:localizations="clr-namespace:TerrLauncherPackCreator.Resources.Localizations" xmlns:viewModels="clr-namespace:TerrLauncherPackCreator.Code.ViewModels" xmlns:controls="clr-namespace:TerrLauncherPackCreator.Controls" - xmlns:enums="clr-namespace:TerrLauncherPackCreator.Code.Enums;assembly=CrossPlatform" xmlns:packCreation="clr-namespace:TerrLauncherPackCreator.Pages.PackCreation" + xmlns:enums="clr-namespace:CrossPlatform.Code.Enums;assembly=CrossPlatform" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml.cs b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml.cs index 81fb7aa..ee949ae 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml.cs +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep1.xaml.cs @@ -1,6 +1,6 @@ using System.Windows; using System.Windows.Input; -using TerrLauncherPackCreator.Code.Enums; +using CrossPlatform.Code.Enums; using TerrLauncherPackCreator.Code.ViewModels; namespace TerrLauncherPackCreator.Pages.PackCreation diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml index 82ede80..e802944 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml @@ -10,6 +10,7 @@ xmlns:json="clr-namespace:TerrLauncherPackCreator.Code.Json;assembly=CrossPlatform" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:me="clr-namespace:TerrLauncherPackCreator.Code.MarkupExtensions" + xmlns:fileInfos="clr-namespace:CrossPlatform.Code.FileInfos;assembly=CrossPlatform" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" @@ -187,7 +188,7 @@ SelectedItem="{Binding CurrentTextureType}" ItemsSource="{Binding TextureTypes}"> - + @@ -198,7 +199,7 @@ Visibility="{ Binding CurrentTextureType, Converter={StaticResource VisibleIfEqualToParameterConverter}, - ConverterParameter={x:Static json:TextureFileInfo+TextureType.General} + ConverterParameter={x:Static fileInfos:TextureFileInfo+TextureType.General} }"> @@ -288,7 +289,7 @@ Visibility="{ Binding CurrentTextureType, Converter={StaticResource CollapsedIfEqualToParameterConverter}, - ConverterParameter={x:Static json:TextureFileInfo+TextureType.General} + ConverterParameter={x:Static fileInfos:TextureFileInfo+TextureType.General} }" IsEnabled="{ Binding CurrentTextureType, diff --git a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs index 60508d0..b49ff1d 100644 --- a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs +++ b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using CrossPlatform.Code.Enums; +using CrossPlatform.Code.Utils; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerrLauncherPackCreator.Code.Enums; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreatorTests.Tests.Code.Utils diff --git a/TerrLauncherPackCreatorUpdater/App.xaml.cs b/TerrLauncherPackCreatorUpdater/App.xaml.cs index 6eb1220..b680629 100644 --- a/TerrLauncherPackCreatorUpdater/App.xaml.cs +++ b/TerrLauncherPackCreatorUpdater/App.xaml.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Windows; using CommonLibrary.CommonUtils; +using CrossPlatform.Code.Utils; using IWshRuntimeLibrary; using TerrLauncherPackCreatorUpdater.Resources.Localizations; using TerrLauncherPackCreatorUpdater.Windows; From 9866f1fe91dff5170559c35eb79a56798878291b Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 21:12:44 +0300 Subject: [PATCH 16/33] Json via an util function --- .../Code/Implementations/FileConverter.cs | 52 ++++++++----------- CrossPlatform/Code/Utils/JsonUtils.cs | 5 ++ 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/CrossPlatform/Code/Implementations/FileConverter.cs b/CrossPlatform/Code/Implementations/FileConverter.cs index 3af2f0c..8cd5927 100644 --- a/CrossPlatform/Code/Implementations/FileConverter.cs +++ b/CrossPlatform/Code/Implementations/FileConverter.cs @@ -6,7 +6,6 @@ using CrossPlatform.Code.Interfaces; using CrossPlatform.Code.Json.FileInfos; using CrossPlatform.Code.Utils; -using Newtonsoft.Json; using AudioFileInfo = CrossPlatform.Code.FileInfos.AudioFileInfo; namespace CrossPlatform.Code.Implementations @@ -124,7 +123,7 @@ await File.WriteAllTextAsync( private static TextureFileInfo DeserializeTextureFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new TextureFileInfo( Type: json.Type, EntryName: json.EntryName ?? string.Empty, @@ -140,7 +139,7 @@ private static TextureFileInfo DeserializeTextureFileInfo(string text) private static MapFileInfo DeserializeMapFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new MapFileInfo( ResultFileName: json.ResultFileName ); @@ -148,7 +147,7 @@ private static MapFileInfo DeserializeMapFileInfo(string text) private static CharacterFileInfo DeserializeCharacterFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new CharacterFileInfo( ResultFileName: json.ResultFileName ); @@ -156,7 +155,7 @@ private static CharacterFileInfo DeserializeCharacterFileInfo(string text) private static TextureFileInfo DeserializeGuiFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new GuiFileInfo( Type: json.Type, EntryName: json.EntryName ?? string.Empty, @@ -172,7 +171,7 @@ private static TextureFileInfo DeserializeGuiFileInfo(string text) private static TranslationFileInfo DeserializeTranslationFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new TranslationFileInfo( Language: json.Language ); @@ -180,7 +179,7 @@ private static TranslationFileInfo DeserializeTranslationFileInfo(string text) private static FontFileInfo DeserializeFontFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException();; return new FontFileInfo( EntryName: json.EntryName ?? string.Empty ); @@ -188,15 +187,15 @@ private static FontFileInfo DeserializeFontFileInfo(string text) private static AudioFileInfo DeserializeAudioFileInfo(string text) { - var json = JsonConvert.DeserializeObject(text); + var json = JsonUtils.Deserialize(text) ?? throw new InvalidOperationException(); return new AudioFileInfo( - EntryName: json.EntryName + EntryName: json.EntryName ?? throw new InvalidOperationException() ); } public static string SerializeFileInfo(TextureFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new TextureFileInfoJson { Type = fileInfo.Type, @@ -208,36 +207,33 @@ public static string SerializeFileInfo(TextureFileInfo fileInfo) NumberOfHorizontalFrames = fileInfo.NumberOfHorizontalFrames, MillisecondsPerFrame = fileInfo.MillisecondsPerFrame, ApplyOriginalSize = fileInfo.ApplyOriginalSize - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(MapFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new MapFileInfoJson { ResultFileName = fileInfo.ResultFileName - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(CharacterFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new CharacterFileInfoJson { ResultFileName = fileInfo.ResultFileName - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(GuiFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new GuiFileInfoJson { Type = fileInfo.Type, @@ -249,41 +245,37 @@ public static string SerializeFileInfo(GuiFileInfo fileInfo) NumberOfHorizontalFrames = fileInfo.NumberOfHorizontalFrames, MillisecondsPerFrame = fileInfo.MillisecondsPerFrame, ApplyOriginalSize = fileInfo.ApplyOriginalSize - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(TranslationFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new TranslationFileInfoJson { Language = fileInfo.Language - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(FontFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new FontFileInfoJson { EntryName = fileInfo.EntryName - }, - Formatting.Indented + } ); } public static string SerializeFileInfo(AudioFileInfo fileInfo) { - return JsonConvert.SerializeObject( + return JsonUtils.Serialize( new AudioFileInfoJson { EntryName = fileInfo.EntryName - }, - Formatting.Indented + } ); } } diff --git a/CrossPlatform/Code/Utils/JsonUtils.cs b/CrossPlatform/Code/Utils/JsonUtils.cs index e339045..396af42 100644 --- a/CrossPlatform/Code/Utils/JsonUtils.cs +++ b/CrossPlatform/Code/Utils/JsonUtils.cs @@ -24,5 +24,10 @@ public static string Serialize(T value) return sw.ToString(); } + + public static T? Deserialize(string value) + { + return JsonConvert.DeserializeObject(value); + } } } From dcb0eec80ba9c014848cef18494d222b4f17cfc1 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 21:29:03 +0300 Subject: [PATCH 17/33] Json via an util function v2 --- CrossPlatform/Code/Utils/JsonUtils.cs | 2 +- TerrLauncherPackCreator/Code/Json/AuthorsJson.cs | 4 +--- TerrLauncherPackCreator/Code/Utils/AppUtils.cs | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CrossPlatform/Code/Utils/JsonUtils.cs b/CrossPlatform/Code/Utils/JsonUtils.cs index 396af42..d5ea552 100644 --- a/CrossPlatform/Code/Utils/JsonUtils.cs +++ b/CrossPlatform/Code/Utils/JsonUtils.cs @@ -25,7 +25,7 @@ public static string Serialize(T value) return sw.ToString(); } - public static T? Deserialize(string value) + public static T Deserialize(string value) { return JsonConvert.DeserializeObject(value); } diff --git a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs index 3414e64..1568f87 100644 --- a/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs +++ b/TerrLauncherPackCreator/Code/Json/AuthorsJson.cs @@ -5,8 +5,6 @@ using CrossPlatform.Code.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using TerrLauncherPackCreator.Code.Implementations; -using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Json { @@ -59,7 +57,7 @@ public static AuthorsJson Deserialize(string json) { return updatePerformed ? fileJson.ToObject() ?? throw new Exception("Can't parse updated authors file") - : JsonConvert.DeserializeObject(json); + : JsonUtils.Deserialize(json); } public static string Serialize(AuthorsJson model) { diff --git a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs index e941328..4eaf13a 100644 --- a/TerrLauncherPackCreator/Code/Utils/AppUtils.cs +++ b/TerrLauncherPackCreator/Code/Utils/AppUtils.cs @@ -2,7 +2,6 @@ using System.IO; using CommonLibrary.CommonUtils; using CrossPlatform.Code.Utils; -using Newtonsoft.Json; using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Resources.Localizations; @@ -17,7 +16,7 @@ public static AppSettingsJson LoadAppSettings() try { - return JsonConvert.DeserializeObject( + return JsonUtils.Deserialize( File.ReadAllText(Paths.AppSettingsFile) ); } @@ -33,7 +32,7 @@ public static void SaveAppSettings(AppSettingsJson settings) IOUtils.EnsureParentDirExists(Paths.AppSettingsFile); File.WriteAllText( Paths.AppSettingsFile, - JsonConvert.SerializeObject(settings, Formatting.Indented) + JsonUtils.Serialize(settings) ); } } From e4d77f19038d3fc676f9bdc56d764d6102f675c7 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 21:30:23 +0300 Subject: [PATCH 18/33] Removed unused references --- TerrLauncherPackCreator/App.xaml.cs | 4 ---- .../Code/Implementations/ImageConverter.cs | 1 - TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs | 2 -- .../Code/Models/ModifiedTranslationModel.cs | 1 - .../Code/ViewModels/PackCreationViewModel.cs | 2 -- .../Tests/Code/Utils/PackUtilsTests.cs | 1 - 6 files changed, 11 deletions(-) diff --git a/TerrLauncherPackCreator/App.xaml.cs b/TerrLauncherPackCreator/App.xaml.cs index 13a889a..1f8545d 100644 --- a/TerrLauncherPackCreator/App.xaml.cs +++ b/TerrLauncherPackCreator/App.xaml.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; using System.Diagnostics; using System.Globalization; using System.IO; -using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; diff --git a/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs index 39868fd..5c88a62 100644 --- a/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs +++ b/TerrLauncherPackCreator/Code/Implementations/ImageConverter.cs @@ -1,5 +1,4 @@ using CrossPlatform.Code.Interfaces; -using TerrLauncherPackCreator.Code.Interfaces; using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Implementations diff --git a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs index 31f8da1..58c099c 100644 --- a/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs +++ b/TerrLauncherPackCreator/Code/Models/AuthorItemModel.cs @@ -2,8 +2,6 @@ using CrossPlatform.Code.Implementations; using CrossPlatform.Code.Utils; using MVVM_Tools.Code.Commands; -using TerrLauncherPackCreator.Code.Implementations; -using TerrLauncherPackCreator.Code.Utils; using TerrLauncherPackCreator.Code.ViewModels; using TerrLauncherPackCreator.Windows; diff --git a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs index e846c6c..6f75e3d 100644 --- a/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs +++ b/TerrLauncherPackCreator/Code/Models/ModifiedTranslationModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using CrossPlatform.Code.Utils; -using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreator.Code.Models { diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index 53f44ff..bcd61f9 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -18,8 +18,6 @@ using CrossPlatform.Code.Utils; using Microsoft.Win32; using MVVM_Tools.Code.Commands; -using TerrLauncherPackCreator.Code.Interfaces; -using TerrLauncherPackCreator.Code.Json; using TerrLauncherPackCreator.Code.Models; using TerrLauncherPackCreator.Code.Utils; using TerrLauncherPackCreator.Resources.Localizations; diff --git a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs index b49ff1d..d5998ba 100644 --- a/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs +++ b/TerrLauncherPackCreatorTests/Tests/Code/Utils/PackUtilsTests.cs @@ -4,7 +4,6 @@ using CrossPlatform.Code.Enums; using CrossPlatform.Code.Utils; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerrLauncherPackCreator.Code.Utils; namespace TerrLauncherPackCreatorTests.Tests.Code.Utils { From 855ad0cfccc053e73cfd85ea57304b1eef4706e4 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 22:12:48 +0300 Subject: [PATCH 19/33] A bit more C# 9 changes --- CrossPlatform/Code/Implementations/ImageInfo.cs | 13 ++++--------- CrossPlatform/Code/Implementations/PackProcessor.cs | 12 +++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CrossPlatform/Code/Implementations/ImageInfo.cs b/CrossPlatform/Code/Implementations/ImageInfo.cs index b08f79b..42457ce 100644 --- a/CrossPlatform/Code/Implementations/ImageInfo.cs +++ b/CrossPlatform/Code/Implementations/ImageInfo.cs @@ -1,17 +1,12 @@ namespace CrossPlatform.Code.Implementations { - public class ImageInfo { + public record ImageInfo( + byte[] Bytes, + ImageInfo.ImageType Type + ) { public enum ImageType { Png = 0, Gif = 1 } - - public byte[] Bytes { get; } - public ImageType Type { get; } - - public ImageInfo(byte[] bytes, ImageType type) { - Bytes = bytes; - Type = type; - } } } \ No newline at end of file diff --git a/CrossPlatform/Code/Implementations/PackProcessor.cs b/CrossPlatform/Code/Implementations/PackProcessor.cs index 60de472..5646146 100644 --- a/CrossPlatform/Code/Implementations/PackProcessor.cs +++ b/CrossPlatform/Code/Implementations/PackProcessor.cs @@ -204,11 +204,13 @@ private async Task LoadPackModelInternal(string filePath) targetFile: modifiedFile, configFile: configFile ); - modifiedFiles.Add(new PackModel.ModifiedFile( - Config: fileInfo, - FilePath: sourceFile, - FileType: fileType - )); + modifiedFiles.Add( + new PackModel.ModifiedFile( + Config: fileInfo, + FilePath: sourceFile, + FileType: fileType + ) + ); } return new PackModel( From 86c847f1ab2f7dc28c1abd977faf6543de300b19 Mon Sep 17 00:00:00 2001 From: And42 Date: Wed, 10 Feb 2021 22:12:58 +0300 Subject: [PATCH 20/33] Removed unused code --- .../Code/Utils/FreezableUtils.cs | 15 -------- .../Code/Utils/ProcessUtils.cs | 36 ------------------- .../Code/Utils/SafeFileSystemUtils.cs | 19 ---------- 3 files changed, 70 deletions(-) delete mode 100644 TerrLauncherPackCreator/Code/Utils/FreezableUtils.cs delete mode 100644 TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs delete mode 100644 TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs diff --git a/TerrLauncherPackCreator/Code/Utils/FreezableUtils.cs b/TerrLauncherPackCreator/Code/Utils/FreezableUtils.cs deleted file mode 100644 index a416263..0000000 --- a/TerrLauncherPackCreator/Code/Utils/FreezableUtils.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Windows; - -namespace TerrLauncherPackCreator.Code.Utils -{ - public static class FreezableUtils - { - public static T FreezeIfCan(this T obj) where T : Freezable - { - if (obj.CanFreeze) - obj.Freeze(); - - return obj; - } - } -} diff --git a/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs b/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs deleted file mode 100644 index 42ba34d..0000000 --- a/TerrLauncherPackCreator/Code/Utils/ProcessUtils.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; - -namespace TerrLauncherPackCreator.Code.Utils -{ - public static class ProcessUtils - { - public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default) - { - var tcs = new TaskCompletionSource(); - - void ProcessOnExited(object sender, EventArgs e) - { - tcs.TrySetResult(true); - } - - process.EnableRaisingEvents = true; - process.Exited += ProcessOnExited; - - try - { - if (process.HasExited) - return; - - using (cancellationToken.Register(() => tcs.TrySetCanceled())) - await tcs.Task.ConfigureAwait(false); - } - finally - { - process.Exited -= ProcessOnExited; - } - } - } -} \ No newline at end of file diff --git a/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs b/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs deleted file mode 100644 index d8cd24e..0000000 --- a/TerrLauncherPackCreator/Code/Utils/SafeFileSystemUtils.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.IO; - -namespace TerrLauncherPackCreator.Code.Utils -{ - public static class SafeFileSystemUtils - { - public static void DeleteFile(string file) - { - if (File.Exists(file)) - File.Delete(file); - } - - public static void DeleteDir(string dir) - { - if (Directory.Exists(dir)) - Directory.Delete(dir, true); - } - } -} \ No newline at end of file From e3343651fe4b35884f161748457f3e849f730f73 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 12:01:38 +0300 Subject: [PATCH 21/33] Removed unused warning --- CrossPlatform/Code/Utils/PackUtils.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/CrossPlatform/Code/Utils/PackUtils.cs b/CrossPlatform/Code/Utils/PackUtils.cs index d1f8356..493ee1b 100644 --- a/CrossPlatform/Code/Utils/PackUtils.cs +++ b/CrossPlatform/Code/Utils/PackUtils.cs @@ -24,9 +24,7 @@ string ConvertedFilesExt static PackUtils() { -#pragma warning disable 219 const int _ = 1 / (7 / (int) FileType.LastEnumElement); -#pragma warning restore 219 PacksInfo = new PackInfo[] { From e31957ef09ece10668e39ce827255a2504b55116 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:19:45 +0300 Subject: [PATCH 22/33] Added unhandler error handling --- TerrLauncherPackCreator/App.xaml.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TerrLauncherPackCreator/App.xaml.cs b/TerrLauncherPackCreator/App.xaml.cs index 1f8545d..82aeb87 100644 --- a/TerrLauncherPackCreator/App.xaml.cs +++ b/TerrLauncherPackCreator/App.xaml.cs @@ -18,6 +18,11 @@ protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); + DispatcherUnhandledException += (_, args) => + { + MessageBoxUtils.ShowError($"Unhandled exception: `{args.Exception}`"); + }; + Task.Run(() => { try From 609bf8a19489208c21b5145474f9c9cb7df9582f Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:20:03 +0300 Subject: [PATCH 23/33] Single exe publishing profile --- .../SingleExeWithoutNet32bit.pubxml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 TerrLauncherPackCreator/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml diff --git a/TerrLauncherPackCreator/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml b/TerrLauncherPackCreator/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml new file mode 100644 index 0000000..7c69e6f --- /dev/null +++ b/TerrLauncherPackCreator/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml @@ -0,0 +1,17 @@ + + + + + Release + Any CPU + bin\Release\net5.0-windows\publish\ + FileSystem + net5.0-windows + false + win-x86 + True + False + + \ No newline at end of file From f201cb7e5321b791926c475054370ca4056abd98 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:20:13 +0300 Subject: [PATCH 24/33] Fixed app path for single exe --- TerrLauncherPackCreator/Code/Utils/Paths.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/TerrLauncherPackCreator/Code/Utils/Paths.cs b/TerrLauncherPackCreator/Code/Utils/Paths.cs index 5dfd836..cd0a7f2 100644 --- a/TerrLauncherPackCreator/Code/Utils/Paths.cs +++ b/TerrLauncherPackCreator/Code/Utils/Paths.cs @@ -1,17 +1,14 @@ -using System.IO; -using System.Reflection; +using System; +using System.IO; namespace TerrLauncherPackCreator.Code.Utils { public static class Paths { #if DEBUG - public static readonly string ExeDir = Path.GetFullPath(Path.Combine( - Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), - "..", "Release" - )); + public static readonly string ExeDir = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "Release")); #else - public static readonly string ExeDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + public static readonly string ExeDir = AppContext.BaseDirectory; #endif public static readonly string DataDir = Path.Combine(ExeDir, "data"); From 1bad910f391db0e78c8e878b343d841d8759080d Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:26:26 +0300 Subject: [PATCH 25/33] Fixed some issues --- TerrLauncherPackCreator/Windows/ConverterWindow.xaml.cs | 5 +++-- TerrLauncherPackCreator/Windows/MainWindow.xaml | 2 +- TerrLauncherPackCreator/Windows/MainWindow.xaml.cs | 2 +- TerrLauncherPackCreator/Windows/PackStartupWindow.xaml.cs | 6 +----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/TerrLauncherPackCreator/Windows/ConverterWindow.xaml.cs b/TerrLauncherPackCreator/Windows/ConverterWindow.xaml.cs index cc904ea..8b3c887 100644 --- a/TerrLauncherPackCreator/Windows/ConverterWindow.xaml.cs +++ b/TerrLauncherPackCreator/Windows/ConverterWindow.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; using TerrLauncherPackCreator.Code.Utils; using TerrLauncherPackCreator.Code.ViewModels; @@ -15,7 +16,7 @@ public ConverterWindow() public ConverterWindowViewModel ViewModel { - get => DataContext as ConverterWindowViewModel; + get => DataContext as ConverterWindowViewModel ?? throw new InvalidOperationException(); set => DataContext = value; } diff --git a/TerrLauncherPackCreator/Windows/MainWindow.xaml b/TerrLauncherPackCreator/Windows/MainWindow.xaml index d587993..00e3026 100644 --- a/TerrLauncherPackCreator/Windows/MainWindow.xaml +++ b/TerrLauncherPackCreator/Windows/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:localizations="clr-namespace:TerrLauncherPackCreator.Resources.Localizations" xmlns:viewModels="clr-namespace:TerrLauncherPackCreator.Code.ViewModels" xmlns:controls="clr-namespace:TerrLauncherPackCreator.Controls" - xmlns:interfaces="clr-namespace:TerrLauncherPackCreator.Code.Interfaces" + xmlns:interfaces="clr-namespace:CrossPlatform.Code.Interfaces;assembly=CrossPlatform" mc:Ignorable="d" Title="{Binding WindowTitle, Mode=OneWay}" MinWidth="600" diff --git a/TerrLauncherPackCreator/Windows/MainWindow.xaml.cs b/TerrLauncherPackCreator/Windows/MainWindow.xaml.cs index 62f9d66..04f47ea 100644 --- a/TerrLauncherPackCreator/Windows/MainWindow.xaml.cs +++ b/TerrLauncherPackCreator/Windows/MainWindow.xaml.cs @@ -32,7 +32,7 @@ public MainWindow() public MainWindowViewModel ViewModel { - get => DataContext as MainWindowViewModel; + get => DataContext as MainWindowViewModel ?? throw new InvalidOperationException(); set => DataContext = value; } diff --git a/TerrLauncherPackCreator/Windows/PackStartupWindow.xaml.cs b/TerrLauncherPackCreator/Windows/PackStartupWindow.xaml.cs index b9ac2c3..96a5234 100644 --- a/TerrLauncherPackCreator/Windows/PackStartupWindow.xaml.cs +++ b/TerrLauncherPackCreator/Windows/PackStartupWindow.xaml.cs @@ -1,8 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media.Animation; using CommonLibrary.CommonUtils; using TerrLauncherPackCreator.Code.Implementations; using TerrLauncherPackCreator.Code.ViewModels; @@ -13,7 +9,7 @@ public partial class PackStartupWindow { public PackStartupWindowViewModel ViewModel { - get => DataContext as PackStartupWindowViewModel; + get => DataContext as PackStartupWindowViewModel ?? throw new InvalidOperationException(); set => DataContext = value; } From 304596c66cc86da33b2939e0e8f124dc03b4abd8 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:27:16 +0300 Subject: [PATCH 26/33] Removed unused assembly reference --- .../Pages/PackCreation/PackCreationStep3.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml index e802944..283a5c8 100644 --- a/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml +++ b/TerrLauncherPackCreator/Pages/PackCreation/PackCreationStep3.xaml @@ -7,7 +7,6 @@ xmlns:localizations="clr-namespace:TerrLauncherPackCreator.Resources.Localizations" xmlns:viewModels="clr-namespace:TerrLauncherPackCreator.Code.ViewModels" xmlns:models="clr-namespace:TerrLauncherPackCreator.Code.Models" - xmlns:json="clr-namespace:TerrLauncherPackCreator.Code.Json;assembly=CrossPlatform" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:me="clr-namespace:TerrLauncherPackCreator.Code.MarkupExtensions" xmlns:fileInfos="clr-namespace:CrossPlatform.Code.FileInfos;assembly=CrossPlatform" From d552bf42e1a1b277f67e3eac51db2f41930c5ed7 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 13:43:20 +0300 Subject: [PATCH 27/33] Pack title as default pack name --- .../Code/ViewModels/PackCreationViewModel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs index bcd61f9..52ea7b5 100644 --- a/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs +++ b/TerrLauncherPackCreator/Code/ViewModels/PackCreationViewModel.cs @@ -513,11 +513,16 @@ private void DeleteAuthorCommand_Execute(AuthorItemModel author) private void ExportPackCommand_Execute() { + string fileName = Title; + foreach (char invalidChar in Path.GetInvalidFileNameChars()) + fileName = fileName.Replace(invalidChar, '_'); + var dialog = new SaveFileDialog { Title = StringResources.SavePackDialogTitle, Filter = $"{StringResources.TlPacksFilter} (*{PackUtils.PacksExtension})|*{PackUtils.PacksExtension}", - AddExtension = true + AddExtension = true, + FileName = $"{fileName}.{PackUtils.PacksExtension}" }; if (dialog.ShowDialog() != true) From 9ae787d5c89236062962a17505b77bae29154278 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:09:48 +0300 Subject: [PATCH 28/33] Pack creator version changed: 1.23 > 1.24 --- TerrLauncherPackCreator/TerrLauncherPackCreator.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index 3f8f624..d495f6f 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -7,8 +7,8 @@ TerrLauncherPackCreator TerrLauncherPackCreator - 1.23.0.0 - 1.23.0.0 + 1.24.0.0 + 1.24.0.0 en enable From 0a3e0fb9040e44de21b64a1f28dd34b9b7e19084 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:15:31 +0300 Subject: [PATCH 29/33] Fixed single exe for updater --- TerrLauncherPackCreatorUpdater/App.xaml.cs | 8 ++------ .../Code/ViewModels/UpdaterWindowViewModel.cs | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/TerrLauncherPackCreatorUpdater/App.xaml.cs b/TerrLauncherPackCreatorUpdater/App.xaml.cs index b680629..52cdacc 100644 --- a/TerrLauncherPackCreatorUpdater/App.xaml.cs +++ b/TerrLauncherPackCreatorUpdater/App.xaml.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics; using System.IO; -using System.Reflection; using System.Windows; using CommonLibrary.CommonUtils; using CrossPlatform.Code.Utils; @@ -69,7 +68,7 @@ private static string GetCreatorPath() private static void RunUpdate() { - string currentExeLocation = Assembly.GetExecutingAssembly().Location; + string currentExeLocation = Process.GetCurrentProcess().MainModule!.FileName!; string tempFile = Path.GetTempFileName(); @@ -87,10 +86,7 @@ private static void CreateShortcut() var shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut) shell.CreateShortcut( - Path.Combine( - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, - "TerrLauncherPackCreator.lnk" - ) + Path.Combine(AppContext.BaseDirectory, "TerrLauncherPackCreator.lnk") ); shortcut.TargetPath = GetCreatorPath(); diff --git a/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs b/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs index 67a9d57..54efc13 100644 --- a/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs +++ b/TerrLauncherPackCreatorUpdater/Code/ViewModels/UpdaterWindowViewModel.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.IO; using System.Net; -using System.Reflection; using System.Windows; using System.Windows.Shell; using CommonLibrary; @@ -105,7 +104,7 @@ private void WebClientOnDownloadDataCompleted(object sender, DownloadDataComplet Process.Start( Path.Combine(ApplicationDataUtils.PathToRootFolder, "updater.exe"), - $"delete_temp \"{Assembly.GetExecutingAssembly().Location}\"" + $"delete_temp \"{Process.GetCurrentProcess().MainModule!.FileName}\"" ); Environment.Exit(0); From 3fbbda4d61f70784889d4142db1e981258f60012 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:21:00 +0300 Subject: [PATCH 30/33] Added single exe publish for updater --- .../SingleExeWithoutNet32bit.pubxml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 TerrLauncherPackCreatorUpdater/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml diff --git a/TerrLauncherPackCreatorUpdater/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml b/TerrLauncherPackCreatorUpdater/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml new file mode 100644 index 0000000..02f6d54 --- /dev/null +++ b/TerrLauncherPackCreatorUpdater/Properties/PublishProfiles/SingleExeWithoutNet32bit.pubxml @@ -0,0 +1,17 @@ + + + + + Release + Any CPU + bin\Release\net5.0-windows\publish\ + FileSystem + net5.0-windows + win-x86 + false + True + False + + \ No newline at end of file From 3087e6be08180a6cefd3e1b99d2978ce0e10f36a Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:22:28 +0300 Subject: [PATCH 31/33] Pack updater version changed: 1.3.1 > 1.4 --- .../TerrLauncherPackCreatorUpdater.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj index 4bebd87..42c3cb7 100644 --- a/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj +++ b/TerrLauncherPackCreatorUpdater/TerrLauncherPackCreatorUpdater.csproj @@ -8,8 +8,8 @@ TerrLauncherPackCreatorUpdater TerrLauncherPackCreatorUpdater - 1.3.1.0 - 1.3.1.0 + 1.4.0.0 + 1.4.0.0 enable From 94551ca2aa7c9271a94e313d1210b1114342d391 Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:24:42 +0300 Subject: [PATCH 32/33] Added the icon to creator --- TerrLauncherPackCreator/TerrLauncherPackCreator.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index d495f6f..cf018b4 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -11,6 +11,7 @@ 1.24.0.0 en enable + Resources\Images\app.ico From 96ad2da045ce7a90ef9078f4af56b858888130cd Mon Sep 17 00:00:00 2001 From: And42 Date: Thu, 4 Mar 2021 14:27:47 +0300 Subject: [PATCH 33/33] Pack creator version changed: 1.24.1 --- TerrLauncherPackCreator/TerrLauncherPackCreator.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj index cf018b4..9d0e0fa 100644 --- a/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj +++ b/TerrLauncherPackCreator/TerrLauncherPackCreator.csproj @@ -7,8 +7,8 @@ TerrLauncherPackCreator TerrLauncherPackCreator - 1.24.0.0 - 1.24.0.0 + 1.24.1.0 + 1.24.1.0 en enable Resources\Images\app.ico