Skip to content

Commit d6b2cd9

Browse files
committed
Name fix
Considering it's the whole point of the mod, you'd think this should have worked properly to begin with. 😅
1 parent 53700fe commit d6b2cd9

2 files changed

Lines changed: 26 additions & 20 deletions

File tree

CollectionLabels/modinfo.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"id": "sabreml.collectionlabels",
33
"name": "Collection Labels",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"target_game_version": "v1.9.06",
66
"authors": "SabreML",
7-
"description": "Adds a name/location to each item in the Collections menu.<LINE>(Warning: May contain light spoilers for region names and collectibles!)",
7+
"description": "Adds a name/location to each item in the Collections menu, for spoiler-free collectible hunting!",
88
"requirements": ["moreslugcats"],
99
"requirements_names": ["More Slugcats Expansion"],
1010
"tags": ["Cosmetics"]

src/CollectionLabelsMod.cs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace CollectionLabels
1414
{
15-
[BepInPlugin("sabreml.collectionlabels", "CollectionLabels", "1.0.0")]
15+
[BepInPlugin("sabreml.collectionlabels", "CollectionLabels", "1.0.1")]
1616
public class CollectionLabelsMod : BaseUnityPlugin
1717
{
1818
// A list of pearl names/locations. (E.g. "[Shoreline pearl 1]", "[Chimney Canopy pearl]", etc.)
@@ -71,13 +71,14 @@ private void LoadPearlNames(CollectionsMenu self)
7171
foreach (DataPearl.AbstractDataPearl.DataPearlType pearlType in self.usedPearlTypes)
7272
{
7373
// 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.)
7575
string pearlName = pearlType.value switch
7676
{
7777
"RM" => "Music",
7878
"Red_stomach" => "Hunter",
7979
"Spearmasterpearl" => "Spearmaster",
8080
"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)
8182
_ => Region.GetRegionFullName(pearlType.value.Split('_')[0], null)
8283
};
8384

@@ -112,23 +113,28 @@ private void LoadChatlogNames(CollectionsMenu self)
112113

113114
private static List<string> FormatListDuplicates(List<string> inputList)
114115
{
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
119132
{
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;
132138
}
133139

134140
private void SingalHK(On.MoreSlugcats.CollectionsMenu.orig_Singal orig, CollectionsMenu self, MenuObject sender, string message)

0 commit comments

Comments
 (0)