mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Nodes - Improved changing pin types without reconnecting pins
UI - Fixed possible lingering UI elements in node editor and several other places
This commit is contained in:
1 parent
eca8985fc4
commit
cdd814d920
8 files changed
+27
-47
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.Core;
|
||||
@@ -143,30 +144,20 @@ public abstract class Pin : CorePropertyChanged, IPin
|
||||
/// <param name="currentType">The backing field of the current type of the pin.</param>
|
||||
protected void ChangeType(Type type, ref Type currentType)
|
||||
{
|
||||
// Enums are a special case that disconnect and, if still compatible, reconnect
|
||||
if (type.IsEnum && currentType.IsEnum)
|
||||
{
|
||||
List<IPin> connections = new(ConnectedTo);
|
||||
DisconnectAll();
|
||||
if (currentType == type)
|
||||
return;
|
||||
|
||||
// Change the type
|
||||
SetAndNotify(ref currentType, type, nameof(Type));
|
||||
IsNumeric = type == typeof(Numeric);
|
||||
bool changingEnums = type.IsEnum && currentType.IsEnum;
|
||||
|
||||
foreach (IPin pin in connections.Where(p => p.IsTypeCompatible(type)))
|
||||
ConnectTo(pin);
|
||||
}
|
||||
// Disconnect pins incompatible with the new type
|
||||
else
|
||||
{
|
||||
List<IPin> toDisconnect = ConnectedTo.Where(p => !p.IsTypeCompatible(type, false)).ToList();
|
||||
foreach (IPin pin in toDisconnect)
|
||||
DisconnectFrom(pin);
|
||||
List<IPin> connections = new(ConnectedTo);
|
||||
DisconnectAll();
|
||||
|
||||
// Change the type
|
||||
SetAndNotify(ref currentType, type, nameof(Type));
|
||||
IsNumeric = type == typeof(Numeric);
|
||||
}
|
||||
// Change the type
|
||||
SetAndNotify(ref currentType, type, nameof(Type));
|
||||
IsNumeric = type == typeof(Numeric);
|
||||
|
||||
foreach (IPin pin in connections.Where(p => p.IsTypeCompatible(type, changingEnums)))
|
||||
ConnectTo(pin);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user