So I need some advice on mod handling...
In order to load the save correctly, WarBender needs two things:
1. Module data (.txt and .ini) for the corresponding module.
2. Slots metadata (.wmmx) for that module.
The second one is nice to have, but not crucial, since it doesn't affect how the data is stored or accessed; only how it's displayed in UI. The first one is crucial, however, because there are some bits of data there that are necessary to even parse the save properly.
So, given a .sav file, how to figure out the module? The saves themselves don't appear to store that information. So, right now it's a heuristic that works like this:
1. Look at the folder where the save file is located, and check if there's a shortcut there named Module.lnk. If there is, it should point at another folder, and that folder is assumed to contain the module - we're done!
2. Look at the name of the folder, and assume that it is the module name, e.g. "...\Documents\Mount&Blade Warband Savegames\Native" -> "Native". Look for a matching folder under M&B install folder, e.g. "...\steam\steamapps\common\mountblade warband\Modules\Native". If it exists, then create Module.lnk in the save folder, and proceed to load.
3. If neither worked, then pop up the dialog asking the user to specify where module.ini for a given module is. Once specified, create Module.lnk in the save folder, so that we don't have to ask again, and proceed to load.
I was hoping that the final fallback wouldn't be triggered all that often. In practice, it usually gets triggered for all modules installed via Steam Workshop, because they end up in weird places like "...\steam\steamapps\workshop\content\48700\285119009". Now, the parent folder for those appears to be the same everywhere - I'm assuming that 48700 is some kind of Steam ID for M&B - the question is how to figure out which modules are which. There's module_name in module.ini, but that doesn't correspond to the name of the save folder in any way. What else is there? There's clearly some way to map module names to numbers, since M&B itself can display the list of all installed modules on startup. But I can't find where it is. And I'm not sure whether it'd help even if I did, because the names M&B shows do not match the names of the save folders! For example, for Diplomacy, the name in the list is just "Diplomacy", but the corresponding save folder is named "...\Documents\Mount&Blade Warband Savegames\Diplomacy (Steam Workshop)".
Also, for non-Steam modules, I'm not sure that the name of the folder containing the save actually matches the name of the module folder, either...
So, is there any way to do this automatically at all? Or at least to provide human-readable names for Workshop modules, so that I could give a list of those, rather than requiring you to find module.ini by yourself?
Either way, once we figure out the right module, there's a question of finding the corresponding .wmmx file. The current approach is to use the name of the save folder - so for "...\Documents\Mount&Blade Warband Savegames\Native", it loads Native.wmmx. But that assumes that the name of the folder is the canonical name of the module... is it, though?