52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using Godot;
|
|
|
|
public partial class NodeDisplay : RichTextLabel
|
|
{
|
|
ProgramNode node;
|
|
bool isHovering = false;
|
|
bool isDragging = false;
|
|
|
|
public void SetNode(ProgramNode node)
|
|
{
|
|
this.node = node;
|
|
}
|
|
|
|
public void SetupUIElement()
|
|
{
|
|
Text = node.DisplayText;
|
|
FitContent = true;
|
|
HorizontalAlignment = HorizontalAlignment.Center;
|
|
AutowrapMode = TextServer.AutowrapMode.Off;
|
|
GuiInput += HandleInput;
|
|
StyleBoxFlat styleBox = new StyleBoxFlat
|
|
{
|
|
BorderColor = new Color(1, 1, 1),
|
|
BgColor = new Color(0, 0, 0, 0.5f)
|
|
};
|
|
styleBox.SetBorderWidthAll(2);
|
|
styleBox.SetCornerRadiusAll(6);
|
|
AddThemeStyleboxOverride("normal", styleBox);
|
|
}
|
|
|
|
public override void _Ready()
|
|
{
|
|
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (Input.IsActionJustPressed("left_click"))
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public void HandleInput(InputEvent input)
|
|
{
|
|
if (input is InputEventMouseButton mouseEvent && mouseEvent.ButtonIndex == MouseButton.Left && mouseEvent.IsReleased())
|
|
{
|
|
GetNode<Control>("../../../EditorWindow/CodeContainer/VBoxContainer").AddChild(node.editorDisplay.Instantiate());
|
|
}
|
|
}
|
|
} |