예제 #1
0
 void PickObject(PopupData data)
 {
     ImGui.Combo("Object", ref dumpindex, dumpoptions);
     if (ImGui.Button("Ok"))
     {
         var output = FileDialog.Save();
         if (output != null)
         {
             if (dumpindex == 0)
             {
                 DumpStatus(DumpObject.DumpObj(dumpcmp, output));
             }
             else
             {
                 var mdl = dumpcmp.Models[dumpoptions[dumpindex]];
                 DumpStatus(DumpObject.DumpObj(mdl, output));
             }
             ImGui.CloseCurrentPopup();
         }
     }
     ImGui.SameLine();
     if (ImGui.Button("Cancel"))
     {
         ImGui.CloseCurrentPopup();
     }
 }
예제 #2
0
        void Rename(PopupData data)
        {
            ImGui.Text("Name: ");
            ImGui.SameLine();
            bool entered = ImGui.InputText("", text.Pointer, (uint)text.Size, InputTextFlags.EnterReturnsTrue, text.Callback);

            if (data.DoFocus)
            {
                ImGui.SetKeyboardFocusHere();
            }
            if (entered || 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();
            }
        }
예제 #3
0
        unsafe void ColorPicker(PopupData data)
        {
            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();
            }
        }
예제 #4
0
 void MinMaxWarning(PopupData data)
 {
     ImGui.Text("Min was bigger than max, swapped.");
     if (ImGui.Button("Ok"))
     {
         ImGui.CloseCurrentPopup();
     }
 }
예제 #5
0
        void HexEditor(PopupData data)
        {
            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();
        }
예제 #6
0
 void StringConfirm(PopupData data)
 {
     ImGui.Text("Data is >255 bytes, string will be truncated. Continue?");
     if (ImGui.Button("Yes"))
     {
         text.SetBytes(selectedNode.Data, 255);
         popups.OpenPopup("String Editor");
         ImGui.CloseCurrentPopup();
     }
     ImGui.SameLine();
     if (ImGui.Button("No"))
     {
         ImGui.CloseCurrentPopup();
     }
 }
예제 #7
0
 void StringEditor(PopupData data)
 {
     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();
     }
 }
예제 #8
0
 void StringEditor(PopupData data)
 {
     ImGui.Text("String: ");
     ImGui.SameLine();
     text.InputText("##str", ImGuiInputTextFlags.None, 255);
     if (ImGui.Button("Ok"))
     {
         selectedNode.Data = text.GetByteArray();
         ImGui.CloseCurrentPopup();
     }
     ImGui.SameLine();
     if (ImGui.Button("Cancel"))
     {
         ImGui.CloseCurrentPopup();
     }
 }
예제 #9
0
 void HexEditor(PopupData data)
 {
     ImGui.SameLine(ImGui.GetWindowWidth() - 90);
     if (ImGui.Button("Ok"))
     {
         selectedNode.Data = hexdata;
         ImGui.CloseCurrentPopup();
     }
     ImGui.SameLine(ImGui.GetWindowWidth() - 60);
     if (ImGui.Button("Cancel"))
     {
         ImGui.CloseCurrentPopup();
     }
     ImGui.PushFont(ImGuiHelper.Default);
     mem.DrawContents(hexdata, hexdata.Length);
     ImGui.PopFont();
 }
예제 #10
0
        void AddPopup(PopupData data)
        {
            ImGui.Text("Name: ");
            ImGui.SameLine();
            bool entered = ImGui.InputText("", text.Pointer, (uint)text.Size, InputTextFlags.EnterReturnsTrue, text.Callback);

            if (data.DoFocus)
            {
                ImGui.SetKeyboardFocusHere();
            }
            if (entered || 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();
            }
        }
예제 #11
0
 void ConfirmDelete(PopupData data)
 {
     ImGui.Text(string.Format("Are you sure you wish to delete '{0}'?", hpDelete.Name));
     if (ImGui.Button("Yes"))
     {
         hpDeleteFrom.Remove(hpDelete);
         var gz = gizmos.Where((x) => x.Definition == hpDelete).First();
         if (hpDelete == hpEditing)
         {
             hpEditing = null;
         }
         gizmos.Remove(gz);
         ImGui.CloseCurrentPopup();
     }
     ImGui.SameLine();
     if (ImGui.Button("No"))
     {
         ImGui.CloseCurrentPopup();
     }
 }
예제 #12
0
        void NewHardpoint(PopupData data)
        {
            ImGui.Text("Name: ");
            ImGui.SameLine();
            newHpBuffer.InputText("##hpname", ImGuiInputTextFlags.None);
            ImGui.SameLine();
            if (ImGui.Button(".."))
            {
                ImGui.OpenPopup("names");
            }
            if (ImGui.BeginPopupContextItem("names"))
            {
                var infos = newIsFixed ? HardpointInformation.Fix : HardpointInformation.Rev;
                foreach (var item in infos)
                {
                    if (Theme.IconMenuItem(item.Name, item.Icon, item.Color, true))
                    {
                        switch (item.Autoname)
                        {
                        case HpNaming.None:
                            newHpBuffer.SetText(item.Name);
                            break;

                        case HpNaming.Number:
                            newHpBuffer.SetText(item.Name + GetHpNumbering(item.Name).ToString("00"));
                            break;

                        case HpNaming.Letter:
                            newHpBuffer.SetText(item.Name + GetHpLettering(item.Name));
                            break;
                        }
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.Text("Type: " + (newIsFixed ? "Fixed" : "Revolute"));
            if (newErrorTimer > 0)
            {
                ImGui.TextColored(new Vector4(1, 0, 0, 1), "Hardpoint with that name already exists.");
            }
            if (ImGui.Button("Ok"))
            {
                var txt = newHpBuffer.GetText();
                if (txt.Length == 0)
                {
                    return;
                }
                if (gizmos.Any((x) => x.Definition.Name.Equals(txt, StringComparison.OrdinalIgnoreCase)))
                {
                    newErrorTimer = 6;
                }
                else
                {
                    HardpointDefinition def;
                    if (newIsFixed)
                    {
                        def = new FixedHardpointDefinition(txt);
                    }
                    else
                    {
                        def = new RevoluteHardpointDefinition(txt);
                    }
                    gizmos.Add(new HardpointGizmo(def, addConstruct));
                    addTo.Add(def);
                    ImGui.CloseCurrentPopup();
                }
            }
            ImGui.SameLine();
            if (ImGui.Button("Cancel"))
            {
                ImGui.CloseCurrentPopup();
            }
        }
예제 #13
0
        void TexImportDialog(PopupData data)
        {
            if (teximportprev == null)
            { //processing
                ImGui.Text("Processing...");
                if (!texImportWaiting)
                {
                    if (texImportChildren != null)
                    {
                        selectedNode.Data = null;
                        foreach (var c in texImportChildren)
                        {
                            c.Parent = selectedNode;
                        }
                        selectedNode.Children = texImportChildren;
                    }
                    else
                    {
                        selectedNode.Children = null;
                        selectedNode.Data     = texImportData;
                    }
                    texImportData     = null;
                    texImportChildren = null;
                    ImGui.CloseCurrentPopup();
                }
            }
            else
            {
                ImGui.Image((IntPtr)teximportid, new Vector2(64, 64),
                            new Vector2(0, 1), new Vector2(1, 0), Vector4.One, Vector4.Zero);
                ImGui.Text(string.Format("Dimensions: {0}x{1}", teximportprev.Width, teximportprev.Height));
                ImGui.Combo("Format", ref compressOption, texOptions);
                ImGui.Combo("Mipmaps", ref mipmapOption, mipmapOptions);
                ImGui.Checkbox("High Quality (slow)", ref compressSlow);
                if (ImGui.Button("Import"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev    = null;
                    texImportWaiting = true;
                    new System.Threading.Thread(() =>
                    {
                        var format = DDSFormat.Uncompressed;
                        switch (compressOption)
                        {
                        case 1:
                            format = DDSFormat.DXT1;
                            break;

                        case 2:
                            format = DDSFormat.DXT1a;
                            break;

                        case 3:
                            format = DDSFormat.DXT3;
                            break;

                        case 4:
                            format = DDSFormat.DXT5;
                            break;
                        }
                        var mipm = MipmapMethod.None;
                        switch (mipmapOption)
                        {
                        case 1:
                            mipm = MipmapMethod.Box;
                            break;

                        case 2:
                            mipm = MipmapMethod.Bicubic;
                            break;

                        case 3:
                            mipm = MipmapMethod.Bilinear;
                            break;

                        case 4:
                            mipm = MipmapMethod.Bspline;
                            break;

                        case 5:
                            mipm = MipmapMethod.CatmullRom;
                            break;

                        case 6:
                            mipm = MipmapMethod.Lanczos3;
                            break;
                        }
                        if (mipm == MipmapMethod.None && format == DDSFormat.Uncompressed)
                        {
                            texImportData = TextureImport.TGANoMipmap(teximportpath);
                        }
                        else if (format == DDSFormat.Uncompressed)
                        {
                            texImportChildren = TextureImport.TGAMipmaps(teximportpath, mipm);
                        }
                        else
                        {
                            texImportData = TextureImport.CreateDDS(teximportpath, format, mipm, compressSlow);
                        }
                        texImportWaiting = false;
                    }).Start();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev = null;
                    ImGui.CloseCurrentPopup();
                }
            }
        }