예제 #1
0
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.Always);

            var isOpen = true;

            if (!ImGui.Begin(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings", ref isOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize))
            {
                ImGui.End();
                return(false);
            }

            ImGui.BeginChild("scrolling", new Vector2(499, 430), false, ImGuiWindowFlags.HorizontalScrollbar);

            if (ImGui.BeginTabBar("SetTabBar"))
            {
                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsLanguage", "Language"));
                    ImGui.Combo("##XlLangCombo", ref this.langIndex, this.languages,
                                this.languages.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsLanguageHint", "Select the language Dalamud will be displayed in."));

                    ImGui.Dummy(new Vector2(5f, 5f));

                    ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel"));
                    ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes,
                                this.chatTypes.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."));

                    ImGui.Dummy(new Vector2(5f, 5f));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"), ref this.doCfTaskBarFlash);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsFlashHint", "Select, if the FFXIV window should be flashed in your task bar when a duty is ready."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsRestartHint", "You need to restart your game after changing these settings."));

                    ImGui.Dummy(new Vector2(10f, 10f));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Check this box to receive testing prereleases for plugins."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingDalamudTest", "Get Dalamud testing builds"), ref this.doDalamudTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingDalamudTestHint", "Check this box to receive testing prereleases for Dalamud."));

                    ImGui.EndTabItem();
                }

                ImGui.EndTabBar();
            }

            ImGui.EndChild();


            if (ImGui.Button(Loc.Localize("Save", "Save")))
            {
                Save();
            }
            ImGui.SameLine();
            if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
            {
                Save();
                isOpen = false;
            }

            ImGui.End();

            return(isOpen);
        }
예제 #2
0
        private bool PropertyRow(Type typ, object oldval, out object newval, bool isBool)
        {
            try
            {
                if (isBool)
                {
                    dynamic val      = oldval;
                    bool    checkVal = val > 0;
                    if (ImGui.Checkbox("##valueBool", ref checkVal))
                    {
                        newval = Convert.ChangeType(checkVal ? 1 : 0, oldval.GetType());
                        return(true);
                    }
                    ImGui.SameLine();
                }
            }
            catch
            {
            }

            if (typ == typeof(long))
            {
                long   val    = (long)oldval;
                string strval = $@"{val}";
                if (ImGui.InputText("##value", ref strval, 128))
                {
                    var res = long.TryParse(strval, out val);
                    if (res)
                    {
                        newval = val;
                        return(true);
                    }
                }
            }
            else if (typ == typeof(int))
            {
                int val = (int)oldval;
                if (ImGui.InputInt("##value", ref val))
                {
                    newval = val;
                    return(true);
                }
            }
            else if (typ == typeof(uint))
            {
                uint   val    = (uint)oldval;
                string strval = $@"{val}";
                if (ImGui.InputText("##value", ref strval, 16))
                {
                    var res = uint.TryParse(strval, out val);
                    if (res)
                    {
                        newval = val;
                        return(true);
                    }
                }
            }
            else if (typ == typeof(short))
            {
                int val = (short)oldval;
                if (ImGui.InputInt("##value", ref val))
                {
                    newval = (short)val;
                    return(true);
                }
            }
            else if (typ == typeof(ushort))
            {
                ushort val    = (ushort)oldval;
                string strval = $@"{val}";
                if (ImGui.InputText("##value", ref strval, 5))
                {
                    var res = ushort.TryParse(strval, out val);
                    if (res)
                    {
                        newval = val;
                        return(true);
                    }
                }
            }
            else if (typ == typeof(sbyte))
            {
                int val = (sbyte)oldval;
                if (ImGui.InputInt("##value", ref val))
                {
                    newval = (sbyte)val;
                    return(true);
                }
            }
            else if (typ == typeof(byte))
            {
                byte   val    = (byte)oldval;
                string strval = $@"{val}";
                if (ImGui.InputText("##value", ref strval, 3))
                {
                    var res = byte.TryParse(strval, out val);
                    if (res)
                    {
                        newval = val;
                        return(true);
                    }
                }
            }
            else if (typ == typeof(bool))
            {
                bool val = (bool)oldval;
                if (ImGui.Checkbox("##value", ref val))
                {
                    newval = val;
                    return(true);
                }
            }
            else if (typ == typeof(float))
            {
                float val = (float)oldval;
                if (ImGui.DragFloat("##value", ref val, 0.1f))
                {
                    newval = val;
                    return(true);
                    // shouldUpdateVisual = true;
                }
            }
            else if (typ == typeof(string))
            {
                string val = (string)oldval;
                if (val == null)
                {
                    val = "";
                }
                if (ImGui.InputText("##value", ref val, 128))
                {
                    newval = val;
                    return(true);
                }
            }
            else if (typ == typeof(Vector2))
            {
                Vector2 val = (Vector2)oldval;
                if (ImGui.DragFloat2("##value", ref val, 0.1f))
                {
                    newval = val;
                    return(true);
                    // shouldUpdateVisual = true;
                }
            }
            else if (typ == typeof(Vector3))
            {
                Vector3 val = (Vector3)oldval;
                if (ImGui.DragFloat3("##value", ref val, 0.1f))
                {
                    newval = val;
                    return(true);
                    // shouldUpdateVisual = true;
                }
            }
            else
            {
                ImGui.Text("ImplementMe");
            }

            newval = null;
            return(false);
        }
예제 #3
0
 public static bool DrawBool(string label, ref bool b, RenderContext rc)
 {
     return(ImGui.Checkbox(label, ref b));
 }
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(500, 500) * ImGui.GetIO().FontGlobalScale, ImGuiCond.Always);

            var isOpen = true;

            if (!ImGui.Begin(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings", ref isOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize))
            {
                ImGui.End();
                return(false);
            }

            ImGui.BeginChild("scrolling", new Vector2(499, 430) * ImGui.GetIO().FontGlobalScale, false, ImGuiWindowFlags.HorizontalScrollbar);

            if (ImGui.BeginTabBar("SetTabBar"))
            {
                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsLanguage", "Language"));
                    ImGui.Combo("##XlLangCombo", ref this.langIndex, this.languages,
                                this.languages.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsLanguageHint", "Select the language Dalamud will be displayed in."));

                    ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel"));
                    ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes,
                                this.chatTypes.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."));

                    ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"), ref this.doCfTaskBarFlash);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsFlashHint", "Select, if the FFXIV window should be flashed in your task bar when a duty is ready."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"), ref this.doCfChatMessage);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsDutyFinderMessageHint", "Select, if a message should be sent in the FFXIV chat when a duty is ready."));


                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsVisual", "Look & Feel")))
                {
                    if (ImGui.DragFloat(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI scale"), ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f"))
                    {
                        ImGui.GetIO().FontGlobalScale = this.globalUiScale;
                    }

                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays."));

                    ImGui.Dummy(new Vector2(10f, 16f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off."), ref this.doToggleUiHide);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideHint", "Check this box to hide any open windows by plugins when toggling the game overlay."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes."), ref this.doToggleUiHideDuringCutscenes);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Check this box to hide any open windows by plugins during cutscenes."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active."), ref this.doToggleUiHideDuringGpose);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Check this box to hide any open windows by plugins while gpose is active."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsRestartHint", "You need to restart your game after changing these settings."));

                    ImGui.Dummy(new Vector2(10f, 10f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Check this box to receive testing prereleases for plugins."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingDalamudTest", "Get Dalamud testing builds"), ref this.doDalamudTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingDalamudTestHint", "Check this box to receive testing prereleases for Dalamud."));

                    ImGui.EndTabItem();
                }

                ImGui.EndTabBar();
            }

            ImGui.EndChild();

            if (ImGui.Button(Loc.Localize("Save", "Save")))
            {
                Save();
            }
            ImGui.SameLine();
            if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
            {
                Save();
                isOpen = false;
            }

            ImGui.End();

            return(isOpen);
        }
예제 #5
0
        private static void HandleType(SettingsHolder holder, object type, string propertyInfo)
        {
            switch (type)
            {
            case ButtonNode buttonNode:
                holder.DrawDelegate = () =>
                {
                    if (ImGui.Button(holder.Unique))
                    {
                        buttonNode.OnPressed();
                    }
                };
                return;

            case null:
            case EmptyNode _:
                holder.DrawDelegate = () => { };
                return;

            case HotkeyNode hotkeyNode:
                holder.DrawDelegate = () =>
                {
                    var str         = $"{holder.Name} {hotkeyNode.Value}##{hotkeyNode.Value}";
                    var popupOpened = true;

                    if (ImGui.Button(str))
                    {
                        ImGui.OpenPopup(str);
                        popupOpened = true;
                    }

                    if (!ImGui.BeginPopupModal(str, ref popupOpened,
                                               ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse))
                    {
                        return;
                    }

                    if (Input.GetKeyState(Keys.Escape))
                    {
                        ImGui.CloseCurrentPopup();
                        ImGui.EndPopup();
                        return;
                    }

                    foreach (var key in Enum.GetValues(typeof(Keys)))
                    {
                        if (!Input.GetKeyState((Keys)key))
                        {
                            continue;
                        }
                        hotkeyNode.Value = (Keys)key;
                        ImGui.CloseCurrentPopup();
                        break;
                    }

                    ImGui.Text($"Press new key to change '{hotkeyNode.Value}' or Esc for exit.");
                    ImGui.EndPopup();
                };
                return;

            case ToggleNode toggleNode:
                holder.DrawDelegate = () =>
                {
                    var isChecked = toggleNode.Value;
                    ImGui.Checkbox(holder.Unique, ref isChecked);
                    toggleNode.Value = isChecked;
                };
                return;

            case ColorNode colorNode:
                holder.DrawDelegate = () =>
                {
                    var color = colorNode.Value.ToVector4().ToVector4Num();
                    if (ImGui.ColorEdit4(holder.Unique, ref color,
                                         ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.AlphaBar |
                                         ImGuiColorEditFlags.AlphaPreviewHalf))
                    {
                        colorNode.Value = color.ToSharpColor();
                    }
                };
                return;

            case ListNode listNode:
                holder.DrawDelegate = () =>
                {
                    if (!ImGui.BeginCombo(holder.Unique, listNode.Value))
                    {
                        return;
                    }

                    foreach (var value in listNode.Values)
                    {
                        if (!ImGui.Selectable(value))
                        {
                            continue;
                        }
                        listNode.Value = value;
                        break;
                    }

                    ImGui.EndCombo();
                };
                return;

            case FileNode fileNode:
                holder.DrawDelegate = () =>
                {
                    if (!ImGui.TreeNode(holder.Unique))
                    {
                        return;
                    }

                    var value = fileNode.Value;
                    if (ImGui.BeginChildFrame(1, new Vector2(0f, 300f)))
                    {
                        var directoryInfo = new DirectoryInfo("config");
                        if (directoryInfo.Exists)
                        {
                            var files = directoryInfo.GetFiles();
                            foreach (var fileInfo in files)
                            {
                                if (ImGui.Selectable(fileInfo.Name, value == fileInfo.FullName))
                                {
                                    fileNode.Value = fileInfo.FullName;
                                }
                            }
                        }

                        ImGui.EndChildFrame();
                    }

                    ImGui.TreePop();
                };
                return;

            case RangeNode <int> iRangeNode:
                holder.DrawDelegate = () =>
                {
                    var value = iRangeNode.Value;
                    ImGui.SliderInt(holder.Unique, ref value, iRangeNode.Min, iRangeNode.Max);
                    iRangeNode.Value = value;
                };
                return;

            case RangeNode <float> fRangeNode:
                holder.DrawDelegate = () =>
                {
                    var value = fRangeNode.Value;
                    ImGui.SliderFloat(holder.Unique, ref value, fRangeNode.Min, fRangeNode.Max);
                    fRangeNode.Value = value;
                };
                return;

            case RangeNode <long> lRangeNode:
                holder.DrawDelegate = () =>
                {
                    var value = (int)lRangeNode.Value;
                    ImGui.SliderInt(holder.Unique, ref value, (int)lRangeNode.Min, (int)lRangeNode.Max);
                    lRangeNode.Value = value;
                };
                return;

            case RangeNode <Vector2> vRangeNode:
                holder.DrawDelegate = () =>
                {
                    var value = vRangeNode.Value;
                    ImGui.SliderFloat2(holder.Unique, ref value, vRangeNode.Min.X, vRangeNode.Max.X);
                    vRangeNode.Value = value;
                };
                return;

            case TextNode textNode:
                holder.DrawDelegate = () =>
                {
                    var value = textNode.Value;
                    ImGui.InputText(holder.Unique, ref value, 200);
                    textNode.Value = value;
                };
                return;
            }

            DebugWindow.LogDebug(
                $"SettingsParser => DrawDelegate not auto-generated for '{propertyInfo}'.");
        }
예제 #6
0
파일: GUI.cs 프로젝트: randomcrab/SE
 public static bool Checkbox(string label, ref bool val, string fmt)
 {
     GUIUtility.TextIndentFunction(fmt);
     return(ImGui.Checkbox(label, ref val));
 }
예제 #7
0
        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();
            }
        }
예제 #8
0
        public bool DrawConfigUI()
        {
            var drawConfig  = true;
            var windowFlags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse;

            ImGui.Begin($"{plugin.Name} Config##fpsPluginConfigWindow", ref drawConfig, windowFlags);

            var changed = false;

            changed |= ImGui.Checkbox("Show Display##fpsPluginEnabledSetting", ref Enable);
            ImGui.SameLine();
            ImGui.TextDisabled("/pfps [show|hide|toggle]");

            changed |= ImGui.Checkbox("Lock Display##fpsPluginLockSetting", ref Locked);
            changed |= ImGui.Checkbox("Show Decimals##fpsPluginDecimalsSetting", ref ShowDecimals);
            changed |= ImGui.Checkbox("Show Average##fpsPluginShowAverageSetting", ref ShowAverage);
            changed |= ImGui.Checkbox("Show Minimum##fpsPluginShowMinimumSetting", ref ShowMinimum);
            changed |= ImGui.Checkbox("Multiline##fpsPluginMultiline", ref MultiLine);
            changed |= ImGui.InputInt("Tracking Timespan (Seconds)", ref HistorySnapshotCount, 1, 60);

            if (ImGui.TreeNode("Style Options###fpsPluginStyleOptions"))
            {
                changed |= ImGui.SliderFloat("Background Opacity##fpsPluginOpacitySetting", ref Alpha, 0, 1);

                if (ImGui.BeginCombo("Font##fpsPluginFontSelect", this.Font.Description()))
                {
                    foreach (var v in (FPSPluginFont[])Enum.GetValues(typeof(FPSPluginFont)))
                    {
                        if (ImGui.Selectable($"{v.Description()}##fpsPluginFont_{v}"))
                        {
                            this.Font      = v;
                            changed        = true;
                            FontChangeTime = DateTime.Now.Ticks;
                        }
                    }
                    ImGui.EndCombo();
                }


                if (ImGui.SliderFloat("Font Size##fpsPluginFontSizeSetting", ref FontSize, 6, 90, "%.0f"))
                {
                    FontChangeTime = DateTime.Now.Ticks;
                    changed        = true;
                }
                ImGui.SameLine();
                if (ImGui.SmallButton("Reload Font"))
                {
                    plugin.ReloadFont();
                }
                changed |= ImGui.ColorEdit4("Text Colour##fpsPluginColorSetting", ref Colour);

                changed |= ImGui.SliderFloat("Corner Rounding###fpsPluginCornerRounding", ref WindowCornerRounding, 0f, 20f, "%.0f");
                changed |= ImGui.SliderFloat2("Window Padding###fpsPluginWindowPadding", ref WindowPadding, 0f, 20f, "%.0f");

                ImGui.TreePop();
            }


#if DEBUG
            if (ImGui.TreeNode("Debug##fpsPlugin"))
            {
                ImGui.InputText("Test Text", ref TestText, 100, ImGuiInputTextFlags.Multiline);
                ImGui.TreePop();
            }
#endif

            ImGui.Separator();
            if (ImGui.Button("Restore Default##fpsPluginDefaultsButton"))
            {
                LoadDefaults();
                changed = true;
            }

            if (changed)
            {
                if (HistorySnapshotCount < 1)
                {
                    HistorySnapshotCount = 1;
                }
                if (HistorySnapshotCount > 10000)
                {
                    HistorySnapshotCount = 10000;
                }
                Save();
            }

            ImGui.SameLine();

            ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF);
            ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA);
            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD);
            var c = ImGui.GetCursorPos();
            ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize("Support on Ko-fi").X - ImGui.GetStyle().FramePadding.X * 2);
            if (ImGui.Button("Support on Ko-fi"))
            {
                Process.Start("https://ko-fi.com/Caraxi");
            }
            ImGui.SetCursorPos(c);
            ImGui.PopStyleColor(3);


            ImGui.End();

            return(drawConfig);
        }
예제 #9
0
        public void Draw()
        {
            if (!this.plugin.SettingsVisible)
            {
                return;
            }

            bool settingsVisible = this.plugin.SettingsVisible;

            if (ImGui.Begin("Oops, All Lalafells!", ref settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
            {
                bool shouldChangeOthers = this.plugin.config.ShouldChangeOthers;
                ImGui.Checkbox("Change other players", ref shouldChangeOthers);

                Race othersTargetRace = this.plugin.config.ChangeOthersTargetRace;
                if (shouldChangeOthers)
                {
                    if (ImGui.BeginCombo("Race", othersTargetRace.GetAttribute <Display>().Value))
                    {
                        foreach (Race race in Enum.GetValues(typeof(Race)))
                        {
                            ImGui.PushID((byte)race);
                            if (ImGui.Selectable(race.GetAttribute <Display>().Value, race == othersTargetRace))
                            {
                                othersTargetRace = race;
                            }

                            if (race == othersTargetRace)
                            {
                                ImGui.SetItemDefaultFocus();
                            }

                            ImGui.PopID();
                        }

                        ImGui.EndCombo();
                    }
                }

                this.plugin.UpdateOtherRace(othersTargetRace);
                this.plugin.ToggleOtherRace(shouldChangeOthers);

                ImGui.Checkbox("Change self", ref this.changeSelf);
                if (changeSelf)
                {
                    if (!changeSelfLaunched)
                    {
                        changeSelfLaunched = true;
                        Process.Start("explorer", "https://store.finalfantasyxiv.com/ffxivstore/en-us/product/1");
                        TriggerChangeSelfText();
                    }

                    if (changeSelfShowText)
                    {
                        ImGui.TextColored(WHAT_THE_HELL_ARE_YOU_DOING,
                                          "Changing your own character's race/gender is not, and will never, be\na feature of this plugin. " +
                                          "This is a policy held by both myself as the developer,\nas well as by the XIVLauncher/Dalamud folks. Sorry to be the bearer of bad news!");
                    }
                }

                if (enableExperimental)
                {
                    bool immersiveMode = this.plugin.config.ImmersiveMode;
                    ImGui.Checkbox("Immersive Mode", ref immersiveMode);
                    ImGui.Text("If Immersive Mode is enabled, \"Examine\" windows will also be modified.");

                    this.plugin.UpdateImmersiveMode(immersiveMode);
                }

                ImGui.Separator();

                ImGui.Checkbox("Enable Experimental Features", ref this.enableExperimental);
                if (enableExperimental)
                {
                    ImGui.Text("Experimental feature configuration will (intentionally) not persist,\n" +
                               "so you will need to open this settings menu to re-activate\n" +
                               "them if you disable the plugin or restart your game.");

                    ImGui.TextColored(WHAT_THE_HELL_ARE_YOU_DOING,
                                      "Experimental features may crash your game, uncat your boy,\nor cause the Eighth Umbral Calamity. YOU HAVE BEEN WARNED!");

                    ImGui.Text(
                        "But seriously, if you do encounter any crashes, please report\nthem to Avaflow#0001 on Discord with whatever details you can get.");
                }

                ImGui.End();
            }

            this.plugin.SettingsVisible = settingsVisible;
            this.plugin.SaveConfig();
        }
예제 #10
0
    private void DrawTweakConfig(BaseTweak t, ref bool hasChange)
    {
        var enabled = t.Enabled;

        if (t.Experimental && !ShowExperimentalTweaks && !enabled)
        {
            return;
        }

        if (!enabled && ImGui.GetIO().KeyShift)
        {
            if (HiddenTweaks.Contains(t.Key))
            {
                if (ImGui.Button($"S##unhideTweak_{t.Key}", new Vector2(23) * ImGui.GetIO().FontGlobalScale))
                {
                    HiddenTweaks.Remove(t.Key);
                    Save();
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip(Loc.Localize("Unhide Tweak", "Unhide Tweak"));
                }
            }
            else
            {
                if (ImGui.Button($"H##hideTweak_{t.Key}", new Vector2(23) * ImGui.GetIO().FontGlobalScale))
                {
                    HiddenTweaks.Add(t.Key);
                    Save();
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip(Loc.Localize("Hide Tweak", "Hide Tweak"));
                }
            }
        }
        else
        if (ImGui.Checkbox($"###{t.Key}enabledCheckbox", ref enabled))
        {
            if (enabled)
            {
                SimpleLog.Debug($"Enable: {t.Name}");
                try {
                    t.Enable();
                    if (t.Enabled)
                    {
                        EnabledTweaks.Add(t.Key);
                    }
                } catch (Exception ex) {
                    plugin.Error(t, ex, false, $"Error in Enable for '{t.Name}'");
                }
            }
            else
            {
                SimpleLog.Debug($"Disable: {t.Name}");
                try {
                    t.Disable();
                } catch (Exception ex) {
                    plugin.Error(t, ex, true, $"Error in Disable for '{t.Name}'");
                }
                EnabledTweaks.RemoveAll(a => a == t.Key);
            }
            Save();
        }
        ImGui.SameLine();
        var descriptionX = ImGui.GetCursorPosX();

        if (!t.DrawConfig(ref hasChange))
        {
            if (ShowTweakDescriptions && !string.IsNullOrEmpty(t.Description))
            {
                ImGui.SetCursorPosX(descriptionX);
                ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x0);
                ImGui.PushStyleColor(ImGuiCol.HeaderActive, 0x0);
                ImGui.TreeNodeEx(" ", ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen);
                ImGui.PopStyleColor();
                ImGui.PopStyleColor();
                ImGui.SameLine();
                ImGui.PushStyleColor(ImGuiCol.Text, 0xFF888888);
                var tweakDescription = t.LocString("Description", t.Description, "Tweak Description");
                ImGui.TextWrapped($"{tweakDescription}");
                ImGui.PopStyleColor();
            }
        }
        ImGui.Separator();
    }
예제 #11
0
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(740, 500) * ImGui.GetIO().FontGlobalScale, ImGuiCond.FirstUseEver);

            var isOpen = true;

            if (!ImGui.Begin(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2", ref isOpen, ImGuiWindowFlags.NoCollapse))
            {
                ImGui.End();
                return(false);
            }

            var windowSize = ImGui.GetWindowSize();

            ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 10, windowSize.Y - 70) * ImGui.GetIO().FontGlobalScale, false, ImGuiWindowFlags.HorizontalScrollbar);

            if (ImGui.BeginTabBar("SetTabBar"))
            {
                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsLanguage", "Language"));
                    ImGui.Combo("##XlLangCombo", ref this.langIndex, this.locLanguages,
                                this.locLanguages.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsLanguageHint", "Select the language Dalamud will be displayed in."));

                    ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel"));
                    ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes,
                                this.chatTypes.Length);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."));

                    ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"), ref this.doCfTaskBarFlash);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsFlashHint", "Flash the FFXIV window in your task bar when a duty is ready."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"), ref this.doCfChatMessage);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsDutyFinderMessageHint", "Send a message in FFXIV chat when a duty is ready."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"), ref this.printPluginsWelcomeMsg);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsAutoUpdatePlugins", "Auto-update plugins"), ref this.autoUpdatePlugins);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsAutoUpdatePluginsMsgHint", "Automatically update plugins when logging in with a character."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsVisual", "Look & Feel")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI Scale"));
                    if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f"))
                    {
                        ImGui.GetIO().FontGlobalScale = this.globalUiScale;
                    }

                    ImGui.SameLine();
                    if (ImGui.Button("Reset"))
                    {
                        this.globalUiScale = 1.0f;
                        ImGui.GetIO().FontGlobalScale = this.globalUiScale;
                    }

                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays."));

                    ImGui.Dummy(new Vector2(10f, 16f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"), ref this.doToggleUiHide);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"), ref this.doToggleUiHideDuringCutscenes);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"), ref this.doToggleUiHideDuringGpose);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental")))
                {
                    ImGui.Text(Loc.Localize("DalamudSettingsRestartHint", "You need to restart your game after changing these settings."));

                    ImGui.Dummy(new Vector2(10f, 10f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for plugins."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingDalamudTest", "Get Dalamud testing builds"), ref this.doDalamudTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingDalamudTestHint", "Receive testing prereleases for Dalamud."));

                    ImGui.Dummy(new Vector2(12f, 12f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Text(Loc.Localize("DalamudSettingsCustomRepo", "Custom Plugin Repositories"));
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingCustomRepoHint", "Add custom plugin repositories. Only change these settings if you know what you are doing."));

                    ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);

                    ImGui.Columns(3);
                    ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() - 350);
                    ImGui.SetColumnWidth(1, 60);
                    ImGui.SetColumnWidth(2, 60);

                    ImGui.Separator();

                    ImGui.Text("URL");
                    ImGui.NextColumn();
                    ImGui.Text("Enabled");
                    ImGui.NextColumn();
                    ImGui.Text("");
                    ImGui.NextColumn();

                    ImGui.Separator();

                    ImGui.Text("XIVLauncher");
                    ImGui.NextColumn();
                    ImGui.NextColumn();
                    ImGui.NextColumn();
                    ImGui.Separator();

                    ThirdRepoSetting toRemove = null;

                    foreach (var thirdRepoSetting in this.thirdRepoList)
                    {
                        var isEnabled = thirdRepoSetting.IsEnabled;

                        ImGui.PushID(thirdRepoSetting.Url);

                        ImGui.Text(thirdRepoSetting.Url);
                        ImGui.NextColumn();
                        ImGui.Checkbox("##thirdRepoCheck", ref isEnabled);
                        ImGui.NextColumn();
                        ImGui.PushFont(InterfaceManager.IconFont);
                        if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString()))
                        {
                            toRemove = thirdRepoSetting;
                        }
                        ImGui.PopFont();
                        ImGui.NextColumn();
                        ImGui.Separator();

                        thirdRepoSetting.IsEnabled = isEnabled;
                    }

                    if (toRemove != null)
                    {
                        this.thirdRepoList.Remove(toRemove);
                    }

                    ImGui.InputText("##thirdRepoUrlInput", ref this.thirdRepoTempUrl, 300);
                    ImGui.NextColumn();
                    ImGui.NextColumn();
                    ImGui.PushFont(InterfaceManager.IconFont);
                    if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString()))
                    {
                        this.thirdRepoList.Add(new ThirdRepoSetting {
                            Url = this.thirdRepoTempUrl
                        });

                        this.thirdRepoTempUrl = string.Empty;
                    }
                    ImGui.PopFont();

                    ImGui.Columns(1);

                    ImGui.EndTabItem();
                }

                ImGui.EndTabBar();
            }

            ImGui.EndChild();

            if (!isOpen)
            {
                ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
            }
            if (ImGui.Button(Loc.Localize("Save", "Save")))
            {
                Save();
            }
            ImGui.SameLine();
            if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
            {
                Save();
                isOpen = false;
            }

            ImGui.End();

            return(isOpen);
        }
예제 #12
0
    public bool DrawConfigUI()
    {
        var drawConfig  = true;
        var changed     = false;
        var scale       = ImGui.GetIO().FontGlobalScale;
        var windowFlags = ImGuiWindowFlags.NoCollapse;

        ImGui.SetNextWindowSizeConstraints(new Vector2(600 * scale, 200 * scale), new Vector2(800 * scale, 800 * scale));
        ImGui.Begin($"{plugin.Name} Config", ref drawConfig, windowFlags);

        var showbutton  = plugin.ErrorList.Count != 0 || !HideKofi;
        var buttonText  = plugin.ErrorList.Count > 0 ? $"{plugin.ErrorList.Count} Errors Detected" : "Support on Ko-fi";
        var buttonColor = (uint)(plugin.ErrorList.Count > 0 ? 0x000000FF : 0x005E5BFF);

        if (showbutton)
        {
            ImGui.SetNextItemWidth(-(ImGui.CalcTextSize(buttonText).X + ImGui.GetStyle().FramePadding.X * 2 + ImGui.GetStyle().ItemSpacing.X));
        }
        else
        {
            ImGui.SetNextItemWidth(-1);
        }

        ImGui.InputTextWithHint("###tweakSearchInput", "Search...", ref searchInput, 100);

        if (showbutton)
        {
            ImGui.SameLine();
            ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | buttonColor);
            ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | buttonColor);
            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | buttonColor);

            if (ImGui.Button(buttonText, new Vector2(-1, ImGui.GetItemRectSize().Y)))
            {
                if (plugin.ErrorList.Count == 0)
                {
                    Common.OpenBrowser("https://ko-fi.com/Caraxi");
                }
                else
                {
                    plugin.ShowErrorWindow = true;
                }
            }
            ImGui.PopStyleColor(3);
        }

        ImGui.Dummy(new Vector2(1, ImGui.GetStyle().WindowPadding.Y - ImGui.GetStyle().ItemSpacing.Y * 2));
        ImGui.Separator();

        if (!string.IsNullOrEmpty(searchInput))
        {
            if (lastSearchInput != searchInput)
            {
                lastSearchInput = searchInput;
                searchResults   = new List <BaseTweak>();
                var searchValue = searchInput.ToLowerInvariant();
                foreach (var t in plugin.Tweaks)
                {
                    if (t is SubTweakManager stm)
                    {
                        if (!stm.Enabled)
                        {
                            continue;
                        }
                        foreach (var st in stm.GetTweakList())
                        {
                            if (st.Name.ToLowerInvariant().Contains(searchValue) || st.Tags.Any(tag => tag.ToLowerInvariant().Contains(searchValue)) || st.LocalizedName.ToLowerInvariant().Contains(searchValue))
                            {
                                searchResults.Add(st);
                            }
                        }
                        continue;
                    }
                    if (t.Name.ToLowerInvariant().Contains(searchValue) || t.Tags.Any(tag => tag.ToLowerInvariant().Contains(searchValue)) || t.LocalizedName.ToLowerInvariant().Contains(searchValue))
                    {
                        searchResults.Add(t);
                    }
                }

                searchResults = searchResults.OrderBy(t => t.Name).ToList();
            }

            ImGui.BeginChild("search_scroll", new Vector2(-1));

            foreach (var t in searchResults)
            {
                if (HiddenTweaks.Contains(t.Key) && !t.Enabled)
                {
                    continue;
                }
                DrawTweakConfig(t, ref changed);
            }

            ImGui.EndChild();
        }
        else
        {
            var flags = settingTab ? ImGuiTabBarFlags.AutoSelectNewTabs : ImGuiTabBarFlags.None;
            if (ImGui.BeginTabBar("tweakCategoryTabBar", flags))
            {
                if (settingTab && setTab == null)
                {
                    settingTab = false;
                }
                else
                {
                    if (ImGui.BeginTabItem(Loc.Localize("General Tweaks", "General Tweaks", "General Tweaks Tab Header") + "###generalTweaksTab"))
                    {
                        ImGui.BeginChild("generalTweaks", new Vector2(-1, -1), false);

                        // ImGui.Separator();
                        foreach (var t in plugin.Tweaks)
                        {
                            if (t is SubTweakManager)
                            {
                                continue;
                            }
                            if (HiddenTweaks.Contains(t.Key) && !t.Enabled)
                            {
                                continue;
                            }
                            DrawTweakConfig(t, ref changed);
                        }

                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }
                }

                foreach (var stm in plugin.Tweaks.Where(t => t is SubTweakManager stm && (t.Enabled || stm.AlwaysEnabled)).Cast <SubTweakManager>())
                {
                    var subTweakList = stm.GetTweakList().Where(t => t.Enabled || !HiddenTweaks.Contains(t.Key)).ToList();
                    if (subTweakList.Count <= 0)
                    {
                        continue;
                    }
                    if (settingTab == false && setTab == stm)
                    {
                        settingTab = true;
                        continue;
                    }

                    if (settingTab && setTab == stm)
                    {
                        settingTab = false;
                        setTab     = null;
                    }

                    if (ImGui.BeginTabItem($"{stm.LocalizedName}###tweakCategoryTab_{stm.Key}"))
                    {
                        ImGui.BeginChild($"{stm.Key}-scroll", new Vector2(-1, -1));
                        foreach (var tweak in subTweakList)
                        {
                            if (!tweak.Enabled && HiddenTweaks.Contains(tweak.Key))
                            {
                                continue;
                            }
                            DrawTweakConfig(tweak, ref changed);
                        }
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }
                }

                if (ImGui.BeginTabItem(Loc.Localize("General Options / TabHeader", "General Options") + $"###generalOptionsTab"))
                {
                    ImGui.BeginChild($"generalOptions-scroll", new Vector2(-1, -1));
                    if (ImGui.Checkbox(Loc.Localize("General Options / Show Experimental Tweaks", "Show Experimental Tweaks."), ref ShowExperimentalTweaks))
                    {
                        Save();
                    }
                    ImGui.Separator();
                    if (ImGui.Checkbox(Loc.Localize("General Options / Show Tweak Descriptions", "Show tweak descriptions."), ref ShowTweakDescriptions))
                    {
                        Save();
                    }
                    ImGui.Separator();
                    if (ImGui.Checkbox(Loc.Localize("General Options / Show Tweak IDs", "Show tweak IDs."), ref ShowTweakIDs))
                    {
                        Save();
                    }
                    ImGui.Separator();

                    if (Loc.DownloadError != null)
                    {
                        ImGui.TextColored(new Vector4(1, 0, 0, 1), Loc.DownloadError.ToString());
                    }

                    if (Loc.LoadingTranslations)
                    {
                        ImGui.Text("Downloading Translations...");
                    }
                    else
                    {
                        ImGui.SetNextItemWidth(130);
                        if (ImGui.BeginCombo(Loc.Localize("General Options / Language", "Language"), plugin.PluginConfig.Language))
                        {
                            if (ImGui.Selectable("en", Language == "en"))
                            {
                                Language = "en";
                                plugin.SetupLocalization();
                                Save();
                            }

#if DEBUG
                            if (ImGui.Selectable("DEBUG", Language == "DEBUG"))
                            {
                                Language = "DEBUG";
                                plugin.SetupLocalization();
                                Save();
                            }
#endif

                            var locDir = pluginInterface.GetPluginLocDirectory();

                            var locFiles = Directory.GetDirectories(locDir);

                            foreach (var f in locFiles)
                            {
                                var dir = new DirectoryInfo(f);
                                if (ImGui.Selectable($"{dir.Name}##LanguageSelection", Language == dir.Name))
                                {
                                    Language = dir.Name;
                                    plugin.SetupLocalization();
                                    Save();
                                }
                            }

                            ImGui.EndCombo();
                        }

                        ImGui.SameLine();

                        if (ImGui.SmallButton("Update Translations"))
                        {
                            Loc.UpdateTranslations();
                        }

#if DEBUG
                        ImGui.SameLine();
                        if (ImGui.SmallButton("Export Localizable"))
                        {
                            // Auto fill dictionary with all Name/Description
                            foreach (var t in plugin.Tweaks)
                            {
                                t.LocString("Name", t.Name, "Tweak Name");
                                if (t.Description != null)
                                {
                                    t.LocString("Description", t.Description, "Tweak Description");
                                }

                                if (t is SubTweakManager stm)
                                {
                                    foreach (var st in stm.GetTweakList())
                                    {
                                        st.LocString("Name", st.Name, "Tweak Name");
                                        if (st.Description != null)
                                        {
                                            st.LocString("Description", st.Description, "Tweak Description");
                                        }
                                    }
                                }
                            }

                            try {
                                ImGui.SetClipboardText(Loc.ExportLoadedDictionary());
                            } catch (Exception ex) {
                                SimpleLog.Error(ex);
                            }
                        }
                        ImGui.SameLine();
                        if (ImGui.SmallButton("Import"))
                        {
                            var json = ImGui.GetClipboardText();
                            Loc.ImportDictionary(json);
                        }
#endif
                    }

                    ImGui.Separator();

                    ImGui.SetNextItemWidth(130);
                    if (ImGui.BeginCombo(Loc.Localize("General Options / Formatting Culture", "Formatting Culture"), plugin.Culture.Name))
                    {
                        var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
                        for (var i = 0; i < cultures.Length; i++)
                        {
                            var c = cultures[i];
                            if (ImGui.Selectable($"{c.Name}", Equals(c, plugin.Culture)))
                            {
                                CustomCulture  = c.Name;
                                plugin.Culture = c;
                                Save();
                            }
                        }

                        ImGui.EndCombo();
                    }
                    ImGui.SameLine();
                    ImGui.TextDisabled("Changes number formatting, not all tweaks support this.");

                    ImGui.Separator();
                    if (ImGui.Checkbox(Loc.Localize("General Options / Hide KoFi", "Hide Ko-fi link."), ref HideKofi))
                    {
                        Save();
                    }
                    ImGui.Separator();

                    foreach (var t in plugin.Tweaks.Where(t => t is SubTweakManager).Cast <SubTweakManager>())
                    {
                        if (t.AlwaysEnabled)
                        {
                            continue;
                        }
                        var enabled = t.Enabled;
                        if (t.Experimental && !ShowExperimentalTweaks && !enabled)
                        {
                            continue;
                        }
                        if (ImGui.Checkbox($"###{t.GetType().Name}enabledCheckbox", ref enabled))
                        {
                            if (enabled)
                            {
                                SimpleLog.Debug($"Enable: {t.Name}");
                                try {
                                    t.Enable();
                                    if (t.Enabled)
                                    {
                                        EnabledTweaks.Add(t.GetType().Name);
                                    }
                                } catch (Exception ex) {
                                    plugin.Error(t, ex, false, $"Error in Enable for '{t.Name}'");
                                }
                            }
                            else
                            {
                                SimpleLog.Debug($"Disable: {t.Name}");
                                try {
                                    t.Disable();
                                } catch (Exception ex) {
                                    plugin.Error(t, ex, true, $"Error in Disable for '{t.Name}'");
                                }
                                EnabledTweaks.RemoveAll(a => a == t.GetType().Name);
                            }
                            Save();
                        }
                        ImGui.SameLine();
                        ImGui.TreeNodeEx($"Enable Category: {t.LocalizedName}", ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.NoTreePushOnOpen);
                        if (ImGui.IsItemClicked() && t.Enabled)
                        {
                            setTab     = t;
                            settingTab = false;
                        }
                        ImGui.Separator();
                    }

                    if (HiddenTweaks.Count > 0)
                    {
                        if (ImGui.TreeNode($"Hidden Tweaks ({HiddenTweaks.Count})###hiddenTweaks"))
                        {
                            string removeKey = null;
                            foreach (var hidden in HiddenTweaks)
                            {
                                var tweak = plugin.GetTweakById(hidden);
                                if (tweak == null)
                                {
                                    continue;
                                }
                                if (ImGui.Button($"S##unhideTweak_{tweak.Key}", new Vector2(23) * ImGui.GetIO().FontGlobalScale))
                                {
                                    removeKey = hidden;
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip(Loc.Localize("Unhide Tweak", "Unhide Tweak"));
                                }

                                ImGui.SameLine();
                                ImGui.Text(tweak.LocalizedName);
                            }

                            if (removeKey != null)
                            {
                                HiddenTweaks.RemoveAll(t => t == removeKey);
                                Save();
                            }
                            ImGui.TreePop();
                        }
                        ImGui.Separator();
                    }

                    if (CustomProviders.Count > 0 || ShowExperimentalTweaks)
                    {
                        ImGui.Text("Tweak Providers:");
                        string?deleteCustomProvider = null;
                        for (var i = 0; i < CustomProviders.Count; i++)
                        {
                            if (ImGui.Button($"X##deleteCustomProvider_{i}"))
                            {
                                deleteCustomProvider = CustomProviders[i];
                            }
                            ImGui.SameLine();
                            if (ImGui.Button($"R##reloadcustomProvider_{i}"))
                            {
                                foreach (var tp in SimpleTweaksPlugin.Plugin.TweakProviders)
                                {
                                    if (tp.IsDisposed)
                                    {
                                        continue;
                                    }
                                    if (tp is not CustomTweakProvider ctp)
                                    {
                                        continue;
                                    }
                                    if (ctp.AssemblyPath == CustomProviders[i])
                                    {
                                        ctp.Dispose();
                                    }
                                }
                                plugin.LoadCustomProvider(CustomProviders[i]);
                                Loc.ClearCache();
                            }
                            ImGui.SameLine();
                            ImGui.Text(CustomProviders[i]);
                        }

                        if (deleteCustomProvider != null)
                        {
                            CustomProviders.Remove(deleteCustomProvider);

                            foreach (var tp in SimpleTweaksPlugin.Plugin.TweakProviders)
                            {
                                if (tp.IsDisposed)
                                {
                                    continue;
                                }
                                if (tp is not CustomTweakProvider ctp)
                                {
                                    continue;
                                }
                                if (ctp.AssemblyPath == deleteCustomProvider)
                                {
                                    ctp.Dispose();
                                }
                            }
                            DebugManager.Reload();

                            Save();
                        }

                        if (ImGui.Button("+##addCustomProvider"))
                        {
                            if (!string.IsNullOrWhiteSpace(addCustomProviderInput) && !CustomProviders.Contains(addCustomProviderInput))
                            {
                                CustomProviders.Add(addCustomProviderInput);
                                SimpleTweaksPlugin.Plugin.LoadCustomProvider(addCustomProviderInput);
                                addCustomProviderInput = string.Empty;
                                Save();
                            }
                        }

                        ImGui.SameLine();
                        ImGui.InputText("##addCustomProviderInput", ref addCustomProviderInput, 500);
                    }

                    ImGui.EndChild();
                    ImGui.EndTabItem();
                }

                ImGui.EndTabBar();
            }
        }

        ImGui.End();

        if (changed)
        {
            Save();
        }

        return(drawConfig);
    }
