|
12 | 12 |
|
13 | 13 | namespace CollectionLabels |
14 | 14 | { |
15 | | - [BepInPlugin("sabreml.collectionlabels", "CollectionLabels", "1.0.0")] |
| 15 | + [BepInPlugin("sabreml.collectionlabels", "CollectionLabels", "1.0.1")] |
16 | 16 | public class CollectionLabelsMod : BaseUnityPlugin |
17 | 17 | { |
18 | 18 | // A list of pearl names/locations. (E.g. "[Shoreline pearl 1]", "[Chimney Canopy pearl]", etc.) |
@@ -71,13 +71,14 @@ private void LoadPearlNames(CollectionsMenu self) |
71 | 71 | foreach (DataPearl.AbstractDataPearl.DataPearlType pearlType in self.usedPearlTypes) |
72 | 72 | { |
73 | 73 | // The region this pearl is found in. ("SL_moon" > "SL" > "Shoreline") |
74 | | - // (Unless it's the music pearl or a scug starting pearl, then it gets set manually.) |
| 74 | + // (Some like the music pearl or scug starting pearls are set manually.) |
75 | 75 | string pearlName = pearlType.value switch |
76 | 76 | { |
77 | 77 | "RM" => "Music", |
78 | 78 | "Red_stomach" => "Hunter", |
79 | 79 | "Spearmasterpearl" => "Spearmaster", |
80 | 80 | "Rivulet_stomach" => "Rivulet", |
| 81 | + "MS" => "Garbage Wastes", // Interestingly, this one seems to be mislabeled in the game's code. (It appears in GW, not MS) |
81 | 82 | _ => Region.GetRegionFullName(pearlType.value.Split('_')[0], null) |
82 | 83 | }; |
83 | 84 |
|
@@ -112,23 +113,28 @@ private void LoadChatlogNames(CollectionsMenu self) |
112 | 113 |
|
113 | 114 | private static List<string> FormatListDuplicates(List<string> inputList) |
114 | 115 | { |
115 | | - return inputList |
116 | | - .GroupBy(x => x) // Create groups of each distinct name. |
117 | | - .SelectMany(g => g.Select((name, index) => |
118 | | - // Go through each item name in each group (and grab the index of the name too). |
| 116 | + List<string> outputList = new(); |
| 117 | + foreach (string name in inputList) |
| 118 | + { |
| 119 | + // The number of times this entry name has occurs in `inputList`. |
| 120 | + int inputListOccurrences = inputList.Count(x => x == name); |
| 121 | + // The number of times an entry *containing* this name occurs in `outputList`. (The name is modified so just `==` won't work.) |
| 122 | + int outputListOccurrences = outputList.Count(x => x.Contains(name)); |
| 123 | + |
| 124 | + // If there's more than 1 pearl/chatlog with this name, append a number onto the end. |
| 125 | + // This changes ("[Shoreline pearl", "[Shoreline pearl") into ("[Shoreline pearl 1]", "[Shoreline pearl 2]") |
| 126 | + if (inputListOccurrences > 1) |
| 127 | + { |
| 128 | + outputList.Add($"{name} {outputListOccurrences + 1}]"); |
| 129 | + } |
| 130 | + // Otherwise, just leave it as-is and add the closing bracket. |
| 131 | + else |
119 | 132 | { |
120 | | - if (g.Count() > 1) |
121 | | - { |
122 | | - // If there's more than one of the same name, append index+1 to the end of it. |
123 | | - // This changes "[Shoreline pearl", "[Shoreline pearl" into "[Shoreline pearl 1]", "[Shoreline pearl 2]" |
124 | | - return $"{name} {index + 1}]"; |
125 | | - } |
126 | | - else |
127 | | - { |
128 | | - // If there's only one instance of the name, just add the closing bracket. |
129 | | - return $"{name}]"; |
130 | | - } |
131 | | - })).ToList(); |
| 133 | + outputList.Add($"{name}]"); |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + return outputList; |
132 | 138 | } |
133 | 139 |
|
134 | 140 | private void SingalHK(On.MoreSlugcats.CollectionsMenu.orig_Singal orig, CollectionsMenu self, MenuObject sender, string message) |
|
0 commit comments