public override void CreateModelDropdown(ImGui gui, Type type, Project project, ref bool close) { if (gui.BuildContextMenuButton("Create production sheet")) { close = true; ProjectPageSettingsPanel.Show(null, (name, icon) => MainScreen.Instance.AddProjectPage(name, icon, typeof(ProductionTable), true)); } }
public override void CreateModelDropdown(ImGui gui, Type type, Project project, ref bool close) { if (gui.BuildContextMenuButton("Auto planner (Alpha)")) { close = true; WizardPanel.Show("New auto planner", CreateAutoPlannerWizard); } }
private void OtherToolsDropdown(ImGui gui, ref bool closed) { if (gui.BuildContextMenuButton("Duplicate page")) { closed = true; var project = editingPage.owner; var collector = new ErrorCollector(); var serializedCopy = JsonUtils.Copy(editingPage, project, collector); if (collector.severity > ErrorSeverity.None) { ErrorListPanel.Show(collector); } if (serializedCopy != null) { serializedCopy.GenerateNewGuid(); serializedCopy.icon = icon; serializedCopy.name = name; project.RecordUndo().pages.Add(serializedCopy); MainScreen.Instance.SetActivePage(serializedCopy); Close(); } } if (gui.BuildContextMenuButton("Share (export string to clipboard)")) { closed = true; var data = JsonUtils.SaveToJson(editingPage); using (var targetStream = new MemoryStream()) { using (var compress = new DeflateStream(targetStream, CompressionLevel.Optimal, true)) { using (var writer = new BinaryWriter(compress, Encoding.UTF8, true)) { // write some magic chars and version as a marker writer.Write("YAFC\nProjectPage\n".AsSpan()); writer.Write(YafcLib.version.ToString().AsSpan()); writer.Write("\n\n\n".AsSpan()); } data.CopyTo(compress); } var encoded = Convert.ToBase64String(targetStream.GetBuffer(), 0, (int)targetStream.Length); SDL.SDL_SetClipboardText(encoded); } } }