mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Removed Regions.
This commit is contained in:
parent
817c3a2206
commit
82dff6be25
3 changed files with 308 additions and 315 deletions
|
|
@ -20,13 +20,10 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
public partial class SettingsInterface
|
public partial class SettingsInterface
|
||||||
{
|
{
|
||||||
private class PluginDetails
|
private partial class PluginDetails
|
||||||
{
|
{
|
||||||
#region ========== Literals ===============
|
|
||||||
private const string LabelPluginDetails = "PenumbraPluginDetails";
|
private const string LabelPluginDetails = "PenumbraPluginDetails";
|
||||||
private const string LabelAboutTab = "About";
|
private const string LabelAboutTab = "About";
|
||||||
private const string TooltipAboutEdit = "Use Ctrl+Enter for newlines.";
|
|
||||||
private const string LabelDescEdit = "##descedit";
|
|
||||||
private const string LabelChangedItemsTab = "Changed Items";
|
private const string LabelChangedItemsTab = "Changed Items";
|
||||||
private const string LabelChangedItemsHeader = "##changedItems";
|
private const string LabelChangedItemsHeader = "##changedItems";
|
||||||
private const string LabelChangedItemIdx = "##citem_";
|
private const string LabelChangedItemIdx = "##citem_";
|
||||||
|
|
@ -38,38 +35,22 @@ namespace Penumbra.UI
|
||||||
private const string LabelFileListTab = "Files";
|
private const string LabelFileListTab = "Files";
|
||||||
private const string LabelFileListHeader = "##fileList";
|
private const string LabelFileListHeader = "##fileList";
|
||||||
private const string TooltipFilesTab = "Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\nYellow files are restricted to some options.";
|
private const string TooltipFilesTab = "Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\nYellow files are restricted to some options.";
|
||||||
private const string ButtonAddToGroup = "Add to Group";
|
|
||||||
private const string ButtonRemoveFromGroup = "Remove from Group";
|
|
||||||
private const string LabelGroupSelect = "##groupSelect";
|
private const string LabelGroupSelect = "##groupSelect";
|
||||||
private const string LabelOptionSelect = "##optionSelect";
|
private const string LabelOptionSelect = "##optionSelect";
|
||||||
private const string TextNoOptionAvailable = "[No Option Available]";
|
|
||||||
private const string LabelConfigurationTab = "Configuration";
|
private const string LabelConfigurationTab = "Configuration";
|
||||||
private const string LabelNewSingleGroup = "New Single Group";
|
|
||||||
private const string LabelNewSingleGroupEdit = "##newSingleGroup";
|
|
||||||
private const string LabelNewMultiGroup = "New Multi Group";
|
|
||||||
private const string TextDefaultGamePath = "default";
|
|
||||||
private const string LabelGamePathsEdit = "Game Paths";
|
|
||||||
private const string LabelGamePathsEditBox = "##gamePathsEdit";
|
|
||||||
private const string TooltipGamePathText = "Click to copy to clipboard.";
|
|
||||||
private static readonly string TooltipGamePathsEdit = $"Enter all game paths to add or remove, separated by '{GamePathsSeparator}'.\nUse '{TextDefaultGamePath}' to add the original file path.";
|
|
||||||
private static readonly string TooltipFilesTabEdit = $"{TooltipFilesTab}\nRed Files are replaced in another group or a different option in this group, but not contained in the current option.";
|
|
||||||
|
|
||||||
private const char GamePathsSeparator = ';';
|
|
||||||
private const float TextSizePadding = 5f;
|
private const float TextSizePadding = 5f;
|
||||||
private const float OptionSelectionWidth = 140f;
|
private const float OptionSelectionWidth = 140f;
|
||||||
private const float CheckMarkSize = 50f;
|
private const float CheckMarkSize = 50f;
|
||||||
private const float MultiEditBoxWidth = 300f;
|
|
||||||
private const uint ColorGreen = 0xFF00C800;
|
private const uint ColorGreen = 0xFF00C800;
|
||||||
private const uint ColorYellow = 0xFF00C8C8;
|
private const uint ColorYellow = 0xFF00C8C8;
|
||||||
private const uint ColorRed = 0xFF0000C8;
|
private const uint ColorRed = 0xFF0000C8;
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ========== State ==================
|
|
||||||
private bool _editMode = false;
|
private bool _editMode = false;
|
||||||
private int _selectedGroupIndex = 0;
|
private int _selectedGroupIndex = 0;
|
||||||
private InstallerInfo? _selectedGroup = null;
|
private InstallerInfo? _selectedGroup = null;
|
||||||
private int _selectedOptionIndex = 0;
|
private int _selectedOptionIndex = 0;
|
||||||
private Option? _selectedOption = null;
|
private Option? _selectedOption = null;
|
||||||
private (string label, string name)[] _changedItemsList = null;
|
private (string label, string name)[] _changedItemsList = null;
|
||||||
private float? _fileSwapOffset = null;
|
private float? _fileSwapOffset = null;
|
||||||
private string _currentGamePaths = "";
|
private string _currentGamePaths = "";
|
||||||
|
|
@ -129,9 +110,6 @@ namespace Penumbra.UI
|
||||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ========== Tabs ===================
|
|
||||||
private void DrawAboutTab()
|
private void DrawAboutTab()
|
||||||
{
|
{
|
||||||
if (!_editMode && Meta.Description?.Length == 0)
|
if (!_editMode && Meta.Description?.Length == 0)
|
||||||
|
|
@ -140,7 +118,7 @@ namespace Penumbra.UI
|
||||||
if(ImGui.BeginTabItem( LabelAboutTab ) )
|
if(ImGui.BeginTabItem( LabelAboutTab ) )
|
||||||
{
|
{
|
||||||
var desc = Meta.Description;
|
var desc = Meta.Description;
|
||||||
var flags = _editMode
|
var flags = _editMode
|
||||||
? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine
|
? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine
|
||||||
: ImGuiInputTextFlags.ReadOnly;
|
: ImGuiInputTextFlags.ReadOnly;
|
||||||
|
|
||||||
|
|
@ -158,7 +136,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
ImGui.TextWrapped( desc );
|
ImGui.TextWrapped( desc );
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +146,7 @@ namespace Penumbra.UI
|
||||||
if (!_editMode && Meta.ChangedItems?.Count == 0)
|
if (!_editMode && Meta.ChangedItems?.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var flags = _editMode
|
var flags = _editMode
|
||||||
? ImGuiInputTextFlags.EnterReturnsTrue
|
? ImGuiInputTextFlags.EnterReturnsTrue
|
||||||
: ImGuiInputTextFlags.ReadOnly;
|
: ImGuiInputTextFlags.ReadOnly;
|
||||||
|
|
||||||
|
|
@ -267,9 +245,7 @@ namespace Penumbra.UI
|
||||||
_fileSwapOffset = null;
|
_fileSwapOffset = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ========== FileList ===============
|
|
||||||
private void UpdateFilenameList()
|
private void UpdateFilenameList()
|
||||||
{
|
{
|
||||||
if (_fullFilenameList == null)
|
if (_fullFilenameList == null)
|
||||||
|
|
@ -385,38 +361,6 @@ namespace Penumbra.UI
|
||||||
HandleSelectedFilesButton(true);
|
HandleSelectedFilesButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawEditGroupSelector()
|
|
||||||
{
|
|
||||||
ImGui.SetNextItemWidth( OptionSelectionWidth );
|
|
||||||
if (Meta.Groups.Count == 0)
|
|
||||||
{
|
|
||||||
ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, TextNoOptionAvailable, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, Meta.Groups.Values.Select( G => G.GroupName ).ToArray(), Meta.Groups.Count))
|
|
||||||
{
|
|
||||||
SelectGroup();
|
|
||||||
SelectOption(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawEditOptionSelector()
|
|
||||||
{
|
|
||||||
ImGui.SameLine();
|
|
||||||
ImGui.SetNextItemWidth( OptionSelectionWidth );
|
|
||||||
if (_selectedGroup?.Options.Count == 0)
|
|
||||||
{
|
|
||||||
ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, TextNoOptionAvailable, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var group = (InstallerInfo) _selectedGroup;
|
|
||||||
if (ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, group.Options.Select(O => O.OptionName).ToArray(), group.Options.Count))
|
|
||||||
SelectOption();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawGamePathInput()
|
private void DrawGamePathInput()
|
||||||
{
|
{
|
||||||
ImGui.TextUnformatted( LabelGamePathsEdit );
|
ImGui.TextUnformatted( LabelGamePathsEdit );
|
||||||
|
|
@ -426,7 +370,7 @@ namespace Penumbra.UI
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip(TooltipGamePathsEdit);
|
ImGui.SetTooltip(TooltipGamePathsEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawGroupRow()
|
private void DrawGroupRow()
|
||||||
{
|
{
|
||||||
if (_selectedGroup == null)
|
if (_selectedGroup == null)
|
||||||
|
|
@ -484,247 +428,6 @@ namespace Penumbra.UI
|
||||||
Selectable(ColorYellow, ColorRed);
|
Selectable(ColorYellow, ColorRed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawFileListTabEdit()
|
|
||||||
{
|
|
||||||
if( ImGui.BeginTabItem( LabelFileListTab ) )
|
|
||||||
{
|
|
||||||
UpdateFilenameList();
|
|
||||||
if (ImGui.IsItemHovered())
|
|
||||||
ImGui.SetTooltip( _editMode ? TooltipFilesTabEdit : TooltipFilesTab );
|
|
||||||
|
|
||||||
ImGui.SetNextItemWidth( -1 );
|
|
||||||
if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize - new Vector2(0, 1.5f * ImGui.GetTextLineHeight()) ) )
|
|
||||||
for(var i = 0; i < Mod.Mod.ModFiles.Count; ++i)
|
|
||||||
DrawFileAndGamePaths(i);
|
|
||||||
|
|
||||||
ImGui.ListBoxFooter();
|
|
||||||
|
|
||||||
DrawGroupRow();
|
|
||||||
ImGui.EndTabItem();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_fullFilenameList = null;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ========== Configuration ==========
|
|
||||||
#region ========== MultiSelectorEdit ==========
|
|
||||||
private bool DrawMultiSelectorEditBegin(InstallerInfo group)
|
|
||||||
{
|
|
||||||
var groupName = group.GroupName;
|
|
||||||
if (ImGuiCustom.BeginFramedGroupEdit(ref groupName)
|
|
||||||
&& groupName != group.GroupName && !Meta.Groups.ContainsKey(groupName))
|
|
||||||
{
|
|
||||||
var oldConf = Mod.Conf[group.GroupName];
|
|
||||||
Meta.Groups.Remove(group.GroupName);
|
|
||||||
Mod.Conf.Remove(group.GroupName);
|
|
||||||
if (groupName.Length > 0)
|
|
||||||
{
|
|
||||||
Meta.Groups[groupName] = new(){ GroupName = groupName, SelectionType = SelectType.Multi, Options = group.Options };
|
|
||||||
Mod.Conf[groupName] = oldConf;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private void DrawMultiSelectorEditAdd(InstallerInfo group, float nameBoxStart)
|
|
||||||
{
|
|
||||||
var newOption = "";
|
|
||||||
ImGui.SetCursorPosX(nameBoxStart);
|
|
||||||
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
|
||||||
if (ImGui.InputText($"##new_{group.GroupName}_l", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
||||||
{
|
|
||||||
if (newOption.Length != 0)
|
|
||||||
{
|
|
||||||
group.Options.Add(new(){ OptionName = newOption, OptionDesc = "", OptionFiles = new() });
|
|
||||||
_selector.SaveCurrentMod();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawMultiSelectorEdit(InstallerInfo group)
|
|
||||||
{
|
|
||||||
var nameBoxStart = CheckMarkSize;
|
|
||||||
var flag = Mod.Conf[group.GroupName];
|
|
||||||
|
|
||||||
var modChanged = DrawMultiSelectorEditBegin(group);
|
|
||||||
|
|
||||||
for (var i = 0; i < group.Options.Count; ++i)
|
|
||||||
{
|
|
||||||
var opt = group.Options[i];
|
|
||||||
var label = $"##{opt.OptionName}_{group.GroupName}";
|
|
||||||
DrawMultiSelectorCheckBox(group, i, flag, label);
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
|
||||||
var newName = opt.OptionName;
|
|
||||||
|
|
||||||
if (nameBoxStart == CheckMarkSize)
|
|
||||||
nameBoxStart = ImGui.GetCursorPosX();
|
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
|
||||||
if (ImGui.InputText($"{label}_l", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
||||||
{
|
|
||||||
if (newName.Length == 0)
|
|
||||||
{
|
|
||||||
group.Options.RemoveAt(i);
|
|
||||||
var bitmaskFront = (1 << i) - 1;
|
|
||||||
Mod.Conf[group.GroupName] = (flag & bitmaskFront) | ((flag & ~bitmaskFront) >> 1);
|
|
||||||
modChanged = true;
|
|
||||||
}
|
|
||||||
else if (newName != opt.OptionName)
|
|
||||||
{
|
|
||||||
group.Options[i] = new(){ OptionName = newName, OptionDesc = opt.OptionDesc, OptionFiles = opt.OptionFiles };
|
|
||||||
_selector.SaveCurrentMod();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawMultiSelectorEditAdd(group, nameBoxStart);
|
|
||||||
|
|
||||||
if (modChanged)
|
|
||||||
{
|
|
||||||
_selector.SaveCurrentMod();
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiCustom.EndFramedGroup();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ========== SingleSelectorEdit ==========
|
|
||||||
private bool DrawSingleSelectorEditGroup(InstallerInfo group)
|
|
||||||
{
|
|
||||||
var groupName = group.GroupName;
|
|
||||||
if (ImGui.InputText($"##{groupName}_add", ref groupName, 64, ImGuiInputTextFlags.EnterReturnsTrue)
|
|
||||||
&& !Meta.Groups.ContainsKey(groupName))
|
|
||||||
{
|
|
||||||
var oldConf = Mod.Conf[group.GroupName];
|
|
||||||
if (groupName != group.GroupName)
|
|
||||||
{
|
|
||||||
Meta.Groups.Remove(group.GroupName);
|
|
||||||
Mod.Conf.Remove(group.GroupName);
|
|
||||||
}
|
|
||||||
if (groupName.Length > 0)
|
|
||||||
{
|
|
||||||
Meta.Groups.Add(groupName, new InstallerInfo(){ GroupName = groupName, Options = group.Options, SelectionType = SelectType.Single } );
|
|
||||||
Mod.Conf[groupName] = oldConf;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float DrawSingleSelectorEdit(InstallerInfo group)
|
|
||||||
{
|
|
||||||
var code = Mod.Conf[group.GroupName];
|
|
||||||
var selectionChanged = false;
|
|
||||||
var modChanged = false;
|
|
||||||
var newName = "";
|
|
||||||
if (ImGuiCustom.RenameableCombo($"##{group.GroupName}", ref code, ref newName, group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count))
|
|
||||||
{
|
|
||||||
if (code == group.Options.Count)
|
|
||||||
{
|
|
||||||
if (newName.Length > 0)
|
|
||||||
{
|
|
||||||
selectionChanged = true;
|
|
||||||
modChanged = true;
|
|
||||||
Mod.Conf[group.GroupName] = code;
|
|
||||||
group.Options.Add(new(){ OptionName = newName, OptionDesc = "", OptionFiles = new()});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (newName.Length == 0)
|
|
||||||
{
|
|
||||||
modChanged = true;
|
|
||||||
group.Options.RemoveAt(code);
|
|
||||||
if (code >= group.Options.Count)
|
|
||||||
code = 0;
|
|
||||||
}
|
|
||||||
else if (newName != group.Options[code].OptionName)
|
|
||||||
{
|
|
||||||
modChanged = true;
|
|
||||||
group.Options[code] = new Option(){ OptionName = newName, OptionDesc = group.Options[code].OptionDesc, OptionFiles = group.Options[code].OptionFiles};
|
|
||||||
}
|
|
||||||
if (Mod.Conf[group.GroupName] != code)
|
|
||||||
{
|
|
||||||
selectionChanged = true;
|
|
||||||
Mod.Conf[group.GroupName] = code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
|
||||||
var labelEditPos = ImGui.GetCursorPosX();
|
|
||||||
modChanged |= DrawSingleSelectorEditGroup(group);
|
|
||||||
|
|
||||||
if (modChanged)
|
|
||||||
_selector.SaveCurrentMod();
|
|
||||||
|
|
||||||
if (selectionChanged)
|
|
||||||
Save();
|
|
||||||
|
|
||||||
return labelEditPos;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
private void AddNewGroup(string newGroup, SelectType selectType)
|
|
||||||
{
|
|
||||||
if (!Meta.Groups.ContainsKey(newGroup) && newGroup.Length > 0)
|
|
||||||
{
|
|
||||||
Meta.Groups[newGroup] = new ()
|
|
||||||
{
|
|
||||||
GroupName = newGroup,
|
|
||||||
SelectionType = selectType,
|
|
||||||
Options = new()
|
|
||||||
} ;
|
|
||||||
|
|
||||||
Mod.Conf[newGroup] = 0;
|
|
||||||
_selector.SaveCurrentMod();
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawAddSingleGroupField(float labelEditPos)
|
|
||||||
{
|
|
||||||
var newGroup = "";
|
|
||||||
if(labelEditPos == CheckMarkSize)
|
|
||||||
{
|
|
||||||
ImGui.SetCursorPosX(CheckMarkSize);
|
|
||||||
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
|
||||||
if (ImGui.InputText(LabelNewSingleGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
||||||
AddNewGroup(newGroup, SelectType.Single);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGuiCustom.RightJustifiedLabel(labelEditPos, LabelNewSingleGroup );
|
|
||||||
if (ImGui.InputText(LabelNewSingleGroupEdit, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
||||||
AddNewGroup(newGroup, SelectType.Single);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawAddMultiGroupField()
|
|
||||||
{
|
|
||||||
var newGroup = "";
|
|
||||||
ImGui.SetCursorPosX(CheckMarkSize);
|
|
||||||
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
|
||||||
if (ImGui.InputText(LabelNewMultiGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
||||||
AddNewGroup(newGroup, SelectType.Multi);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawGroupSelectorsEdit()
|
|
||||||
{
|
|
||||||
var labelEditPos = CheckMarkSize;
|
|
||||||
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Single ) )
|
|
||||||
labelEditPos = DrawSingleSelectorEdit(g);
|
|
||||||
DrawAddSingleGroupField(labelEditPos);
|
|
||||||
|
|
||||||
foreach(var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Multi ))
|
|
||||||
DrawMultiSelectorEdit(g);
|
|
||||||
DrawAddMultiGroupField();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Non-Edit
|
|
||||||
|
|
||||||
private void DrawMultiSelectorCheckBox(InstallerInfo group, int idx, int flag, string label)
|
private void DrawMultiSelectorCheckBox(InstallerInfo group, int idx, int flag, string label)
|
||||||
{
|
{
|
||||||
var opt = group.Options[idx];
|
var opt = group.Options[idx];
|
||||||
|
|
@ -772,15 +475,13 @@ namespace Penumbra.UI
|
||||||
DrawMultiSelector(g);
|
DrawMultiSelector(g);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
private void DrawConfigurationTab()
|
private void DrawConfigurationTab()
|
||||||
{
|
{
|
||||||
if (!_editMode && !Meta.HasGroupWithConfig)
|
if (!_editMode && !Meta.HasGroupWithConfig)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(ImGui.BeginTabItem( LabelConfigurationTab ) )
|
if(ImGui.BeginTabItem( LabelConfigurationTab ) )
|
||||||
{
|
{
|
||||||
if (_editMode)
|
if (_editMode)
|
||||||
DrawGroupSelectorsEdit();
|
DrawGroupSelectorsEdit();
|
||||||
|
|
@ -789,7 +490,6 @@ namespace Penumbra.UI
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void Draw(bool editMode)
|
public void Draw(bool editMode)
|
||||||
{
|
{
|
||||||
|
|
@ -810,4 +510,4 @@ namespace Penumbra.UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
299
Penumbra/UI/TabInstalledDetailsEdit.cs
Normal file
299
Penumbra/UI/TabInstalledDetailsEdit.cs
Normal file
|
|
@ -0,0 +1,299 @@
|
||||||
|
using Penumbra.Models;
|
||||||
|
using ImGuiNET;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace Penumbra.UI
|
||||||
|
{
|
||||||
|
public partial class SettingsInterface
|
||||||
|
{
|
||||||
|
private partial class PluginDetails
|
||||||
|
{
|
||||||
|
private const string LabelDescEdit = "##descedit";
|
||||||
|
private const string LabelNewSingleGroup = "New Single Group";
|
||||||
|
private const string LabelNewSingleGroupEdit = "##newSingleGroup";
|
||||||
|
private const string LabelNewMultiGroup = "New Multi Group";
|
||||||
|
private const string LabelGamePathsEdit = "Game Paths";
|
||||||
|
private const string LabelGamePathsEditBox = "##gamePathsEdit";
|
||||||
|
private const string TextNoOptionAvailable = "[No Option Available]";
|
||||||
|
private const string ButtonAddToGroup = "Add to Group";
|
||||||
|
private const string ButtonRemoveFromGroup = "Remove from Group";
|
||||||
|
private const string TooltipGamePathText = "Click to copy to clipboard.";
|
||||||
|
private const string TooltipAboutEdit = "Use Ctrl+Enter for newlines.";
|
||||||
|
|
||||||
|
private const string TextDefaultGamePath = "default";
|
||||||
|
private const char GamePathsSeparator = ';';
|
||||||
|
private static readonly string TooltipFilesTabEdit = $"{TooltipFilesTab}\nRed Files are replaced in another group or a different option in this group, but not contained in the current option.";
|
||||||
|
private static readonly string TooltipGamePathsEdit = $"Enter all game paths to add or remove, separated by '{GamePathsSeparator}'.\nUse '{TextDefaultGamePath}' to add the original file path.";
|
||||||
|
|
||||||
|
private const float MultiEditBoxWidth = 300f;
|
||||||
|
|
||||||
|
private void DrawEditGroupSelector()
|
||||||
|
{
|
||||||
|
ImGui.SetNextItemWidth( OptionSelectionWidth );
|
||||||
|
if (Meta.Groups.Count == 0)
|
||||||
|
{
|
||||||
|
ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, TextNoOptionAvailable, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, Meta.Groups.Values.Select( G => G.GroupName ).ToArray(), Meta.Groups.Count))
|
||||||
|
{
|
||||||
|
SelectGroup();
|
||||||
|
SelectOption(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawEditOptionSelector()
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.SetNextItemWidth( OptionSelectionWidth );
|
||||||
|
if (_selectedGroup?.Options.Count == 0)
|
||||||
|
{
|
||||||
|
ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, TextNoOptionAvailable, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var group = (InstallerInfo) _selectedGroup;
|
||||||
|
if (ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, group.Options.Select(O => O.OptionName).ToArray(), group.Options.Count))
|
||||||
|
SelectOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawFileListTabEdit()
|
||||||
|
{
|
||||||
|
if( ImGui.BeginTabItem( LabelFileListTab ) )
|
||||||
|
{
|
||||||
|
UpdateFilenameList();
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
ImGui.SetTooltip( _editMode ? TooltipFilesTabEdit : TooltipFilesTab );
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth( -1 );
|
||||||
|
if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize - new Vector2(0, 1.5f * ImGui.GetTextLineHeight()) ) )
|
||||||
|
for(var i = 0; i < Mod.Mod.ModFiles.Count; ++i)
|
||||||
|
DrawFileAndGamePaths(i);
|
||||||
|
|
||||||
|
ImGui.ListBoxFooter();
|
||||||
|
|
||||||
|
DrawGroupRow();
|
||||||
|
ImGui.EndTabItem();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_fullFilenameList = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool DrawMultiSelectorEditBegin(InstallerInfo group)
|
||||||
|
{
|
||||||
|
var groupName = group.GroupName;
|
||||||
|
if (ImGuiCustom.BeginFramedGroupEdit(ref groupName)
|
||||||
|
&& groupName != group.GroupName && !Meta.Groups.ContainsKey(groupName))
|
||||||
|
{
|
||||||
|
var oldConf = Mod.Conf[group.GroupName];
|
||||||
|
Meta.Groups.Remove(group.GroupName);
|
||||||
|
Mod.Conf.Remove(group.GroupName);
|
||||||
|
if (groupName.Length > 0)
|
||||||
|
{
|
||||||
|
Meta.Groups[groupName] = new(){ GroupName = groupName, SelectionType = SelectType.Multi, Options = group.Options };
|
||||||
|
Mod.Conf[groupName] = oldConf;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private void DrawMultiSelectorEditAdd(InstallerInfo group, float nameBoxStart)
|
||||||
|
{
|
||||||
|
var newOption = "";
|
||||||
|
ImGui.SetCursorPosX(nameBoxStart);
|
||||||
|
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
||||||
|
if (ImGui.InputText($"##new_{group.GroupName}_l", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
|
{
|
||||||
|
if (newOption.Length != 0)
|
||||||
|
{
|
||||||
|
group.Options.Add(new(){ OptionName = newOption, OptionDesc = "", OptionFiles = new() });
|
||||||
|
_selector.SaveCurrentMod();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawMultiSelectorEdit(InstallerInfo group)
|
||||||
|
{
|
||||||
|
var nameBoxStart = CheckMarkSize;
|
||||||
|
var flag = Mod.Conf[group.GroupName];
|
||||||
|
|
||||||
|
var modChanged = DrawMultiSelectorEditBegin(group);
|
||||||
|
|
||||||
|
for (var i = 0; i < group.Options.Count; ++i)
|
||||||
|
{
|
||||||
|
var opt = group.Options[i];
|
||||||
|
var label = $"##{opt.OptionName}_{group.GroupName}";
|
||||||
|
DrawMultiSelectorCheckBox(group, i, flag, label);
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
var newName = opt.OptionName;
|
||||||
|
|
||||||
|
if (nameBoxStart == CheckMarkSize)
|
||||||
|
nameBoxStart = ImGui.GetCursorPosX();
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
||||||
|
if (ImGui.InputText($"{label}_l", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
|
{
|
||||||
|
if (newName.Length == 0)
|
||||||
|
{
|
||||||
|
group.Options.RemoveAt(i);
|
||||||
|
var bitmaskFront = (1 << i) - 1;
|
||||||
|
Mod.Conf[group.GroupName] = (flag & bitmaskFront) | ((flag & ~bitmaskFront) >> 1);
|
||||||
|
modChanged = true;
|
||||||
|
}
|
||||||
|
else if (newName != opt.OptionName)
|
||||||
|
{
|
||||||
|
group.Options[i] = new(){ OptionName = newName, OptionDesc = opt.OptionDesc, OptionFiles = opt.OptionFiles };
|
||||||
|
_selector.SaveCurrentMod();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMultiSelectorEditAdd(group, nameBoxStart);
|
||||||
|
|
||||||
|
if (modChanged)
|
||||||
|
{
|
||||||
|
_selector.SaveCurrentMod();
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiCustom.EndFramedGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool DrawSingleSelectorEditGroup(InstallerInfo group)
|
||||||
|
{
|
||||||
|
var groupName = group.GroupName;
|
||||||
|
if (ImGui.InputText($"##{groupName}_add", ref groupName, 64, ImGuiInputTextFlags.EnterReturnsTrue)
|
||||||
|
&& !Meta.Groups.ContainsKey(groupName))
|
||||||
|
{
|
||||||
|
var oldConf = Mod.Conf[group.GroupName];
|
||||||
|
if (groupName != group.GroupName)
|
||||||
|
{
|
||||||
|
Meta.Groups.Remove(group.GroupName);
|
||||||
|
Mod.Conf.Remove(group.GroupName);
|
||||||
|
}
|
||||||
|
if (groupName.Length > 0)
|
||||||
|
{
|
||||||
|
Meta.Groups.Add(groupName, new InstallerInfo(){ GroupName = groupName, Options = group.Options, SelectionType = SelectType.Single } );
|
||||||
|
Mod.Conf[groupName] = oldConf;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float DrawSingleSelectorEdit(InstallerInfo group)
|
||||||
|
{
|
||||||
|
var code = Mod.Conf[group.GroupName];
|
||||||
|
var selectionChanged = false;
|
||||||
|
var modChanged = false;
|
||||||
|
var newName = "";
|
||||||
|
if (ImGuiCustom.RenameableCombo($"##{group.GroupName}", ref code, ref newName, group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count))
|
||||||
|
{
|
||||||
|
if (code == group.Options.Count)
|
||||||
|
{
|
||||||
|
if (newName.Length > 0)
|
||||||
|
{
|
||||||
|
selectionChanged = true;
|
||||||
|
modChanged = true;
|
||||||
|
Mod.Conf[group.GroupName] = code;
|
||||||
|
group.Options.Add(new(){ OptionName = newName, OptionDesc = "", OptionFiles = new()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (newName.Length == 0)
|
||||||
|
{
|
||||||
|
modChanged = true;
|
||||||
|
group.Options.RemoveAt(code);
|
||||||
|
if (code >= group.Options.Count)
|
||||||
|
code = 0;
|
||||||
|
}
|
||||||
|
else if (newName != group.Options[code].OptionName)
|
||||||
|
{
|
||||||
|
modChanged = true;
|
||||||
|
group.Options[code] = new Option(){ OptionName = newName, OptionDesc = group.Options[code].OptionDesc, OptionFiles = group.Options[code].OptionFiles};
|
||||||
|
}
|
||||||
|
if (Mod.Conf[group.GroupName] != code)
|
||||||
|
{
|
||||||
|
selectionChanged = true;
|
||||||
|
Mod.Conf[group.GroupName] = code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
var labelEditPos = ImGui.GetCursorPosX();
|
||||||
|
modChanged |= DrawSingleSelectorEditGroup(group);
|
||||||
|
|
||||||
|
if (modChanged)
|
||||||
|
_selector.SaveCurrentMod();
|
||||||
|
|
||||||
|
if (selectionChanged)
|
||||||
|
Save();
|
||||||
|
|
||||||
|
return labelEditPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddNewGroup(string newGroup, SelectType selectType)
|
||||||
|
{
|
||||||
|
if (!Meta.Groups.ContainsKey(newGroup) && newGroup.Length > 0)
|
||||||
|
{
|
||||||
|
Meta.Groups[newGroup] = new ()
|
||||||
|
{
|
||||||
|
GroupName = newGroup,
|
||||||
|
SelectionType = selectType,
|
||||||
|
Options = new()
|
||||||
|
} ;
|
||||||
|
|
||||||
|
Mod.Conf[newGroup] = 0;
|
||||||
|
_selector.SaveCurrentMod();
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawAddSingleGroupField(float labelEditPos)
|
||||||
|
{
|
||||||
|
var newGroup = "";
|
||||||
|
if(labelEditPos == CheckMarkSize)
|
||||||
|
{
|
||||||
|
ImGui.SetCursorPosX(CheckMarkSize);
|
||||||
|
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
||||||
|
if (ImGui.InputText(LabelNewSingleGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
|
AddNewGroup(newGroup, SelectType.Single);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGuiCustom.RightJustifiedLabel(labelEditPos, LabelNewSingleGroup );
|
||||||
|
if (ImGui.InputText(LabelNewSingleGroupEdit, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
|
AddNewGroup(newGroup, SelectType.Single);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawAddMultiGroupField()
|
||||||
|
{
|
||||||
|
var newGroup = "";
|
||||||
|
ImGui.SetCursorPosX(CheckMarkSize);
|
||||||
|
ImGui.SetNextItemWidth(MultiEditBoxWidth);
|
||||||
|
if (ImGui.InputText(LabelNewMultiGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
|
AddNewGroup(newGroup, SelectType.Multi);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawGroupSelectorsEdit()
|
||||||
|
{
|
||||||
|
var labelEditPos = CheckMarkSize;
|
||||||
|
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Single ) )
|
||||||
|
labelEditPos = DrawSingleSelectorEdit(g);
|
||||||
|
DrawAddSingleGroupField(labelEditPos);
|
||||||
|
|
||||||
|
foreach(var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Multi ))
|
||||||
|
DrawMultiSelectorEdit(g);
|
||||||
|
DrawAddMultiGroupField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,7 +50,6 @@ namespace Penumbra.UI
|
||||||
private ModInfo Mod { get{ return _selector.Mod(); } }
|
private ModInfo Mod { get{ return _selector.Mod(); } }
|
||||||
private ModMeta Meta { get{ return Mod?.Mod.Meta; } }
|
private ModMeta Meta { get{ return Mod?.Mod.Meta; } }
|
||||||
|
|
||||||
#region Header Line Functions
|
|
||||||
private void DrawName()
|
private void DrawName()
|
||||||
{
|
{
|
||||||
var name = Meta.Name;
|
var name = Meta.Name;
|
||||||
|
|
@ -170,9 +169,7 @@ namespace Penumbra.UI
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
DrawWebsite();
|
DrawWebsite();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Enabled Checkmarks
|
|
||||||
private void DrawEnabledMark()
|
private void DrawEnabledMark()
|
||||||
{
|
{
|
||||||
var enabled = Mod.Enabled;
|
var enabled = Mod.Enabled;
|
||||||
|
|
@ -189,9 +186,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
ImGui.Checkbox( LabelEditingEnabled, ref _editMode);
|
ImGui.Checkbox( LabelEditingEnabled, ref _editMode);
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Edit Line Functions
|
|
||||||
private void DrawOpenModFolderButton()
|
private void DrawOpenModFolderButton()
|
||||||
{
|
{
|
||||||
if( ImGui.Button( ButtonOpenModFolder ) )
|
if( ImGui.Button( ButtonOpenModFolder ) )
|
||||||
|
|
@ -246,7 +241,6 @@ namespace Penumbra.UI
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
DrawDeduplicateButton();
|
DrawDeduplicateButton();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue