mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-02 13:53:42 +01:00
Let SubMods know their location in a mod.
This commit is contained in:
parent
0b2b0d1beb
commit
d6c0362404
18 changed files with 223 additions and 121 deletions
|
|
@ -31,7 +31,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
}
|
||||
|
||||
_editor?.Dispose();
|
||||
_editor = new Editor( mod, -1, 0 );
|
||||
_editor = new Editor( mod, mod.Default );
|
||||
_mod = mod;
|
||||
|
||||
SizeConstraints = new WindowSizeConstraints
|
||||
|
|
@ -42,8 +42,8 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
_selectedFiles.Clear();
|
||||
}
|
||||
|
||||
public void ChangeOption( int groupIdx, int optionIdx )
|
||||
=> _editor?.SetSubMod( groupIdx, optionIdx );
|
||||
public void ChangeOption( ISubMod? subMod )
|
||||
=> _editor?.SetSubMod( subMod );
|
||||
|
||||
public override bool DrawConditions()
|
||||
=> _editor != null;
|
||||
|
|
@ -437,56 +437,34 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
|
||||
private void DrawOptionSelectHeader()
|
||||
{
|
||||
const string defaultOption = "Default Option";
|
||||
using var style = ImRaii.PushStyle( ImGuiStyleVar.ItemSpacing, Vector2.Zero ).Push( ImGuiStyleVar.FrameRounding, 0 );
|
||||
var width = new Vector2( ImGui.GetWindowWidth() / 3, 0 );
|
||||
var isDefaultOption = _editor!.GroupIdx == -1 && _editor!.OptionIdx == 0;
|
||||
const string defaultOption = "Default Option";
|
||||
using var style = ImRaii.PushStyle( ImGuiStyleVar.ItemSpacing, Vector2.Zero ).Push( ImGuiStyleVar.FrameRounding, 0 );
|
||||
var width = new Vector2( ImGui.GetWindowWidth() / 3, 0 );
|
||||
if( ImGuiUtil.DrawDisabledButton( defaultOption, width, "Switch to the default option for the mod.\nThis resets unsaved changes.",
|
||||
isDefaultOption ) )
|
||||
_editor!.CurrentOption.IsDefault ) )
|
||||
{
|
||||
_editor.SetSubMod( -1, 0 );
|
||||
isDefaultOption = true;
|
||||
_editor.SetSubMod( _mod!.Default );
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if( ImGuiUtil.DrawDisabledButton( "Refresh Data", width, "Refresh data for the current option.\nThis resets unsaved changes.", false ) )
|
||||
{
|
||||
_editor.SetSubMod( _editor.GroupIdx, _editor.OptionIdx );
|
||||
_editor.SetSubMod( _editor.CurrentOption );
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
string GetLabel()
|
||||
{
|
||||
if( isDefaultOption )
|
||||
{
|
||||
return defaultOption;
|
||||
}
|
||||
|
||||
var group = _mod!.Groups[ _editor!.GroupIdx ];
|
||||
return $"{group.Name}: {group[ _editor.OptionIdx ].Name}";
|
||||
}
|
||||
|
||||
using var combo = ImRaii.Combo( "##optionSelector", GetLabel(), ImGuiComboFlags.NoArrowButton );
|
||||
using var combo = ImRaii.Combo( "##optionSelector", _editor.CurrentOption.FullName, ImGuiComboFlags.NoArrowButton );
|
||||
if( !combo )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.Selectable( $"{defaultOption}###-1_0", isDefaultOption ) )
|
||||
foreach( var option in _mod!.AllSubMods )
|
||||
{
|
||||
_editor.SetSubMod( -1, 0 );
|
||||
}
|
||||
|
||||
foreach( var (group, groupIdx) in _mod!.Groups.WithIndex() )
|
||||
{
|
||||
foreach( var (option, optionIdx) in group.WithIndex() )
|
||||
if( ImGui.Selectable( option.FullName, option == _editor.CurrentOption ) )
|
||||
{
|
||||
var name = $"{group.Name}: {option.Name}###{groupIdx}_{optionIdx}";
|
||||
if( ImGui.Selectable( name, groupIdx == _editor.GroupIdx && optionIdx == _editor.OptionIdx ) )
|
||||
{
|
||||
_editor.SetSubMod( groupIdx, optionIdx );
|
||||
}
|
||||
_editor.SetSubMod( option );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue