68 lines
1.5 KiB
C#
68 lines
1.5 KiB
C#
|
using Godot;
|
||
|
using System;
|
||
|
using BITKit;
|
||
|
|
||
|
namespace BITFactory;
|
||
|
public partial class IDIS_RegisterService : Node
|
||
|
{
|
||
|
[Export] private IDIS_Service service;
|
||
|
[Export] private IDIS_TemplateService templateService;
|
||
|
[Export] private ItemList templateList;
|
||
|
[Export] private LineEdit handleEdit;
|
||
|
[Export] private Button generateHandleButton;
|
||
|
[Export] private Control container;
|
||
|
[Export] private Button registerButton;
|
||
|
[Export] private Label hints;
|
||
|
public override void _Ready()
|
||
|
{
|
||
|
templateList.Clear();
|
||
|
foreach (var x in templateService.templates)
|
||
|
{
|
||
|
templateList.AddItem(x.TemplateName);
|
||
|
}
|
||
|
|
||
|
var lineEdit = new LineEdit();
|
||
|
lineEdit.PlaceholderText = "请输入标识名称";
|
||
|
|
||
|
templateList.ItemClicked += OnItemClicked;
|
||
|
|
||
|
registerButton.Pressed += Register;
|
||
|
|
||
|
generateHandleButton.Pressed += () =>
|
||
|
{
|
||
|
handleEdit.Text = $"88.123.99/{Mathf.Abs(Guid.NewGuid().GetHashCode())}";
|
||
|
};
|
||
|
}
|
||
|
|
||
|
private void OnItemClicked(long index, Vector2 atPosition, long mouseButtonIndex)
|
||
|
{
|
||
|
MathNode.RemoveAllChild(container);
|
||
|
var template = templateService.templates[(int) index];
|
||
|
|
||
|
var grid = new GridContainer();
|
||
|
grid.Columns = 2;
|
||
|
grid.AddThemeConstantOverride("h_separation", 64);
|
||
|
|
||
|
container.AddChild(grid);
|
||
|
|
||
|
foreach (var x in template.Formats)
|
||
|
{
|
||
|
var label = new Label();
|
||
|
var lineEdit = new LineEdit();
|
||
|
|
||
|
label.Text = x.format;
|
||
|
|
||
|
lineEdit.PlaceholderText = x.hint;
|
||
|
lineEdit.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill;
|
||
|
|
||
|
grid.AddChild(label);
|
||
|
grid.AddChild(lineEdit);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void Register()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|