private void DrawUiActions() { var toolbarSize = NVector2.UnitY * (ImGui.GetTextLineHeightWithSpacing() + ImGui.GetStyle().ItemSpacing.Y * 2); ImGui.Text($"{ImGuiEx.IcoMoon.HammerIcon} Actions"); ImGui.BeginChildFrame(1, toolbarSize); { if (ImGuiEx.DelegateButton("New project", $"{ImGuiEx.IcoMoon.HammerIcon}", "New project")) { _state = new State(); ResetEditor(_state); } ImGui.SameLine(); if (ImGuiEx.DelegateButton("Save project", $"{ImGuiEx.IcoMoon.FloppyDiskIcon}", "Save project")) { _openFdDefinition = ImGuiEx.CreateFilePickerDefinition(Assembly.GetExecutingAssembly() .Location, "Save", ".json"); ImGui.OpenPopup("Save project"); } DoPopup("Save project", ref _openFdDefinition, () => { var json = JsonSerializer.Serialize(_state, CreateJsonSerializerOptions(_state.PropertyDefinitions)); File.WriteAllText(_openFdDefinition.SelectedRelativePath, json); }); ImGui.SameLine(); if (ImGuiEx.DelegateButton("Open project", $"{ImGuiEx.IcoMoon.FolderOpenIcon}", "Open project")) { _openFdDefinition = ImGuiEx.CreateFilePickerDefinition(Assembly.GetExecutingAssembly() .Location, "Open", ".json"); ImGui.OpenPopup("Open project"); } DoPopup("Open project", ref _openFdDefinition, () => { // load json var json = File.ReadAllText(_openFdDefinition.SelectedRelativePath); using var jsonDocument = JsonDocument.Parse(json); var propJson = jsonDocument.RootElement.GetProperty(nameof(_state.PropertyDefinitions)).ToString(); var properties = JsonSerializer.Deserialize <Dictionary <string, Property> >(propJson, CreateJsonSerializerOptions()); var newState = JsonSerializer.Deserialize <State>(json, CreateJsonSerializerOptions(properties)); // clean animator and sprites/textures ResetEditor(newState, false); _state = newState; }); ImGui.SameLine(); } ImGui.EndChildFrame(); }