Implement per mapping m3u support#85
Conversation
Summary of ChangesHello @matthew-pye, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the game installation process by introducing explicit support for M3U playlist files. Users can now configure individual emulator mappings to prioritize M3U files when installing multi-file ROMs, ensuring that only the M3U file is registered as the playable game entry if present. This provides better organization and compatibility for games that utilize M3U files for multi-disc or multi-part setups. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for M3U files for multi-file ROMs. The implementation is a good start, but I've identified a couple of areas for improvement. In RomMInstallController.cs, the logic for finding M3U files can be made more robust and simplified, and I've found a potential bug where M3U files might not be discovered under certain conditions. I've provided a suggestion to fix this and improve the code. Additionally, I've made a recommendation in EmulatorMapping.cs to align a new property with C# naming conventions for better maintainability.
Games/RomMInstallController.cs
Outdated
| if(info.Mapping.Usem3u) | ||
| { | ||
| bool m3uPresent = false; | ||
| int m3uIndex = 0; | ||
| foreach (var romFile in actualRomFiles) | ||
| { | ||
| if (romFile.Contains(".m3u") || romFile.Contains(".M3U")) | ||
| { | ||
| m3uPresent = true; | ||
| break; | ||
| } | ||
| m3uIndex++; | ||
| } | ||
|
|
||
| if (m3uPresent) | ||
| { | ||
| roms.Add(new GameRom(Game.Name, actualRomFiles[m3uIndex])); | ||
| } | ||
| else | ||
| { | ||
| foreach (var romFile in actualRomFiles) | ||
| { | ||
| roms.Add(new GameRom(Game.Name, romFile)); | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| else | ||
| { | ||
| foreach (var romFile in actualRomFiles) | ||
| { | ||
| roms.Add(new GameRom(Game.Name, romFile)); | ||
| } | ||
| } |
There was a problem hiding this comment.
The current implementation for handling M3U files has a few areas for improvement:
- Correctness: Using
string.Contains(".m3u")is not robust for checking file extensions, as it could incorrectly match files likegame.m3u.bak. A case-insensitive check of the actual file extension is safer. - Potential Bug: The
GetRomFilesmethod, which is called earlier, may filter out.m3ufiles when an emulator profile has no supported file types defined. This would prevent this new feature from working in that scenario. - Code Quality: The code can be simplified to remove duplication and improve readability by using LINQ.
I suggest the following refactoring which addresses these points. It's more concise, robust, and correctly handles finding the M3U file even if GetRomFiles filters it out.
var m3uFile = info.Mapping.Usem3u
? Directory.EnumerateFiles(installDir, "*", SearchOption.AllDirectories)
.FirstOrDefault(f => f.EndsWith(".m3u", StringComparison.OrdinalIgnoreCase))
: null;
if (m3uFile != null)
{
roms.Add(new GameRom(Game.Name, m3uFile));
}
else
{
roms.AddRange(actualRomFiles.Select(f => new GameRom(Game.Name, f)));
}
Implements #42
Adds new Use M3U tick box

When multi-file ROM is installed only adds m3u as usable ROM file
