Added basic components for DSL. Working on functionality next.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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/VBoxContainer").AddChild(node.editorDisplay.Instantiate());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user