예제 #13
0
        public static void Build(float elapsedTime, float offsetX, float offsetY)
        {
            hoveringOverAnythingThisFrame = false;

            ImGui.PushStyleColor(ImGuiCol.WindowBg, new System.Numerics.Vector4(0.05f, 0.05f, 0.05f, Focused ? 1 : 0f));

            ImGui.Begin("Toolbox", ref RenderConfigOpen, ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize);

            ImGui.SetWindowFontScale(Main.DPIY);
            {
                //if (!Focused)
                //    ImGui.SetWindowCollapsed(true);

                ImGui.PushItemWidth(DefaultItemWidth);

                ImGui.SliderFloat($"Volume", ref FmodManager.AdjustSoundVolume, 0, 200, "%.2f%%");
                ImGui.Button("Reset to 100%");
                if (ImGui.IsItemClicked())
                {
                    FmodManager.AdjustSoundVolume = 100;
                }
                ImGui.Separator();
                ImGui.Text("Tracking Simulation Analog Input");
                ImGui.SliderFloat("Input", ref Model.GlobalTrackingInput, -1, 1);
                ImGui.Button("Reset To 0");
                if (ImGui.IsItemClicked())
                {
                    Model.GlobalTrackingInput = 0;
                }
                ImGui.Separator();

                if (RequestCollapse)
                {
                    RequestCollapse = false;
                    ImGui.SetWindowCollapsed(true);
                }

                float x = Main.TAE_EDITOR.ModelViewerBounds.Width - WindowWidth - WindowMargin;
                float y = 8 + Main.TAE_EDITOR.ModelViewerBounds.Top;
                float w = WindowWidth;
                float h = Main.TAE_EDITOR.ModelViewerBounds.Height - (WindowMargin * 2) - 24;
                ImGui.SetWindowPos(new System.Numerics.Vector2(x, y) * Main.DPIVectorN);
                ImGui.SetWindowSize(new System.Numerics.Vector2(w, h) * Main.DPIVectorN);



                if (EnableDebugMenu)
                {
                    //DBG.DbgPrim_Grid.OverrideColor = HandleColor("Grid Color", DBG.DbgPrim_Grid.OverrideColor.Value);

                    if (RequestExpandAllTreeNodes)
                    {
                        ImGui.SetNextItemOpen(true);
                    }

                    if (ImGui.TreeNode("[DEBUG]"))
                    {
                        //DBG.DbgPrim_Grid.OverrideColor = HandleColor("Grid Color", DBG.DbgPrim_Grid.OverrideColor.Value);
                        //DBG.DbgPrim_Grid.OverrideColor = HandleColor("Grid Color 2", DBG.DbgPrim_Grid.OverrideColor.Value);
                        //DBG.DbgPrim_Grid.OverrideColor = HandleColor("Grid Color 3", DBG.DbgPrim_Grid.OverrideColor.Value);

                        ImGui.TreePop();
                    }
                }

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Colors]"))
                {
                    ImGui.Text("Left click a color to expand/collapse");
                    ImGui.Text("color picker. Middle click a color");
                    ImGui.Text("to reset to default.");

                    ImGui.Separator();

                    ImGui.Text("Window");

                    HandleColor("Window Background", cc => cc.MainColorBackground, (cc, c) => cc.MainColorBackground = c);

                    HandleColor("Memory Usage Text - Low", cc => cc.GuiColorMemoryUseTextGood, (cc, c) => cc.GuiColorMemoryUseTextGood    = c);
                    HandleColor("Memory Usage Text - Medium", cc => cc.GuiColorMemoryUseTextOkay, (cc, c) => cc.GuiColorMemoryUseTextOkay = c);
                    HandleColor("Memory Usage Text - High", cc => cc.GuiColorMemoryUseTextBad, (cc, c) => cc.GuiColorMemoryUseTextBad     = c);

                    HandleColor("Viewport Status Text - Default", cc => cc.GuiColorViewportStatus, (cc, c) => cc.GuiColorViewportStatus = c);
                    HandleColor("Viewport Status Text - Bone Count Exceeded", cc => cc.GuiColorViewportStatusMaxBoneCountExceeded, (cc, c) => cc.GuiColorViewportStatusMaxBoneCountExceeded = c);
                    HandleColor("Viewport Status Text - Anim Doesn't Exist", cc => cc.GuiColorViewportStatusAnimDoesntExist, (cc, c) => cc.GuiColorViewportStatusAnimDoesntExist            = c);
                    HandleColor("Viewport Status Text - Current Combo Chain", cc => cc.GuiColorViewportStatusCombo, (cc, c) => cc.GuiColorViewportStatusCombo = c);

                    ImGui.Text("Event Graph");

                    HandleColor("Event Graph - Background", cc => cc.GuiColorEventGraphBackground, (cc, c) => cc.GuiColorEventGraphBackground = c);
                    HandleColor("Event Graph - Ghost Graph Overlay", cc => cc.GuiColorEventGraphGhostOverlay, (cc, c) => cc.GuiColorEventGraphGhostOverlay = c);
                    HandleColor("Event Graph - Anim End Vertical Line", cc => cc.GuiColorEventGraphAnimEndVerticalLine, (cc, c) => cc.GuiColorEventGraphAnimEndVerticalLine   = c);
                    HandleColor("Event Graph - Anim End Darken Rect", cc => cc.GuiColorEventGraphAnimEndDarkenRect, (cc, c) => cc.GuiColorEventGraphAnimEndDarkenRect         = c);
                    HandleColor("Event Graph - Event Row Horizontal Lines", cc => cc.GuiColorEventGraphRowHorizontalLines, (cc, c) => cc.GuiColorEventGraphRowHorizontalLines = c);
                    HandleColor("Event Graph - Timeline Fill", cc => cc.GuiColorEventGraphTimelineFill, (cc, c) => cc.GuiColorEventGraphTimelineFill = c);
                    HandleColor("Event Graph - Timeline Frame Vertical Lines", cc => cc.GuiColorEventGraphTimelineFrameVerticalLines, (cc, c) => cc.GuiColorEventGraphTimelineFrameVerticalLines = c);
                    HandleColor("Event Graph - Timeline Frame Number Text", cc => cc.GuiColorEventGraphTimelineFrameNumberText, (cc, c) => cc.GuiColorEventGraphTimelineFrameNumberText          = c);
                    HandleColor("Event Graph - Frame Vertical Lines", cc => cc.GuiColorEventGraphVerticalFrameLines, (cc, c) => cc.GuiColorEventGraphVerticalFrameLines                      = c);
                    HandleColor("Event Graph - Second Vertical Lines", cc => cc.GuiColorEventGraphVerticalSecondLines, (cc, c) => cc.GuiColorEventGraphVerticalSecondLines                   = c);
                    HandleColor("Event Graph - Selection Rectangle Fill", cc => cc.GuiColorEventGraphSelectionRectangleFill, (cc, c) => cc.GuiColorEventGraphSelectionRectangleFill          = c);
                    HandleColor("Event Graph - Selection Rectangle Outline", cc => cc.GuiColorEventGraphSelectionRectangleOutline, (cc, c) => cc.GuiColorEventGraphSelectionRectangleOutline = c);
                    HandleColor("Event Graph - Playback Cursor", cc => cc.GuiColorEventGraphPlaybackCursor, (cc, c) => cc.GuiColorEventGraphPlaybackCursor = c);
                    HandleColor("Event Graph - Playback Start Time Vertical Line", cc => cc.GuiColorEventGraphPlaybackStartTime, (cc, c) => cc.GuiColorEventGraphPlaybackStartTime = c);
                    HandleColor("Event Graph - Hover Info Box Fill", cc => cc.GuiColorEventGraphHoverInfoBoxFill, (cc, c) => cc.GuiColorEventGraphHoverInfoBoxFill          = c);
                    HandleColor("Event Graph - Hover Info Box Text", cc => cc.GuiColorEventGraphHoverInfoBoxText, (cc, c) => cc.GuiColorEventGraphHoverInfoBoxText          = c);
                    HandleColor("Event Graph - Hover Info Box Outline", cc => cc.GuiColorEventGraphHoverInfoBoxOutline, (cc, c) => cc.GuiColorEventGraphHoverInfoBoxOutline = c);

                    HandleColor("Event Graph - Scrollbar Background", cc => cc.GuiColorEventGraphScrollbarBackground, (cc, c) => cc.GuiColorEventGraphScrollbarBackground = c);
                    HandleColor("Event Graph - Scrollbar Inactive Foreground", cc => cc.GuiColorEventGraphScrollbarForegroundInactive, (cc, c) => cc.GuiColorEventGraphScrollbarForegroundInactive = c);
                    HandleColor("Event Graph - Scrollbar Active Foreground", cc => cc.GuiColorEventGraphScrollbarForegroundActive, (cc, c) => cc.GuiColorEventGraphScrollbarForegroundActive       = c);
                    HandleColor("Event Graph - Scrollbar Inactive Arrow", cc => cc.GuiColorEventGraphScrollbarArrowButtonForegroundInactive, (cc, c) => cc.GuiColorEventGraphScrollbarArrowButtonForegroundInactive = c);
                    HandleColor("Event Graph - Scrollbar Active Arrow", cc => cc.GuiColorEventGraphScrollbarArrowButtonForegroundActive, (cc, c) => cc.GuiColorEventGraphScrollbarArrowButtonForegroundActive       = c);

                    HandleColor("Event Box - Normal - Fill", cc => cc.GuiColorEventBox_Normal_Fill, (cc, c) => cc.GuiColorEventBox_Normal_Fill                    = c);
                    HandleColor("Event Box - Normal - Outline", cc => cc.GuiColorEventBox_Normal_Outline, (cc, c) => cc.GuiColorEventBox_Normal_Outline           = c);
                    HandleColor("Event Box - Normal - Text", cc => cc.GuiColorEventBox_Normal_Text, (cc, c) => cc.GuiColorEventBox_Normal_Text                    = c);
                    HandleColor("Event Box - Normal - Text Shadow", cc => cc.GuiColorEventBox_Normal_TextShadow, (cc, c) => cc.GuiColorEventBox_Normal_TextShadow = c);

                    HandleColor("Event Box - Highlighted - Fill", cc => cc.GuiColorEventBox_Highlighted_Fill, (cc, c) => cc.GuiColorEventBox_Highlighted_Fill                    = c);
                    HandleColor("Event Box - Highlighted - Outline", cc => cc.GuiColorEventBox_Highlighted_Outline, (cc, c) => cc.GuiColorEventBox_Highlighted_Outline           = c);
                    HandleColor("Event Box - Highlighted - Text", cc => cc.GuiColorEventBox_Highlighted_Text, (cc, c) => cc.GuiColorEventBox_Highlighted_Text                    = c);
                    HandleColor("Event Box - Highlighted - Text Shadow", cc => cc.GuiColorEventBox_Highlighted_TextShadow, (cc, c) => cc.GuiColorEventBox_Highlighted_TextShadow = c);

                    HandleColor("Event Box - Selection Dimming Overlay", cc => cc.GuiColorEventBox_SelectionDimmingOverlay, (cc, c) => cc.GuiColorEventBox_SelectionDimmingOverlay      = c);
                    HandleColor("Event Box - Ghost Graph Grayed Out Overlay", cc => cc.GuiColorEventBox_SelectionDimmingOverlay, (cc, c) => cc.GuiColorEventBox_SelectionDimmingOverlay = c);

                    // Deprecated afaik
                    //HandleColor("Event Box - Hovered - Text Outline", Main.Colors.GuiColorEventBox_Hover_TextOutline, c => Main.Colors.GuiColorEventBox_Hover_TextOutline = c);


                    ImGui.Text("Viewport");

                    HandleColor("Grid", cc => cc.ColorGrid, (cc, c) => cc.ColorGrid = c);
                    HandleColor("Viewport Background", cc => cc.MainColorViewportBackground, (cc, c) => cc.MainColorViewportBackground = c);


                    ImGui.Text("Helper");

                    HandleColor("Flver Bone", cc => cc.ColorHelperFlverBone, (cc, c) => cc.ColorHelperFlverBone = c);
                    HandleColor("Flver Bone Bounding Box", cc => cc.ColorHelperFlverBoneBoundingBox, (cc, c) => cc.ColorHelperFlverBoneBoundingBox = c);
                    HandleColor("Sound Event", cc => cc.ColorHelperSoundEvent, (cc, c) => cc.ColorHelperSoundEvent = c);
                    HandleColor("DummyPoly", cc => cc.ColorHelperDummyPoly, (cc, c) => cc.ColorHelperDummyPoly     = c);



                    ImGui.Text("Event Simulation");

                    HandleColor("Hitbox (Tip/Default)", cc => cc.ColorHelperHitboxTip, (cc, c) => cc.ColorHelperHitboxTip  = c);
                    HandleColor("Hitbox (Middle)", cc => cc.ColorHelperHitboxMiddle, (cc, c) => cc.ColorHelperHitboxMiddle = c);
                    HandleColor("Hitbox (Root)", cc => cc.ColorHelperHitboxRoot, (cc, c) => cc.ColorHelperHitboxRoot       = c);

                    HandleColor("DummyPoly SFX Only Spawn", cc => cc.ColorHelperDummyPolySpawnSFX, (cc, c) => cc.ColorHelperDummyPolySpawnSFX = c);
                    HandleColor("DummyPoly Bullet/Misc Only Spawn", cc => cc.ColorHelperDummyPolySpawnBulletsMisc, (cc, c) => cc.ColorHelperDummyPolySpawnBulletsMisc        = c);
                    HandleColor("DummyPoly SFX + Bullet/Misc Spawn", cc => cc.ColorHelperDummyPolySpawnSFXBulletsMisc, (cc, c) => cc.ColorHelperDummyPolySpawnSFXBulletsMisc = c);



                    ImGui.Button("Reset All Colors to Default");
                    if (ImGui.IsItemClicked())
                    {
                        if (System.Windows.Forms.MessageBox.Show("Reset all to default, losing any custom colors?",
                                                                 "Reset All?", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            foreach (var kvp in DefaultColorValueActions)
                            {
                                kvp.Value.Invoke();
                            }
                        }
                    }

                    ImGui.TreePop();
                }

                if (Scene.Models.Count > 0 && Scene.Models[0].ChrAsm != null)
                {
                    if (RequestExpandAllTreeNodes)
                    {
                        ImGui.SetNextItemOpen(true);
                    }

                    if (ImGui.TreeNode("[c0000 Parts Animations]"))
                    {
                        void DoWeapon(NewAnimationContainer wpnAnimContainer, string nameStr)
                        {
                            if (wpnAnimContainer == null)
                            {
                                return;
                            }

                            string[] animNames   = wpnAnimContainer.Animations.Keys.ToArray();
                            int      curItem     = wpnAnimContainer.CurrentAnimationName == null ? -1 : animNames.ToList().IndexOf(wpnAnimContainer.CurrentAnimationName);
                            int      prevSelItem = curItem;

                            ImGui.ListBox(nameStr, ref curItem, animNames, animNames.Length);
                            if (curItem != prevSelItem)
                            {
                                wpnAnimContainer.CurrentAnimationName = curItem >= 0 ? animNames[curItem] : null;
                            }
                        }

                        DoWeapon(Scene.Models[0].ChrAsm?.RightWeaponModel0?.AnimContainer, "R WPN Model 0");
                        DoWeapon(Scene.Models[0].ChrAsm?.RightWeaponModel1?.AnimContainer, "R WPN Model 1");
                        DoWeapon(Scene.Models[0].ChrAsm?.RightWeaponModel2?.AnimContainer, "R WPN Model 2");
                        DoWeapon(Scene.Models[0].ChrAsm?.RightWeaponModel3?.AnimContainer, "R WPN Model 3");
                        DoWeapon(Scene.Models[0].ChrAsm?.LeftWeaponModel0?.AnimContainer, "L WPN Model 0");
                        DoWeapon(Scene.Models[0].ChrAsm?.LeftWeaponModel1?.AnimContainer, "L WPN Model 1");
                        DoWeapon(Scene.Models[0].ChrAsm?.LeftWeaponModel2?.AnimContainer, "L WPN Model 2");
                        DoWeapon(Scene.Models[0].ChrAsm?.LeftWeaponModel3?.AnimContainer, "L WPN Model 3");
                        ImGui.TreePop();
                    }
                }

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Animation Overlays]"))
                {
                    if (Scene.Models.Count >= 1 && Scene.Models[0].AnimContainer != null)
                    {
                        lock (Scene.Models[0].AnimContainer._lock_AdditiveOverlays)
                        {
                            bool requestReset = false;
                            foreach (var overlay in Scene.Models[0].AnimContainer.AdditiveBlendOverlays)
                            {
                                bool selected     = overlay.Weight >= 0;
                                bool prevSelected = selected;
                                ImGui.Selectable(overlay.Name, ref selected);

                                if (selected)
                                {
                                    if (overlay.Weight < 0)
                                    {
                                        overlay.Weight = 1;
                                    }

                                    float weight = overlay.Weight;
                                    ImGui.SliderFloat(overlay.Name + " Weight", ref weight, 0, 10);
                                    overlay.Weight = weight;
                                }
                                else
                                {
                                    overlay.Weight = -1;
                                    overlay.Reset();
                                }

                                if (selected != prevSelected)
                                {
                                    requestReset = true;
                                }
                            }

                            if (requestReset)
                            {
                                foreach (var overlay in Scene.Models[0].AnimContainer.AdditiveBlendOverlays)
                                {
                                    overlay.Reset();
                                }
                            }
                        }
                    }
                    ImGui.TreePop();
                }


                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[DummyPoly]"))
                {
                    lock (Scene._lock_ModelLoad_Draw)
                    {
                        if (Scene.Models.Count > 0 && Scene.Models[0].DummyPolyMan != null)
                        {
                            bool wasAnyDmyForceVis = false;

                            void DoDummyPolyManager(NewDummyPolyManager dmyPolyMan, string dmyPolyGroupName)
                            {
                                if (dmyPolyMan == null)
                                {
                                    return;
                                }

                                if (RequestExpandAllTreeNodes)
                                {
                                    ImGui.SetNextItemOpen(true);
                                }

                                if (ImGui.TreeNode(dmyPolyGroupName))
                                {
                                    foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                    {
                                        if (dmyPolyMan.DummyPolyVisibleByRefID.ContainsKey(kvp.Key))
                                        {
                                            bool dmyVis = dmyPolyMan.DummyPolyVisibleByRefID[kvp.Key];

                                            bool highlightColor = NewDummyPolyManager.GlobalForceDummyPolyIDVisible == (dmyPolyMan.GlobalDummyPolyIDOffset + kvp.Key);

                                            if (highlightColor)
                                            {
                                                ImGui.PushStyleColor(ImGuiCol.WindowBg, new System.Numerics.Vector4(0, 1, 1, 1));
                                            }


                                            //ImGui.Checkbox($"{kvp.Key} ({kvp.Value.Count}x)                                       ", ref dmyVis);

                                            ImGui.Selectable($"{dmyPolyMan.GlobalDummyPolyIDPrefix}{kvp.Key} ({kvp.Value.Count}x)                                       ", ref dmyVis);

                                            dmyPolyMan.SetDummyPolyVisibility(kvp.Key, dmyVis);
                                            if (!wasAnyDmyForceVis && ImGui.IsItemHovered())
                                            {
                                                wasAnyDmyForceVis = true;
                                                NewDummyPolyManager.GlobalForceDummyPolyIDVisible = (dmyPolyMan.GlobalDummyPolyIDOffset + kvp.Key);
                                            }

                                            if (highlightColor)
                                            {
                                                ImGui.PopStyleColor();
                                            }
                                        }
                                    }

                                    ImGui.Button($"{dmyPolyMan.GlobalDummyPolyIDPrefix}Show All");
                                    if (ImGui.IsItemClicked())
                                    {
                                        foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                        {
                                            dmyPolyMan.SetDummyPolyVisibility(kvp.Key, true);
                                        }
                                    }

                                    ImGui.Button($"{dmyPolyMan.GlobalDummyPolyIDPrefix}Hide All");
                                    if (ImGui.IsItemClicked())
                                    {
                                        foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                        {
                                            dmyPolyMan.SetDummyPolyVisibility(kvp.Key, false);
                                        }
                                    }

                                    ImGui.Button($"{dmyPolyMan.GlobalDummyPolyIDPrefix}Invert All");
                                    if (ImGui.IsItemClicked())
                                    {
                                        foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                        {
                                            dmyPolyMan.SetDummyPolyVisibility(kvp.Key, !dmyPolyMan.DummyPolyVisibleByRefID[kvp.Key]);
                                        }
                                    }

                                    ImGui.TreePop();
                                }

                                ImGui.Separator();
                            }

                            DoDummyPolyManager(Scene.Models[0].DummyPolyMan, "Body");

                            if (Scene.Models[0].ChrAsm != null)
                            {
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.RightWeaponModel0?.DummyPolyMan, "Right Weapon Model 0");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.RightWeaponModel1?.DummyPolyMan, "Right Weapon Model 1");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.RightWeaponModel2?.DummyPolyMan, "Right Weapon Model 2");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.RightWeaponModel3?.DummyPolyMan, "Right Weapon Model 3");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.LeftWeaponModel0?.DummyPolyMan, "Left Weapon Model 0");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.LeftWeaponModel1?.DummyPolyMan, "Left Weapon Model 1");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.LeftWeaponModel2?.DummyPolyMan, "Left Weapon Model 2");
                                DoDummyPolyManager(Scene.Models[0].ChrAsm?.LeftWeaponModel3?.DummyPolyMan, "Left Weapon Model 3");
                            }

                            if (!wasAnyDmyForceVis)
                            {
                                NewDummyPolyManager.GlobalForceDummyPolyIDVisible = -1;
                            }

                            //ImGui.Separator();

                            void DummyOperationShowAll(NewDummyPolyManager dmyPolyMan)
                            {
                                if (dmyPolyMan == null)
                                {
                                    return;
                                }
                                foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                {
                                    dmyPolyMan.SetDummyPolyVisibility(kvp.Key, true);
                                }
                            }

                            void DummyOperationHideAll(NewDummyPolyManager dmyPolyMan)
                            {
                                if (dmyPolyMan == null)
                                {
                                    return;
                                }
                                foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                {
                                    dmyPolyMan.SetDummyPolyVisibility(kvp.Key, false);
                                }
                            }

                            void DummyOperationInvertAll(NewDummyPolyManager dmyPolyMan)
                            {
                                if (dmyPolyMan == null)
                                {
                                    return;
                                }
                                foreach (var kvp in dmyPolyMan.DummyPolyByRefID)
                                {
                                    dmyPolyMan.SetDummyPolyVisibility(kvp.Key, !dmyPolyMan.DummyPolyVisibleByRefID[kvp.Key]);
                                }
                            }

                            ImGui.Button("Global - Show All");
                            if (ImGui.IsItemClicked())
                            {
                                DummyOperationShowAll(Scene.Models[0].DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.RightWeaponModel0?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.RightWeaponModel1?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.RightWeaponModel2?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.RightWeaponModel3?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.LeftWeaponModel0?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.LeftWeaponModel1?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.LeftWeaponModel2?.DummyPolyMan);
                                DummyOperationShowAll(Scene.Models[0].ChrAsm?.LeftWeaponModel3?.DummyPolyMan);
                            }

                            ImGui.Button("Global - Hide All");
                            if (ImGui.IsItemClicked())
                            {
                                DummyOperationHideAll(Scene.Models[0].DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.RightWeaponModel0?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.RightWeaponModel1?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.RightWeaponModel2?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.RightWeaponModel3?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.LeftWeaponModel0?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.LeftWeaponModel1?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.LeftWeaponModel2?.DummyPolyMan);
                                DummyOperationHideAll(Scene.Models[0].ChrAsm?.LeftWeaponModel3?.DummyPolyMan);
                            }

                            ImGui.Button("Global - Invert All");
                            if (ImGui.IsItemClicked())
                            {
                                DummyOperationInvertAll(Scene.Models[0].DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.RightWeaponModel0?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.RightWeaponModel1?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.RightWeaponModel2?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.RightWeaponModel3?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.LeftWeaponModel0?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.LeftWeaponModel1?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.LeftWeaponModel2?.DummyPolyMan);
                                DummyOperationInvertAll(Scene.Models[0].ChrAsm?.LeftWeaponModel3?.DummyPolyMan);
                            }
                        }
                    }


                    ImGui.TreePop();
                }

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Lighting]"))
                {
                    ImGui.Checkbox("Auto Light Spin", ref GFX.FlverAutoRotateLight);

                    if (!GFX.FlverAutoRotateLight)
                    {
                        ImGui.Checkbox("Light Follows Camera", ref GFX.FlverLightFollowsCamera);

                        DoTooltip("Light Follows Camera", "Makes the light always point forward from the camera. " +
                                  "\nOnly works if Auto Light Spin is turned off.");

                        ImGui.SliderFloat("Light H", ref GFX.World.LightRotationH, -MathHelper.Pi, MathHelper.Pi);

                        DoTooltip("Light Horizontal Movement", "Turns the light left/right. " +
                                  "\nOnly works if both Auto Light Spin and Light " +
                                  "\nFollows Camera are turned off.");

                        ImGui.SliderFloat("Light V", ref GFX.World.LightRotationV, -MathHelper.PiOver2, MathHelper.PiOver2);

                        DoTooltip("Light Vertical Movement", "Turns the light up/down. " +
                                  "\nOnly works if both Auto Light Spin and Light " +
                                  "\nFollows Camera are turned off.");

                        //if (!GFX.FlverLightFollowsCamera)
                        //{
                        //    ImGui.SliderFloat("Light H", ref GFX.World.LightRotationH, -MathHelper.Pi, MathHelper.Pi);

                        //    DoTooltip("Light Horizontal Movement", "Turns the light left/right. " +
                        //        "\nOnly works if both Auto Light Spin and Light " +
                        //        "\nFollows Camera are turned off.");

                        //    ImGui.SliderFloat("Light V", ref GFX.World.LightRotationV, -MathHelper.PiOver2, MathHelper.PiOver2);

                        //    DoTooltip("Light Vertical Movement", "Turns the light up/down. " +
                        //        "\nOnly works if both Auto Light Spin and Light " +
                        //        "\nFollows Camera are turned off.");
                        //}
                        //else
                        //{
                        //    ImGui.LabelText("Light H", "(Disabled)");

                        //    DoTooltip("Light Horizontal Movement", "Turns the light left/right. " +
                        //        "\nOnly works if both Auto Light Spin and Light " +
                        //        "\nFollows Camera are turned off.");

                        //    ImGui.LabelText("Light V", "(Disabled)");

                        //    DoTooltip("Light Vertical Movement", "Turns the light up/down. " +
                        //       "\nOnly works if both Auto Light Spin and Light " +
                        //       "\nFollows Camera are turned off.");
                        //}
                    }
                    else
                    {
                        ImGui.LabelText("Light Follows Camera", "(Disabled)");

                        DoTooltip("Light Follows Camera", "Makes the light always point forward from the camera. " +
                                  "\nOnly works if Auto Light Spin is turned off.");

                        ImGui.LabelText("Light H", "(Disabled)");

                        DoTooltip("Light Horizontal Movement", "Turns the light left/right. " +
                                  "\nOnly works if both Auto Light Spin and Light " +
                                  "\nFollows Camera are turned off.");

                        ImGui.LabelText("Light V", "(Disabled)");

                        DoTooltip("Light Vertical Movement", "Turns the light up/down. " +
                                  "\nOnly works if both Auto Light Spin and Light " +
                                  "\nFollows Camera are turned off.");
                    }



                    ImGui.SliderFloat("Direct Light Mult", ref Environment.FlverDirectLightMult, 0, 3);

                    DoTooltip("Direct Light Multiplier", "Multiplies the brightness of light reflected directly off" +
                              "\nthe surface of the model.");

                    ImGui.SliderFloat("Specular Power Mult", ref GFX.SpecularPowerMult, 1, 8);
                    ImGui.SliderFloat("Indirect Light Mult", ref Environment.FlverIndirectLightMult, 0, 3);

                    DoTooltip("Indirect Light Multiplier", "Multiplies the brightness of environment map lighting reflected");

                    ImGui.SliderFloat("Emissive Light Mult", ref Environment.FlverEmissiveMult, 0, 3);

                    DoTooltip("Emissive Light Multiplier", "Multiplies the brightness of light emitted by the model's " +
                              "\nemissive texture map, if applicable.");

                    ImGui.SliderFloat("Brightness", ref Environment.FlverSceneBrightness, 0, 5);
                    ImGui.SliderFloat("Contrast", ref Environment.FlverSceneContrast, 0, 1);
                    //ImGui.SliderFloat("LdotN Power", ref GFX.LdotNPower, 0, 1);

                    //if (ImGui.TreeNode("Cubemap Select"))
                    //{
                    //    ImGui.ListBox("Cubemap",
                    //        ref Environment.CubemapNameIndex, Environment.CubemapNames,
                    //        Environment.CubemapNames.Length, Environment.CubemapNames.Length);

                    //    ImGui.TreePop();
                    //}



                    //ImGui.BeginGroup();

                    //{
                    //    //ImGui.ListBoxHeader("TEST HEADER", Environment.CubemapNames.Length, Environment.CubemapNames.Length);


                    //    //ImGui.ListBoxFooter();
                    //}


                    //ImGui.EndGroup();


                    ImGui.Checkbox("Show Cubemap As Skybox", ref Environment.DrawCubemap);

                    DoTooltip("Show Cubemap As Skybox", "Draws the environment map as the sky behind the model.");

                    ImGui.Separator();
                    ImGui.Button("Reset All");
                    if (ImGui.IsItemClicked())
                    {
                        GFX.FlverAutoRotateLight    = false;
                        GFX.FlverLightFollowsCamera = true;

                        GFX.World.LightRotationH = 1.7f;
                        GFX.World.LightRotationV = 0;

                        Environment.FlverDirectLightMult   = 0.65f;
                        Environment.FlverIndirectLightMult = 0.65f;
                        Environment.FlverEmissiveMult      = 1;
                        Environment.FlverSceneBrightness   = 1;
                        Environment.FlverSceneContrast     = 0.6f;

                        GFX.LdotNPower        = 0.1f;
                        GFX.SpecularPowerMult = 1;

                        Environment.DrawCubemap = true;
                    }
                    ImGui.Separator();

                    //ImGui.LabelText(" ", " ");
                    ImGui.ListBox("Cubemap",
                                  ref Environment.CubemapNameIndex, Environment.CubemapNames,
                                  Environment.CubemapNames.Length);

                    ImGui.TreePop();
                }

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Shader]"))
                {
                    ImGui.Checkbox("Enable Texture Alphas", ref GFX.FlverEnableTextureAlphas);
                    ImGui.Checkbox("Use Fancy Texture Alphas", ref GFX.FlverUseFancyAlpha);
                    ImGui.SliderFloat("Fancy Texture Alpha Cutoff", ref GFX.FlverFancyAlphaEdgeCutoff, 0, 1);
                    ImGui.Checkbox("Enable Texture Blending", ref GFX.FlverEnableTextureBlending);

                    ImGui.LabelText(" ", "Shading Mode:");

                    DoTooltip("Shading Mode", "The shading mode to use for the 3D rendering. " +
                              "\nSome of the modes are only here for testing purposes.");
                    ImGui.PushItemWidth(256 * Main.DPIX);
                    ImGui.ListBox(" ",
                                  ref GFX.ForcedFlverShadingModeIndex, GFX.FlverShadingModeNamesList,
                                  GFX.FlverShadingModeNamesList.Length);

                    ImGui.Separator();
                    ImGui.Button("Reset All");
                    if (ImGui.IsItemClicked())
                    {
                        GFX.FlverEnableTextureAlphas    = true;
                        GFX.FlverEnableTextureBlending  = true;
                        GFX.ForcedFlverShadingModeIndex = 0;
                    }

                    ImGui.PopItemWidth();

                    ImGui.TreePop();
                }


                ImGui.Separator();


                //ImGui.LabelText("", "DISPLAY");

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Display]"))
                {
                    ImGui.Button(GFX.Display.Vsync ? "[V-SYNC: ON]" : "[V-SYNC: OFF]");
                    if (ImGui.IsItemClicked())
                    {
                        GFX.Display.Vsync      = !GFX.Display.Vsync;
                        GFX.Display.Width      = GFX.Device.Viewport.Width;
                        GFX.Display.Height     = GFX.Device.Viewport.Height;
                        GFX.Display.Fullscreen = false;
                        GFX.Display.Apply();
                    }

                    //ImGui.DragInt("Cam Mouse Tick Rate", ref WorldView.BGUpdateWaitMS, 0.5f, 1, 1000, "%dx ms");

                    //DoTooltip("Camera Mouse Input Tick Rate", "Milliseconds to wait between mouse input updates. " +
                    //    "\nLower this if mouse movement looks choppy or raise if it's using too much CPU.");

                    ImGui.PushItemWidth(100 * Main.DPIX);
                    {
                        if (ImGui.SliderInt("MSAA (SSAA must be off)", ref GFX.MSAA, 1, 8, GFX.MSAA > 1 ? "%dx" : "Off"))
                        {
                            Main.RequestViewportRenderTargetResolutionChange = true;
                        }
                        DoTooltip("MSAA", "Multi-sample antialiasing. Only works if SSAA is set to Off " +
                                  "\ndue to a bug in MonoGame's RenderTarget causing a crash with both mipmaps " +
                                  "\nand MSAA enabled (SSAA requires mipmaps).");

                        if (ImGui.SliderInt("SSAA (VRAM hungry)", ref GFX.SSAA, 1, 4, GFX.SSAA > 1 ? "%dx" : "Off"))
                        {
                            Main.RequestViewportRenderTargetResolutionChange = true;
                        }
                        DoTooltip("SSAA", "Super-sample antialiasing. " +
                                  "\nRenders at a higher resolution giving very crisp antialiasing." +
                                  "\nHas very high VRAM usage. Disables MSAA due to a bug in MonoGame's " +
                                  "\nRenderTarget causing a crash with both mipmaps and MSAA enabled " +
                                  "\n(SSAA requires mipmaps).");
                    }
                    ImGui.PopItemWidth();


                    ImGui.Checkbox("Show Grid", ref DBG.ShowGrid);
                    ImGui.SliderFloat("Vertical FOV", ref GFX.World.FieldOfView, 1, 160);

                    ImGui.SliderFloat("Near Clip Dist", ref GFX.World.NearClipDistance, 0.001f, 1);
                    DoTooltip("Near Clipping Distance", "Distance for the near clipping plane. " +
                              "\nSetting it too high will cause geometry to disappear when near the camera. " +
                              "\nSetting it too low will cause geometry to flicker or render with " +
                              "the wrong depth when very far away from the camera.");

                    ImGui.SliderFloat("Far Clip Dist", ref GFX.World.FarClipDistance, 1000, 100000);
                    DoTooltip("Far Clipping Distance", "Distance for the far clipping plane. " +
                              "\nSetting it too low will cause geometry to disappear when far from the camera. " +
                              "\nSetting it too high will cause geometry to flicker or render with " +
                              "the wrong depth when near the camera.");

                    ImGui.Separator();
                    ImGui.Button("Reset All");
                    if (ImGui.IsItemClicked())
                    {
                        DBG.ShowGrid               = true;
                        GFX.World.FieldOfView      = 43;
                        GFX.World.NearClipDistance = 0.1f;
                        GFX.World.FarClipDistance  = 10000;

                        GFX.Display.Vsync      = true;
                        GFX.Display.Width      = GFX.Device.Viewport.Width;
                        GFX.Display.Height     = GFX.Device.Viewport.Height;
                        GFX.Display.Fullscreen = false;
                        GFX.Display.Apply();

                        GFX.MSAA = 2;
                        GFX.SSAA = 1;

                        Main.RequestViewportRenderTargetResolutionChange = true;
                    }


                    ImGui.TreePop();
                }

                ImGui.Separator();

                if (RequestExpandAllTreeNodes)
                {
                    ImGui.SetNextItemOpen(true);
                }

                if (ImGui.TreeNode("[Controls]"))
                {
                    ImGui.SliderFloat("Camera Move Speed", ref GFX.World.CameraMoveSpeed, 0.1f, 10);
                    ImGui.SliderFloat("Camera Turn Speed", ref GFX.World.CameraTurnSpeedMouse, 0.001f, 2);
                    ImGui.Separator();
                    ImGui.Button("Reset All");
                    if (ImGui.IsItemClicked())
                    {
                        GFX.World.CameraMoveSpeed      = 1;
                        GFX.World.CameraTurnSpeedMouse = 1;
                    }


                    ImGui.TreePop();
                }


                Focused = ImGui.IsWindowFocused() || ImGui.IsAnyItemFocused();

                if (ImGui.IsWindowHovered() || ImGui.IsAnyItemHovered())
                {
                    Focused = true;
                    ImGui.SetWindowFocus();
                }



                var pos  = ImGui.GetWindowPos();
                var size = ImGui.GetWindowSize();

                ImGui.PopItemWidth();
            }
            ImGui.End();

            RequestExpandAllTreeNodes = false;

            if (!hoveringOverAnythingThisFrame)
            {
                tooltipTimer       = 0;
                desiredTooltipText = null;
                currentHoverIDKey  = null;
            }
            else
            {
                if (currentHoverIDKey != prevHoverIDKey)
                {
                    tooltipTimer = 0;

                    tooltipHelper.Update(false, 0);
                }

                //if (currentHoverIDKey != null)
                //{
                //    if (tooltipTimer < TooltipDelay)
                //    {
                //        tooltipTimer += elapsedTime;
                //    }
                //    else
                //    {
                //        ImGui.SetTooltip(desiredTooltipText);
                //    }
                //}
            }

            var mousePos = ImGui.GetMousePos();

            tooltipHelper.DrawPosition = new Vector2(mousePos.X + offsetX + 16, mousePos.Y + offsetY + 16);

            tooltipHelper.Update(currentHoverIDKey != null, elapsedTime);

            tooltipHelper.UpdateTooltip(Main.WinForm, currentHoverIDKey, desiredTooltipText);

            prevHoverIDKey = currentHoverIDKey;

            ImGui.PopStyleColor();

            IsFirstFrameCaptureDefaultValue = false;
        }
