Added button to immediately assign collection to current player.

This commit is contained in:
Ottermandias 2022-12-03 14:41:04 +01:00
parent 37a56c56af
commit 0534fecc0c

View file

@ -166,7 +166,7 @@ public partial class ConfigWindow
}
}
ImGui.Dummy( Vector2.Zero );
ImGui.Dummy( _window._defaultSpace );
DrawNewIndividualCollection();
}
@ -243,11 +243,13 @@ public partial class ConfigWindow
var buttonWidth1 = new Vector2( 90 * ImGuiHelpers.GlobalScale, 0 );
var buttonWidth2 = new Vector2( 120 * ImGuiHelpers.GlobalScale, 0 );
var combo = GetNpcCombo( _newKind );
var change = DrawNewPlayerCollection( buttonWidth1, width );
var change = DrawNewCurrentPlayerCollection();
change |= DrawNewPlayerCollection( buttonWidth1, width );
ImGui.SameLine();
change |= DrawNewRetainerCollection( buttonWidth2 );
var combo = GetNpcCombo( _newKind );
change |= DrawNewNpcCollection( combo, buttonWidth1, width );
ImGui.SameLine();
change |= DrawNewOwnedCollection( buttonWidth2 );
@ -258,6 +260,27 @@ public partial class ConfigWindow
}
}
private bool DrawNewCurrentPlayerCollection()
{
var player = Penumbra.Actors.GetCurrentPlayer();
var result = Penumbra.CollectionManager.Individuals.CanAdd( player );
var tt = result switch
{
IndividualCollections.AddResult.Valid => $"Assign a collection to {player}.",
IndividualCollections.AddResult.AlreadySet => AlreadyAssigned,
IndividualCollections.AddResult.Invalid => "No logged-in character detected.",
_ => string.Empty,
};
if( ImGuiUtil.DrawDisabledButton( "Assign Currently Played Character", _window._inputTextWidth, tt, result != IndividualCollections.AddResult.Valid ) )
{
Penumbra.CollectionManager.Individuals.Add( new[] { player }, Penumbra.CollectionManager.Default );
return true;
}
return false;
}
private void UpdateIdentifiers()
{
var combo = GetNpcCombo( _newKind );
@ -306,7 +329,9 @@ public partial class ConfigWindow
private void UpdateIdentifiers( CollectionType type, ModCollection? _1, ModCollection? _2, string _3 )
{
if( type == CollectionType.Individual )
{
UpdateIdentifiers();
}
}
}
}