Lots of SzGui work
This commit is contained in:
44
SzGui/Windows/NewObjectModal.cs
Normal file
44
SzGui/Windows/NewObjectModal.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using ImGuiNET;
|
||||
using SzCore;
|
||||
using SzCore.DataObjects;
|
||||
using SzGui.Windows;
|
||||
|
||||
public class NewObjectModal : SzGuiWindowBase
|
||||
{
|
||||
private readonly SzDataset _dataset;
|
||||
private string _objName = "";
|
||||
|
||||
public NewObjectModal(SzDataset dataset)
|
||||
{
|
||||
_dataset = dataset;
|
||||
WindowName = $"Add Object to {dataset.Name}";
|
||||
}
|
||||
|
||||
protected override void RenderContent()
|
||||
{
|
||||
ImGui.Text($"Creating object for template: {_dataset.DataObjectTemplateId}");
|
||||
ImGui.InputText("Object Name", ref _objName, 64);
|
||||
|
||||
if (ImGui.Button("Create", new System.Numerics.Vector2(100, 0)))
|
||||
{
|
||||
Create();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Create()
|
||||
{
|
||||
var templateResult = await SZ.DataHandler.LoadTemplateAsync<SzDataObjectTemplate>(_dataset.DataObjectTemplateId);
|
||||
|
||||
if (templateResult.IsSuccess)
|
||||
{
|
||||
var objResult = SZ.DataHandler.CreateDataObject(templateResult.Value!, _objName);
|
||||
|
||||
if (objResult.IsSuccess)
|
||||
{
|
||||
_dataset.DataObjects.Add(objResult.Value!.Id, objResult.Value);
|
||||
await SZ.DataHandler.SaveDatasetAsync(_dataset);
|
||||
IsOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user