예제 #14
0
        public void Draw(ref bool isGameViewFocused)
        {
            var viewport = ImGui.GetMainViewport();

            ImGui.SetNextWindowPos(viewport.WorkPos);
            ImGui.SetNextWindowSize(viewport.WorkSize);
            ImGui.SetNextWindowViewport(viewport.ID);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);

            var windowFlags = ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoDocking;

            windowFlags |= ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
            windowFlags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoNavFocus;
            //windowFlags |= ImGuiWindowFlags.NoBackground;

            ImGui.Begin("Root", windowFlags);

            ImGui.PopStyleVar(3);

            ImGui.DockSpace(ImGui.GetID("DockSpace"), Vector2.Zero, ImGuiDockNodeFlags.None);

            float menuBarHeight = 0;

            if (ImGui.BeginMenuBar())
            {
                menuBarHeight = ImGui.GetWindowHeight();

                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Jump"))
                {
                    if (ImGui.BeginMenu("Faction: " + _faction?.Side ?? "<null reference>"))
                    {
                        foreach (var side in _playableSides)
                        {
                            if (ImGui.MenuItem(side.Side))
                            {
                                _faction = side;
                                ImGui.SetWindowFocus(side.Name);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Map: " + _map.Item2))
                    {
                        foreach (var mapCache in _maps)
                        {
                            if (ImGui.MenuItem(mapCache.Value))
                            {
                                _map = (mapCache.Key, mapCache.Value);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.Button("Go!"))
                    {
                        var random   = new Random();
                        var faction2 = _playableSides[random.Next(0, _playableSides.Count())];

                        if (_map.Item1.IsMultiplayer)
                        {
                            _context.Game.StartSkirmishOrMultiPlayerGame(
                                _map.Item1.Name,
                                new EchoConnection(),
                                new PlayerSetting[]
                            {
                                new PlayerSetting(1, $"Faction{_faction.Side}", new ColorRgb(255, 0, 0), 0, PlayerOwner.Player),
                                new PlayerSetting(2, $"Faction{faction2.Side}", new ColorRgb(255, 255, 255), 0, PlayerOwner.EasyAi),
                            },
                                Environment.TickCount,
                                false
                                );
                        }
                        else
                        {
                            _context.Game.StartSinglePlayerGame(_map.Item1.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Windows"))
                {
                    foreach (var view in _views)
                    {
                        if (ImGui.MenuItem(view.DisplayName, null, view.IsVisible, true))
                        {
                            view.IsVisible = true;

                            ImGui.SetWindowFocus(view.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Preferences"))
                {
                    var isVSyncEnabled = _context.Game.GraphicsDevice.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true))
                    {
                        _context.Game.GraphicsDevice.SyncToVerticalBlank = isVSyncEnabled;
                    }
                    var isFullscreen = _context.Window.Fullscreen;
                    if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true))
                    {
                        _context.Window.Fullscreen = isFullscreen;
                    }
                    ImGui.EndMenu();
                }

                if (_context.Game.Configuration.UseRenderDoc && ImGui.BeginMenu("RenderDoc"))
                {
                    var renderDoc         = Game.RenderDoc;
                    var isRenderDocActive = renderDoc != null;

                    if (ImGui.MenuItem("Trigger Capture", isRenderDocActive))
                    {
                        renderDoc.TriggerCapture();
                    }
                    if (ImGui.BeginMenu("Options", isRenderDocActive))
                    {
                        bool allowVsync = renderDoc.AllowVSync;
                        if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                        {
                            renderDoc.AllowVSync = allowVsync;
                        }
                        bool validation = renderDoc.APIValidation;
                        if (ImGui.Checkbox("API Validation", ref validation))
                        {
                            renderDoc.APIValidation = validation;
                        }
                        int delayForDebugger = (int)renderDoc.DelayForDebugger;
                        if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                        {
                            delayForDebugger           = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                            renderDoc.DelayForDebugger = (uint)delayForDebugger;
                        }
                        bool verifyBufferAccess = renderDoc.VerifyBufferAccess;
                        if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                        {
                            renderDoc.VerifyBufferAccess = verifyBufferAccess;
                        }
                        bool overlayEnabled = renderDoc.OverlayEnabled;
                        if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                        {
                            renderDoc.OverlayEnabled = overlayEnabled;
                        }
                        bool overlayFrameRate = renderDoc.OverlayFrameRate;
                        if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                        {
                            renderDoc.OverlayFrameRate = overlayFrameRate;
                        }
                        bool overlayFrameNumber = renderDoc.OverlayFrameNumber;
                        if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                        {
                            renderDoc.OverlayFrameNumber = overlayFrameNumber;
                        }
                        bool overlayCaptureList = renderDoc.OverlayCaptureList;
                        if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                        {
                            renderDoc.OverlayCaptureList = overlayCaptureList;
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.MenuItem("Launch Replay UI", isRenderDocActive))
                    {
                        renderDoc.LaunchReplayUI();
                    }

                    ImGui.EndMenu();
                }

                DrawTimingControls();

                var fpsText     = $"{ImGui.GetIO().Framerate:N2} FPS";
                var fpsTextSize = ImGui.CalcTextSize(fpsText).X;
                ImGui.SetCursorPosX(ImGui.GetContentRegionAvail().X - fpsTextSize);
                ImGui.Text(fpsText);

                ImGui.EndMenuBar();
            }

            foreach (var view in _views)
            {
                view.Draw(ref isGameViewFocused);
            }

            var launcherImage = _context.Game.LauncherImage;

            if (launcherImage != null)
            {
                var launcherImageMaxSize = new Vector2(150, 150);

                var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio(
                    new SizeF(launcherImage.Width, launcherImage.Height),
                    new Size((int)launcherImageMaxSize.X, (int)launcherImageMaxSize.Y));

                const int launcherImagePadding = 10;
                ImGui.SetNextWindowPos(new Vector2(
                                           _context.Window.ClientBounds.Width - launcherImageSize.Width - launcherImagePadding,
                                           menuBarHeight + launcherImagePadding));

                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
                ImGui.Begin("LauncherImage", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration);

                ImGui.Image(
                    _context.ImGuiRenderer.GetOrCreateImGuiBinding(_context.Game.GraphicsDevice.ResourceFactory, launcherImage),
                    new Vector2(launcherImageSize.Width, launcherImageSize.Height),
                    Vector2.Zero,
                    Vector2.One,
                    Vector4.One,
                    Vector4.Zero);

                ImGui.End();
                ImGui.PopStyleVar();
            }

            ImGui.End();
        }
예제 #15
0
 public static bool Checkbox(string labelString, bool boolValue, out bool outBool)
 {
     ImGui.Checkbox(labelString, ref boolValue);
     outBool = boolValue;
     return(boolValue);
 }
예제 #16
0
        public override void Draw()
        {
            bool doTabs = false;

            popups.Run();
            HardpointEditor();
            PartEditor();
            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetWindowContentRegionWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierarchyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                if (openTabs[2])
                {
                    SkeletonPanel();
                }
                if (openTabs[3])
                {
                    RenderPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            ViewerControls.DropdownButton("View Mode", ref viewMode, viewModes);
            ImGui.SameLine();
            ImGui.Checkbox("Background", ref doBackground);
            ImGui.SameLine();
            if (!(drawable is SphFile)) //Grid too small for planets lol
            {
                ImGui.Checkbox("Grid", ref showGrid);
                ImGui.SameLine();
            }
            if (hasVWire)
            {
                ImGui.Checkbox("VMeshWire", ref drawVMeshWire);
                ImGui.SameLine();
            }
            ImGui.Checkbox("Wireframe", ref doWireframe);
            DoViewport();
            //
            var camModes = (cameraPart != null) ? camModesCockpit : camModesNormal;

            ViewerControls.DropdownButton("Camera Mode", ref selectedCam, camModes);
            modelViewport.Mode = (CameraModes)(camModes[selectedCam].Tag);
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                ResetCamera();
            }
            ImGui.SameLine();
            //
            if (!(drawable is SphFile) && !(drawable is DF.DfmFile))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Level of Detail:");
                ImGui.SameLine();
                ImGui.Checkbox("Use Distance", ref useDistance);
                ImGui.SameLine();
                ImGui.PushItemWidth(-1);
                if (useDistance)
                {
                    ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f");
                }
                else
                {
                    ImGui.Combo("Level", ref level, levels, levels.Length);
                }
                ImGui.PopItemWidth();
            }
            ImGui.EndChild();

            if (_window.Config.ViewButtons)
            {
                ImGui.SetNextWindowPos(new Vector2(_window.Width - viewButtonsWidth, 90));
                ImGui.Begin("viewButtons#" + Unique, ImGuiWindowFlags.AlwaysAutoResize |
                            ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove);
                ImGui.Dummy(new Vector2(120, 2));
                ImGui.Columns(2, "##border", false);
                if (ImGui.Button("Top", new Vector2(55, 0)))
                {
                    modelViewport.GoTop();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Bottom", new Vector2(55, 0)))
                {
                    modelViewport.GoBottom();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Left", new Vector2(55, 0)))
                {
                    modelViewport.GoLeft();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Right", new Vector2(55, 0)))
                {
                    modelViewport.GoRight();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Front", new Vector2(55, 0)))
                {
                    modelViewport.GoFront();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Back", new Vector2(55, -1)))
                {
                    modelViewport.GoBack();
                }
                viewButtonsWidth = ImGui.GetWindowWidth() + 60;
                ImGui.End();
            }
        }
예제 #17
0
        public bool Draw()
        {
            var isOpen = true;

            try {
                var isSearch = false;
                if (pluginConfig.SelectedClientLanguage != plugin.LuminaItemsClientLanguage)
                {
                    UpdateItemList(1000);
                }


                if ((selectedItemIndex < 0 && selectedItem != null) || (selectedItemIndex >= 0 && selectedItem == null))
                {
                    // Should never happen, but just incase
                    selectedItemIndex = -1;
                    selectedItem      = null;
                    return(true);
                }

                ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);

                PushStyle(ImGuiStyleVar.WindowMinSize, new Vector2(350, 400));

                if (!ImGui.Begin(Loc.Localize("ItemSearchPlguinMainWindowHeader", "Item Search") + "###itemSearchPluginMainWindow", ref isOpen, ImGuiWindowFlags.NoCollapse))
                {
                    ResetStyle();
                    ImGui.End();
                    return(false);
                }

                PopStyle();

                // Main window
                ImGui.AlignTextToFramePadding();

                if (selectedItem != null)
                {
                    var icon = selectedItem.Icon;

                    if (icon < 65000)
                    {
                        if (textureDictionary.ContainsKey(icon))
                        {
                            var tex = textureDictionary[icon];
                            if (tex == null || tex.ImGuiHandle == IntPtr.Zero)
                            {
                                ImGui.PushStyleColor(ImGuiCol.Border, new Vector4(1, 0, 0, 1));
                                ImGui.BeginChild("FailedTexture", new Vector2(45, 45), true);
                                ImGui.Text(icon.ToString());
                                ImGui.EndChild();
                                ImGui.PopStyleColor();
                            }
                            else
                            {
                                ImGui.Image(textureDictionary[icon].ImGuiHandle, new Vector2(45, 45));
                            }
                        }
                        else
                        {
                            ImGui.BeginChild("WaitingTexture", new Vector2(45, 45), true);
                            ImGui.EndChild();

                            textureDictionary[icon] = null;

                            Task.Run(() => {
                                try {
                                    var iconTex = this.data.GetIcon(icon);
                                    var tex     = this.builder.LoadImageRaw(iconTex.GetRgbaImageData(), iconTex.Header.Width, iconTex.Header.Height, 4);
                                    if (tex != null && tex.ImGuiHandle != IntPtr.Zero)
                                    {
                                        textureDictionary[icon] = tex;
                                    }
                                } catch {
                                    // Ignore
                                }
                            });
                        }
                    }
                    else
                    {
                        ImGui.BeginChild("NoIcon", new Vector2(45, 45), true);
                        if (pluginConfig.ShowItemID)
                        {
                            ImGui.Text(icon.ToString());
                        }

                        ImGui.EndChild();
                    }


                    ImGui.SameLine();
                    ImGui.BeginGroup();

                    ImGui.Text(selectedItem.Name);

                    if (pluginConfig.ShowItemID)
                    {
                        ImGui.SameLine();
                        ImGui.Text($"(ID: {selectedItem.RowId}) (Rarity: {selectedItem.Rarity})");
                    }

                    var imGuiStyle    = ImGui.GetStyle();
                    var windowVisible = ImGui.GetWindowPos().X + ImGui.GetWindowContentRegionMax().X;

                    IActionButton[] buttons = this.ActionButtons.Where(ab => ab.ButtonPosition == ActionButtonPosition.TOP).ToArray();

                    for (var i = 0; i < buttons.Length; i++)
                    {
                        var button = buttons[i];

                        if (button.GetShowButton(selectedItem))
                        {
                            var buttonText = button.GetButtonText(selectedItem);
                            ImGui.PushID($"TopActionButton{i}");
                            if (ImGui.Button(buttonText))
                            {
                                button.OnButtonClicked(selectedItem);
                            }

                            if (i < buttons.Length - 1)
                            {
                                var lX2 = ImGui.GetItemRectMax().X;
                                var nbw = ImGui.CalcTextSize(buttons[i + 1].GetButtonText(selectedItem)).X + imGuiStyle.ItemInnerSpacing.X * 2;
                                var nX2 = lX2 + (imGuiStyle.ItemSpacing.X * 2) + nbw;
                                if (nX2 < windowVisible)
                                {
                                    ImGui.SameLine();
                                }
                            }

                            ImGui.PopID();
                        }
                    }

                    ImGui.EndGroup();
                }
                else
                {
                    ImGui.BeginChild("NoSelectedItemBox", new Vector2(200, 45));
                    ImGui.Text(Loc.Localize("ItemSearchSelectItem", "Please select an item."));
                    ImGui.EndChild();
                }

                ImGui.Separator();

                ImGui.Columns(2);
                var filterNameMax = SearchFilters.Where(x => x.IsEnabled && x.ShowFilter).Select(x => {
                    x._LocalizedName      = Loc.Localize(x.NameLocalizationKey, x.Name);
                    x._LocalizedNameWidth = ImGui.CalcTextSize($"{x._LocalizedName}").X;
                    return(x._LocalizedNameWidth);
                }).Max();

                ImGui.SetColumnWidth(0, filterNameMax + ImGui.GetStyle().ItemSpacing.X * 2);
                var filterInUseColour = new Vector4(0, 1, 0, 1);
                foreach (var filter in SearchFilters.Where(x => x.IsEnabled && x.ShowFilter))
                {
                    ImGui.SetCursorPosX((filterNameMax + ImGui.GetStyle().ItemSpacing.X) - filter._LocalizedNameWidth);
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
                    if (filter.IsSet)
                    {
                        ImGui.TextColored(filterInUseColour, $"{filter._LocalizedName}: ");
                    }
                    else
                    {
                        ImGui.Text($"{filter._LocalizedName}: ");
                    }

                    ImGui.NextColumn();
                    filter.DrawEditor();
                    while (ImGui.GetColumnIndex() != 0)
                    {
                        ImGui.NextColumn();
                    }
                }

                ImGui.Columns(1);
                var windowSize = ImGui.GetWindowSize();
                var childSize  = new Vector2(0, Math.Max(100, windowSize.Y - ImGui.GetCursorPosY() - 40));
                ImGui.BeginChild("scrolling", childSize, true, ImGuiWindowFlags.HorizontalScrollbar);

                PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

                if (errorLoadingItems)
                {
                    ImGui.TextColored(new Vector4(1f, 0.1f, 0.1f, 1.00f), Loc.Localize("ItemSearchListLoadFailed", "Error loading item list."));
                    if (ImGui.SmallButton("Retry"))
                    {
                        UpdateItemList();
                    }
                }
                else if (plugin.LuminaItems != null)
                {
                    if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.IsSet))
                    {
                        isSearch = true;
                        if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.HasChanged) || forceReload)
                        {
                            forceReload = false;
                            this.searchCancelTokenSource?.Cancel();
                            this.searchCancelTokenSource = new CancellationTokenSource();
                            var asyncEnum = plugin.LuminaItems.ToAsyncEnumerable();

                            if (!pluginConfig.ShowLegacyItems)
                            {
                                asyncEnum = asyncEnum.Where(x => x.RowId < 100 || x.RowId > 1600);
                            }

                            asyncEnum = SearchFilters.Where(filter => filter.IsEnabled && filter.ShowFilter && filter.IsSet).Aggregate(asyncEnum, (current, filter) => current.Where(filter.CheckFilter));
                            this.selectedItemIndex = -1;
                            selectedItem           = null;
                            this.searchTask        = asyncEnum.ToListAsync(this.searchCancelTokenSource.Token);
                        }

                        if (this.searchTask.IsCompletedSuccessfully)
                        {
                            var   itemSize   = Vector2.Zero;
                            float cursorPosY = 0;
                            var   scrollY    = ImGui.GetScrollY();
                            var   style      = ImGui.GetStyle();
                            for (var i = 0; i < this.searchTask.Result.Count; i++)
                            {
                                if (i == 0 && itemSize == Vector2.Zero)
                                {
                                    itemSize = ImGui.CalcTextSize(this.searchTask.Result[i].Name);
                                    if (!doSearchScroll)
                                    {
                                        var sizePerItem = itemSize.Y + style.ItemSpacing.Y;
                                        var skipItems   = (int)Math.Floor(scrollY / sizePerItem);
                                        cursorPosY = skipItems * sizePerItem;
                                        ImGui.SetCursorPosY(cursorPosY + style.ItemSpacing.X);
                                        i = skipItems;
                                    }
                                }

                                if (!(doSearchScroll && selectedItemIndex == i) && (cursorPosY < scrollY - itemSize.Y || cursorPosY > scrollY + childSize.Y))
                                {
                                    ImGui.SetCursorPosY(cursorPosY + itemSize.Y + style.ItemSpacing.Y);
                                }
                                else if (ImGui.Selectable(this.searchTask.Result[i].Name, this.selectedItemIndex == i, ImGuiSelectableFlags.AllowDoubleClick))
                                {
                                    this.selectedItem      = this.searchTask.Result[i];
                                    this.selectedItemIndex = i;

                                    if (ImGui.IsMouseDoubleClicked(0))
                                    {
                                        if (this.selectedItem != null && selectedItem.Icon < 65000)
                                        {
                                            try {
                                                plugin.LinkItem(selectedItem);
                                                if (pluginConfig.CloseOnChoose)
                                                {
                                                    isOpen = false;
                                                }
                                            } catch (Exception ex) {
                                                PluginLog.LogError(ex.ToString());
                                            }
                                        }
                                    }

                                    if ((autoTryOn = autoTryOn && pluginConfig.ShowTryOn) && plugin.FittingRoomUI.CanUseTryOn && pluginInterface.ClientState.LocalPlayer != null)
                                    {
                                        if (selectedItem.ClassJobCategory.Row != 0)
                                        {
                                            plugin.FittingRoomUI.TryOnItem(selectedItem);
                                        }
                                    }
                                }

                                if (doSearchScroll && selectedItemIndex == i)
                                {
                                    doSearchScroll = false;
                                    ImGui.SetScrollHereY(0.5f);
                                }

                                cursorPosY = ImGui.GetCursorPosY();

                                if (cursorPosY > scrollY + childSize.Y && !doSearchScroll)
                                {
                                    var c = this.searchTask.Result.Count - i;
                                    ImGui.BeginChild("###scrollFillerBottom", new Vector2(0, c * (itemSize.Y + style.ItemSpacing.Y)), false);
                                    ImGui.EndChild();
                                    break;
                                }
                            }

                            var keyStateDown = ImGui.GetIO().KeysDown[0x28] || pluginInterface.ClientState.KeyState[0x28];
                            var keyStateUp   = ImGui.GetIO().KeysDown[0x26] || pluginInterface.ClientState.KeyState[0x26];

#if DEBUG
                            // Random up/down if both are pressed
                            if (keyStateUp && keyStateDown)
                            {
                                debounceKeyPress = 0;

                                var r = new Random().Next(0, 5);

                                switch (r)
                                {
                                case 1:
                                    keyStateUp   = true;
                                    keyStateDown = false;
                                    break;

                                case 0:
                                    keyStateUp   = false;
                                    keyStateDown = false;
                                    break;

                                default:
                                    keyStateUp   = false;
                                    keyStateDown = true;
                                    break;
                                }
                            }
#endif

                            var hotkeyUsed = false;
                            if (keyStateUp && !keyStateDown)
                            {
                                if (debounceKeyPress == 0)
                                {
                                    debounceKeyPress = 5;
                                    if (selectedItemIndex > 0)
                                    {
                                        hotkeyUsed         = true;
                                        selectedItemIndex -= 1;
                                    }
                                }
                            }
                            else if (keyStateDown && !keyStateUp)
                            {
                                if (debounceKeyPress == 0)
                                {
                                    debounceKeyPress = 5;
                                    if (selectedItemIndex < searchTask.Result.Count - 1)
                                    {
                                        selectedItemIndex += 1;
                                        hotkeyUsed         = true;
                                    }
                                }
                            }
                            else if (debounceKeyPress > 0)
                            {
                                debounceKeyPress -= 1;
                                if (debounceKeyPress < 0)
                                {
                                    debounceKeyPress = 5;
                                }
                            }

                            if (hotkeyUsed)
                            {
                                doSearchScroll    = true;
                                this.selectedItem = this.searchTask.Result[selectedItemIndex];
                                if ((autoTryOn = autoTryOn && pluginConfig.ShowTryOn) && plugin.FittingRoomUI.CanUseTryOn && pluginInterface.ClientState.LocalPlayer != null)
                                {
                                    if (selectedItem.ClassJobCategory.Row != 0)
                                    {
                                        plugin.FittingRoomUI.TryOnItem(selectedItem);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectHint", "Type to start searching..."));

                        this.selectedItemIndex = -1;
                        selectedItem           = null;
                    }
                }
                else
                {
                    ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectLoading", "Loading item list..."));
                }

                PopStyle();

                ImGui.EndChild();

                // Darken choose button if it shouldn't be clickable
                PushStyle(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 || selectedItem == null || selectedItem.Icon >= 65000 ? 0.25f : 1);

                if (ImGui.Button(Loc.Localize("Choose", "Choose")))
                {
                    try {
                        if (selectedItem != null && selectedItem.Icon < 65000)
                        {
                            plugin.LinkItem(selectedItem);
                            if (pluginConfig.CloseOnChoose)
                            {
                                isOpen = false;
                            }
                        }
                    } catch (Exception ex) {
                        Log.Error($"Exception in Choose: {ex.Message}");
                    }
                }

                PopStyle();

                if (!pluginConfig.CloseOnChoose)
                {
                    ImGui.SameLine();
                    if (ImGui.Button(Loc.Localize("Close", "Close")))
                    {
                        selectedItem = null;
                        isOpen       = false;
                    }
                }

                if (this.selectedItemIndex >= 0 && this.selectedItem != null && selectedItem.Icon >= 65000)
                {
                    ImGui.SameLine();
                    ImGui.Text(Loc.Localize("DalamudItemNotLinkable", "This item is not linkable."));
                }

                if (pluginConfig.ShowTryOn && pluginInterface.ClientState.LocalPlayer != null)
                {
                    ImGui.SameLine();
                    ImGui.Checkbox(Loc.Localize("ItemSearchTryOnButton", "Try On"), ref autoTryOn);
                }

                var configText    = Loc.Localize("ItemSearchConfigButton", "Config");
                var itemCountText = isSearch ? string.Format(Loc.Localize("ItemCount", "{0} Items"), this.searchTask.Result.Count) : $"v{plugin.Version}";
                ImGui.SameLine(ImGui.GetWindowWidth() - (ImGui.CalcTextSize(configText).X + ImGui.GetStyle().ItemSpacing.X) - (ImGui.CalcTextSize(itemCountText).X + ImGui.GetStyle().ItemSpacing.X * 2));
                ImGui.Text(itemCountText);
                ImGui.SameLine(ImGui.GetWindowWidth() - (ImGui.CalcTextSize(configText).X + ImGui.GetStyle().ItemSpacing.X * 2));
                if (ImGui.Button(configText))
                {
                    plugin.ToggleConfigWindow();
                }

                ImGui.End();

                return(isOpen);
            } catch (Exception ex) {
                ResetStyle();
                PluginLog.LogError(ex.ToString());
                selectedItem      = null;
                selectedItemIndex = -1;
                return(isOpen);
            }
        }
예제 #18
0
        void HierarchyPanel()
        {
            if (!(drawable is DF.DfmFile) && !(drawable is SphFile))
            {
                //Sur
                if (ImGui.Button("Open Sur"))
                {
                    var file = FileDialog.Open(SurFilters);
                    surname = System.IO.Path.GetFileName(file);
                    LibreLancer.Physics.Sur.SurFile sur;
                    try
                    {
                        using (var f = System.IO.File.OpenRead(file))
                        {
                            sur = new LibreLancer.Physics.Sur.SurFile(f);
                        }
                    }
                    catch (Exception)
                    {
                        sur = null;
                    }
                    if (sur != null)
                    {
                        ProcessSur(sur);
                    }
                }
                if (surs != null)
                {
                    ImGui.Separator();
                    ImGui.Text("Sur: " + surname);
                    ImGui.Checkbox("Show Hull", ref surShowHull);
                    ImGui.Checkbox("Show Hardpoints", ref surShowHps);
                    ImGui.Separator();
                }
            }
            if (ImGuiExt.Button("Apply Hardpoints", _isDirtyHp))
            {
                if (drawable is ModelFile)
                {
                    hprefs.Nodes[0].HardpointsToNodes(vmsModel.Root.Hardpoints);
                }
                else if (drawable is CmpFile)
                {
                    foreach (var mdl in vmsModel.AllParts)
                    {
                        var node = hprefs.Nodes.First((x) => x.Name == mdl.Path);
                        node.HardpointsToNodes(mdl.Hardpoints);
                    }
                }
                if (_isDirtyHp)
                {
                    _isDirtyHp = false;
                    parent.DirtyCountHp--;
                }
                popups.OpenPopup("Apply Complete");
            }
            if (vmsModel.AllParts.Length > 1 && ImGuiExt.Button("Apply Parts", _isDirtyPart))
            {
                WriteConstructs();
                if (_isDirtyPart)
                {
                    _isDirtyPart = false;
                    parent.DirtyCountPart--;
                }
                popups.OpenPopup("Apply Complete##Parts");
            }
            if (ImGuiExt.ToggleButton("Filter", doFilter))
            {
                doFilter = !doFilter;
            }
            if (doFilter)
            {
                ImGui.InputText("##filter", filterText.Pointer, (uint)filterText.Size, ImGuiInputTextFlags.None, filterText.Callback);
                currentFilter = filterText.GetText();
            }
            else
            {
                currentFilter = null;
            }

            ImGui.Separator();
            if (selectedNode != null)
            {
                ImGui.Text(selectedNode.Construct.ChildName);
                ImGui.Text(selectedNode.Construct.GetType().Name);
                ImGui.Text("Origin: " + selectedNode.Construct.Origin.ToString());
                var euler = selectedNode.Construct.Rotation.GetEuler();
                ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                         MathHelper.RadiansToDegrees(euler.X),
                                         MathHelper.RadiansToDegrees(euler.Y),
                                         MathHelper.RadiansToDegrees(euler.Z)));
                ImGui.Separator();
            }

            if (!vmsModel.Root.Active)
            {
                var col = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled];
                ImGui.PushStyleColor(ImGuiCol.Text, col);
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
                if (vmsModel.Root.Children != null)
                {
                    foreach (var n in vmsModel.Root.Children)
                    {
                        DoConstructNode(n);
                    }
                }

                DoModel(vmsModel.Root);
                //if (!(drawable is SphFile)) DoModel(rootModel, null);
                ImGui.TreePop();
            }
            else
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
            }
        }
예제 #19
0
        public static unsafe void RenderDebug(string id, JsonValue parent, JsonValue root)
        {
            if (ImGui.TreeNode("Origin"))
            {
                var v      = new System.Numerics.Vector2((float)root["ox"].AsNumber * 3, (float)root["oy"].AsNumber * 3);
                var region = CommonAse.Items.GetSlice(id);
                var m      = ImGui.GetScrollY();
                var pos    = ImGui.GetWindowPos() + ImGui.GetCursorPos() - new System.Numerics.Vector2(0, m);

                if (ImGui.IsMouseDown(1))
                {
                    v = ImGui.GetMousePos() - pos;

                    if (!(v.X < 0) && !(v.Y < 0) && !(v.X > region.Width * 3) && !(v.Y > region.Height * 3))
                    {
                        if (snapGrid)
                        {
                            v.X = (float)(Math.Floor(v.X / 3) * 3);
                            v.Y = (float)(Math.Floor(v.Y / 3) * 3);
                        }

                        v.X = VelcroPhysics.Utilities.MathUtils.Clamp(v.X, 0, region.Width * 3);
                        v.Y = VelcroPhysics.Utilities.MathUtils.Clamp(v.Y, 0, region.Height * 3);

                        root["ox"] = v.X / 3f;
                        root["oy"] = v.Y / 3f;
                    }
                }

                ImGuiNative.ImDrawList_AddRect(ImGui.GetWindowDrawList(), pos - new System.Numerics.Vector2(1, 1),
                                               pos + new System.Numerics.Vector2(region.Width * 3 + 1, region.Height * 3 + 1),
                                               ColorUtils.WhiteColor.PackedValue, 0, 0, 1);

                ItemEditor.DrawItem(region);

                ImGuiNative.ImDrawList_AddCircleFilled(ImGui.GetWindowDrawList(), pos + v, 3, ColorUtils.WhiteColor.PackedValue,
                                                       8);

                v /= 3f;

                ImGui.Checkbox("Snap to grid", ref snapGrid);

                if (ImGui.InputFloat2("Origin", ref v))
                {
                    root["ox"] = v.X;
                    root["oy"] = v.Y;
                }

                if (ImGui.Button("tx"))
                {
                    root["ox"] = 0;
                }

                ImGui.SameLine();

                if (ImGui.Button("ty"))
                {
                    root["oy"] = 0;
                }

                if (ImGui.Button("cx"))
                {
                    root["ox"] = region.Width / 2f;
                }

                ImGui.SameLine();

                if (ImGui.Button("cy"))
                {
                    root["oy"] = region.Height / 2f;
                }

                if (ImGui.Button("bx"))
                {
                    root["ox"] = region.Width;
                }

                ImGui.SameLine();

                if (ImGui.Button("by"))
                {
                    root["oy"] = region.Height;
                }

                ImGui.TreePop();
            }

            if (ImGui.TreeNode("Nozzle"))
            {
                var v      = new System.Numerics.Vector2((float)root["nx"].AsNumber * 3, (float)root["ny"].AsNumber * 3);
                var region = CommonAse.Items.GetSlice(id);
                var m      = ImGui.GetScrollY();
                var pos    = ImGui.GetWindowPos() + ImGui.GetCursorPos() - new System.Numerics.Vector2(0, m);

                if (ImGui.IsMouseDown(1))
                {
                    v = ImGui.GetMousePos() - pos;

                    if (!(v.X < 0) && !(v.Y < 0) && !(v.X > region.Width * 3) && !(v.Y > region.Height * 3))
                    {
                        if (snapGrid)
                        {
                            v.X = (float)(Math.Floor(v.X / 3) * 3);
                            v.Y = (float)(Math.Floor(v.Y / 3) * 3);
                        }

                        v.X = VelcroPhysics.Utilities.MathUtils.Clamp(v.X, 0, region.Width * 3);
                        v.Y = VelcroPhysics.Utilities.MathUtils.Clamp(v.Y, 0, region.Height * 3);

                        root["nx"] = v.X / 3f;
                        root["ny"] = v.Y / 3f;
                    }
                }

                ImGuiNative.ImDrawList_AddRect(ImGui.GetWindowDrawList(), pos - new System.Numerics.Vector2(1, 1),
                                               pos + new System.Numerics.Vector2(region.Width * 3 + 1, region.Height * 3 + 1),
                                               ColorUtils.WhiteColor.PackedValue, 0, 0, 1);

                ItemEditor.DrawItem(region);

                ImGuiNative.ImDrawList_AddCircleFilled(ImGui.GetWindowDrawList(), pos + v, 3, ColorUtils.WhiteColor.PackedValue,
                                                       8);

                v /= 3f;

                ImGui.Checkbox("Snap to grid", ref snapGrid);

                if (ImGui.InputFloat2("Nozzle", ref v))
                {
                    root["nx"] = v.X;
                    root["ny"] = v.Y;
                }

                if (ImGui.Button("tx"))
                {
                    root["nx"] = 0;
                }

                ImGui.SameLine();

                if (ImGui.Button("ty"))
                {
                    root["ny"] = 0;
                }

                if (ImGui.Button("cx"))
                {
                    root["nx"] = region.Width / 2f;
                }

                ImGui.SameLine();

                if (ImGui.Button("cy"))
                {
                    root["ny"] = region.Height / 2f;
                }

                if (ImGui.Button("bx"))
                {
                    root["nx"] = region.Width;
                }

                ImGui.SameLine();

                if (ImGui.Button("by"))
                {
                    root["oy"] = region.Height;
                }

                ImGui.TreePop();
            }
        }
예제 #20
0
        private void DrawWindow()
        {
            if (_check)
            {
                var tempCastBar = _getUi2ObjByName(Marshal.ReadIntPtr(_getBaseUiObj(), 0x20), "_CastBar", 1);
                if (tempCastBar != IntPtr.Zero)
                {
                    _wait = 1000;
                    if (_config)
                    {
                        ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                        ImGui.Begin("SlideCast Config", ref _config);
                        ImGui.InputInt("Time (cs)", ref _slideTime);
                        ImGui.TextWrapped("The time for slidecasting is 50cs (half a second) by default.\n" +
                                          "Lower numbers make it later in the cast, higher numbers earlier in the cast.\n" +
                                          "Apart from missed packets, 50cs is the exact safe time to slidecast.");
                        ImGui.ColorEdit4("Bar Colour", ref _slideCol, ImGuiColorEditFlags.NoInputs);
                        ImGui.Checkbox("Enable Debug Mode", ref _debug);
                        ImGui.Separator();
                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();
                            _config = false;
                        }
                        ImGui.SameLine();
                        ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF);

                        if (ImGui.Button("Buy Haplo a Hot Chocolate"))
                        {
                            System.Diagnostics.Process.Start("https://ko-fi.com/haplo");
                        }
                        ImGui.PopStyleColor(3);
                        ImGui.End();
                    }

                    if (_enabled)
                    {
                        if (_castBar != tempCastBar)
                        {
                            _castBar = IntPtr.Zero;
                        }

                        if (_castBar != IntPtr.Zero)
                        {
                            _cbCastLast = _cbCastPer;
                            _cbX        = Marshal.ReadInt16(_castBar + 0x1BC);
                            _cbY        = Marshal.ReadInt16(_castBar + 0x1BE);
                            _cbScale    = Marshal.PtrToStructure <float>(_castBar + 0x1AC);
                            _cbCastTime = Marshal.ReadInt16(_castBar + 0x2BC);
                            _cbCastPer  = Marshal.PtrToStructure <float>(_castBar + 0x2C0);
                            var plus = 0;
                            _cbSpell = new List <byte>();

                            while (Marshal.ReadByte(_castBar + 0x242 + plus) != 0)
                            {
                                _cbSpell.Add(Marshal.ReadByte(_castBar + 0x242 + plus));
                                plus++;
                            }

                            if (_cbCastLast == _cbCastPer)
                            {
                                if (_cbCastSameCount < 5)
                                {
                                    _cbCastSameCount++;
                                }
                            }
                            else
                            {
                                _cbCastSameCount = 0;
                            }

                            if (_cbCastPer == 5)
                            {
                                _colS = new Colour(_col1S.R / 255f, _col1S.G / 255f, _col1S.B / 255f);
                            }

                            if (Marshal.ReadByte(_castBar + 0x182).ToString() != "84")
                            {
                                ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY));
                                ImGui.Begin("SlideCast", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);
                                ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale));
                                //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                                float slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime;
                                ImGui.GetWindowDrawList().AddRectFilled(
                                    new Num.Vector2(
                                        ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale),
                                        ImGui.GetWindowPos().Y + (20 * _cbScale)),
                                    new Num.Vector2(
                                        ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale),
                                        ImGui.GetWindowPos().Y + (29 * _cbScale)),
                                    ImGui.GetColorU32(_slideCol));
                                ImGui.End();
                            }
                        }
                        else
                        {
                            _castBar = tempCastBar;
                        }

                        if (_debug)
                        {
                            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY));
                            ImGui.Begin("SlideCast DEBUG", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar);
                            ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale));
                            //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                            var slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime;
                            ImGui.GetWindowDrawList().AddRectFilled(
                                new Num.Vector2(
                                    ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale),
                                    ImGui.GetWindowPos().Y + (20 * _cbScale)),
                                new Num.Vector2(
                                    ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale),
                                    ImGui.GetWindowPos().Y + (29 * _cbScale)),
                                ImGui.GetColorU32(_slideCol));
                            ImGui.End();

                            ImGui.Begin("Slidecast Debug Values");
                            ImGui.Text("cbX: " + _cbX);
                            ImGui.Text("cbY: " + _cbY);
                            ImGui.Text("cbS: " + _cbScale);
                            ImGui.Text("cbCastTime: " + _cbCastTime);
                            ImGui.Text("cbCastPer: " + _cbCastPer);
                            ImGui.Text("Mem Addr: " + _castBar.ToString("X"));
                            ImGui.Text(_colS.Hue.ToString());
                            ImGui.Text(_colS.Saturation.ToString());
                            ImGui.Text(_colS.Brightness.ToString());
                            ImGui.End();
                        }
                    }
                }
                else
                {
                    _check = false;
                }
            }

            if (_wait > 0)
            {
                _wait--;
            }
            else
            {
                _check = true;
            }
        }
        public void draw()
        {
            // check to see if we are still alive
            if (entity.isDestroyed)
            {
                Core.getGlobalManager <ImGuiManager>().stopInspectingEntity(this);
                return;
            }

            if (_shouldFocusWindow)
            {
                _shouldFocusWindow = false;
                ImGui.SetNextWindowFocus();
                ImGui.SetNextWindowCollapsed(false);
            }

            // every 60 frames we check for newly added Components and add them
            if (Time.frameCount % 60 == 0)
            {
                for (var i = 0; i < _entity.components.count; i++)
                {
                    var component = _entity.components[i];
                    if (_componentInspectors.Where(inspector => inspector.component != null && inspector.component == component).Count() == 0)
                    {
                        _componentInspectors.Insert(0, new ComponentInspector(component));
                    }
                }
            }

            ImGui.SetNextWindowSize(new Num.Vector2(335, 400), ImGuiCond.FirstUseEver);
            ImGui.SetNextWindowSizeConstraints(new Num.Vector2(335, 200), new Num.Vector2(Screen.width, Screen.height));

            var open = true;

            if (ImGui.Begin($"Entity Inspector: {entity.name}###" + _entityWindowId, ref open))
            {
                var enabled = entity.enabled;
                if (ImGui.Checkbox("Enabled", ref enabled))
                {
                    entity.enabled = enabled;
                }

                ImGui.InputText("Name", ref _entity.name, 25);

                var updateInterval = (int)entity.updateInterval;
                if (ImGui.SliderInt("Update Interval", ref updateInterval, 1, 100))
                {
                    entity.updateInterval = (uint)updateInterval;
                }

                var tag = entity.tag;
                if (ImGui.InputInt("Tag", ref tag))
                {
                    entity.tag = tag;
                }

                NezImGui.MediumVerticalSpace();
                _transformInspector.draw();
                NezImGui.MediumVerticalSpace();

                // watch out for removed Components
                for (var i = _componentInspectors.Count - 1; i >= 0; i--)
                {
                    if (_componentInspectors[i].entity == null)
                    {
                        _componentInspectors.RemoveAt(i);
                        continue;
                    }
                    _componentInspectors[i].draw();
                    NezImGui.MediumVerticalSpace();
                }

                if (NezImGui.CenteredButton("Add Component", 0.6f))
                {
                    _componentNameFilter = "";
                    ImGui.OpenPopup("component-selector");
                }

                drawComponentSelectorPopup();

                ImGui.End();
            }

            if (!open)
            {
                Core.getGlobalManager <ImGuiManager>().stopInspectingEntity(this);
            }
        }
예제 #22
0
        private void ImGuiLayout()
        {
            ImGui.BeginWindow("Settings", WindowFlags.AlwaysAutoResize);

            if (RenderThread.IsAlive)
            {
                if (ImGui.Button("Stop render"))
                {
                    Window.AllowUserResizing = true;
                    RenderThread.Abort();
                }
                if (Progressive)
                {
                    ImGui.Text("Current samples: " + (Frames * RT.Samples).ToString());
                }
                ImGui.SameLine();
            }
            else
            {
                if (ImGui.Button("Start render"))
                {
                    Window.AllowUserResizing = false;
                    RenderTarget             = new Texture2D(GraphicsDevice, RT.Width, RT.Height);
                    if (Progressive)
                    {
                        RenderThread = new Thread(RenderProgressive);
                        RenderThread.Start();
                    }
                    else
                    {
                        RenderThread = new Thread(RenderStandard);
                        RenderThread.Start();
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Clear framebuffer"))
                {
                    RenderTarget.SetData(new Color[RT.Width * RT.Height]);
                }

                ImGui.Checkbox("Progressive", ref Progressive);
                ImGui.SameLine();
                if (ImGui.Checkbox("Direct Light Sampling", ref NEE))
                {
                    RT.NEE = NEE;
                }
                if (ImGui.SliderFloat("FOV", ref FOV, 0, 180, "%f", 1))
                {
                    RT.FOV = FOV;
                }
                if (ImGui.DragVector3("Camera Position", ref CamPos, -float.MinValue, float.MaxValue, 0.1f))
                {
                    RT.CameraPosition = new Core.Vector3(CamPos.X, CamPos.Y, CamPos.Z);
                }
                if (ImGui.DragVector3("Camera Rotation", ref CamRot, -float.MinValue, float.MaxValue, 0.1f))
                {
                    RT.CameraRotation = new Core.Vector3(CamRot.X, CamRot.Y, CamRot.Z);
                }
                if (ImGui.DragIntRange2("Min/Max Bounces", ref MinBounces, ref MaxBounces, 1, 1, int.MaxValue))
                {
                    RT.MinBounces = MinBounces;
                    RT.MaxBounces = MaxBounces;
                }
                if (ImGui.DragInt("Samples per pixel", ref Samples, 1, 1, int.MaxValue, "%g"))
                {
                    RT.Samples = Samples;
                }
                if (ImGui.SliderInt("Threads", ref Threads, 1, Environment.ProcessorCount, "%g"))
                {
                    RT.Threads = Threads;
                }
                ImGui.Separator();
                ImGui.Combo("Select scene", ref SelectedScene, Scenes);
                if (ImGui.Button("Load scene"))
                {
                    if (Scenes.Length > 0)
                    {
                        RT.LoadScene(Scenes[SelectedScene], SceneRenderSettings);

                        FOV    = (float)RT.FOV;
                        CamPos = new System.Numerics.Vector3((float)RT.CameraPosition.X, (float)RT.CameraPosition.Y, (float)RT.CameraPosition.Z);
                        CamRot = new System.Numerics.Vector3((float)RT.CameraRotation.X, (float)RT.CameraRotation.Y, (float)RT.CameraRotation.Z);
                        graphics.PreferredBackBufferWidth  = RT.Width;
                        graphics.PreferredBackBufferHeight = RT.Height;
                        graphics.ApplyChanges();
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Scan scene directory"))
                {
                    ScanSceneDirectory();
                }
                ImGui.Checkbox("Load scene render settings", ref SceneRenderSettings);
            }

            ImGui.EndWindow();
        }
예제 #23
0
        public override void Draw()
        {
            ImGui.Text("Zoom: ");
            ImGui.SameLine();
            ImGui.PushItemWidth(120);
            ImGui.SliderFloat("", ref zoom, 10, 800, "%.0f%%", 1);
            ImGui.PopItemWidth();
            ImGui.SameLine();
            if (anim != null)
            {
                ImGui.PushItemWidth(80);
                ImGui.InputInt("Frame Number", ref frame, 1, 1);
                if (frame <= 0)
                {
                    frame = 0;
                }
                if (frame >= anim.FrameCount)
                {
                    frame = anim.FrameCount - 1;
                }
                ImGui.PopItemWidth();
                ImGui.SameLine();
            }
            ImGui.Checkbox("Checkerboard", ref checkerboard);
            ImGui.SameLine();

            bool doOpen = ImGui.Button("Info");

            if (doOpen)
            {
                ImGui.OpenPopup("Info##" + Unique);
            }
            ImGui.Separator();
            var w = ImGui.GetWindowContentRegionWidth();

            zoom = (int)zoom;
            var scale = zoom / 100;
            var sz    = new Vector2(tex.Width, tex.Height) * scale;

            ImGuiNative.igSetNextWindowContentSize(new Vector2(sz.X, 0));
            bool isOpen = true;

            if (ImGui.BeginPopupModal("Info##" + Unique, ref isOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Format: " + tex.Format);
                ImGui.Text("Width: " + tex.Width);
                ImGui.Text("Height: " + tex.Height);
                ImGui.Text("Mipmaps: " + ((tex.LevelCount > 1) ? "Yes" : "No"));
                ImGui.EndPopup();
            }
            ImGui.BeginChild("##scroll", new Vector2(-1), false, ImGuiWindowFlags.HorizontalScrollbar);
            var pos     = ImGui.GetCursorScreenPos();
            var windowH = ImGui.GetWindowHeight();
            var windowW = ImGui.GetWindowWidth();
            var cbX     = Math.Max(windowW, sz.X);
            var cbY     = Math.Max(windowH, sz.Y);

            if (checkerboard)
            {
                unsafe
                {
                    var lst = ImGuiNative.igGetWindowDrawList();
                    ImGuiNative.ImDrawList_AddImage(lst, (IntPtr)ImGuiHelper.CheckerboardId,
                                                    pos, new Vector2(pos.X + cbX, pos.Y + cbY),
                                                    new Vector2(0, 0),
                                                    new Vector2(cbX / 16, cbY / 16),
                                                    uint.MaxValue);
                }
            }
            if (sz.Y < windowH) //Centre
            {
                ImGui.Dummy(new Vector2(5, (windowH / 2) - (sz.Y / 2)));
            }
            if (sz.X < w)
            {
                ImGui.Dummy(new Vector2((w / 2) - (sz.X / 2), 5));
                ImGui.SameLine();
            }
            var tl = new Vector2(0, 1);
            var br = new Vector2(1, 0);

            if (anim != null)
            {
                var f = anim.Frames[frame];
                tl = new Vector2(f.UV1.X, 1 - f.UV1.Y);
                br = new Vector2(f.UV2.X, 1 - f.UV2.Y);
            }
            ImGui.Image((IntPtr)tid, sz, tl, br,
                        Vector4.One, Vector4.Zero);

            ImGui.EndChild();
        }
예제 #24
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, texOptions.Length);
                ImGui.Combo("Mipmaps", ref mipmapOption, mipmapOptions, mipmapOptions.Length);
                ImGui.Checkbox("Flip Vertically", ref texFlip);
                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, texFlip);
                        }
                        else if (format == DDSFormat.Uncompressed)
                        {
                            texImportChildren = TextureImport.TGAMipmaps(teximportpath, mipm, texFlip);
                        }
                        else
                        {
                            texImportData = TextureImport.CreateDDS(teximportpath, format, mipm, compressSlow, texFlip);
                        }
                        texImportWaiting = false;
                    }).Start();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev = null;
                    ImGui.CloseCurrentPopup();
                }
            }
        }
