From b26072d43031734423a50886c3fe5709ee293b2b Mon Sep 17 00:00:00 2001 From: Dmitry Khudyakov Date: Wed, 30 Oct 2024 21:05:30 +0600 Subject: [PATCH 01/19] fix for loading hideout productions --- SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs | 2 +- SPT-AKI Profile Editor/Core/AppData.cs | 4 ++-- .../Core/ServerClasses/Hideout/HideoutProductions.cs | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 SPT-AKI Profile Editor/Core/ServerClasses/Hideout/HideoutProductions.cs diff --git a/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs b/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs index a5b0a7bc..7a8d9d92 100644 --- a/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs +++ b/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs @@ -11,7 +11,7 @@ namespace SPT_AKI_Profile_Editor.Tests.Hepers internal class TestHelpers { public static readonly JsonSerializerSettings seriSettings = new() { Formatting = Formatting.Indented, Converters = new List() { new StringEnumConverterExt() } }; - public static readonly string profileFile = @"D:\SPT\user\profiles\668a193f0002aeaa425816ac.json"; + public static readonly string profileFile = @"D:\SPT\user\profiles\670243b60004ce099760c812.json"; public static readonly string serverPath = @"D:\SPT"; public static readonly string wrongServerPath = @"D:\WinSetupFromUSB"; public static readonly string profileWithDuplicatedItems = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testFiles", "profileWithDuplicatedItems.json"); diff --git a/SPT-AKI Profile Editor/Core/AppData.cs b/SPT-AKI Profile Editor/Core/AppData.cs index 3ad72be0..e1f88ae5 100644 --- a/SPT-AKI Profile Editor/Core/AppData.cs +++ b/SPT-AKI Profile Editor/Core/AppData.cs @@ -262,8 +262,8 @@ private static void LoadHideoutProduction() : Path.Combine(AppSettings.ServerPath, AppSettings.FilesList[SPTServerFile.production]); try { - HideoutProduction[] HideoutProduction = JsonConvert.DeserializeObject(File.ReadAllText(path)); - ServerDatabase.HideoutProduction = HideoutProduction; + HideoutProductions HideoutProductions = JsonConvert.DeserializeObject(File.ReadAllText(path)); + ServerDatabase.HideoutProduction = HideoutProductions.Recipes; } catch (Exception ex) { Logger.Log($"ServerDatabase HideoutProduction ({path}) loading error: {ex.Message}"); } } diff --git a/SPT-AKI Profile Editor/Core/ServerClasses/Hideout/HideoutProductions.cs b/SPT-AKI Profile Editor/Core/ServerClasses/Hideout/HideoutProductions.cs new file mode 100644 index 00000000..15ca796d --- /dev/null +++ b/SPT-AKI Profile Editor/Core/ServerClasses/Hideout/HideoutProductions.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace SPT_AKI_Profile_Editor.Core.ServerClasses.Hideout +{ + public class HideoutProductions + { + [JsonProperty("recipes")] + public HideoutProduction[] Recipes { get; set; } + } +} \ No newline at end of file From 42188586f2ec54757e0cb7daf69ef1b5da8d0be5 Mon Sep 17 00:00:00 2001 From: Dmitry Khudyakov Date: Sun, 5 Jan 2025 00:17:17 +0600 Subject: [PATCH 02/19] update for 3.10 ragfair standing --- .../Hepers/TestHelpers.cs | 2 +- SPT-AKI Profile Editor.Tests/ProfileTests.cs | 23 +++++++++++------- SPT-AKI Profile Editor/Core/AppSettings.cs | 10 -------- .../Core/CleaningService.cs | 2 +- SPT-AKI Profile Editor/Core/DefaultValues.cs | 1 - .../Core/ProfileClasses/Character.cs | 3 +-- .../CharacterTraderStandingExtended.cs | 15 ++++-------- .../Views/MerchantsTab.xaml | 24 ++++++++++++++++--- 8 files changed, 43 insertions(+), 37 deletions(-) diff --git a/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs b/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs index 7a8d9d92..46c5a625 100644 --- a/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs +++ b/SPT-AKI Profile Editor.Tests/Hepers/TestHelpers.cs @@ -11,7 +11,7 @@ namespace SPT_AKI_Profile_Editor.Tests.Hepers internal class TestHelpers { public static readonly JsonSerializerSettings seriSettings = new() { Formatting = Formatting.Indented, Converters = new List() { new StringEnumConverterExt() } }; - public static readonly string profileFile = @"D:\SPT\user\profiles\670243b60004ce099760c812.json"; + public static readonly string profileFile = @"D:\SPT\user\profiles\67796e1f0004b59665cc84f3.json"; public static readonly string serverPath = @"D:\SPT"; public static readonly string wrongServerPath = @"D:\WinSetupFromUSB"; public static readonly string profileWithDuplicatedItems = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testFiles", "profileWithDuplicatedItems.json"); diff --git a/SPT-AKI Profile Editor.Tests/ProfileTests.cs b/SPT-AKI Profile Editor.Tests/ProfileTests.cs index 8a85f857..5e7bf654 100644 --- a/SPT-AKI Profile Editor.Tests/ProfileTests.cs +++ b/SPT-AKI Profile Editor.Tests/ProfileTests.cs @@ -147,12 +147,6 @@ public void UnlockedInfoLoadsCorrectly() public void RagfairInfoNotNull() => Assert.That(AppData.Profile.Characters.Pmc.RagfairInfo, Is.Not.Null, "RagfairInfo is null"); - [Test] - public void RagfairStandingLoadCorrectly() => - Assert.That(AppData.Profile.Characters.Pmc.TraderStandingsExt.First(x => x.Id == AppData.AppSettings.RagfairTraderId).Standing, - Is.EqualTo(AppData.Profile.Characters.Pmc.RagfairInfo.Rating), - "Ragfair standing not load correctly"); - [Test] public void QuestsLoadCorrectly() { @@ -489,8 +483,7 @@ public void ProfileSavesCorrectly() public void TraderSalesSumAndStandingCanIncreaseLevel() { static bool CanBeUsedForTest(CharacterTraderStandingExtended x) - => x.Id != AppData.AppSettings.RagfairTraderId - && x.LoyaltyLevel < 2 + => x.LoyaltyLevel < 2 && x.TraderBase.LoyaltyLevels.Count > x.LoyaltyLevel; AppData.Profile.Load(TestHelpers.profileFile); @@ -524,7 +517,7 @@ public void TradersLoadedCorrectly() Assert.That(AppData.Profile.Characters.Pmc.TraderStandingsExt.Any(x => x.BitmapImage == null), Is.False, "Traders BitmapImage's not loaded"); - Assert.That(AppData.Profile.Characters.Pmc.TraderStandingsExt.Any(x => x.Id != AppData.AppSettings.RagfairTraderId && x.LocalizedName == x.Id), + Assert.That(AppData.Profile.Characters.Pmc.TraderStandingsExt.Any(x => x.LocalizedName == x.Id), Is.False, "Traders LocalizedName's not loaded"); Assert.That(AppData.Profile.Characters.Pmc.TraderStandingsExt.Any(x => x.SalesSum != x.TraderStanding.SalesSum), @@ -543,6 +536,18 @@ public void TradersSavesCorrectly() "TraderStandingsExt not in max levels"); } + [Test] + public void RagfairStandingSavesCorrectly() + { + AppData.Profile.Load(TestHelpers.profileFile); + var startingRating = AppData.Profile.Characters.Pmc.RagfairInfo.Rating; + AppData.Profile.Characters.Pmc.RagfairInfo.Rating += 3; + TestHelpers.SaveAndLoadProfile("testRagfairStanding.json"); + Assert.That(AppData.Profile.Characters.Pmc.RagfairInfo.Rating, + Is.EqualTo(startingRating + 3), + "Ragfair standing not saves correctly"); + } + [Test] public void ChangeFenceStandingAffectScavCharacter() { diff --git a/SPT-AKI Profile Editor/Core/AppSettings.cs b/SPT-AKI Profile Editor/Core/AppSettings.cs index 0f2d7539..3a00f747 100644 --- a/SPT-AKI Profile Editor/Core/AppSettings.cs +++ b/SPT-AKI Profile Editor/Core/AppSettings.cs @@ -205,8 +205,6 @@ public bool AutoAddMissingScavSkills public string MoneysEurosTpl { get; set; } - public string RagfairTraderId { get; set; } - public string EndlessDevBackpackId { get; set; } public string BearDogtagTpl { get; set; } @@ -277,7 +275,6 @@ public string GetStamp() + MoneysDollarsTpl + MoneysEurosTpl + MoneysRublesTpl - + RagfairTraderId + BearDogtagTpl + EndlessDevBackpackId + FenceTraderId; @@ -406,7 +403,6 @@ private void ApplyLoadedValues(AppSettings loaded) MoneysDollarsTpl = loaded.MoneysDollarsTpl; MoneysEurosTpl = loaded.MoneysEurosTpl; MoneysRublesTpl = loaded.MoneysRublesTpl; - RagfairTraderId = loaded.RagfairTraderId; BannedItems = loaded.BannedItems; IssuesAction = loaded.IssuesAction; BearDogtagTpl = loaded.BearDogtagTpl; @@ -553,11 +549,6 @@ private bool CheckValues() CheckUpdates = DefaultValues.CheckUpdates; _needReSave = true; } - if (RagfairTraderId == null) - { - RagfairTraderId = DefaultValues.RagfairTraderId; - _needReSave = true; - } if (BearDogtagTpl == null) { BearDogtagTpl = DefaultValues.BearDogtagTpl; @@ -610,7 +601,6 @@ private void CreateDefault() MoneysDollarsTpl = DefaultValues.MoneysDollarsTpl; MoneysEurosTpl = DefaultValues.MoneysEurosTpl; MoneysRublesTpl = DefaultValues.MoneysRublesTpl; - RagfairTraderId = DefaultValues.RagfairTraderId; BannedItems = DefaultValues.BannedItems; IssuesAction = DefaultValues.DefaultIssuesAction; BearDogtagTpl = DefaultValues.BearDogtagTpl; diff --git a/SPT-AKI Profile Editor/Core/CleaningService.cs b/SPT-AKI Profile Editor/Core/CleaningService.cs index a049eb6f..c9e12c91 100644 --- a/SPT-AKI Profile Editor/Core/CleaningService.cs +++ b/SPT-AKI Profile Editor/Core/CleaningService.cs @@ -160,7 +160,7 @@ private void GetModdedMerchants(IEnumerable merchantIds, ObservableColle { if (merchantIds != null && AppData.ServerDatabase?.LocalesGlobal != null) AddModdedEntity(merchantIds, - x => x != AppData.AppSettings.RagfairTraderId && !AppData.ServerDatabase.LocalesGlobal.ContainsKey(x.Nickname()), + x => !AppData.ServerDatabase.LocalesGlobal.ContainsKey(x.Nickname()), x => x, ModdedEntityType.Merchant, compositeCollection); diff --git a/SPT-AKI Profile Editor/Core/DefaultValues.cs b/SPT-AKI Profile Editor/Core/DefaultValues.cs index 484a4bbc..a77b63ce 100644 --- a/SPT-AKI Profile Editor/Core/DefaultValues.cs +++ b/SPT-AKI Profile Editor/Core/DefaultValues.cs @@ -30,7 +30,6 @@ public static class DefaultValues public const string MoneysDollarsTpl = "5696686a4bdc2da3298b456a"; public const string MoneysRublesTpl = "5449016a4bdc2d6f028b456f"; public const string MoneysEurosTpl = "569668774bdc2da2298b4568"; - public const string RagfairTraderId = "ragfair"; public const string EndlessDevBackpackId = "56e294cdd2720b603a8b4575"; public const string BearDogtagTpl = "59f32bb586f774757e1e8442"; public const float CommonSkillMaxValue = 5100; diff --git a/SPT-AKI Profile Editor/Core/ProfileClasses/Character.cs b/SPT-AKI Profile Editor/Core/ProfileClasses/Character.cs index e31703e6..bd82286a 100644 --- a/SPT-AKI Profile Editor/Core/ProfileClasses/Character.cs +++ b/SPT-AKI Profile Editor/Core/ProfileClasses/Character.cs @@ -211,8 +211,7 @@ public int StashRowsBonusCount public ObservableCollection TraderStandingsExt => new(TraderStandings?.Select(x => new CharacterTraderStandingExtended(x.Value, x.Key, - GetTraderInfo(x.Key), - RagfairInfo?.Rating ?? 0f))); + GetTraderInfo(x.Key)))); [JsonIgnore] public IEnumerable ExaminedItems => Encyclopedia? diff --git a/SPT-AKI Profile Editor/Core/ProfileClasses/CharacterTraderStandingExtended.cs b/SPT-AKI Profile Editor/Core/ProfileClasses/CharacterTraderStandingExtended.cs index 31bc55bb..0150845a 100644 --- a/SPT-AKI Profile Editor/Core/ProfileClasses/CharacterTraderStandingExtended.cs +++ b/SPT-AKI Profile Editor/Core/ProfileClasses/CharacterTraderStandingExtended.cs @@ -15,10 +15,10 @@ public class CharacterTraderStandingExtended : BindableEntity private bool? unlockedStart; private int? levelStart; - public CharacterTraderStandingExtended(CharacterTraderStanding standing, string id, TraderBase traderBase, float ragfairRating) + public CharacterTraderStandingExtended(CharacterTraderStanding standing, string id, TraderBase traderBase) { TraderStanding = standing; - Standing = id == AppData.AppSettings.RagfairTraderId ? ragfairRating : standing.Standing; + Standing = standing.Standing; Id = id; TraderBase = traderBase; MaxLevel = Math.Max(TraderBase?.LoyaltyLevels.Count ?? 0, TraderStanding.LoyaltyLevel); @@ -55,14 +55,9 @@ public float Standing set { TraderStanding.Standing = value; - if (Id == AppData.AppSettings.RagfairTraderId) - AppData.Profile.Characters.Pmc.RagfairInfo.Rating = value; - if (Id == AppData.AppSettings.FenceTraderId) - { - // Must add rep to scav profile to ensure consistency - if (AppData.Profile.Characters.Scav.TraderStandings.ContainsKey(Id)) - AppData.Profile.Characters.Scav.TraderStandings[Id].Standing = value; - } + // Must add rep to scav profile to ensure consistency + if (Id == AppData.AppSettings.FenceTraderId && AppData.Profile.Characters.Scav.TraderStandings.ContainsKey(Id)) + AppData.Profile.Characters.Scav.TraderStandings[Id].Standing = value; OnPropertyChanged(nameof(Standing)); SetLevel(); } diff --git a/SPT-AKI Profile Editor/Views/MerchantsTab.xaml b/SPT-AKI Profile Editor/Views/MerchantsTab.xaml index c24f07d8..d937eb95 100644 --- a/SPT-AKI Profile Editor/Views/MerchantsTab.xaml +++ b/SPT-AKI Profile Editor/Views/MerchantsTab.xaml @@ -8,15 +8,33 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:views="clr-namespace:SPT_AKI_Profile_Editor.Views" x:Name="Control" + d:Background="White" d:DataContext="{d:DesignInstance Type=views:MerchantsTabViewModel}" + d:Width="500" mc:Ignorable="d"> + + +