Skip to content

Commit ae20a75

Browse files
Add stricter filtering for hardware MSUs
1 parent b4b5bac commit ae20a75

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

MSURandomizer/Services/MsuListService.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,24 @@ public void FilterMSUs(MsuType msuType, MsuFilter msuFilter)
7777
userOptions.MsuUserOptions.DefaultMsuPath;
7878
var rootPath = Model.HardwareMode ? "" : GetMsuTypeBasePath(msuType);
7979
var useAbsolutePath = string.IsNullOrWhiteSpace(rootPath);
80+
81+
// Hardware MSUs are more limited in compatibility
82+
List<string>? compatibleMsuNames = null;
83+
if (Model.HardwareMode)
84+
{
85+
if (appSettingsService.MsuAppSettings.HardwareCompatibleMsuTypes.TryGetValue(msuType.DisplayName,
86+
out compatibleMsuNames))
87+
{
88+
compatibleMsuNames.Add(msuType.DisplayName);
89+
}
90+
else
91+
{
92+
compatibleMsuNames = [msuType.DisplayName];
93+
}
94+
}
95+
8096
var filteredMsus = Model.MsuViewModels
81-
.Where(x => x.Msu.MatchesFilter(msuFilter, msuType, msuTypePath) &&
97+
.Where(x => x.Msu.MatchesFilter(msuFilter, msuType, msuTypePath, compatibleMsuNames) &&
8298
(x.Msu.NumUniqueTracks > x.Msu.MsuType?.RequiredTrackNumbers.Count / 5 || x.Msu.NumUniqueTracks > 10))
8399
.OrderBy(x => x.MsuName)
84100
.ToList();

MSURandomizerLibrary/Configs/Msu.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,21 @@ public Msu(MsuType? type, string name, string folderName, string fileName, strin
182182
/// <param name="type">The MSU type being looked for</param>
183183
/// <param name="path">The path being looked at</param>
184184
/// <returns>True if matches, false otherwise</returns>
185-
public bool MatchesFilter(MsuFilter filter, MsuType type, string? path)
185+
public bool MatchesFilter(MsuFilter filter, MsuType type, string? path, List<string>? compatibleMsuTypeNames = null)
186186
{
187-
return MatchesFilterType(filter, type) && MatchesPath(path) && Tracks.Count >= 1;
187+
if (MatchesFilterType(filter, type) && MatchesPath(path) && Tracks.Count >= 1)
188+
{
189+
if (compatibleMsuTypeNames == null || filter == MsuFilter.All)
190+
{
191+
return true;
192+
}
193+
194+
return compatibleMsuTypeNames.Contains(MsuTypeName);
195+
}
196+
else
197+
{
198+
return false;
199+
}
188200
}
189201

190202
private bool MatchesFilterType(MsuFilter filter, MsuType type)

MSURandomizerLibrary/Configs/MsuAppSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public class MsuAppSettings
100100
/// </summary>
101101
public bool DisableMessageSender { get; set; }
102102

103+
/// <summary>
104+
/// For hardware MSUs, the list of compatible MSU types
105+
/// </summary>
106+
public Dictionary<string, List<string>> HardwareCompatibleMsuTypes { get; set; } = [];
107+
103108
/// <summary>
104109
/// Default directory for misc save data
105110
/// </summary>

MSURandomizerLibrary/settings.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ MsuWindowDisplayOptionsButton: true
2424
MsuWindowDisplaySelectButton: false
2525
ForcedMsuType:
2626
DisableMessageSender: false
27+
HardwareCompatibleMsuTypes:
28+
A Link to the Past:
29+
- SMZ3 Combo Randomizer
30+
Super Metroid:
31+
- SMZ3 Classic (Metroid First)

0 commit comments

Comments
 (0)