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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
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 index = _currentCollectionIndex;
|
||||||
var combo = ImGui.Combo( LabelCurrentCollection, ref index, _collectionNames );
|
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." );
|
"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 ] );
|
SetCurrentCollection( index );
|
||||||
_currentCollectionIndex = index;
|
|
||||||
_selector.ReloadSelection();
|
|
||||||
_selector.Cache.ResetModList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,7 +305,7 @@ namespace Penumbra.UI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawCurrentCollectionSelector(true);
|
DrawCurrentCollectionSelector( true );
|
||||||
|
|
||||||
ImGui.Dummy( new Vector2( 0, 10 ) );
|
ImGui.Dummy( new Vector2( 0, 10 ) );
|
||||||
DrawNewCollectionInput();
|
DrawNewCollectionInput();
|
||||||
|
|
|
||||||
|
|
@ -331,9 +331,11 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
private void DrawModsSelectorFilter()
|
private void DrawModsSelectorFilter()
|
||||||
{
|
{
|
||||||
|
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector );
|
||||||
DrawTextFilter();
|
DrawTextFilter();
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
DrawToggleFilter();
|
DrawToggleFilter();
|
||||||
|
ImGui.PopStyleVar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -611,16 +613,43 @@ namespace Penumbra.UI
|
||||||
Cache = new ModListCache( _modManager );
|
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()
|
private void DrawHeaderBar()
|
||||||
{
|
{
|
||||||
const float size = 200;
|
const float size = 200;
|
||||||
DrawModsSelectorFilter();
|
DrawModsSelectorFilter();
|
||||||
var textSize = ImGui.CalcTextSize( TabCollections.LabelCurrentCollection ).X + ImGui.GetStyle().ItemInnerSpacing.X;
|
var textSize = ImGui.CalcTextSize( TabCollections.LabelCurrentCollection ).X + ImGui.GetStyle().ItemInnerSpacing.X;
|
||||||
var comboSize = size * ImGui.GetIO().FontGlobalScale;
|
var comboSize = size * ImGui.GetIO().FontGlobalScale;
|
||||||
var offset = comboSize + textSize;
|
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.SetNextItemWidth( comboSize );
|
||||||
|
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, Vector2.Zero );
|
||||||
_base._menu.CollectionsTab.DrawCurrentCollectionSelector( false );
|
_base._menu.CollectionsTab.DrawCurrentCollectionSelector( false );
|
||||||
|
ImGui.PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawFolderContent( ModFolder folder, ref int idx )
|
private void DrawFolderContent( ModFolder folder, ref int idx )
|
||||||
|
|
@ -720,7 +749,6 @@ namespace Penumbra.UI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector );
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_selectorScalingFactor = _base._plugin.Configuration.ScaleModSelector
|
_selectorScalingFactor = _base._plugin.Configuration.ScaleModSelector
|
||||||
|
|
@ -728,6 +756,7 @@ namespace Penumbra.UI
|
||||||
: 1f;
|
: 1f;
|
||||||
// Selector pane
|
// Selector pane
|
||||||
DrawHeaderBar();
|
DrawHeaderBar();
|
||||||
|
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, Vector2.Zero );
|
||||||
ImGui.BeginGroup();
|
ImGui.BeginGroup();
|
||||||
// Inlay selector list
|
// Inlay selector list
|
||||||
ImGui.BeginChild( LabelSelectorList,
|
ImGui.BeginChild( LabelSelectorList,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue