diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -2,3 +2,4 @@ f419334a476f33b0b93cbd02eba7a44f08f89733 99f3d61e20d74cac591cb81f69afc7be0eae0a59 R_T10_1.1 d7b40cfbe0f3d20f25a52944cf8c0f1ecdc81471 R_T10_1.2 6919080271d55f3f138660bb37dccd116249d13e R_T10_1.3 +e7cc8ddcbf589086578134ec292ad8b7c739237c R_T10_1.4 diff --git a/DesertPaintCodex.csproj b/DesertPaintCodex.csproj --- a/DesertPaintCodex.csproj +++ b/DesertPaintCodex.csproj @@ -6,6 +6,7 @@ Assets\desert_paint_codex_icon.ico DesertPaintCodex.Program AnyCPU;x64 + 1.4.0 x64 diff --git a/Models/PlayerProfile.cs b/Models/PlayerProfile.cs --- a/Models/PlayerProfile.cs +++ b/Models/PlayerProfile.cs @@ -129,36 +129,69 @@ namespace DesertPaintCodex.Models { using StreamReader reader = new(ppFile); using StreamWriter writer = new(dpFile, false); - string? line; + string? line; while ((line = reader.ReadLine()) != null) { string[] tokens = line.Split('|'); //if ((tokens.Length > 0) && (tokens [0] != "//")) if ((tokens.Length == 5) && (tokens[0].Trim() != "//")) { - string reagent1 = tokens[0].Trim(); - string reagent2 = tokens[1].Trim(); + string reagent1Name = tokens[0].Trim(); + string reagent2Name = tokens[1].Trim(); string colorCode = tokens[2].Trim(); string change1 = tokens[3].Trim(); string change2 = tokens[4].Trim(); + + Reagent reagent1 = ReagentService.GetReagent(reagent1Name); + Reagent reagent2 = ReagentService.GetReagent(reagent2Name); + + if (reagent1 == null || reagent2 == null) continue; + + bool hasChange1 = int.TryParse(change1, out _); + bool hasChange2 = int.TryParse(change2, out _); + // Write reaction. switch (colorCode) { case "W": - WriteReaction(writer, reagent1, reagent2, change1, change1, change1); - WriteReaction(writer, reagent2, reagent1, change2, change2, change2); + if (hasChange1) + { + WriteReaction(writer, reagent1Name, reagent2Name, change1, change1, change1); + } + if (hasChange2) + { + WriteReaction(writer, reagent2Name, reagent1Name, change2, change2, change2); + } break; case "R": - WriteReaction(writer, reagent1, reagent2, change1, "0", "0"); - WriteReaction(writer, reagent2, reagent1, change2, "0", "0"); + if (hasChange1) + { + WriteReaction(writer, reagent1Name, reagent2Name, change1, "0", "0"); + } + if (hasChange2) + { + WriteReaction(writer, reagent2Name, reagent1Name, change2, "0", "0"); + } break; case "G": - WriteReaction(writer, reagent1, reagent2, "0", change1, "0"); - WriteReaction(writer, reagent2, reagent1, "0", change2, "0"); + if (hasChange1) + { + WriteReaction(writer, reagent1Name, reagent2Name, "0", change1, "0"); + } + if (hasChange2) + { + WriteReaction(writer, reagent2Name, reagent1Name, "0", change2, "0"); + } break; case "B": - WriteReaction(writer, reagent1, reagent2, "0", "0", change1); - WriteReaction(writer, reagent2, reagent1, "0", "0", change2); + if (hasChange1) + { + WriteReaction(writer, reagent1Name, reagent2Name, "0", "0", change1); + } + if (hasChange2) + { + WriteReaction(writer, reagent2Name, reagent1Name, "0", "0", change2); + } break; } } diff --git a/Properties/PublishProfiles/Win64 Self-Contained.pubxml b/Properties/PublishProfiles/Win64 Self-Contained.pubxml --- a/Properties/PublishProfiles/Win64 Self-Contained.pubxml +++ b/Properties/PublishProfiles/Win64 Self-Contained.pubxml @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID= Release x64 - publish\win-x64 + publish\win-x64\DesertPaintCodex FileSystem net5.0 win-x64 diff --git a/ViewModels/ExperimentLogViewModel.cs b/ViewModels/ExperimentLogViewModel.cs --- a/ViewModels/ExperimentLogViewModel.cs +++ b/ViewModels/ExperimentLogViewModel.cs @@ -135,7 +135,10 @@ namespace DesertPaintCodex.ViewModels { int oldPos = list.IndexOf(test); - if (((oldPos > 0) || (test.CompareTo(list[oldPos - 1]) > 0)) + // If the item is first in the list or the previous item is valued < the test + // And either the item is last in the list or the next item in the list is valued > than the item + // Don't move it + if (((oldPos == 0) || (test.CompareTo(list[oldPos - 1]) > 0)) && ((oldPos == list.Count - 1) || (test.CompareTo(list[oldPos + 1]) < 0))) return oldPos; // No need to move. list.RemoveAt(oldPos);