Keep first empty option in its desired location.

This commit is contained in:
Ottermandias 2024-03-16 16:21:06 +01:00
parent 8318a4bd84
commit 4fc763c9aa

View file

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using OtterGui;
using Penumbra.Api.Enums;
using Penumbra.Import.Structs;
using Penumbra.Mods;
@ -35,7 +36,8 @@ public partial class TexToolsImporter
var modList = modListRaw.Select(m => JsonConvert.DeserializeObject<SimpleMod>(m, JsonSettings)!).ToList();
_currentModDirectory = ModCreator.CreateModFolder(_baseDirectory, Path.GetFileNameWithoutExtension(modPackFile.Name), _config.ReplaceNonAsciiOnImport, true);
_currentModDirectory = ModCreator.CreateModFolder(_baseDirectory, Path.GetFileNameWithoutExtension(modPackFile.Name),
_config.ReplaceNonAsciiOnImport, true);
// Create a new ModMeta from the TTMP mod list info
_modManager.DataEditor.CreateMeta(_currentModDirectory, _currentModName, DefaultTexToolsData.Author, DefaultTexToolsData.Description,
null, null);
@ -193,15 +195,17 @@ public partial class TexToolsImporter
optionIdx += maxOptions;
// Handle empty options for single select groups without creating a folder for them.
// We only want one of those at most, and it should usually be the first option.
// We only want one of those at most.
if (group.SelectionType == GroupType.Single)
{
var empty = group.OptionList.FirstOrDefault(o => o.Name.Length > 0 && o.ModsJsons.Length == 0);
if (empty != null)
var idx = group.OptionList.IndexOf(o => o.Name.Length > 0 && o.ModsJsons.Length == 0);
if (idx >= 0)
{
_currentOptionName = empty.Name;
options.Insert(0, ModCreator.CreateEmptySubMod(empty.Name));
defaultSettings = defaultSettings == null ? 0 : defaultSettings.Value + 1;
var option = group.OptionList[idx];
_currentOptionName = option.Name;
options.Insert(idx, ModCreator.CreateEmptySubMod(option.Name));
if (option.IsChecked)
defaultSettings = (uint) idx;
}
}