update forge
This commit is contained in:
@@ -91,6 +91,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
});
|
||||
|
||||
_variableDropdown = new OptionButton { SizeFlagsHorizontal = SizeFlags.ExpandFill };
|
||||
_variableDropdown.SetMeta("is_shared_variable_dropdown", true);
|
||||
PopulateVariableDropdown();
|
||||
varRow.AddChild(_variableDropdown);
|
||||
|
||||
@@ -109,6 +110,35 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool TryGetInlineSummary(out string summary)
|
||||
{
|
||||
summary = string.IsNullOrWhiteSpace(_selectedVariableName)
|
||||
? "(None)"
|
||||
: _selectedVariableName;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override InlineSummaryBadgeKind GetInlineSummaryBadgeKind()
|
||||
{
|
||||
return InlineSummaryBadgeKind.SharedVariable;
|
||||
}
|
||||
|
||||
public override bool TryGetHighlightedVariableName(out string variableName)
|
||||
{
|
||||
variableName = string.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool TryGetHighlightedSharedVariable(out string sharedVariableSetPath, out string variableName)
|
||||
{
|
||||
sharedVariableSetPath = _selectedSetPath;
|
||||
variableName = _selectedVariableName;
|
||||
return !string.IsNullOrWhiteSpace(sharedVariableSetPath)
|
||||
&& !string.IsNullOrWhiteSpace(variableName);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void ClearCallbacks()
|
||||
{
|
||||
@@ -116,6 +146,24 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
_onChanged = null;
|
||||
}
|
||||
|
||||
private static bool IsCompatibleType(Type expectedType, StatescriptVariableType variableType)
|
||||
{
|
||||
return StatescriptVariableTypeConverter.IsCompatible(expectedType, variableType);
|
||||
}
|
||||
|
||||
private static bool IsCompatibleType(Type[] expectedTypes, StatescriptVariableType variableType)
|
||||
{
|
||||
for (int i = 0; i < expectedTypes.Length; i++)
|
||||
{
|
||||
if (IsCompatibleType(expectedTypes[i], variableType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<string> FindAllSharedVariableSetPaths()
|
||||
{
|
||||
var results = new List<string>();
|
||||
@@ -126,9 +174,9 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
|
||||
private static void ScanFilesystemDirectory(EditorFileSystemDirectory dir, List<string> results)
|
||||
{
|
||||
for (var i = 0; i < dir.GetFileCount(); i++)
|
||||
for (int i = 0; i < dir.GetFileCount(); i++)
|
||||
{
|
||||
var path = dir.GetFilePath(i);
|
||||
string path = dir.GetFilePath(i);
|
||||
|
||||
if (!path.EndsWith(".tres", StringComparison.InvariantCultureIgnoreCase)
|
||||
&& !path.EndsWith(".res", StringComparison.InvariantCultureIgnoreCase))
|
||||
@@ -144,7 +192,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < dir.GetSubdirCount(); i++)
|
||||
for (int i = 0; i < dir.GetSubdirCount(); i++)
|
||||
{
|
||||
ScanFilesystemDirectory(dir.GetSubdir(i), results);
|
||||
}
|
||||
@@ -157,7 +205,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = _setDropdown.Selected;
|
||||
int idx = _setDropdown.Selected;
|
||||
_selectedSetPath = idx >= 0 && idx < _setPaths.Count ? _setPaths[idx] : string.Empty;
|
||||
_selectedVariableName = string.Empty;
|
||||
_selectedVariableType = StatescriptVariableType.Int;
|
||||
@@ -174,7 +222,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = _variableDropdown.Selected;
|
||||
int idx = _variableDropdown.Selected;
|
||||
|
||||
if (idx >= 0 && idx < _variableNames.Count)
|
||||
{
|
||||
@@ -205,9 +253,9 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
_setPaths.Add(string.Empty);
|
||||
_setDisplayNames.Add("(None)");
|
||||
|
||||
foreach (var path in FindAllSharedVariableSetPaths())
|
||||
foreach (string path in FindAllSharedVariableSetPaths())
|
||||
{
|
||||
var displayName = path[(path.LastIndexOf('/') + 1)..];
|
||||
string displayName = path[(path.LastIndexOf('/') + 1)..];
|
||||
|
||||
if (displayName.EndsWith(".tres", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -220,7 +268,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
}
|
||||
|
||||
// Restore selection.
|
||||
for (var i = 0; i < _setPaths.Count; i++)
|
||||
for (int i = 0; i < _setPaths.Count; i++)
|
||||
{
|
||||
if (_setPaths[i] == _selectedSetPath)
|
||||
{
|
||||
@@ -240,12 +288,16 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
return;
|
||||
}
|
||||
|
||||
_variableDropdown.SetMeta("shared_variable_set_path", _selectedSetPath);
|
||||
|
||||
_variableDropdown.Clear();
|
||||
_variableNames.Clear();
|
||||
|
||||
_variableDropdown.AddItem("(None)");
|
||||
_variableNames.Add(string.Empty);
|
||||
|
||||
Type[] allowedExpectedTypes = GetAllowedExpectedTypes(_expectedType);
|
||||
|
||||
if (!string.IsNullOrEmpty(_selectedSetPath) && ResourceLoader.Exists(_selectedSetPath))
|
||||
{
|
||||
ForgeSharedVariableSet? set = ResourceLoader.Load<ForgeSharedVariableSet>(_selectedSetPath);
|
||||
@@ -259,13 +311,12 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_expectedType != typeof(Variant128)
|
||||
&& !StatescriptVariableTypeConverter.IsCompatible(_expectedType, def.VariableType))
|
||||
if (!IsCompatibleType(allowedExpectedTypes, def.VariableType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var label = $"{def.VariableName}";
|
||||
string label = $"{def.VariableName}";
|
||||
_variableDropdown.AddItem(label);
|
||||
_variableNames.Add(def.VariableName);
|
||||
}
|
||||
@@ -273,7 +324,7 @@ internal sealed partial class SharedVariableResolverEditor : NodeEditorProperty
|
||||
}
|
||||
|
||||
// Restore selection.
|
||||
for (var i = 0; i < _variableNames.Count; i++)
|
||||
for (int i = 0; i < _variableNames.Count; i++)
|
||||
{
|
||||
if (_variableNames[i] == _selectedVariableName)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user