예제 #25
0
        protected override void RenderImGui()
        {
            if (ImGui.BeginMenuBar())
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.3f, 0.3f, 0.3f, 1f));
                if (ImGui.Button("Open OBJ"))
                {
                    var explorer = new FileExplorer <ObjMeshAsset>(asset => { DisplayObject.Entity = asset.Entity; });
                    _toolsRoot.AddLegacyWindow(explorer);
                }

                if (ImGui.Button("Open EM3"))
                {
                    var explorer = new FileExplorer <EmotionMeshAsset>(asset => { DisplayObject.Entity = asset.Entity; });
                    _toolsRoot.AddLegacyWindow(explorer);
                }

                if (ImGui.Button("Open Sprite Stack Texture"))
                {
                    var explorer = new FileExplorer <SpriteStackTexture>(asset =>
                    {
                        _toolsRoot.AddLegacyWindow(new Vec2Modal(size =>
                        {
                            MeshEntity entity    = asset.GetSpriteStackEntity(size);
                            DisplayObject.Entity = entity;
                        }, "Sprite Stack Settings", "Individual Frame Size", new Vector2(32, 32)));
                    });
                    _toolsRoot.AddLegacyWindow(explorer);
                }

                ImGui.EndMenuBar();
            }

            ImGui.Checkbox("Show Terrain", ref _showTerrain);

            Vector3 pos = DisplayObject.Position;

            if (ImGui.DragFloat3("Position", ref pos))
            {
                DisplayObject.Position = pos;
            }

            float scale = DisplayObject.Scale;

            if (ImGui.DragFloat("Scale", ref scale))
            {
                DisplayObject.Scale = scale;
            }

            Vector3 rot = DisplayObject.RotationDeg;

            if (ImGui.DragFloat3("Rotation", ref rot))
            {
                DisplayObject.RotationDeg = rot;
            }

            if (DisplayObject.Entity != null && DisplayObject.Entity.Animations != null && ImGui.BeginCombo("Animation", DisplayObject.CurrentAnimation))
            {
                if (ImGui.Button("None"))
                {
                    DisplayObject.SetAnimation(null);
                }

                for (var i = 0; i < DisplayObject.Entity.Animations.Length; i++)
                {
                    SkeletalAnimation anim = DisplayObject.Entity.Animations[i];
                    if (ImGui.Button($"{anim.Name}"))
                    {
                        DisplayObject.SetAnimation(anim.Name);
                    }
                }

                ImGui.EndCombo();
            }
        }
예제 #26
0
        private void ProcessingConfig()
        {
            // restrict in combat
            var restrictInCombat = this.Plugin.Configuration.RestrictInCombat;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictInCombat", "Don't process in combat") +
                    "###PlayerTrack_RestrictInCombat_Checkbox",
                    ref restrictInCombat))
            {
                this.Plugin.Configuration.RestrictInCombat = restrictInCombat;
                this.Plugin.SaveConfig();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictInCombat_HelpMarker",
                                           "stop processing players while in combat"));
            ImGui.Spacing();

            // add / update players
            ImGui.Text(Loc.Localize("RestrictAddUpdatePlayers", "Add / Update Players"));
            var restrictAddUpdatePlayersIndex = this.plugin.Configuration.RestrictAddUpdatePlayers;

            ImGui.SetNextItemWidth(180f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_RestrictAddUpdatePlayers_Combo",
                    ref restrictAddUpdatePlayersIndex,
                    ContentRestrictionType.RestrictionTypeNames.ToArray(),
                    ContentRestrictionType.RestrictionTypeNames.Count))
            {
                this.plugin.Configuration.RestrictAddUpdatePlayers = ContentRestrictionType.GetContentRestrictionTypeByIndex(restrictAddUpdatePlayersIndex).Index;
                this.plugin.SaveConfig();
                this.plugin.PlayerService.ResetViewPlayers();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictAddUpdatePlayers_HelpMarker",
                                           "when to add or update players in your area"));
            ImGui.Spacing();

            // add encounters
            ImGui.Text(Loc.Localize("RestrictAddEncounters", "Add New Encounters"));
            var restrictAddEncountersIndex = this.plugin.Configuration.RestrictAddEncounters;

            ImGui.SetNextItemWidth(180f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_RestrictAddEncounters_Combo",
                    ref restrictAddEncountersIndex,
                    ContentRestrictionType.RestrictionTypeNames.ToArray(),
                    ContentRestrictionType.RestrictionTypeNames.Count))
            {
                this.plugin.Configuration.RestrictAddEncounters = ContentRestrictionType.GetContentRestrictionTypeByIndex(restrictAddEncountersIndex).Index;
                this.plugin.SaveConfig();
                this.plugin.PlayerService.ResetViewPlayers();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictAddEncounters_HelpMarker",
                                           "when to add new encounters (new row in the encounters tab). " +
                                           "don't recommend using always as this will significantly increase file size."));
            ImGui.Spacing();

            // encounters threshold
            ImGui.Text(Loc.Localize("NewEncounterThreshold", "New Encounter Threshold (minutes)"));
            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "NewEncounterThreshold_HelpMarker",
                                           "threshold for creating new encounter for player in same location"));
            var newEncounterThreshold =
                this.plugin.Configuration.CreateNewEncounterThreshold.FromMillisecondsToMinutes();

            if (ImGui.SliderInt("###PlayerTrack_NewEncounterThreshold_Slider", ref newEncounterThreshold, 0, 240))
            {
                this.plugin.Configuration.CreateNewEncounterThreshold =
                    newEncounterThreshold.FromMinutesToMilliseconds();
                this.plugin.SaveConfig();
            }

            ImGui.Spacing();
        }
예제 #27
0
 public static bool Checkbox(string labelString, bool boolValue)
 {
     ImGui.Checkbox(labelString, ref boolValue);
     return(boolValue);
 }
예제 #28
0
        private void Update(float deltaseconds)
        {
            ImguiRenderer.Update(deltaseconds, InputTracker.FrameSnapshot);
            //ImGui.

            var command = EditorCommandQueue.GetNextCommand();

            string[] commandsplit = null;
            if (command != null)
            {
                commandsplit = command.Split($@"/");
            }

            ApplyStyle();
            var vp = ImGui.GetMainViewport();

            ImGui.SetNextWindowPos(vp.Pos);
            ImGui.SetNextWindowSize(vp.Size);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0.0f, 0.0f));
            ImGuiWindowFlags flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;

            flags |= ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.MenuBar;
            flags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoNavFocus;
            flags |= ImGuiWindowFlags.NoBackground;
            if (ImGui.Begin("DockSpace_W", flags))
            {
                //Console.WriteLine("hi");
            }
            var dsid = ImGui.GetID("DockSpace");

            ImGui.DockSpace(dsid, new Vector2(0, 0), ImGuiDockNodeFlags.NoSplit);
            ImGui.PopStyleVar(1);
            ImGui.End();

            bool newProject = false;

            ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0.0f);
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (_projectSettings == null || _projectSettings.ProjectName == null)
                    {
                        ImGui.MenuItem("No project open", false);
                    }
                    else
                    {
                        ImGui.MenuItem($@"Settings: {_projectSettings.ProjectName}");
                    }

                    if (ImGui.MenuItem("Enable Texturing (alpha)", "", CFG.Current.EnableTexturing))
                    {
                        CFG.Current.EnableTexturing = !CFG.Current.EnableTexturing;
                    }

                    if (ImGui.MenuItem("New Project", "CTRL+N") || InputTracker.GetControlShortcut(Key.I))
                    {
                        newProject = true;
                    }
                    if (ImGui.MenuItem("Open Project", ""))
                    {
                        var browseDlg = new System.Windows.Forms.OpenFileDialog()
                        {
                            Filter          = AssetLocator.JsonFilter,
                            ValidateNames   = true,
                            CheckFileExists = true,
                            CheckPathExists = true,
                        };

                        if (browseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            var settings = MsbEditor.ProjectSettings.Deserialize(browseDlg.FileName);
                            AttemptLoadProject(settings, browseDlg.FileName);
                        }
                    }
                    if (ImGui.BeginMenu("Recent Projects"))
                    {
                        CFG.RecentProject recent = null;
                        foreach (var p in CFG.Current.RecentProjects)
                        {
                            if (ImGui.MenuItem($@"{p.GameType.ToString()}:{p.Name}"))
                            {
                                if (File.Exists(p.ProjectFile))
                                {
                                    var settings = MsbEditor.ProjectSettings.Deserialize(p.ProjectFile);
                                    if (AttemptLoadProject(settings, p.ProjectFile, false))
                                    {
                                        recent = p;
                                    }
                                }
                            }
                        }
                        if (recent != null)
                        {
                            CFG.Current.RecentProjects.Remove(recent);
                            CFG.Current.RecentProjects.Insert(0, recent);
                            CFG.Current.LastProjectFile = recent.ProjectFile;
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.MenuItem("Save", "Ctrl-S"))
                    {
                        if (_msbEditorFocused)
                        {
                            MSBEditor.Save();
                        }
                        if (_modelEditorFocused)
                        {
                            ModelEditor.Save();
                        }
                        if (_paramEditorFocused)
                        {
                            ParamEditor.Save();
                        }
                        if (_textEditorFocused)
                        {
                            TextEditor.Save();
                        }
                    }
                    if (ImGui.MenuItem("Save All", ""))
                    {
                        MSBEditor.SaveAll();
                        ModelEditor.SaveAll();
                        ParamEditor.SaveAll();
                        TextEditor.SaveAll();
                    }
                    if (Resource.FlverResource.CaptureMaterialLayouts && ImGui.MenuItem("Dump Flver Layouts (Debug)", ""))
                    {
                        DumpFlverLayouts();
                    }
                    ImGui.EndMenu();
                }
                if (_msbEditorFocused)
                {
                    MSBEditor.DrawEditorMenu();
                }
                else if (_modelEditorFocused)
                {
                    ModelEditor.DrawEditorMenu();
                }
                else if (_paramEditorFocused)
                {
                    ParamEditor.DrawEditorMenu();
                }
                else if (_textEditorFocused)
                {
                    TextEditor.DrawEditorMenu();
                }
                ImGui.EndMainMenuBar();
            }
            ImGui.PopStyleVar();

            // New project modal
            if (newProject)
            {
                _newProjectSettings  = new MsbEditor.ProjectSettings();
                _newProjectDirectory = "";
                ImGui.OpenPopup("New Project");
            }
            bool open = true;

            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 7.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 1.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(14.0f, 8.0f));
            if (ImGui.BeginPopupModal("New Project", ref open, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Project Name:      ");
                ImGui.SameLine();
                var pname = _newProjectSettings.ProjectName;
                if (ImGui.InputText("##pname", ref pname, 255))
                {
                    _newProjectSettings.ProjectName = pname;
                }

                ImGui.AlignTextToFramePadding();
                ImGui.Text("Project Directory: ");
                ImGui.SameLine();
                ImGui.InputText("##pdir", ref _newProjectDirectory, 255);
                ImGui.SameLine();
                if (ImGui.Button($@"{ForkAwesome.FileO}"))
                {
                    var browseDlg = new System.Windows.Forms.FolderBrowserDialog();

                    if (browseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        _newProjectDirectory = browseDlg.SelectedPath;
                    }
                }

                ImGui.AlignTextToFramePadding();
                ImGui.Text("Game Executable:   ");
                ImGui.SameLine();
                var gname = _newProjectSettings.GameRoot;
                if (ImGui.InputText("##gdir", ref gname, 255))
                {
                    _newProjectSettings.GameRoot = gname;
                    _newProjectSettings.GameType = _assetLocator.GetGameTypeForExePath(_newProjectSettings.GameRoot);
                }
                ImGui.SameLine();
                ImGui.PushID("fd2");
                if (ImGui.Button($@"{ForkAwesome.FileO}"))
                {
                    var browseDlg = new System.Windows.Forms.OpenFileDialog()
                    {
                        Filter          = AssetLocator.GameExecutatbleFilter,
                        ValidateNames   = true,
                        CheckFileExists = true,
                        CheckPathExists = true,
                        //ShowReadOnly = true,
                    };

                    if (browseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        _newProjectSettings.GameRoot = browseDlg.FileName;
                        _newProjectSettings.GameType = _assetLocator.GetGameTypeForExePath(_newProjectSettings.GameRoot);
                    }
                }
                ImGui.PopID();
                ImGui.Text($@"Detected Game:      {_newProjectSettings.GameType.ToString()}");

                ImGui.NewLine();
                ImGui.Separator();
                ImGui.NewLine();
                if (_newProjectSettings.GameType == GameType.DarkSoulsIISOTFS || _newProjectSettings.GameType == GameType.DarkSoulsIII)
                {
                    ImGui.AlignTextToFramePadding();
                    ImGui.Text($@"Use Loose Params:  ");
                    ImGui.SameLine();
                    var looseparams = _newProjectSettings.UseLooseParams;
                    if (ImGui.Checkbox("##looseparams", ref looseparams))
                    {
                        _newProjectSettings.UseLooseParams = looseparams;
                    }
                    ImGui.NewLine();
                }

                if (ImGui.Button("Create", new Vector2(120, 0)))
                {
                    bool validated = true;
                    if (_newProjectSettings.GameRoot == null || !File.Exists(_newProjectSettings.GameRoot))
                    {
                        System.Windows.Forms.MessageBox.Show("Your game executable path does not exist. Please select a valid executable.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }
                    if (validated && _newProjectSettings.GameType == GameType.Undefined)
                    {
                        System.Windows.Forms.MessageBox.Show("Your game executable is not a valid supported game.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }
                    if (validated && (_newProjectDirectory == null || !Directory.Exists(_newProjectDirectory)))
                    {
                        System.Windows.Forms.MessageBox.Show("Your selected project directory is not valid.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }
                    if (validated && File.Exists($@"{_newProjectDirectory}\project.json"))
                    {
                        System.Windows.Forms.MessageBox.Show("Your selected project directory is already a project.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }
                    if (validated && (_newProjectSettings.ProjectName == null || _newProjectSettings.ProjectName == ""))
                    {
                        System.Windows.Forms.MessageBox.Show("You must specify a project name.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }

                    string gameroot = Path.GetDirectoryName(_newProjectSettings.GameRoot);
                    if (_newProjectSettings.GameType == GameType.Bloodborne)
                    {
                        gameroot = gameroot + @"\dvdroot_ps4";
                    }
                    if (!_assetLocator.CheckFilesExpanded(gameroot, _newProjectSettings.GameType))
                    {
                        System.Windows.Forms.MessageBox.Show($@"The files for {_newProjectSettings.GameType} do not appear to be unpacked. Please use UDSFM for DS1:PTDE and UXM for the rest of the games to unpack the files.", "Error",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.None);
                        validated = false;
                    }

                    if (validated)
                    {
                        _projectSettings          = _newProjectSettings;
                        _projectSettings.GameRoot = gameroot;
                        _projectSettings.Serialize($@"{_newProjectDirectory}\project.json");
                        ChangeProjectSettings(_projectSettings, _newProjectDirectory);

                        CFG.Current.LastProjectFile = $@"{_newProjectDirectory}\project.json";
                        var recent = new CFG.RecentProject();
                        recent.Name        = _projectSettings.ProjectName;
                        recent.GameType    = _projectSettings.GameType;
                        recent.ProjectFile = $@"{_newProjectDirectory}\project.json";
                        CFG.Current.RecentProjects.Insert(0, recent);
                        if (CFG.Current.RecentProjects.Count > CFG.MAX_RECENT_PROJECTS)
                        {
                            CFG.Current.RecentProjects.RemoveAt(CFG.Current.RecentProjects.Count - 1);
                        }

                        ImGui.CloseCurrentPopup();
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel", new Vector2(120, 0)))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.PopStyleVar(3);

            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0.0f, 0.0f));
            if (FirstFrame)
            {
                ImGui.SetNextWindowFocus();
            }
            string[] mapcmds = null;
            if (commandsplit != null && commandsplit[0] == "map")
            {
                mapcmds = commandsplit.Skip(1).ToArray();
                ImGui.SetNextWindowFocus();
            }
            if (ImGui.Begin("Map Editor"))
            {
                ImGui.PopStyleVar(1);
                MSBEditor.OnGUI(mapcmds);
                ImGui.End();
                _msbEditorFocused = true;
                MSBEditor.Update(deltaseconds);
            }
            else
            {
                ImGui.PopStyleVar(1);
                _msbEditorFocused = false;
                ImGui.End();
            }

            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0.0f, 0.0f));
            if (ImGui.Begin("Model Editor"))
            {
                ImGui.PopStyleVar(1);
                ModelEditor.OnGUI();
                _modelEditorFocused = true;
                ModelEditor.Update(deltaseconds);
            }
            else
            {
                ImGui.PopStyleVar(1);
                _modelEditorFocused = false;
            }
            ImGui.End();


            string[] paramcmds = null;
            if (commandsplit != null && commandsplit[0] == "param")
            {
                paramcmds = commandsplit.Skip(1).ToArray();
                ImGui.SetNextWindowFocus();
            }
            if (ImGui.Begin("Param Editor"))
            {
                ParamEditor.OnGUI(paramcmds);
                _paramEditorFocused = true;
            }
            else
            {
                _paramEditorFocused = false;
            }
            ImGui.End();

            string[] textcmds = null;
            if (commandsplit != null && commandsplit[0] == "text")
            {
                textcmds = commandsplit.Skip(1).ToArray();
                ImGui.SetNextWindowFocus();
            }
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(4, 4));
            if (ImGui.Begin("Text Editor"))
            {
                TextEditor.OnGUI(textcmds);
                _textEditorFocused = true;
            }
            else
            {
                _textEditorFocused = false;
            }
            ImGui.End();
            ImGui.PopStyleVar();

            ImGui.PopStyleVar(2);
            UnapplyStyle();

            Resource.ResourceManager.UpdateTasks();

            if (!_firstframe)
            {
                FirstFrame = false;
            }
            _firstframe = false;
        }
예제 #29
0
        /// <inheritdoc />
        protected override void OnRender()
        {
            ImGui.SetNextWindowPos(new Vector2(10.0f, 100.0f));
            ImGui.SetNextWindowSize(new Vector2(200.0f, 700.0f));
            ImGui.Begin("Tuning", ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize);

            ImGui.Separator();

            ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.5f);

            const ImGuiComboFlags comboFlags = 0;

            string[] bendModels    = { "Spring", "PBD Ang", "XPBD Ang", "PBD Dist", "PBD Height" };
            string[] stretchModels = { "PBD", "XPBD" };

            ImGui.Text("Rope 1");

            var bendModel1 = (int)_tuning1.BendingModel;

            if (ImGui.BeginCombo("Bend Model##1", bendModels[bendModel1], comboFlags))
            {
                for (var i = 0; i < bendModels.Length; ++i)
                {
                    var isSelected = bendModel1 == i;
                    if (ImGui.Selectable(bendModels[i], isSelected))
                    {
                        bendModel1            = i;
                        _tuning1.BendingModel = (BendingModel)i;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.SliderFloat("Damping##B1", ref _tuning1.BendDamping, 0.0f, 4.0f, "%.1f");
            ImGui.SliderFloat("Hertz##B1", ref _tuning1.BendHertz, 0.0f, 60.0f, "%.0f");
            ImGui.SliderFloat("Stiffness##B1", ref _tuning1.BendStiffness, 0.0f, 1.0f, "%.1f");

            ImGui.Checkbox("Isometric##1", ref _tuning1.Isometric);
            ImGui.Checkbox("Fixed Mass##1", ref _tuning1.FixedEffectiveMass);
            ImGui.Checkbox("Warm Start##1", ref _tuning1.WarmStart);

            var stretchModel1 = (int)_tuning1.StretchingModel;

            if (ImGui.BeginCombo("Stretch Model##1", stretchModels[stretchModel1], comboFlags))
            {
                for (var i = 0; i < stretchModels.Length; ++i)
                {
                    var isSelected = stretchModel1 == i;
                    if (ImGui.Selectable(stretchModels[i], isSelected))
                    {
                        stretchModel1            = i;
                        _tuning1.StretchingModel = (StretchingModel)i;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.SliderFloat("Damping##S1", ref _tuning1.StretchDamping, 0.0f, 4.0f, "%.1f");
            ImGui.SliderFloat("Hertz##S1", ref _tuning1.StretchHertz, 0.0f, 60.0f, "%.0f");
            ImGui.SliderFloat("Stiffness##S1", ref _tuning1.StretchStiffness, 0.0f, 1.0f, "%.1f");

            ImGui.SliderInt("Iterations##1", ref _iterations1, 1, 100, "%d");

            ImGui.Separator();

            ImGui.Text("Rope 2");

            var bendModel2 = (int)_tuning2.BendingModel;

            if (ImGui.BeginCombo("Bend Model##2", bendModels[bendModel2], comboFlags))
            {
                for (var i = 0; i < bendModels.Length; ++i)
                {
                    var isSelected = bendModel2 == i;
                    if (ImGui.Selectable(bendModels[i], isSelected))
                    {
                        bendModel2            = i;
                        _tuning2.BendingModel = (BendingModel)i;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.SliderFloat("Damping##", ref _tuning2.BendDamping, 0.0f, 4.0f, "%.1f");
            ImGui.SliderFloat("Hertz##", ref _tuning2.BendHertz, 0.0f, 60.0f, "%.0f");
            ImGui.SliderFloat("Stiffness##", ref _tuning2.BendStiffness, 0.0f, 1.0f, "%.1f");

            ImGui.Checkbox("Isometric##2", ref _tuning2.Isometric);
            ImGui.Checkbox("Fixed Mass##2", ref _tuning2.FixedEffectiveMass);
            ImGui.Checkbox("Warm Start##2", ref _tuning2.WarmStart);

            var stretchModel2 = (int)_tuning2.StretchingModel;

            if (ImGui.BeginCombo("Stretch Model##2", stretchModels[stretchModel2], comboFlags))
            {
                for (var i = 0; i < stretchModels.Length; ++i)
                {
                    var isSelected = stretchModel2 == i;
                    if (ImGui.Selectable(stretchModels[i], isSelected))
                    {
                        stretchModel2            = i;
                        _tuning2.StretchingModel = (StretchingModel)i;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.SliderFloat("Damping##S2", ref _tuning2.StretchDamping, 0.0f, 4.0f, "%.1f");
            ImGui.SliderFloat("Hertz##S2", ref _tuning2.StretchHertz, 0.0f, 60.0f, "%.0f");
            ImGui.SliderFloat("Stiffness##S2", ref _tuning2.StretchStiffness, 0.0f, 1.0f, "%.1f");

            ImGui.SliderInt("Iterations##2", ref _iterations2, 1, 100, "%d");

            ImGui.Separator();

            ImGui.SliderFloat("Speed", ref _speed, 10.0f, 100.0f, "%.0f");

            if (ImGui.Button("Reset"))
            {
                _position1.Set(-5.0f, 15.0f);
                _position2.Set(5.0f, 15.0f);
                _rope1.Reset(_position1);
                _rope2.Reset(_position2);
            }

            ImGui.PopItemWidth();

            ImGui.End();

            _rope1.Draw(Drawer);
            _rope2.Draw(Drawer);

            DrawString("Press comma and period to move left and right");
        }
예제 #30
0
        private void DrawPluginConfigWindow()
        {
            ImGui.SetNextWindowSizeConstraints(new Vector2(588, 500), ImGui.GetIO().DisplaySize);
            ImGui.Begin("QoL Bar Configuration", ref configOpen);

            if (ImGui.Checkbox("Export on Delete", ref config.ExportOnDelete))
            {
                config.Save();
            }
            ImGui.SameLine(ImGui.GetWindowWidth() / 2);
            if (ImGui.Checkbox("Resizing Repositions Bars", ref config.ResizeRepositionsBars))
            {
                config.Save();
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Undocked bars will automatically readjust if you change resolutions.");
            }
            if (ImGui.Checkbox("Use Hotbar Frames on Icons", ref config.UseIconFrame))
            {
                config.Save();
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Might cause lag.");
            }

            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.SameLine(30);
            ImGui.Text("Bar Manager");
            ImGui.Spacing();
            ImGui.Separator();

            Vector2 textsize = new Vector2(-1, 0);
            float   textx    = 0.0f;

            ImGui.Columns(3, "QoLBarsList", false);
            for (int i = 0; i < bars.Count; i++)
            {
                ImGui.PushID(i);

                ImGui.Text($"#{i + 1}");
                ImGui.SameLine();

                textx = ImGui.GetCursorPosX();

                ImGui.SetNextItemWidth(-1);
                if (ImGui.InputText("##Title", ref config.BarConfigs[i].Title, 32))
                {
                    config.Save();
                }

                textsize = ImGui.GetItemRectSize();

                ImGui.NextColumn();

                if (ImGui.Button("O"))
                {
                    ImGui.OpenPopup($"BarConfig##{i}");
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Options");
                }
                bars[i].BarConfigPopup();
                ImGui.SameLine();
                if (ImGui.Button(config.BarConfigs[i].Hidden ? "R" : "H"))
                {
                    bars[i].ToggleVisible();
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip(config.BarConfigs[i].Hidden ? "Reveal" : "Hide");
                }

                ImGui.NextColumn();

                if (ImGui.Button("↑") && i > 0)
                {
                    var b = bars[i];
                    bars.RemoveAt(i);
                    bars.Insert(i - 1, b);

                    var b2 = config.BarConfigs[i];
                    config.BarConfigs.RemoveAt(i);
                    config.BarConfigs.Insert(i - 1, b2);
                    config.Save();
                    RefreshBarIndexes();
                }
                ImGui.SameLine();
                if (ImGui.Button("↓") && i < (bars.Count - 1))
                {
                    var b = bars[i];
                    bars.RemoveAt(i);
                    bars.Insert(i + 1, b);

                    var b2 = config.BarConfigs[i];
                    config.BarConfigs.RemoveAt(i);
                    config.BarConfigs.Insert(i + 1, b2);
                    config.Save();
                    RefreshBarIndexes();
                }
                ImGui.SameLine();
                if (ImGui.Button("Export"))
                {
                    ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], false));
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Export to clipboard without default settings (May change with updates).\n" +
                                     "Right click to export with every setting (Longer string, doesn't change).");

                    if (ImGui.IsMouseReleased(1))
                    {
                        ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], true));
                    }
                }

                if (i > 0)
                {
                    ImGui.SameLine();
                    if (ImGui.Button(config.ExportOnDelete ? "Cut" : "Delete"))
                    {
                        plugin.ExecuteCommand("/echo <se> Right click to delete!");
                    }
                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip($"Right click this button to delete bar #{i + 1}!" +
                                         (config.ExportOnDelete ? "\nThe bar will be exported to clipboard first." : ""));

                        if (ImGui.IsMouseReleased(1))
                        {
                            if (config.ExportOnDelete)
                            {
                                ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], false));
                            }

                            bars.RemoveAt(i);
                            config.BarConfigs.RemoveAt(i);
                            config.Save();
                            RefreshBarIndexes();
                        }
                    }
                }

                ImGui.NextColumn();

                ImGui.PopID();
            }

            ImGui.Separator();
            ImGui.Spacing();
            ImGui.SameLine(textx);
            if (ImGui.Button("+", textsize))
            {
                AddBar(new BarConfig());
            }
            ImGui.NextColumn();
            ImGui.NextColumn();
            if (ImGui.Button("Import", textsize))
            {
                try
                {
                    AddBar(plugin.ImportBar(ImGui.GetClipboardText()));
                }
                catch (Exception e) // Try as a shortcut instead
                {
                    try
                    {
                        var sh  = plugin.ImportShortcut(ImGui.GetClipboardText());
                        var bar = new BarConfig();
                        bar.ShortcutList.Add(sh);
                        AddBar(bar);
                    }
                    catch (Exception e2)
                    {
                        PluginLog.LogError("Invalid import string!");
                        PluginLog.LogError($"{e.GetType()}\n{e.Message}");
                        PluginLog.LogError($"{e2.GetType()}\n{e2.Message}");
                    }
                }
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Import a bar from the clipboard,\n" +
                                 "or import a single shortcut as a new bar.");
            }

            ImGui.Columns(1); // I just wanna know who did this and where they live

            ImGui.End();
        }