freelancer-hd-edition icon indicating copy to clipboard operation
freelancer-hd-edition copied to clipboard

Integrate FLSubs

Open BC46 opened this issue 3 years ago • 0 comments

Some players have requested subtitles to be added to the mod. While I personally don't think subtitles fit a game like Freelancer (maybe except for the cutscenes and cinematics), I still think it's nice to at least have the option so players can enable them if they wish.

There's a mod out there called FLSubs (GitHub) that adds English subtitles to the game. It comes with a license that allows other mods/projects to use it without any problems.

Though there are three issues (including two major ones) which should be addressed and reviewed before FLSubs can be properly integrated into Freelancer: HD Edition.

Issue 1

First of all, the subtitles mod makes use of d3d8.dll. Therefore, our DirectX-related enhancements can't be used while the subtitles are enabled, meaning players can only use them if they select the vanilla graphics API in the installer. It might be possible to combine it with DxWrapper.

Issue 2

The subtitles mod comes with a modified Freelancer.exe where the stack size has been increased to 2 MB. From my quick tests, this modification worked fine with HDE for the most part. Unfortunately it seems to cause a few conflicts with the Console plugin, where some commands can't be entered properly anymore. Consequently, the Console option may have to be disabled automatically if the subtitles are enabled.

Issue 3

FLSubs makes use of hardcoded configs for every screen resolution. These configs store the font sizes, text positions for the subtitles, etc. The issue is that there are a ton of different screen resolutions that players use to play Freelancer: HD Edition in. Since only a few default configs exist, the subtitles mod won't work properly out of the box for all the other resolutions. Creating configs manually by request doesn't seem viable either.

It might be possible to automatically create configs in the HDE installer based on the user's screen resolution (which can already be detected). This would allow us to dynamically set all the font sizes and positions in the config files. If this works properly, we can later do it in the launcher so we can support any resolution the user wants to play HDE in with subtitles.

Alternative

Alternatively to integrating FLSubs, a new standalone plugin can be made which basically does the same thing as FLSubs, but without relying on DirectX hooks. Instead, the plugin can use Freelancer's engine functions to draw text on the screen. This should allow for a much less volatile and less error-prone approach.

Hook the function 0042B5E0 in Freelancer.exe which is responsible for playing generic sounds. [[esp+0x4]] == 0x005CABFC checks if the sound you're trying to play is a voice file (I believe). This struct also contains the IDS of the voice file and the UTF.

BC46 avatar Oct 24 '22 21:10 BC46