diff --git a/Penumbra/UI/MenuTabs/TabCollections.cs b/Penumbra/UI/MenuTabs/TabCollections.cs index 8c581117..553ff63f 100644 --- a/Penumbra/UI/MenuTabs/TabCollections.cs +++ b/Penumbra/UI/MenuTabs/TabCollections.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -131,7 +132,35 @@ namespace Penumbra.UI } } - public void DrawCurrentCollectionSelector(bool tooltip) + private void SetCurrentCollection( int idx ) + { + if( idx == _currentCollectionIndex ) + { + return; + } + + _manager.Collections.SetCurrentCollection( _collections[ idx + 1 ] ); + _currentCollectionIndex = idx; + _selector.ReloadSelection(); + _selector.Cache.ResetModList(); + } + + public void SetCurrentCollection( ModCollection collection ) + { + var idx = Array.IndexOf( _collections, collection ) - 1; + if( idx >= 0 && idx != _currentCollectionIndex ) + { + _manager.Collections.SetCurrentCollection( _collections[ idx + 1 ] ); + _currentCollectionIndex = idx; + _selector.Cache.ResetModList(); + if( _selector.Mod != null ) + { + _selector.SelectModByDir( _selector.Mod.Data.BasePath.Name ); + } + } + } + + public void DrawCurrentCollectionSelector( bool tooltip ) { var index = _currentCollectionIndex; var combo = ImGui.Combo( LabelCurrentCollection, ref index, _collectionNames ); @@ -141,12 +170,9 @@ namespace Penumbra.UI "This collection will be modified when using the Installed Mods tab and making changes. It does not apply to anything by itself." ); } - if( combo && index != _currentCollectionIndex ) + if( combo ) { - _manager.Collections.SetCurrentCollection( _collections[ index + 1 ] ); - _currentCollectionIndex = index; - _selector.ReloadSelection(); - _selector.Cache.ResetModList(); + SetCurrentCollection( index ); } } @@ -279,7 +305,7 @@ namespace Penumbra.UI return; } - DrawCurrentCollectionSelector(true); + DrawCurrentCollectionSelector( true ); ImGui.Dummy( new Vector2( 0, 10 ) ); DrawNewCollectionInput(); diff --git a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledSelector.cs b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledSelector.cs index 606cb09c..aaf39643 100644 --- a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledSelector.cs +++ b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledSelector.cs @@ -331,9 +331,11 @@ namespace Penumbra.UI private void DrawModsSelectorFilter() { + ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector ); DrawTextFilter(); ImGui.SameLine(); DrawToggleFilter(); + ImGui.PopStyleVar(); } } @@ -611,16 +613,43 @@ namespace Penumbra.UI Cache = new ModListCache( _modManager ); } + private void DrawCollectionButton( string label, string tooltipLabel, float size, ModCollection collection ) + { + if( collection == ModCollection.Empty + || collection == _modManager.Collections.CurrentCollection ) + { + ImGui.PushStyleVar( ImGuiStyleVar.Alpha, 0.5f ); + ImGui.Button( label, Vector2.UnitX * size ); + ImGui.PopStyleVar(); + } + else if( ImGui.Button( label, Vector2.UnitX * size ) ) + { + _base._menu.CollectionsTab.SetCurrentCollection( collection ); + } + if( ImGui.IsItemHovered() ) + ImGui.SetTooltip( $"Switches to the currently set {tooltipLabel} collection, if it is not set to None and it is not the current collection already." ); + } + private void DrawHeaderBar() { - const float size = 200; + const float size = 200; DrawModsSelectorFilter(); var textSize = ImGui.CalcTextSize( TabCollections.LabelCurrentCollection ).X + ImGui.GetStyle().ItemInnerSpacing.X; var comboSize = size * ImGui.GetIO().FontGlobalScale; - var offset = comboSize + textSize; - ImGui.SameLine( ImGui.GetWindowContentRegionWidth() - offset ); + var offset = comboSize + textSize; + + var buttonSize = (ImGui.GetWindowContentRegionWidth() - offset - SelectorPanelWidth * _selectorScalingFactor - 4 * ImGui.GetStyle().ItemSpacing.X) / 2; + ImGui.SameLine(); + DrawCollectionButton("Default", "default", buttonSize, _modManager.Collections.DefaultCollection ); + + ImGui.SameLine(); + DrawCollectionButton( "Forced", "forced", buttonSize, _modManager.Collections.ForcedCollection ); + + ImGui.SameLine(); ImGui.SetNextItemWidth( comboSize ); + ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, Vector2.Zero ); _base._menu.CollectionsTab.DrawCurrentCollectionSelector( false ); + ImGui.PopStyleVar(); } private void DrawFolderContent( ModFolder folder, ref int idx ) @@ -720,7 +749,6 @@ namespace Penumbra.UI return; } - ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector ); try { _selectorScalingFactor = _base._plugin.Configuration.ScaleModSelector @@ -728,6 +756,7 @@ namespace Penumbra.UI : 1f; // Selector pane DrawHeaderBar(); + ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, Vector2.Zero ); ImGui.BeginGroup(); // Inlay selector list ImGui.BeginChild( LabelSelectorList,