unsafe void Popups() { //StringEditor if (stringConfirm) { ImGui.OpenPopup("Confirm?##stringedit" + Unique); stringConfirm = false; } if (ImGui.BeginPopupModal("Confirm?##stringedit" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text("Data is >255 bytes, string will be truncated. Continue?"); if (ImGui.Button("Yes")) { text.SetBytes(selectedNode.Data, 255); stringEditor = true; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("No")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (stringEditor) { ImGui.OpenPopup("String Editor##" + Unique); stringEditor = false; } if (ImGui.BeginPopupModal("String Editor##" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text("String: "); ImGui.SameLine(); ImGui.InputText("", text.Pointer, 255, InputTextFlags.Default, text.Callback); if (ImGui.Button("Ok")) { selectedNode.Data = text.GetByteArray(); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } //Hex Editor if (hexEditor) { ImGui.OpenPopup("HexEditor##" + Unique); hexEditor = false; } if (ImGui.BeginPopupModal("HexEditor##" + Unique)) { ImGui.PushFont(ImGuiHelper.Default); int res; if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0) { if (res == 1) { selectedNode.Data = hexdata; } ImGui.CloseCurrentPopup(); } ImGui.PopFont(); ImGui.EndPopup(); } //Color Picker if (colorPicker) { ImGui.OpenPopup("Color Picker##" + Unique); colorPicker = false; } if (ImGui.BeginPopupModal("Color Picker##" + Unique, WindowFlags.AlwaysAutoResize)) { bool old4 = pickcolor4; ImGui.Checkbox("Alpha?", ref pickcolor4); if (old4 != pickcolor4) { if (old4 == false) { color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1); } if (old4 == true) { color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z); } } ImGui.Separator(); if (pickcolor4) { ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar); } else { ImGui.ColorPicker3("Color", ref color3); } ImGui.Separator(); if (ImGui.Button("Ok")) { ImGui.CloseCurrentPopup(); if (pickcolor4) { var bytes = new byte[16]; fixed(byte *ptr = bytes) { var f = (System.Numerics.Vector4 *)ptr; f[0] = color4; } selectedNode.Data = bytes; } else { var bytes = new byte[12]; fixed(byte *ptr = bytes) { var f = (System.Numerics.Vector3 *)ptr; f[0] = color3; } selectedNode.Data = bytes; } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } //Float Editor if (floatEditor) { ImGui.OpenPopup("Float Editor##" + Unique); floatEditor = false; } DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode); if (intEditor) { ImGui.OpenPopup("Int Editor##" + Unique); intEditor = false; } DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode); //Rename dialog if (doRename) { ImGui.OpenPopup("Rename##" + Unique); doRename = false; } if (ImGui.BeginPopupModal("Rename##" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text("Name: "); ImGui.SameLine(); ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback); if (ImGui.Button("Ok")) { var n = text.GetText().Trim(); if (n.Length == 0) { ErrorPopup("Node name cannot be empty"); } else { renameNode.Name = text.GetText(); } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } //Error if (doError) { ImGui.OpenPopup("Error##" + Unique); doError = false; } if (ImGui.BeginPopupModal("Error##" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text(errorText); if (ImGui.Button("Ok")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } //Add if (doAdd) { ImGui.OpenPopup("New Node##" + Unique); doAdd = false; } if (ImGui.BeginPopupModal("New Node##" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text("Name: "); ImGui.SameLine(); ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback); if (ImGui.Button("Ok")) { var node = new LUtfNode() { Name = text.GetText().Trim(), Parent = addParent ?? addNode }; if (node.Name.Length == 0) { ErrorPopup("Node name cannot be empty"); } else { if (addParent != null) { addParent.Children.Insert(addParent.Children.IndexOf(addNode) + addOffset, node); } else { addNode.Data = null; if (addNode.Children == null) { addNode.Children = new List <LUtfNode>(); } addNode.Children.Add(node); } selectedNode = node; } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } //Confirmation if (doConfirm) { ImGui.OpenPopup("Confirm?##generic" + Unique); doConfirm = false; } if (ImGui.BeginPopupModal("Confirm?##generic" + Unique, WindowFlags.AlwaysAutoResize)) { ImGui.Text(confirmText); if (ImGui.Button("Yes")) { confirmAction(); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("No")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } }