mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Add quick-switch buttons for default and forced collection if they are set.
This commit is contained in:
parent
2532e73f9d
commit
88224d4e27
2 changed files with 66 additions and 11 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -331,9 +331,11 @@ namespace Penumbra.UI
|
|||
|
||||
private void DrawModsSelectorFilter()
|
||||
{
|
||||
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector );
|
||||
DrawTextFilter();
|
||||
ImGui.SameLine();
|
||||
DrawToggleFilter();
|
||||
ImGui.PopStyleVar();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -611,6 +613,23 @@ 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;
|
||||
|
|
@ -618,9 +637,19 @@ namespace Penumbra.UI
|
|||
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 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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue