Support for custom music mods. The file name must contain the words in the correct order with correct upper case letters: Custom Music Mod and can optionally include spaces, -, or _.

This commit is contained in:
Storm Dragon
2025-09-04 13:04:16 -04:00
parent 96fc322d6e
commit 380bb2ba81

View File

@@ -2081,6 +2081,64 @@ class DoomLauncher(QMainWindow):
return shutil.which("gzdoom")
def find_custom_music_mod(self):
"""Find custom music mod files with flexible pattern matching.
Looks for files containing "Custom Music Mod" in sequence anywhere in the filename.
Supports variations like:
- Custom Music Mod
- Custom_Music_Mod
- CustomMusicMod
Returns the first matching file found (.pk3 files prioritized), or None if no match exists.
"""
if not self.gamePath.exists():
return None
# Define the sequence patterns to look for (case-insensitive)
sequence_patterns = [
["custom", "music", "mod"], # spaces or any separators
["custom_music_mod"], # underscores as single token
["custommusicmod"] # no separators
]
# Check for .pk3 files first (higher priority), then .wad
for extension in [".pk3", ".wad"]:
for file_path in self.gamePath.iterdir():
if file_path.is_file() and file_path.suffix.lower() == extension:
filename_lower = file_path.name.lower()
# Check each sequence pattern
for pattern_sequence in sequence_patterns:
if self._contains_sequence(filename_lower, pattern_sequence):
return file_path
return None
def _contains_sequence(self, text, sequence):
"""Check if text contains all words in sequence in order.
Args:
text: The text to search in (already lowercase)
sequence: List of words that must appear in order
Returns:
True if all words in sequence are found in order, False otherwise
"""
if len(sequence) == 1:
# Single token match (like "custommusicmod")
return sequence[0] in text
# Multi-word sequence match
current_pos = 0
for word in sequence:
pos = text.find(word, current_pos)
if pos == -1:
return False
current_pos = pos + len(word)
return True
def get_addon_files(self, game_type: str = "DOOM", use_funny_pack: bool = False) -> List[str]:
"""Get all addon PK3 files for specified game type
@@ -2204,15 +2262,21 @@ class DoomLauncher(QMainWindow):
# Add music files at the end for Doom games
if gameType == "DOOM" and not isFunnyPack:
metalV10 = self.gamePath / "DOOM Metal X IDKFA Soundtrack.pk3"
metalV7 = self.gamePath / "DoomMetalVol7.wad"
metalV6 = self.gamePath / "DoomMetalVol6.wad"
if metalV10.exists():
baseFiles.append(str(metalV10))
elif metalV7.exists():
baseFiles.append(str(metalV7))
elif metalV6.exists():
baseFiles.append(str(metalV6))
# First check for custom music mod patterns (highest priority)
customMusicMod = self.find_custom_music_mod()
if customMusicMod:
baseFiles.append(str(customMusicMod))
else:
# Fall back to standard metal mod detection
metalV10 = self.gamePath / "DOOM Metal X IDKFA Soundtrack.pk3"
metalV7 = self.gamePath / "DoomMetalVol7.wad"
metalV6 = self.gamePath / "DoomMetalVol6.wad"
if metalV10.exists():
baseFiles.append(str(metalV10))
elif metalV7.exists():
baseFiles.append(str(metalV7))
elif metalV6.exists():
baseFiles.append(str(metalV6))
if "Toby Doom" in selectedGame:
musicRenamer = self.gamePath / "Toby-Doom-Level-Music-Renamer.pk3"