Implement Reminder for External Node Types

This commit is contained in:
DE YU 2024-09-25 19:07:22 +08:00
parent c3e16cda00
commit 8240e27636
3 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,35 @@
using Godot;
using GodotTools.Internals;
namespace GodotTools.Inspector;
public partial class ExternalTypeReminder : HBoxContainer
{
public override void _Ready()
{
SetAnchorsPreset(LayoutPreset.TopWide);
var iconTexture = GetThemeIcon("NodeInfo", "EditorIcons");
var icon = new TextureRect()
{
Texture = iconTexture,
ExpandMode = TextureRect.ExpandModeEnum.FitWidthProportional,
CustomMinimumSize = iconTexture.GetSize(),
};
icon.SizeFlagsVertical = SizeFlags.ShrinkCenter;
var label = new Label()
{
Text = "This inspector inherits an external type. Please build the C# project when the external type changes.".TTR(),
AutowrapMode = TextServer.AutowrapMode.WordSmart,
CustomMinimumSize = new Vector2(100f, 0f),
};
label.SizeFlagsHorizontal = SizeFlags.Fill | SizeFlags.Expand;
AddChild(icon);
AddChild(label);
}
}

View File

@ -31,9 +31,9 @@ namespace GodotTools.Inspector
if (string.IsNullOrEmpty(scriptPath)) if (string.IsNullOrEmpty(scriptPath))
{ {
// Generic types used empty paths in older versions of Godot // Types from an external source (PackageReference or ProjectReference)
// so we assume your project is out of sync. // uses empty paths, in such case we do not show out of sync warning.
AddCustomControl(new InspectorOutOfSyncWarning()); AddCustomControl(new ExternalTypeReminder());
break; break;
} }

View File

@ -217,7 +217,6 @@ namespace Godot.Bridge
// not a global class. But if the script is not a global class it must return an empty // not a global class. But if the script is not a global class it must return an empty
// outClassName string since it should not have a name. // outClassName string since it should not have a name.
string scriptPathStr = Marshaling.ConvertStringToManaged(*scriptPath); string scriptPathStr = Marshaling.ConvertStringToManaged(*scriptPath);
Debug.Assert(!string.IsNullOrEmpty(scriptPathStr), "Script path can't be empty.");
if (!_pathTypeBiMap.TryGetScriptType(scriptPathStr, out Type? scriptType)) if (!_pathTypeBiMap.TryGetScriptType(scriptPathStr, out Type? scriptType))
{ {