Skip to content

Implement per mapping m3u support#85

Merged
gantoine merged 2 commits intorommapp:mainfrom
matthew-pye:m3u
Jan 30, 2026
Merged

Implement per mapping m3u support#85
gantoine merged 2 commits intorommapp:mainfrom
matthew-pye:m3u

Conversation

@matthew-pye
Copy link
Copy Markdown
Contributor

Implements #42

Adds new Use M3U tick box
image

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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

  • M3U Support Toggle: Introduced a new 'Usem3u' property in 'EmulatorMapping' to enable or disable M3U file prioritization for game installations.
  • User Interface Integration: Added a 'Use M3U File' checkbox to the settings view, allowing users to configure this new setting per emulator mapping.
  • Installation Logic Update: Modified the ROM installation process to detect and exclusively use M3U files for multi-file ROMs when the 'Usem3u' setting is enabled.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +105 to +137
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));
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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 like game.m3u.bak. A case-insensitive check of the actual file extension is safer.
  • Potential Bug: The GetRomFiles method, which is called earlier, may filter out .m3u files 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)));
                        }

@gantoine gantoine merged commit 9423fd5 into rommapp:main Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants