2023-09-15 23:02:46 +08:00
|
|
|
#if Deprecated
|
2023-07-10 00:00:20 +08:00
|
|
|
using Godot;
|
|
|
|
using System;
|
2023-07-12 12:11:10 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2023-07-11 00:14:36 +08:00
|
|
|
using BITKit;
|
2023-07-10 00:00:20 +08:00
|
|
|
|
2023-07-11 00:14:36 +08:00
|
|
|
namespace BITFactory;
|
2023-07-10 00:00:20 +08:00
|
|
|
public partial class IDIS_UpdateService : Node
|
|
|
|
{
|
2023-07-11 00:14:36 +08:00
|
|
|
[ExportCategory("Service")]
|
2023-07-10 00:00:20 +08:00
|
|
|
[Export] private IDIS_Service service;
|
2023-07-11 00:14:36 +08:00
|
|
|
[Export] private IDIS_TemplateService templateService;
|
|
|
|
|
2023-07-10 00:00:20 +08:00
|
|
|
[ExportCategory("UI 绑定")]
|
2023-07-11 00:14:36 +08:00
|
|
|
[Export] private NodeBuilder indexBuilder;
|
|
|
|
[Export] private NodeBuilder templateBuilder;
|
2023-07-10 00:00:20 +08:00
|
|
|
[Export] private LineEdit handleEdit;
|
2023-07-12 12:11:10 +08:00
|
|
|
[Export] private Button submitButton;
|
|
|
|
[Export] private RichTextLabel hintsLabel;
|
2023-07-11 00:14:36 +08:00
|
|
|
|
|
|
|
private ButtonGroup _buttonGroup;
|
2023-07-12 12:11:10 +08:00
|
|
|
|
|
|
|
private readonly Dictionary<string,LineEdit> dataEdits = new();
|
2023-07-10 00:00:20 +08:00
|
|
|
public override void _Ready()
|
|
|
|
{
|
2023-07-11 00:14:36 +08:00
|
|
|
_buttonGroup = new ButtonGroup();
|
2023-07-12 12:11:10 +08:00
|
|
|
|
|
|
|
submitButton.Pressed += Submit;
|
|
|
|
|
|
|
|
submitButton.Disabled = true;
|
|
|
|
|
2023-07-11 00:14:36 +08:00
|
|
|
Refresh();
|
2023-07-10 00:00:20 +08:00
|
|
|
}
|
2023-07-11 00:14:36 +08:00
|
|
|
|
|
|
|
private void Refresh()
|
2023-07-10 00:00:20 +08:00
|
|
|
{
|
2023-07-11 00:14:36 +08:00
|
|
|
templateBuilder.Clear();
|
|
|
|
indexBuilder.Clear();
|
|
|
|
foreach (var x in templateService.templates)
|
2023-07-10 00:00:20 +08:00
|
|
|
{
|
2023-07-11 00:14:36 +08:00
|
|
|
var container = indexBuilder.Build<UXContainer>();
|
|
|
|
container.button.Text = x.TemplateName;
|
|
|
|
container.button.ButtonPressed = true;
|
|
|
|
container.button.ButtonGroup = _buttonGroup;
|
|
|
|
container.button.Pressed +=()=> Entry(x);
|
2023-07-10 00:00:20 +08:00
|
|
|
}
|
2023-07-11 00:14:36 +08:00
|
|
|
}
|
|
|
|
private void Entry(IDIS_Template template)
|
|
|
|
{
|
|
|
|
templateBuilder.Clear();
|
2023-07-12 12:11:10 +08:00
|
|
|
dataEdits.Clear();
|
2023-07-11 00:14:36 +08:00
|
|
|
foreach (var x in template.Formats)
|
2023-07-10 00:00:20 +08:00
|
|
|
{
|
2023-07-11 00:14:36 +08:00
|
|
|
var container = templateBuilder.Build<UXContainer>();
|
|
|
|
container.Text = x.format;
|
|
|
|
container.lineEdit.PlaceholderText = x.hint;
|
2023-07-12 12:11:10 +08:00
|
|
|
|
|
|
|
dataEdits.TryAdd(x.format, container.lineEdit);
|
|
|
|
}
|
|
|
|
|
|
|
|
submitButton.Disabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Submit()
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(handleEdit.Text))
|
|
|
|
{
|
|
|
|
hintsLabel.Text="请填写标识码";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var handle = handleEdit.Text;
|
|
|
|
var values = new Dictionary<string, string>(
|
|
|
|
dataEdits
|
|
|
|
.Where(x=>string.IsNullOrEmpty(x.Value.Text) is false)
|
|
|
|
.Select(x => new KeyValuePair<string, string>(x.Key, x.Value.Text))
|
|
|
|
);
|
|
|
|
foreach (var x in values)
|
|
|
|
{
|
|
|
|
service.Update(handle, x.Key, x.Value);
|
2023-07-10 00:00:20 +08:00
|
|
|
}
|
2023-07-12 12:11:10 +08:00
|
|
|
hintsLabel.Text=$"更新成功,已更新{values.Count}个值"+DateTime.Now;
|
2023-07-10 00:00:20 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-15 23:02:46 +08:00
|
|
|
#endif
|