Exemplo n.º 1
0
        /// <summary>
        /// Draw the plugin installer view ImGui.
        /// </summary>
        public override void Draw()
        {
            ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGui.GetIO().FontGlobalScale));
            var descriptionText = Loc.Localize("InstallerHint", "This window allows you to install and remove in-game plugins.\nThey are made by third-party developers.");

            ImGui.Text(descriptionText);

            var sortingTextSize = ImGui.CalcTextSize(Loc.Localize("SortDownloadCounts", "Download Count")) + ImGui.CalcTextSize(Loc.Localize("PluginSort", "Sort By"));

            ImGui.SameLine(ImGui.GetWindowWidth() - sortingTextSize.X - ((250 + 20) * ImGui.GetIO().FontGlobalScale));
            ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (ImGui.CalcTextSize(descriptionText).Y / 4) - 2);
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() - sortingTextSize.X - ((250 + 20) * ImGui.GetIO().FontGlobalScale));

            ImGui.SetNextItemWidth(240 * ImGui.GetIO().FontGlobalScale);
            ImGui.InputTextWithHint("###XPlPluginInstaller_Search", Loc.Localize("InstallerSearch", "Search"), ref this.searchText, 100);

            ImGui.SameLine();
            ImGui.SetNextItemWidth((10 * ImGui.GetIO().FontGlobalScale) + ImGui.CalcTextSize(Loc.Localize("SortDownloadCounts", "Download Count")).X);
            if (ImGui.BeginCombo(Loc.Localize("PluginSort", "Sort By"), this.filterText, ImGuiComboFlags.NoArrowButton))
            {
                if (ImGui.Selectable(Loc.Localize("SortAlphabetical", "Alphabetical")))
                {
                    this.sortKind   = PluginSortKind.Alphabetical;
                    this.filterText = Loc.Localize("SortAlphabetical", "Alphabetical");

                    this.ResortPlugins();
                }

                if (ImGui.Selectable(Loc.Localize("SortDownloadCounts", "Download Count")))
                {
                    this.sortKind   = PluginSortKind.DownloadCount;
                    this.filterText = Loc.Localize("SortDownloadCounts", "Download Count");

                    this.ResortPlugins();
                }

                if (ImGui.Selectable(Loc.Localize("SortLastUpdate", "Last Update")))
                {
                    this.sortKind   = PluginSortKind.LastUpdate;
                    this.filterText = Loc.Localize("SortLastUpdate", "Last Update");

                    this.ResortPlugins();
                }

                ImGui.EndCombo();
            }

            ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGui.GetIO().FontGlobalScale));

            string initializationStatusText = null;

            if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress)
            {
                initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins...");
                this.pluginListAvailable = null;
            }
            else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail)
            {
                initializationStatusText = Loc.Localize("InstallerDownloadFailed", "Download failed.");
                this.pluginListAvailable = null;
            }
            else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo)
            {
                initializationStatusText = Loc.Localize("InstallerDownloadFailedThird", "One of your third party repos is unreachable or there is no internet connection.");
                this.pluginListAvailable = null;
            }
            else
            {
                if (this.pluginListAvailable == null)
                {
                    this.RefetchPlugins();
                }
            }

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 3) * ImGui.GetIO().FontGlobalScale);

            if (ImGui.BeginTabBar("PluginsTabBar", ImGuiTabBarFlags.NoTooltip))
            {
                this.DrawTab(false, initializationStatusText);
                this.DrawTab(true, initializationStatusText);

                ImGui.EndTabBar();
                ImGui.Separator();
            }

            ImGui.PopStyleVar();

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

            if (this.installStatus == PluginInstallStatus.InProgress)
            {
                ImGui.Button(Loc.Localize("InstallerUpdating", "Updating..."));
            }
            else
            {
                if (this.updateComplete)
                {
                    ImGui.Button(this.updatePluginCount == 0
                                     ? Loc.Localize("InstallerNoUpdates", "No updates found!")
                                     : string.Format(Loc.Localize("InstallerUpdateComplete", "{0} plugins updated!"), this.updatePluginCount));
                }
                else
                {
                    if (ImGui.Button(Loc.Localize("InstallerUpdatePlugins", "Update plugins")) &&
                        this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Success)
                    {
                        this.installStatus = PluginInstallStatus.InProgress;

                        Task.Run(() => this.dalamud.PluginRepository.UpdatePlugins()).ContinueWith(t =>
                        {
                            this.installStatus =
                                t.Result.Success ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
                            this.installStatus =
                                t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus;

                            if (this.installStatus == PluginInstallStatus.Success)
                            {
                                this.updateComplete = true;
                            }

                            if (t.Result.UpdatedPlugins != null)
                            {
                                this.updatePluginCount = t.Result.UpdatedPlugins.Count;
                                this.updatedPlugins    = t.Result.UpdatedPlugins;
                            }

                            this.errorModalDrawing     = this.installStatus == PluginInstallStatus.Fail;
                            this.errorModalOnNextFrame = this.installStatus == PluginInstallStatus.Fail;

                            this.dalamud.PluginRepository.PrintUpdatedPlugins(
                                this.updatedPlugins, Loc.Localize("DalamudPluginUpdates", "Updates:"));

                            this.RefetchPlugins();
                        });
                    }
                }
            }

            ImGui.SameLine();

            if (ImGui.Button(Loc.Localize("SettingsInstaller", "Settings")))
            {
                this.dalamud.DalamudUi.OpenSettings();
            }

            var closeText = Loc.Localize("Close", "Close");

            ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(closeText).X - (16 * ImGui.GetIO().FontGlobalScale));
            if (ImGui.Button(closeText))
            {
                this.IsOpen = false;
                this.dalamud.Configuration.Save();
            }

            if (ImGui.BeginPopupModal(Loc.Localize("InstallerError", "Installer failed"), ref this.errorModalDrawing, ImGuiWindowFlags.AlwaysAutoResize))
            {
                var message = Loc.Localize(
                    "InstallerErrorHint",
                    "The plugin installer ran into an issue or the plugin is incompatible.\nPlease restart the game and report this error on our discord.");

                if (this.updatedPlugins != null)
                {
                    if (this.updatedPlugins.Any(x => x.WasUpdated == false))
                    {
                        var extraInfoMessage = Loc.Localize(
                            "InstallerErrorPluginInfo",
                            "\n\nThe following plugins caused these issues:\n\n{0}\nYou may try removing these plugins manually and reinstalling them.");

                        var insert = this.updatedPlugins.Where(x => x.WasUpdated == false)
                                     .Aggregate(
                            string.Empty,
                            (current, pluginUpdateStatus) =>
                            current + $"* {pluginUpdateStatus.InternalName}\n");
                        extraInfoMessage = string.Format(extraInfoMessage, insert);
                        message         += extraInfoMessage;
                    }
                }

                ImGui.Text(message);

                ImGui.Spacing();

                if (ImGui.Button(Loc.Localize("OK", "OK"), new Vector2(120, 40)))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            if (this.errorModalOnNextFrame)
            {
                ImGui.OpenPopup(Loc.Localize("InstallerError", "Installer failed"));
                this.errorModalOnNextFrame = false;
            }
        }
        public void Draw()
        {
            if (windowOpen)
            {
                ImGui.Begin("Options", ref windowOpen, ImGuiWindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    SetTexFilter();
                    config.TextureFilter = cFilter;
                }
                ImGui.Combo("Antialiasing", ref cMsaa, msaaStrings, Math.Min(msaaLevels.Length, msaaStrings.Length));
                config.MSAA = msaaLevels[cMsaa];
                ImGui.Checkbox("View Buttons", ref config.ViewButtons);
                ImGui.Checkbox("Pause When Unfocused", ref config.PauseWhenUnfocused);
                if (ViewerControls.GradientButton("Viewport Background", config.Background, config.Background2, new Vector2(22), vps, config.BackgroundGradient))
                {
                    ImGui.OpenPopup("Viewport Background");
                    editCol  = new Vector3(config.Background.R, config.Background.G, config.Background.B);
                    editCol2 = new Vector3(config.Background2.R, config.Background2.G, config.Background2.B);
                    editGrad = config.BackgroundGradient;
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Viewport Background");
                bool wOpen = true;
                if (ImGui.BeginPopupModal("Viewport Background", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Gradient", ref editGrad);

                    ImGui.ColorPicker3(editGrad ? "Top###a" : "###a", ref editCol);
                    if (editGrad)
                    {
                        ImGui.SameLine();
                        ImGui.ColorPicker3("Bottom###b", ref editCol2);
                    }
                    if (ImGui.Button("OK"))
                    {
                        config.Background         = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        config.Background2        = new Color4(editCol2.X, editCol2.Y, editCol2.Z, 1);
                        config.BackgroundGradient = editGrad;
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Cancel"))
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.ColorButton("Grid Color", config.GridColor, ImGuiColorEditFlags.NoAlpha, new Vector2(22)))
                {
                    ImGui.OpenPopup("Grid Color");
                    editCol = new Vector3(config.GridColor.R, config.GridColor.G, config.GridColor.B);
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Grid Color");
                if (ImGui.BeginPopupModal("Grid Color", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.ColorPicker3("###a", ref editCol);
                    if (ImGui.Button("OK"))
                    {
                        config.GridColor = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue;
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.EndPopup();
                }
                guiHelper.PauseWhenUnfocused = config.PauseWhenUnfocused;
                ImGui.End();
            }
        }
Exemplo n.º 3
0
        public override void Draw()
        {
            //Main Window Contents
            if (propertiesOpen && !statePlaying)
            {
                ImGui.Columns(2, "##alecolumns", true);
                if (firstProperties)
                {
                    ImGui.SetColumnWidth(0, 300);
                    firstProperties = false;
                }
                ImGui.BeginChild("##leftpanel");
                DoProperties();
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            if (TabHandler.VerticalTab("Properties", propertiesOpen))
            {
                propertiesOpen = !propertiesOpen;
            }
            //Viewport
            ImGui.SameLine();
            ImGui.BeginChild("##maincontent");
            var totalH = ImGui.GetWindowHeight();

            ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
            h1 = totalH - h2 - 24f;
            ImGui.BeginChild("###viewport", new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            if (validXml)
            {
                DoViewport();
            }
            else
            {
                ImGui.Text(exceptionText);
            }
            ImGui.EndChild();
            //Text
            ImGui.BeginChild("###text", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
            if (statePlaying)
            {
                if (ImGui.Button("Stop"))
                {
                    xmlEditor.SetReadOnly(false);
                    TextChanged();
                    statePlaying = false;
                }
            }
            else
            {
                if (ImGui.Button("Play"))
                {
                    xmlEditor.SetReadOnly(true);
                    widget.EnableScripting(context, null);
                    statePlaying = true;
                }
            }

            xmlEditor.Render("##texteditor");
            if (xmlEditor.TextChanged())
            {
                TextChanged();
            }
            var coords = xmlEditor.GetCoordinates();

            editingObject = null;
            if (validXml)
            {
                editingObject = FindEditingObject(coords.Y + 1, coords.X + 1);
            }
            ImGui.EndChild();
            ImGui.EndChild();
        }
Exemplo n.º 4
0
        protected override void RenderContent(RenderComposer composer)
        {
            Vector2[] anchorArray = _anim.Anchors;

            if (_parent.AnimController != null)
            {
                if (_parent.Mirrored)
                {
                    _parent.AnimController.MirrorXAnchors ??= new Vector2[_anim.Anchors.Length];
                    anchorArray = _parent.Mirrored ? _parent.AnimController.MirrorXAnchors : anchorArray;
                }

                if (_parent.Mirrored)
                {
                    if (ImGui.Button("Copy Non-Mirror Anchors"))
                    {
                        for (int i = _anim.StartingFrame; i <= _anim.EndingFrame; i++)
                        {
                            anchorArray[i] = _anim.Anchors[i];
                        }
                    }

                    ImGui.SameLine();
                    if (ImGui.Button("Copy Y Axis of Non-Mirror Anchors"))
                    {
                        for (int i = _anim.StartingFrame; i <= _anim.EndingFrame; i++)
                        {
                            anchorArray[i].Y = _anim.Anchors[i].Y;
                        }
                    }
                }
            }

            bool selected = _anchorSettingFrame == -1;

            if (selected)
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Color(255, 0, 0).ToUint());
            }
            if (ImGui.Button("Interactive Move All"))
            {
                _anchorSettingFrame = -1;
            }
            if (selected)
            {
                ImGui.PopStyleColor();
            }

            int startFrame = _anim.StartingFrame;
            int endFrame   = _anim.EndingFrame;

            for (int i = startFrame; i <= endFrame; i++)
            {
                ImGui.PushID(i);
                ImGui.InputFloat2($"Frame {i} ({_anim.Frames[i]})", ref anchorArray[i]);
                ImGui.SameLine();
                selected = _anchorSettingFrame == i;
                if (selected)
                {
                    ImGui.PushStyleColor(ImGuiCol.Button, new Color(255, 0, 0).ToUint());
                }
                if (ImGui.Button("Interactive Set"))
                {
                    _anchorSettingFrame = i;
                }
                if (selected)
                {
                    ImGui.PopStyleColor();
                }

                ImGui.PopID();
            }

            Vector2 pos = ImGui.GetWindowPos();

            pos.Y += ImGui.GetWindowHeight();
            pos    = pos.IntCastRound();

            float scale           = _parent.Scale;
            var   interactiveRect = Rectangle.Empty;

            if (_anchorSettingFrame != -1)
            {
                _anchorSettingFrame = Maths.Clamp(_anchorSettingFrame, startFrame, endFrame);
                pos.Y += 10 * scale;
                int     prevFrame = Math.Max(_anchorSettingFrame - 1, startFrame);
                Vector2 size      = _anim.Frames[prevFrame].Size * scale;

                Vector2   prevFramePos = pos + anchorArray[prevFrame] * scale;
                Rectangle inflatedRect = new Rectangle(prevFramePos, size).Inflate(scale, scale);
                composer.RenderSprite(inflatedRect.PositionZ(0), inflatedRect.Size, Color.White);
                composer.RenderSprite(new Vector3(prevFramePos, 0), size, Color.White * 0.5f, _anim.Texture, _anim.Frames[prevFrame], _parent.Mirrored);

                size            = _anim.Frames[_anchorSettingFrame].Size * scale;
                interactiveRect = new Rectangle(pos + anchorArray[_anchorSettingFrame] * scale, size);
                composer.RenderSprite(interactiveRect.PositionZ(0), size, Color.White * 0.75f, _anim.Texture, _anim.Frames[_anchorSettingFrame], _parent.Mirrored);
                composer.RenderOutline(interactiveRect.Inflate(scale, scale), Color.Red);
            }
            else
            {
                for (int i = startFrame; i <= endFrame; i++)
                {
                    Vector2 size = _anim.Frames[i].Size * scale;
                    interactiveRect = new Rectangle(pos + anchorArray[i] * scale, size);
                    composer.RenderSprite(interactiveRect.PositionZ(0), size, Color.White * 0.75f, _anim.Texture, _anim.Frames[i], _parent.Mirrored);
                }

                composer.RenderOutline(interactiveRect.Inflate(scale, scale), Color.Red);
            }

            if (!_mouseDown && interactiveRect.Contains(Engine.Host.MousePosition) && Engine.Host.IsKeyDown(Key.MouseKeyLeft))
            {
                _mouseDown              = true;
                _mouseDownPos           = Engine.Host.MousePosition;
                _interactiveAnchorStart = _anchorSettingFrame == -1 ? Vector2.Zero : anchorArray[_anchorSettingFrame];
            }
            else if (!Engine.Host.IsKeyHeld(Key.MouseKeyLeft))
            {
                _mouseDown = false;
            }

            if (_mouseDown)
            {
                Vector2 movedAmount = Engine.Host.MousePosition - _mouseDownPos;
                Vector2 m           = (movedAmount / scale).IntCastRound();
                if (_anchorSettingFrame == -1)
                {
                    for (int i = startFrame; i <= endFrame; i++)
                    {
                        anchorArray[i] = anchorArray[i] - _interactiveAnchorStart;
                        anchorArray[i] = anchorArray[i] + m;
                    }

                    _interactiveAnchorStart = m;
                }
                else
                {
                    anchorArray[_anchorSettingFrame] = _interactiveAnchorStart + m;
                }
            }
        }
Exemplo n.º 5
0
        void ImGuiLayout()
        {
            // 1. Show a simple window
            // Tip: if we don't call ImGui.Begin()/ImGui.End() the widgets appears in a window automatically called "Debug"
            {
                ImGui.Text("Hello, world!【世界】");
                ImGui.SliderFloat("float", ref f, 0.0f, 1.0f, string.Empty, 1f);
                ImGui.ColorEdit3("clear color", ref clear_color);
                if (ImGui.Button("Test Window"))
                {
                    show_test_window = !show_test_window;
                }
                if (ImGui.Button("Another Window"))
                {
                    show_another_window = !show_another_window;
                }
                ImGui.Text(string.Format("Application average {0:F3} ms/frame ({1:F1} FPS)", 1000f / ImGui.GetIO().Framerate, ImGui.GetIO().Framerate));

                ImGui.InputText("Text input", _textBuffer, 100, ImGuiInputTextFlags.EnterReturnsTrue);

                {
                    var anc = ImGui.GetItemRectMin();
                    var siz = ImGui.GetItemRectSize();
                    Keyboard.SetTextInput(ImGui.IsItemActive(), anc.X, anc.Y, siz.X, siz.Y);
                }


                ImGui.Text("Texture sample");
                ImGui.Image(_imGuiTexture, new Vector2(300, 150), Vector2.Zero, Vector2.One, Vector4.One, Vector4.One); // Here, the previously loaded texture is used
            }

            // 2. Show another simple window, this time using an explicit Begin/End pair
            if (show_another_window)
            {
                ImGui.SetNextWindowSize(new Vector2(200, 100), ImGuiCond.FirstUseEver);
                ImGui.Begin("Another Window", ref show_another_window);
                ImGui.Text("Hello");
                ImGui.End();
            }

            // 3. Show the ImGui test window. Most of the sample code is in ImGui.ShowTestWindow()
            if (show_test_window)
            {
                ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver);
                ImGui.ShowDemoWindow(ref show_test_window);
            }

            //dock test
            if (LoveSharp_Imgui.Thirdparty.Dock.DockWindow.BeginDockspace("my_dock"))
            {
                // dock layout by hard-coded or .ini file

                if (LoveSharp_Imgui.Thirdparty.Dock.DockWindow.BeginDock("Dock 1"))
                {
                    ImGui.Text("I'm Wubugui!");
                }
                LoveSharp_Imgui.Thirdparty.Dock.DockWindow.EndDock();

                if (LoveSharp_Imgui.Thirdparty.Dock.DockWindow.BeginDock("Dock 2"))
                {
                    ImGui.Text("I'm BentleyBlanks!");
                }
                LoveSharp_Imgui.Thirdparty.Dock.DockWindow.EndDock();

                if (LoveSharp_Imgui.Thirdparty.Dock.DockWindow.BeginDock("Dock 3"))
                {
                    ImGui.Text("I'm LonelyWaiting!");
                }
                LoveSharp_Imgui.Thirdparty.Dock.DockWindow.EndDock();

                LoveSharp_Imgui.Thirdparty.Dock.DockWindow.EndDockspace();
            }

            //dock_dc.UpdateAndDraw(new Vector2(500, 500));
        }
    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();
    }
Exemplo n.º 7
0
        protected virtual void ImGuiLayout()
        {
            if (ImGui.Button("Test Window"))
            {
                _showTestWindow = !_showTestWindow;
            }
            if (ImGui.Button("Render Buffers"))
            {
                _showRenderBufferWindow = !_showRenderBufferWindow;
            }
            if (ImGui.Button("Entity List"))
            {
                _showEntityListWindow = !_showEntityListWindow;
            }
            if (ImGui.Button("Viewport"))
            {
                _showViewportWindow = !_showViewportWindow;
            }

            var frameRate = 1000f / ImGui.GetIO().Framerate;

            _frameRateValues[_frameRateValuesIndex++ % MaxFrameRateValues] = frameRate;
            ImGui.PlotHistogram("",
                                ref _frameRateValues[0],
                                MaxFrameRateValues,
                                1,
                                $"framerate (ms/frame) - {ImGui.GetIO().Framerate:F1} FPS",
                                0f,
                                _frameRateValues.Average() * 2,
                                new Num.Vector2(256, 64));

            ImGui.Separator();

            ImGui.Text("Graphics Settings:");

            var graphicsSettingsEnableFxaa = GraphicsManager.Instance.EnableFXAA;

            ImGui.Checkbox("FXAA", ref graphicsSettingsEnableFxaa);
            GraphicsManager.Instance.EnableFXAA = graphicsSettingsEnableFxaa;

            var graphicsSettingsEnableSsao = GraphicsManager.Instance.EnableSSAO;

            ImGui.Checkbox("SSAO", ref graphicsSettingsEnableSsao);
            GraphicsManager.Instance.EnableSSAO = graphicsSettingsEnableSsao;

            var graphicsSettingsEnableLights = GraphicsManager.Instance.EnableLights;

            ImGui.Checkbox("Lights", ref graphicsSettingsEnableLights);
            GraphicsManager.Instance.EnableLights = graphicsSettingsEnableLights;

            var graphicsSettingsEnableShadows = GraphicsManager.Instance.EnableShadows;

            ImGui.Checkbox("Shadows", ref graphicsSettingsEnableShadows);
            GraphicsManager.Instance.EnableShadows = graphicsSettingsEnableShadows;

            if (graphicsSettingsEnableShadows)
            {
                var graphicsSettingsShadowMapResolution = GraphicsManager.Instance.ShadowMapResolution;
                ImGui.InputInt("Resolution", ref graphicsSettingsShadowMapResolution, 1);
                GraphicsManager.Instance.ShadowMapResolution = graphicsSettingsShadowMapResolution;
            }

            var graphicsSettingsEnableSky = GraphicsManager.Instance.EnableSky;

            ImGui.Checkbox("Sky", ref graphicsSettingsEnableSky);
            GraphicsManager.Instance.EnableSky = graphicsSettingsEnableSky;

            var graphicsSettingsEnableVSync = GraphicsManager.Instance.EnableVSync;

            ImGui.Checkbox("VSync", ref graphicsSettingsEnableVSync);
            GraphicsManager.Instance.EnableVSync = graphicsSettingsEnableVSync;

            var graphicsSettingsEnableFullscreen = GraphicsManager.Instance.EnableFullscreen;

            ImGui.Checkbox("Fullscreen", ref graphicsSettingsEnableFullscreen);
            GraphicsManager.Instance.EnableFullscreen = graphicsSettingsEnableFullscreen;

            var graphicsSettingsEnableMaxFps = GraphicsManager.Instance.EnableMaxFps;

            ImGui.Checkbox("Limit FPS", ref graphicsSettingsEnableMaxFps);
            GraphicsManager.Instance.EnableMaxFps = graphicsSettingsEnableMaxFps;

            if (graphicsSettingsEnableMaxFps)
            {
                var graphicsSettingsMaxFps = GraphicsManager.Instance.MaxFps;
                ImGui.InputInt("Max FPS", ref graphicsSettingsMaxFps, 1);
                GraphicsManager.Instance.MaxFps = graphicsSettingsMaxFps;
            }

            if (ImGui.Button("Apply"))
            {
                _game.UpdateGraphicsSettings();
            }

            ImGui.Separator();

            ImGui.Text("Physics Settings:");

            var physicsSystemEnableSimulation = _physicsSystem.EnableSimulation;

            ImGui.Checkbox("Enabled", ref physicsSystemEnableSimulation);
            _physicsSystem.EnableSimulation = physicsSystemEnableSimulation;

            if (_clipboard != null)
            {
                ImGui.Separator();
                ImGui.Text("Clipboard: " + _clipboard.GetType().Name + ":" + _clipboard.GetHashCode());
            }

            if (_showRenderBufferWindow)
            {
                ImGui.SetNextWindowSize(new Num.Vector2(200, 100), ImGuiCond.FirstUseEver);
                ImGui.Begin("Render Buffers", ref _showRenderBufferWindow);

                DisplayImageWithTooltip(_imGuiTexture[0], "Color", new Num.Vector2(300, 150));
                DisplayImageWithTooltip(_imGuiTexture[1], "Depth", new Num.Vector2(300, 150));
                if (GraphicsManager.Instance.EnableLights)
                {
                    DisplayImageWithTooltip(_imGuiTexture[2], "Light Info", new Num.Vector2(300, 150));
                }
                DisplayImageWithTooltip(_imGuiTexture[3], "Normal", new Num.Vector2(300, 150));
                if (GraphicsManager.Instance.EnableLights)
                {
                    DisplayImageWithTooltip(_imGuiTexture[4], "Lights", new Num.Vector2(300, 150));
                }
                if (GraphicsManager.Instance.EnableShadows)
                {
                    DisplayImageWithTooltip(_imGuiTexture[5], "Shadows", new Num.Vector2(300, 300));
                }
                if (GraphicsManager.Instance.EnableSSAO)
                {
                    DisplayImageWithTooltip(_imGuiTexture[6], "SSAO", new Num.Vector2(300, 150));
                }

                ImGui.End();
            }

            if (_showTestWindow)
            {
                ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver);
                ImGui.ShowDemoWindow(ref _showTestWindow);
            }

            if (_showEntityListWindow)
            {
                var windowTitle = "Entity List";

                if (SelectedEntity != null)
                {
                    windowTitle += " - Selected Entity: " + SelectedEntity;
                }

                windowTitle += "###SelectedEntity";

                ImGui.SetNextWindowSize(new Num.Vector2(200, 100), ImGuiCond.FirstUseEver);
                ImGui.Begin(windowTitle, ref _showEntityListWindow);

                ImGui.Columns(2);

                ImGui.BeginChild("Entities###SelectedEntityList");

                foreach (var entity in ActiveEntities)
                {
                    var itemName = entity.ToString();

                    if (EntityIdentifiers.ContainsKey(entity))
                    {
                        itemName += " - " + EntityIdentifiers[entity];
                    }

                    if (ImGui.Selectable(itemName, entity == SelectedEntity))
                    {
                        SelectedEntity = entity;
                    }
                }

                ImGui.EndChild();

                ImGui.NextColumn();

                ImGui.BeginChild("Properties###SelectedEntityProperties");

                if (SelectedEntity != null)
                {
                    BuildComponentListWindow((int)SelectedEntity);
                }

                ImGui.EndChild();

                ImGui.End();
            }

            if (_showViewportWindow)
            {
                BuildViewportWindow(_viewPortTextures);
            }
        }
        public bool LoadDialog(UserData userData, bool dialogOpen)
        {
            bool edited = false;

            if (ImGui.BeginPopupModal("##user_data_dialog", ref dialogOpen))
            {
                if (!canParse)
                {
                    ImGui.TextColored(new System.Numerics.Vector4(1, 0, 0, 1), $"Failed to parse type {userData.Type}!");
                }

                ImGuiHelper.InputFromText("Name", userData, "Name", 200);
                ImGuiHelper.ComboFromEnum <RenderInfoType>("Type", userData, "Type");

                var windowSize = ImGui.GetWindowSize();
                var buffer     = Encoding.UTF8.GetBytes(GetDataString(userData));
                if (buffer.Length == 0)
                {
                    buffer = new byte[1];
                }

                if (ImGui.InputText("Values", buffer, (uint)buffer.Length + 1, ImGuiInputTextFlags.Multiline))
                {
                    canParse = true;

                    var      text   = Encoding.UTF8.GetString(buffer);
                    string[] values = text.Split('\n');

                    try
                    {
                        if (userData.Type == UserDataType.Int32)
                        {
                            int[] data = new int[text.Length];
                            for (int i = 0; i < values.Length; i++)
                            {
                                data[i] = int.Parse(values[i]);
                            }
                            userData.SetValue(data);
                        }
                        else if (userData.Type == UserDataType.Byte)
                        {
                            byte[] data = new byte[text.Length];
                            for (int i = 0; i < values.Length; i++)
                            {
                                data[i] = byte.Parse(values[i]);
                            }
                            userData.SetValue(data);
                        }
                        else if (userData.Type == UserDataType.Single)
                        {
                            float[] data = new float[text.Length];
                            for (int i = 0; i < values.Length; i++)
                            {
                                data[i] = float.Parse(values[i]);
                            }
                            userData.SetValue(data);
                        }
                        else
                        {
                            string[] data = new string[text.Length];
                            for (int i = 0; i < values.Length; i++)
                            {
                                data[i] = values[i];
                            }
                            userData.SetValue(data);
                        }
                    }
                    catch
                    {
                        canParse = false;
                    }
                }

                ImGui.SetCursorPos(new System.Numerics.Vector2(windowSize.X - 110, windowSize.Y - 28));
                if (ImGui.Button("Cancel"))
                {
                    dialogOpen = false;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Ok"))
                {
                    if (canParse && !string.IsNullOrEmpty(userData.Name))
                    {
                        edited     = true;
                        dialogOpen = false;
                        ImGui.CloseCurrentPopup();
                    }
                }
                ImGui.EndPopup();
            }
            return(edited);
        }
Exemplo n.º 9
0
        void TexImportDialog(PopupData data)
        {
            if (teximportprev == null)
            { //processing
                ImGui.Text("Processing...");
                if (!texImportWaiting)
                {
                    if (texImportChildren != null)
                    {
                        selectedNode.Data = null;
                        foreach (var c in texImportChildren)
                        {
                            c.Parent = selectedNode;
                        }
                        selectedNode.Children = texImportChildren;
                    }
                    else
                    {
                        selectedNode.Children = null;
                        selectedNode.Data     = texImportData;
                    }
                    texImportData     = null;
                    texImportChildren = null;
                    ImGui.CloseCurrentPopup();
                }
            }
            else
            {
                ImGui.Image((IntPtr)teximportid, new Vector2(64, 64),
                            new Vector2(0, 1), new Vector2(1, 0), Vector4.One, Vector4.Zero);
                ImGui.Text(string.Format("Dimensions: {0}x{1}", teximportprev.Width, teximportprev.Height));
                ImGui.Combo("Format", ref compressOption, texOptions);
                ImGui.Combo("Mipmaps", ref mipmapOption, mipmapOptions);
                ImGui.Checkbox("High Quality (slow)", ref compressSlow);
                if (ImGui.Button("Import"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev    = null;
                    texImportWaiting = true;
                    new System.Threading.Thread(() =>
                    {
                        var format = DDSFormat.Uncompressed;
                        switch (compressOption)
                        {
                        case 1:
                            format = DDSFormat.DXT1;
                            break;

                        case 2:
                            format = DDSFormat.DXT1a;
                            break;

                        case 3:
                            format = DDSFormat.DXT3;
                            break;

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

                        case 2:
                            mipm = MipmapMethod.Bicubic;
                            break;

                        case 3:
                            mipm = MipmapMethod.Bilinear;
                            break;

                        case 4:
                            mipm = MipmapMethod.Bspline;
                            break;

                        case 5:
                            mipm = MipmapMethod.CatmullRom;
                            break;

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

            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetContentRegionAvailableWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierachyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            if (ImGui.ColorButton("Background Color", new Vector4(background.R, background.G, background.B, 1),
                                  ColorEditFlags.NoAlpha, new Vector2(22, 22)))
            {
                ImGui.OpenPopup("Background Color###" + Unique);
                editCol = new System.Numerics.Vector3(background.R, background.G, background.B);
            }
            if (ImGui.BeginPopupModal("Background Color###" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.ColorPicker3("###a", ref editCol);
                if (ImGui.Button("OK"))
                {
                    background = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Default"))
                {
                    var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                    editCol = new System.Numerics.Vector3(def.R, def.G, def.B);
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Background");
            ImGui.SameLine();
            ImGui.Checkbox("Wireframe", ref doWireframe);
            ImGui.SameLine();
            ImGui.Text("View Mode:");
            ImGui.SameLine();
            ImGui.PushItemWidth(-1);
            ImGui.Combo("##modes", ref viewMode, viewModes);
            ImGui.PopItemWidth();
            DoViewport();
            ImGui.EndChild();
            return(true);
        }
Exemplo n.º 11
0
        //displays selected entity info
        internal override void Display()
        {
            ImGui.SetNextWindowSize(new Vector2(175, 225), ImGuiCond.Once);
            if (ImGui.Begin("Currently selected", _flags))
            {
                if (ImGui.Button("see all small bodies"))
                {
                    SmallBodyEntityInfoPanel.GetInstance().SetActive();
                }

                if (_state.LastClickedEntity != null && _state.StarSystemStates.ContainsKey(_state.SelectedStarSysGuid))
                {
                    if (_state.PrimaryEntity != null)
                    {
                        ImGui.Text("Primary: " + _state.PrimaryEntity.Name);
                    }
                    else
                    {
                        ImGui.Text("(Select primary...)");
                    }

                    ImGui.Text("Subject: " + _state.LastClickedEntity.Name);

                    //ImGui.Text(""+_state.LastClickedEntity.);
                    //gets all children and parent nodes, displays their names and makes them clickable to navigate towards them.



                    if (_state.LastClickedEntity.Entity.HasDataBlob <PositionDB>())
                    {
                        ImGui.Text("Parent entity: ");

                        var  parentEntity    = _state.LastClickedEntity.Entity.GetDataBlob <PositionDB>().Parent;
                        bool hasParentEntity = false;
                        if (parentEntity != null)
                        {
                            //checks if parent exists in the selected star system and has a name
                            //notice that parent can be any bodyType(ex. asteroid, comet, planet etc), unlike childrenEntities, which are more selectively displayed...
                            if (_state.StarSystemStates[_state.SelectedStarSysGuid].EntityStatesWithNames.ContainsKey(parentEntity.Guid))
                            {
                                var tempEntityState = _state.StarSystemStates[_state.SelectedStarSysGuid].EntityStatesWithNames[parentEntity.Guid];
                                hasParentEntity = true;
                                if (ImGui.SmallButton(tempEntityState.Name))
                                {
                                    //if(ImGui.SmallButton(parentEntity.GetDataBlob<NameDB>().GetName(_state.Faction.ID))){
                                    _state.EntityClicked(parentEntity.Guid, _state.SelectedStarSysGuid, MouseButtons.Primary);
                                    //}
                                }
                            }
                        }
                        if (!hasParentEntity)
                        {
                            ImGui.Text("(...No parent entity)");
                        }
                        bool hasChildrenEntities = false;
                        ImGui.Text("Children entities: ");
                        foreach (var childEntity in _state.LastClickedEntity.Entity.GetDataBlob <PositionDB>().Children)
                        {
                            //checks if child exists in the seclted star system and has name
                            if (_state.StarSystemStates[_state.SelectedStarSysGuid].EntityStatesWithNames.ContainsKey(childEntity.Guid))
                            {
                                var tempEntityState = _state.StarSystemStates[_state.SelectedStarSysGuid].EntityStatesWithNames[childEntity.Guid];
                                //only show child entities that arent comets or asteroids if the lastClickedEntity(parent entity) isnt either, if LastClickedEntity(parent entity) is either, then show them always
                                if (_state.LastClickedEntity.BodyType == UserOrbitSettings.OrbitBodyType.Asteroid || _state.LastClickedEntity.BodyType == UserOrbitSettings.OrbitBodyType.Comet || (tempEntityState.BodyType != UserOrbitSettings.OrbitBodyType.Asteroid && tempEntityState.BodyType != UserOrbitSettings.OrbitBodyType.Comet))
                                {
                                    hasChildrenEntities = true;
                                    if (ImGui.SmallButton(tempEntityState.Name))
                                    {
                                        _state.EntityClicked(childEntity.Guid, _state.SelectedStarSysGuid, MouseButtons.Primary);
                                    }
                                }
                            }
                        }
                        if (!hasChildrenEntities)
                        {
                            ImGui.Text("(...No children entities)");
                        }
                    }
                }
                else
                {
                    ImGui.Text("(select subject...)");
                }
                ImGui.End();
            }
        }
Exemplo n.º 12
0
        public static void Parse(ISettings settings, List <ISettingsHolder> draws, int id = -1)
        {
            if (settings == null)
            {
                DebugWindow.LogError("Cant parse null settings.");
                return;
            }

            var props = settings.GetType().GetProperties();

            foreach (var property in props)
            {
                if (property.GetCustomAttribute <IgnoreMenuAttribute>() != null)
                {
                    continue;
                }
                var menuAttribute = property.GetCustomAttribute <MenuAttribute>();
                var isSettings    = property.PropertyType.GetInterfaces().ContainsF(typeof(ISettings));

                if (property.Name == "Enable" && menuAttribute == null)
                {
                    continue;
                }

                if (menuAttribute == null)
                {
                    menuAttribute = new MenuAttribute(Regex.Replace(property.Name, "(\\B[A-Z])", " $1"));
                }

                var holder = new SettingsHolder
                {
                    Name    = menuAttribute.MenuName,
                    Tooltip = menuAttribute.Tooltip,
                    ID      = menuAttribute.index == -1 ? MathHepler.Randomizer.Next(int.MaxValue) : menuAttribute.index
                };

                if (isSettings)
                {
                    var innerSettings = (ISettings)property.GetValue(settings);

                    if (menuAttribute.index != -1)
                    {
                        holder.Type = HolderChildType.Tab;
                        draws.Add(holder);
                        Parse(innerSettings, draws, menuAttribute.index);
                        var parent = GetAllDrawers(draws).Find(x => x.ID == menuAttribute.parentIndex);
                        parent?.Children.Add(holder);
                    }
                    else
                    {
                        Parse(innerSettings, draws);
                    }

                    continue;
                }

                var type = property.GetValue(settings);

                if (menuAttribute.parentIndex != -1)
                {
                    var parent = GetAllDrawers(draws).Find(x => x.ID == menuAttribute.parentIndex);
                    parent?.Children.Add(holder);
                }
                else if (id != -1)
                {
                    var parent = GetAllDrawers(draws).Find(x => x.ID == id);
                    parent?.Children.Add(holder);
                }
                else
                {
                    draws.Add(holder);
                }

                switch (type)
                {
                case ButtonNode n:
                    holder.DrawDelegate = () =>
                    {
                        if (ImGui.Button(holder.Unique))
                        {
                            n.OnPressed();
                        }
                    };

                    break;

                case EmptyNode n:

                    break;

                case HotkeyNode n:
                    holder.DrawDelegate = () =>
                    {
                        var holderName = $"{holder.Name} {n.Value}##{n.Value}";
                        var open       = true;

                        if (ImGui.Button(holderName))
                        {
                            ImGui.OpenPopup(holderName);
                            open = true;
                        }

                        if (ImGui.BeginPopupModal(holderName, ref open, (ImGuiWindowFlags)35))
                        {
                            if (Input.GetKeyState(Keys.Escape))
                            {
                                ImGui.CloseCurrentPopup();
                                ImGui.EndPopup();
                                return;
                            }

                            foreach (var key in Enum.GetValues(typeof(Keys)))
                            {
                                var keyState = Input.GetKeyState((Keys)key);

                                if (keyState)
                                {
                                    n.Value = (Keys)key;
                                    ImGui.CloseCurrentPopup();
                                    break;
                                }
                            }

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

                            ImGui.EndPopup();
                        }
                    };

                    break;

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

                    break;

                case ColorNode n:
                    holder.DrawDelegate = () =>
                    {
                        var vector4 = n.Value.ToVector4().ToVector4Num();

                        if (ImGui.ColorEdit4(holder.Unique, ref vector4,
                                             ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.NoInputs |
                                             ImGuiColorEditFlags.AlphaPreviewHalf))
                        {
                            n.Value = vector4.ToSharpColor();
                        }
                    };

                    break;

                case ListNode n:
                    holder.DrawDelegate = () =>
                    {
                        if (ImGui.BeginCombo(holder.Unique, n.Value))
                        {
                            foreach (var t in n.Values)
                            {
                                if (ImGui.Selectable(t))
                                {
                                    n.Value = t;
                                    ImGui.EndCombo();
                                    return;
                                }
                            }

                            ImGui.EndCombo();
                        }
                    };

                    break;

                case FileNode n:
                    holder.DrawDelegate = () =>
                    {
                        if (ImGui.TreeNode(holder.Unique))
                        {
                            var selected = n.Value;

                            if (ImGui.BeginChildFrame(1, new Vector2(0, 300)))
                            {
                                var di = new DirectoryInfo("config");

                                if (di.Exists)
                                {
                                    foreach (var file in di.GetFiles())
                                    {
                                        if (ImGui.Selectable(file.Name, selected == file.FullName))
                                        {
                                            n.Value = file.FullName;
                                        }
                                    }
                                }

                                ImGui.EndChildFrame();
                            }

                            ImGui.TreePop();
                        }
                    };

                    break;

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

                    break;

                case RangeNode <float> n:

                    holder.DrawDelegate = () =>
                    {
                        var r = n.Value;
                        ImGui.SliderFloat(holder.Unique, ref r, n.Min, n.Max);
                        n.Value = r;
                    };

                    break;

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

                    break;

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

                    break;

                default:
                    Core.Logger.Warning($"{type} not supported for menu now. Ask developers to add this type.");
                    break;
                }
            }
        }
Exemplo n.º 13
0
        static DefaultInspectable()
        {
            Drawers = new List <InspectableDrawer>();

            Drawers.Add(new InspectableDrawer(typeof(string), (ref object v, DiagnosticViewContext context) =>
            {
                var s = (string)v;
                if (ImGui.InputText("", ref s, 1000))
                {
                    v = s;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(bool), (ref object v, DiagnosticViewContext context) =>
            {
                var b = (bool)v;
                if (ImGui.Checkbox("", ref b))
                {
                    v = b;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(int), (ref object v, DiagnosticViewContext context) =>
            {
                var i = (int)v;
                if (ImGui.DragInt("", ref i))
                {
                    v = i;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(float), (ref object v, DiagnosticViewContext context) =>
            {
                var f = (float)v;
                if (ImGui.DragFloat("", ref f))
                {
                    v = f;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Vector3), (ref object v, DiagnosticViewContext context) =>
            {
                var c = (Vector3)v;
                if (ImGui.DragFloat3("", ref c))
                {
                    v = c;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Percentage), (ref object v, DiagnosticViewContext context) =>
            {
                var f = (float)(Percentage)v;
                if (ImGui.DragFloat("", ref f))
                {
                    v = new Percentage(f);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgb), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgb)v).ToVector3();
                if (ImGui.ColorEdit3("", ref c))
                {
                    v = new ColorRgb(
                        (byte)(c.X * 255.0f),
                        (byte)(c.Y * 255.0f),
                        (byte)(c.Z * 255.0f));
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgba), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgba)v).ToVector4();
                if (ImGui.ColorEdit4("", ref c))
                {
                    v = new ColorRgba(
                        (byte)(c.X * 255.0f),
                        (byte)(c.Y * 255.0f),
                        (byte)(c.Z * 255.0f),
                        (byte)(c.W * 255.0f));
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgbF), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgbF)v).ToVector3();
                if (ImGui.ColorEdit3("", ref c))
                {
                    v = new ColorRgbF(c.X, c.Y, c.Z);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgbaF), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgbaF)v).ToVector4();
                if (ImGui.ColorEdit4("", ref c))
                {
                    v = new ColorRgbaF(c.X, c.Y, c.Z, c.W);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Enum), (ref object v, DiagnosticViewContext context) =>
            {
                var e = (Enum)v;
                if (ImGuiUtility.ComboEnum(v.GetType(), "", ref e))
                {
                    v = e;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ILazyAssetReference), (ref object v, DiagnosticViewContext context) =>
            {
                var asset = (ILazyAssetReference)v;
                if (asset.Value != null)
                {
                    if (ImGui.Button(asset.Value.FullName))
                    {
                        context.SelectedObject = asset.Value;
                    }
                }
                else
                {
                    ImGui.Text("<null>");
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(BaseAsset), (ref object v, DiagnosticViewContext context) =>
            {
                var asset = (BaseAsset)v;
                if (ImGui.Button(asset.FullName))
                {
                    context.SelectedObject = v;
                }
                return(false);
            }));

            // Order matters here - this must be last.
            Drawers.Add(new InspectableDrawer(typeof(object), (ref object v, DiagnosticViewContext context) =>
            {
                return(false);
            }, hasChildNodes: true));
        }
Exemplo n.º 14
0
        public override void DrawSettings()
        {
            Settings.ShowInventoryView.Value = ImGuiExtension.Checkbox("Show Inventory Slots", Settings.ShowInventoryView.Value);
            Settings.MoveInventoryView.Value = ImGuiExtension.Checkbox("Moveable Inventory Slots", Settings.MoveInventoryView.Value);

            Settings.PickUpKey = ImGuiExtension.HotkeySelector("Pickup Key: " + Settings.PickUpKey.Value.ToString(), Settings.PickUpKey);
            Settings.LeftClickToggleNode.Value = ImGuiExtension.Checkbox("Mouse Button: " + (Settings.LeftClickToggleNode ? "Left" : "Right"), Settings.LeftClickToggleNode);
            Settings.LeftClickToggleNode.Value = ImGuiExtension.Checkbox("Return Mouse To Position Before Click", Settings.ReturnMouseToBeforeClickPosition);
            Settings.GroundChests.Value        = ImGuiExtension.Checkbox("Click Chests If No Items Around", Settings.GroundChests);
            Settings.PickupRange.Value         = ImGuiExtension.IntSlider("Pickup Radius", Settings.PickupRange);
            Settings.ChestRange.Value          = ImGuiExtension.IntSlider("Chest Radius", Settings.ChestRange);
            Settings.ExtraDelay.Value          = ImGuiExtension.IntSlider("Extra Click Delay", Settings.ExtraDelay);
            Settings.MouseSpeed.Value          = ImGuiExtension.FloatSlider("Mouse speed", Settings.MouseSpeed);
            Settings.TimeBeforeNewClick.Value  = ImGuiExtension.IntSlider("Time wait for new click", Settings.TimeBeforeNewClick);
            //Settings.OverrideItemPickup.Value = ImGuiExtension.Checkbox("Item Pickup Override", Settings.OverrideItemPickup); ImGui.SameLine();
            //ImGuiExtension.ToolTip("Override item.CanPickup\n\rDO NOT enable this unless you know what you're doing!");
            Settings.LazyLooting.Value         = ImGuiExtension.Checkbox("Use Lazy Looting", Settings.LazyLooting);
            Settings.LazyLootingPauseKey.Value = ImGuiExtension.HotkeySelector("Pause lazy looting for 2 sec: " + Settings.LazyLootingPauseKey.Value, Settings.LazyLootingPauseKey);

            var tempRef = false;

            if (ImGui.CollapsingHeader("Pickit Rules", ImGuiTreeNodeFlags.Framed | ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (ImGui.Button("Reload All Files"))
                {
                    LoadRuleFiles();
                }
                Settings.NormalRuleFile = ImGuiExtension.ComboBox("Normal Rules", Settings.NormalRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _normalRules = LoadPickit(Settings.NormalRuleFile);
                }
                Settings.MagicRuleFile = ImGuiExtension.ComboBox("Magic Rules", Settings.MagicRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _magicRules = LoadPickit(Settings.MagicRuleFile);
                }
                Settings.RareRuleFile = ImGuiExtension.ComboBox("Rare Rules", Settings.RareRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _rareRules = LoadPickit(Settings.RareRuleFile);
                }
                Settings.UniqueRuleFile = ImGuiExtension.ComboBox("Unique Rules", Settings.UniqueRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _uniqueRules = LoadPickit(Settings.UniqueRuleFile);
                }
                Settings.WeightRuleFile = ImGuiExtension.ComboBox("Weight Rules", Settings.WeightRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _weightsRules = LoadWeights(Settings.WeightRuleFile);
                }
                Settings.IgnoreRuleFile = ImGuiExtension.ComboBox("Ignore Rules", Settings.IgnoreRuleFile, PickitFiles, out tempRef);
                if (tempRef)
                {
                    _ignoreRules = LoadPickit(Settings.IgnoreRuleFile);
                }
            }

            if (ImGui.CollapsingHeader("Item Logic", ImGuiTreeNodeFlags.Framed | ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (ImGui.TreeNode("Influence Types"))
                {
                    Settings.ShaperItems.Value    = ImGuiExtension.Checkbox("Shaper Items", Settings.ShaperItems);
                    Settings.ElderItems.Value     = ImGuiExtension.Checkbox("Elder Items", Settings.ElderItems);
                    Settings.HunterItems.Value    = ImGuiExtension.Checkbox("Hunter Items", Settings.HunterItems);
                    Settings.CrusaderItems.Value  = ImGuiExtension.Checkbox("Crusader Items", Settings.CrusaderItems);
                    Settings.WarlordItems.Value   = ImGuiExtension.Checkbox("Warlord Items", Settings.WarlordItems);
                    Settings.RedeemerItems.Value  = ImGuiExtension.Checkbox("Redeemer Items", Settings.RedeemerItems);
                    Settings.FracturedItems.Value = ImGuiExtension.Checkbox("Fractured Items", Settings.FracturedItems);
                    Settings.VeiledItems.Value    = ImGuiExtension.Checkbox("Veiled Items", Settings.VeiledItems);
                    ImGui.Spacing();
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Links/Sockets/RGB"))
                {
                    Settings.RGB.Value       = ImGuiExtension.Checkbox("RGB Items", Settings.RGB);
                    Settings.RGBWidth.Value  = ImGuiExtension.IntSlider("Maximum Width##RGBWidth", Settings.RGBWidth);
                    Settings.RGBHeight.Value = ImGuiExtension.IntSlider("Maximum Height##RGBHeight", Settings.RGBHeight);
                    ImGui.Spacing();
                    ImGui.Spacing();
                    ImGui.Spacing();
                    Settings.TotalSockets.Value = ImGuiExtension.IntSlider("##Sockets", Settings.TotalSockets);
                    ImGui.SameLine();
                    Settings.Sockets.Value     = ImGuiExtension.Checkbox("Sockets", Settings.Sockets);
                    Settings.LargestLink.Value = ImGuiExtension.IntSlider("##Links", Settings.LargestLink);
                    ImGui.SameLine();
                    Settings.Links.Value = ImGuiExtension.Checkbox("Links", Settings.Links);
                    ImGui.Separator();
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Overrides"))
                {
                    Settings.UseWeight.Value            = ImGuiExtension.Checkbox("Use Weight", Settings.UseWeight);
                    Settings.IgnoreScrollOfWisdom.Value = ImGuiExtension.Checkbox("Ignore Scroll Of Wisdom", Settings.IgnoreScrollOfWisdom);
                    Settings.PickUpEverything.Value     = ImGuiExtension.Checkbox("Pickup Everything", Settings.PickUpEverything);
                    Settings.AllDivs.Value     = ImGuiExtension.Checkbox("All Divination Cards", Settings.AllDivs);
                    Settings.AllCurrency.Value = ImGuiExtension.Checkbox("All Currency", Settings.AllCurrency);
                    Settings.AllUniques.Value  = ImGuiExtension.Checkbox("All Uniques", Settings.AllUniques);
                    Settings.QuestItems.Value  = ImGuiExtension.Checkbox("Quest Items", Settings.QuestItems);
                    Settings.Maps.Value        = ImGuiExtension.Checkbox("##Maps", Settings.Maps);
                    ImGui.SameLine();
                    if (ImGui.TreeNode("Maps"))
                    {
                        Settings.MapTier.Value      = ImGuiExtension.IntSlider("Lowest Tier", Settings.MapTier);
                        Settings.UniqueMap.Value    = ImGuiExtension.Checkbox("All Unique Maps", Settings.UniqueMap);
                        Settings.MapFragments.Value = ImGuiExtension.Checkbox("Fragments", Settings.MapFragments);
                        ImGui.Spacing();
                        ImGui.TreePop();
                    }

                    Settings.GemQuality.Value = ImGuiExtension.IntSlider("##Gems", "Lowest Quality", Settings.GemQuality);
                    ImGui.SameLine();
                    Settings.Gems.Value = ImGuiExtension.Checkbox("Gems", Settings.Gems);

                    Settings.FlasksQuality.Value = ImGuiExtension.IntSlider("##Flasks", "Lowest Quality", Settings.FlasksQuality);
                    ImGui.SameLine();
                    Settings.Flasks.Value = ImGuiExtension.Checkbox("Flasks", Settings.Flasks);
                    ImGui.Separator();
                    ImGui.TreePop();
                }
                Settings.HeistItems.Value = ImGuiExtension.Checkbox("Heist Items", Settings.HeistItems);

                Settings.Rares.Value = ImGuiExtension.Checkbox("##Rares", Settings.Rares);
                ImGui.SameLine();
                if (ImGui.TreeNode("Rares##asd"))
                {
                    Settings.RareJewels.Value    = ImGuiExtension.Checkbox("Jewels", Settings.RareJewels);
                    Settings.RareRingsilvl.Value = ImGuiExtension.IntSlider("##RareRings", "Lowest iLvl", Settings.RareRingsilvl);
                    ImGui.SameLine();
                    Settings.RareRings.Value       = ImGuiExtension.Checkbox("Rings", Settings.RareRings);
                    Settings.RareAmuletsilvl.Value = ImGuiExtension.IntSlider("##RareAmulets", "Lowest iLvl", Settings.RareAmuletsilvl);
                    ImGui.SameLine();
                    Settings.RareAmulets.Value   = ImGuiExtension.Checkbox("Amulets", Settings.RareAmulets);
                    Settings.RareBeltsilvl.Value = ImGuiExtension.IntSlider("##RareBelts", "Lowest iLvl", Settings.RareBeltsilvl);
                    ImGui.SameLine();
                    Settings.RareBelts.Value      = ImGuiExtension.Checkbox("Belts", Settings.RareBelts);
                    Settings.RareGlovesilvl.Value = ImGuiExtension.IntSlider("##RareGloves", "Lowest iLvl", Settings.RareGlovesilvl);
                    ImGui.SameLine();
                    Settings.RareGloves.Value    = ImGuiExtension.Checkbox("Gloves", Settings.RareGloves);
                    Settings.RareBootsilvl.Value = ImGuiExtension.IntSlider("##RareBoots", "Lowest iLvl", Settings.RareBootsilvl);
                    ImGui.SameLine();
                    Settings.RareBoots.Value       = ImGuiExtension.Checkbox("Boots", Settings.RareBoots);
                    Settings.RareHelmetsilvl.Value = ImGuiExtension.IntSlider("##RareHelmets", "Lowest iLvl", Settings.RareHelmetsilvl);
                    ImGui.SameLine();
                    Settings.RareHelmets.Value    = ImGuiExtension.Checkbox("Helmets", Settings.RareHelmets);
                    Settings.RareArmourilvl.Value = ImGuiExtension.IntSlider("##RareArmours", "Lowest iLvl", Settings.RareArmourilvl);
                    ImGui.SameLine();
                    Settings.RareArmour.Value = ImGuiExtension.Checkbox("Armours", Settings.RareArmour);
                    ImGui.Spacing();
                    ImGui.Spacing();
                    ImGui.Spacing();
                    Settings.RareShieldilvl.Value = ImGuiExtension.IntSlider("##Shields", "Lowest iLvl", Settings.RareShieldilvl);
                    ImGui.SameLine();
                    Settings.RareShield.Value       = ImGuiExtension.Checkbox("Shields", Settings.RareShield);
                    Settings.RareShieldWidth.Value  = ImGuiExtension.IntSlider("Maximum Width##RareShieldWidth", Settings.RareShieldWidth);
                    Settings.RareShieldHeight.Value = ImGuiExtension.IntSlider("Maximum Height##RareShieldHeight", Settings.RareShieldHeight);
                    ImGui.Spacing();
                    ImGui.Spacing();
                    ImGui.Spacing();
                    Settings.RareWeaponilvl.Value = ImGuiExtension.IntSlider("##RareWeapons", "Lowest iLvl", Settings.RareWeaponilvl);
                    ImGui.SameLine();
                    Settings.RareWeapon.Value       = ImGuiExtension.Checkbox("Weapons", Settings.RareWeapon);
                    Settings.RareWeaponWidth.Value  = ImGuiExtension.IntSlider("Maximum Width##RareWeaponWidth", Settings.RareWeaponWidth);
                    Settings.RareWeaponHeight.Value = ImGuiExtension.IntSlider("Maximum Height##RareWeaponHeight", Settings.RareWeaponHeight);
                    if (ImGui.TreeNode("Full Rare Set Manager Integration##FRSMI"))
                    {
                        ImGui.BulletText("You must use github.com/DetectiveSquirrel/FullRareSetManager in order to utilize this section\nThis will determine what items are still needed to be picked up\nfor the chaos recipe, it uses FRSM's count to check this.'");
                        ImGui.Spacing();
                        Settings.FullRareSetManagerOverride.Value = ImGuiExtension.Checkbox("Override Rare Pickup with Full Rare Set Managers' needed pieces", Settings.FullRareSetManagerOverride);

                        Settings.FullRareSetManagerOverrideAllowIdentifiedItems.Value = ImGuiExtension.Checkbox("Pickup Identified items?", Settings.FullRareSetManagerOverrideAllowIdentifiedItems);
                        ImGui.Spacing();
                        ImGui.Spacing();
                        ImGui.BulletText("Set the number you wish to pickup for Full Rare Set Manager overrides\nDefault: -1\n-1 will disable these overrides");
                        ImGui.Spacing();
                        Settings.FullRareSetManagerPickupOverrides.Weapons    = ImGuiExtension.IntSlider("Max Weapons(s)##FRSMOverrides1", Settings.FullRareSetManagerPickupOverrides.Weapons, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Helmets    = ImGuiExtension.IntSlider("Max Helmets##FRSMOverrides2", Settings.FullRareSetManagerPickupOverrides.Helmets, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.BodyArmors = ImGuiExtension.IntSlider("Max Body Armors##FRSMOverrides3", Settings.FullRareSetManagerPickupOverrides.BodyArmors, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Gloves     = ImGuiExtension.IntSlider("Max Gloves##FRSMOverrides4", Settings.FullRareSetManagerPickupOverrides.Gloves, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Boots      = ImGuiExtension.IntSlider("Max Boots##FRSMOverrides5", Settings.FullRareSetManagerPickupOverrides.Boots, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Belts      = ImGuiExtension.IntSlider("Max Belts##FRSMOverrides6", Settings.FullRareSetManagerPickupOverrides.Belts, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Amulets    = ImGuiExtension.IntSlider("Max Amulets##FRSMOverrides7", Settings.FullRareSetManagerPickupOverrides.Amulets, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.Rings      = ImGuiExtension.IntSlider("Max Ring Sets##FRSMOverrides8", Settings.FullRareSetManagerPickupOverrides.Rings, -1, 100);
                        ImGui.Spacing();
                        ImGui.Spacing();
                        ImGui.BulletText("Set the ilvl Min/Max you wish to pickup for Full Rare Set Manager overrides\nIt is up to you how to use these two features\nit does not change how FullRareSetManager counts its sets.\nDefault: -1\n-1 will disable these overrides");
                        ImGui.Spacing();
                        Settings.FullRareSetManagerPickupOverrides.MinItemLevel = ImGuiExtension.IntSlider("Minimum Item Level##FRSMOverrides9", Settings.FullRareSetManagerPickupOverrides.MinItemLevel, -1, 100);
                        Settings.FullRareSetManagerPickupOverrides.MaxItemLevel = ImGuiExtension.IntSlider("Max Item Level##FRSMOverrides10", Settings.FullRareSetManagerPickupOverrides.MaxItemLevel, -1, 100);
                        ImGui.TreePop();
                    }
                    ImGui.TreePop();
                }
            }
        }
Exemplo n.º 15
0
        private void ChatUI()
        {
            if (nulled)
            {
                sleep--;
                if (sleep > 0)
                {
                    return;
                }

                scan1 = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
                scan2 = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

                getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(scan1);
                getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(scan2);
                chatLog         = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);

                if (chatLog != IntPtr.Zero)
                {
                    chatLogPanel_0 = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLogPanel_0", 1);
                    chatLogStuff   = Marshal.ReadIntPtr(chatLog, 0xc8);
                }
            }

            if (pluginInterface.ClientState.LocalPlayer == null || getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1) == IntPtr.Zero)
            {
                if (getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1) == IntPtr.Zero)
                {
                    sleep          = 1000;
                    nulled         = true;
                    chatLogStuff   = IntPtr.Zero;
                    chatLog        = IntPtr.Zero;
                    chatLogPanel_0 = IntPtr.Zero;
                }
            }
            else
            {
                nulled = false;
            }

            if (nulled)
            {
                return;
            }

            ImGuiWindowFlags chat_window_flags     = 0;
            ImGuiWindowFlags chat_sub_window_flags = 0;

            if (no_titlebar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoTitleBar;
            }
            if (no_scrollbar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (no_scrollbar)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (!no_menu)
            {
                chat_window_flags |= ImGuiWindowFlags.MenuBar;
            }
            if (no_move)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMove;
            }
            if (no_resize)
            {
                chat_window_flags |= ImGuiWindowFlags.NoResize;
            }
            if (no_collapse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoCollapse;
            }
            if (no_nav)
            {
                chat_window_flags |= ImGuiWindowFlags.NoNav;
            }
            if (no_mouse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }
            if (no_mouse2)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }


            //otherwise update all the values
            if (chatLogStuff != IntPtr.Zero)
            {
                var chatLogProperties = Marshal.ReadIntPtr(chatLog, 0xC8);
                Marshal.Copy(chatLogProperties + 0x44, chatLogPosition, 0, 2);
                Width   = Marshal.ReadInt16(chatLogProperties + 0x90);
                Height  = Marshal.ReadInt16(chatLogProperties + 0x92);
                Alpha   = Marshal.ReadByte(chatLogProperties + 0x73);
                BoxHide = Marshal.ReadByte(chatLogProperties + 0x182);
            }
            //Get initial hooks in
            else
            {
                chatLog = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
                if (chatLog != IntPtr.Zero)
                {
                    chatLogPanel_0 = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLogPanel_0", 1);
                    chatLogStuff   = Marshal.ReadIntPtr(chatLog, 0xc8);
                }
            }

            if (!skipfont)
            {
                if (font.IsLoaded())
                {
                    ImGui.PushFont(font);
                    if (hideWithChat & Alpha.ToString() != "0")
                    {
                        if (chatWindow)
                        {
                            if (flickback)
                            {
                                no_mouse  = false;
                                flickback = false;
                            }
                            ImGui.SetNextWindowSize(new Num.Vector2(200, 100), ImGuiCond.FirstUseEver);
                            ImGui.SetNextWindowBgAlpha(alpha);
                            ImGui.Begin("Another Window", ref chatWindow, chat_window_flags);
                            ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                            if (overrideChat)
                            {
                                ImGui.SetWindowPos(new Num.Vector2(chatLogPosition[0] + 15, chatLogPosition[1] + 10));
                                ImGui.SetWindowSize(new Num.Vector2(Width - 27, Height - 75));
                                //Marshal.WriteByte(chatLogPanel_0 + 0x182, BoxOff);
                            }
                            else
                            {
                                //Marshal.WriteByte(chatLogPanel_0 + 0x182, BoxOn);
                            }

                            if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                            {
                                int loop = 0;
                                foreach (var tab in items)
                                {
                                    if (tab.Enabled)
                                    {
                                        //WIP

                                        if (tab.sel)
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_sel);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_sel_text);
                                            tab.sel = false;
                                        }
                                        else if (tab.msg)
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_ind);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_ind_text);
                                        }
                                        else
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_norm);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_norm_text);
                                        }



                                        if (ImGui.BeginTabItem(tab.Title))
                                        {
                                            tab.sel = true;

                                            float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                            if (!tab.FilterOn)
                                            {
                                                footer = 0;
                                            }
                                            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Num.Vector2(space_hor, space_ver));
                                            ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer), false, chat_sub_window_flags);


                                            foreach (ChatText line in tab.Chat)
                                            {
                                                if (tab.FilterOn)
                                                {
                                                    if (ContainsText(line.Text, tab.Filter))
                                                    {
                                                        if (tab.Config[0])
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.Time + " ");
                                                            }
                                                            ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                                        }
                                                        if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.ChannelShort + " ");
                                                            }
                                                            ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                                        }
                                                        if (line.Sender.Length > 0)
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.Sender + ":");
                                                            }
                                                            ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                                        }

                                                        int count = 0;
                                                        foreach (TextTypes textTypes in line.Text)
                                                        {
                                                            if (textTypes.Type == PayloadType.RawText)
                                                            {
                                                                ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                                Wrap(textTypes.Text);
                                                                ImGui.PopStyleColor();
                                                            }

                                                            if (textTypes.Type == PayloadType.MapLink)
                                                            {
                                                                if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                                {
                                                                    ImGui.Text("");
                                                                }
                                                                if (ImGui.SmallButton(textTypes.Text))
                                                                {
                                                                    this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                                }
                                                            }

                                                            if (count < (line.Text.Count - 1))
                                                            {
                                                                ImGui.SameLine(); count++;
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (tab.Config[0])
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.Time + " ");
                                                        }
                                                        ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                                    }
                                                    if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.ChannelShort + " ");
                                                        }
                                                        ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                                    }
                                                    if (line.Sender.Length > 0)
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.Sender + ":");
                                                        }
                                                        ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                                    }

                                                    int count = 0;
                                                    foreach (TextTypes textTypes in line.Text)
                                                    {
                                                        if (textTypes.Type == PayloadType.RawText)
                                                        {
                                                            ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                            Wrap(textTypes.Text);
                                                            ImGui.PopStyleColor();
                                                        }

                                                        if (textTypes.Type == PayloadType.MapLink)
                                                        {
                                                            if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                            {
                                                                ImGui.Text("");
                                                            }
                                                            if (ImGui.SmallButton(textTypes.Text))
                                                            {
                                                                this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                            }
                                                        }

                                                        if (count < (line.Text.Count - 1))
                                                        {
                                                            ImGui.SameLine();
                                                            count++;
                                                        }
                                                    }
                                                }
                                            }
                                            if (tab.Scroll == true)
                                            {
                                                ImGui.SetScrollHereY();
                                                tab.Scroll = false;
                                            }
                                            ImGui.PopStyleVar();
                                            ImGui.EndChild();

                                            if (tab.FilterOn)
                                            {
                                                ImGui.InputText("Filter Text", ref tab.Filter, 999);
                                                if (ImGui.IsItemHovered())
                                                {
                                                    ImGui.SetTooltip("Only show lines with this text.");
                                                }
                                            }

                                            if (no_mouse2 && !no_mouse)
                                            {
                                                Num.Vector2 vMin = ImGui.GetWindowContentRegionMin();
                                                Num.Vector2 vMax = ImGui.GetWindowContentRegionMax();

                                                vMin.X += ImGui.GetWindowPos().X;
                                                vMin.Y += ImGui.GetWindowPos().Y + 22;
                                                vMax.X += ImGui.GetWindowPos().X - 22;
                                                vMax.Y += ImGui.GetWindowPos().Y;

                                                if (ImGui.IsMouseHoveringRect(vMin, vMax))
                                                {
                                                    no_mouse = true; flickback = true;
                                                }
                                            }
                                            tab.msg = false;
                                            ImGui.EndTabItem();
                                        }
                                        ImGui.PopStyleColor();
                                        ImGui.PopStyleColor();
                                    }
                                    loop++;
                                }
                                ImGui.EndTabBar();
                                ImGui.End();
                            }
                        }
                    }
                    ImGui.PopFont();
                }
            }



            if (configWindow)
            {
                ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                ImGui.Begin("Chat Config", ref configWindow);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer), false);

                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        ImGui.Text("");

                        ImGui.Columns(3);

                        ImGui.Checkbox("Show Chat Extender", ref chatWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Enable Translations", ref allowTranslation);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable Translations from JPN to ENG");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Chat Bubbles", ref bubblesWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable Chat Bubbles");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("24 Hour Time", ref hourTime);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Switch to 24 Hour (Military) time.");
                        }
                        ImGui.NextColumn();

                        //ImGui.Checkbox("Hide with FFXIV Chat", ref hideWithChat);
                        //if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Spoopy"); }
                        ImGui.Text("");
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Checkbox("Hide Scrollbar", ref no_scrollbar);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Shows ScrollBar");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Position", ref no_move);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the position of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Size", ref no_resize);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the size of the Chat Extender");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("ClickThrough Tab Bar", ref no_mouse);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Tab Bar of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Chat", ref no_mouse2);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Chat Extension chatbox");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Columns(1);
                        ImGui.SliderFloat("Chat Extender Alpha", ref alpha, 0.001f, 0.999f);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the Alpha of the Chat Extender");
                        }
                        ImGui.Text("");

                        ImGui.Text("");
                        ImGui.Text("Highlight Example");
                        HighlightText();
                        ImGui.InputText("##HighlightText", ref tempHigh, 999); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Will highlight EXACT matches only. Seperate words with [,].");
                        }
                        ImGui.SameLine();
                        if (ImGui.Button("Apply"))
                        {
                            high.highlights = tempHigh.Split(',');
                        }
                        ImGui.Columns(4);
                        ImGui.SliderInt("Alpha", ref high.htA, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Blue", ref high.htB, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Green", ref high.htG, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Red", ref high.htR, 0, 255); ImGui.NextColumn();
                        ImGui.Columns(1);
                        ImGui.Text("");

                        ImGui.Columns(1);


                        ImGui.EndTabItem();
                    }


                    if (ImGui.BeginTabItem("Channels"))
                    {
                        ImGui.Columns(4);
                        ImGui.Text("Example"); ImGui.NextColumn();
                        ImGui.Text("Colour 1"); ImGui.NextColumn();
                        ImGui.Text("Colour 2"); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(timeColour, "[12:00]"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Time Colour", ref timeColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(nameColour, "Player Names"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Name Colour", ref nameColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        for (int i = 0; i < (Channels.Length); i++)
                        {
                            ImGui.InputText("##Tab Name" + i.ToString(), ref Chan[i], 99); ImGui.NextColumn();
                            ImGui.TextColored(chanColour[i], "[" + Channels[i] + "]"); ImGui.SameLine(); ImGui.TextColored(logColour[i], "Text"); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour1", ref chanColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour2", ref logColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        }
                        ImGui.Columns(1);
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Tabs"))
                    {
                        if (ImGui.Button("Add New Tab"))
                        {
                            tempTitle = "New";

                            while (CheckDupe(items, tempTitle))
                            {
                                tempTitle += ".";
                            }

                            items.Add(new DynTab(tempTitle, new ConcurrentQueue <ChatText>(), true));
                            tempTitle = "Title";
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Add a new Tab to the Chat Extender");
                        }

                        if (ImGui.TreeNode("Tab Order"))
                        {
                            ImGui.Columns(3);
                            ImGui.Text("Tab"); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();

                            List <TabBase> temp_clone = new List <TabBase>();
                            temp_clone = CopyItems(items);
                            for (int i = 0; i < (items.Count); i++)
                            {
                                ImGui.Text(items[i].Title); ImGui.NextColumn();
                                if (i > 0)
                                {
                                    if (ImGui.Button("^##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i - 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                                if (i < items.Count - 1)
                                {
                                    if (ImGui.Button("v##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i + 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            items = CopyItems(temp_clone);
                            ImGui.TreePop();
                        }

                        ImGui.Separator();
                        foreach (var tab in items)
                        {
                            if (tab.Enabled)
                            {
                                if (ImGui.TreeNode(tab.Title))
                                {
                                    float footer2 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                    ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer2), false);
                                    ImGui.InputText("##Tab Name", ref tempTitle, bufSize);
                                    ImGui.SameLine();
                                    if (ImGui.Button("Set Tab Title"))
                                    {
                                        if (tempTitle.Length == 0)
                                        {
                                            tempTitle += ".";
                                        }

                                        while (CheckDupe(items, tempTitle))
                                        {
                                            tempTitle += ".";
                                        }

                                        tab.Title = tempTitle;
                                        tempTitle = "Title";
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Change the title of the Tab");
                                    }

                                    ImGui.Columns(3);

                                    ImGui.Checkbox("Time Stamp", ref tab.Config[0]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show Timestamps in this Tab");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Channel", ref tab.Config[1]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show the Channel the message came from");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Translate", ref tab.Config[2]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Japanese -> English translation");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Checkbox("AutoScroll", ref tab.AutoScroll);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable the Chat to scroll automatically on a new message");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Save to file", ref tab.Config[3]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Write this tab to '\\My Documents\\FFXIV_ChatExtender\\Logs\\<YYYYMMDD>_TAB.txt");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Enable Filter", ref tab.FilterOn);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Filtering of text");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Columns(1);

                                    ImGui.Text("");


                                    //TODO: Add a confirm prompt

                                    if (EnabledTabs(items) > 1)
                                    {
                                        if (ImGui.Button("Delete Tab"))
                                        {
                                            tab.Enabled = false;
                                        }
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Removes Tab");
                                    }



                                    ImGui.Columns(2);
                                    ImGui.Text("Channel"); ImGui.NextColumn();
                                    if (tab.Config[1])
                                    {
                                        ImGui.Text("Show Short");
                                    }
                                    else
                                    {
                                        ImGui.Text("");
                                    }
                                    ImGui.NextColumn();

                                    for (int i = 0; i < (Channels.Length); i++)
                                    {
                                        ImGui.PushStyleColor(ImGuiCol.Text, chanColour[i]);
                                        ImGui.Checkbox("[" + Channels[i] + "]", ref tab.Logs[i]); ImGui.NextColumn();
                                        if (tab.Config[1])
                                        {
                                            ImGui.Checkbox(Chan[i], ref tab.Chans[i]);
                                        }
                                        else
                                        {
                                            ImGui.Text("");
                                        }
                                        ImGui.NextColumn();
                                        ImGui.PopStyleColor();
                                    }
                                    ImGui.Columns(1);
                                    ImGui.EndChild();
                                    ImGui.TreePop();
                                }
                            }
                        }
                        ImGui.EndTabItem();
                    }

                    if (allowTranslation)
                    {
                        if (ImGui.BeginTabItem("Translator"))
                        {
                            ImGui.Checkbox("Inject Translation", ref injectChat);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Inject translated text into the normal FFXIV Chatbox");
                            }

                            ImGui.Text("Surrounds of Translated text");
                            ImGui.PushItemWidth(24);
                            ImGui.InputText("##Left", ref lTr, 3); ImGui.SameLine();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Alter the characters on the left of Translated text");
                            }
                            ImGui.PopItemWidth();
                            ImGui.Text("Translation"); ImGui.SameLine();
                            ImGui.PushItemWidth(24);
                            ImGui.InputText("##Right", ref rTr, 3);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Alter the characters on the right of Translated text");
                            }
                            ImGui.PopItemWidth();
                            ImGui.Text("");
                            ImGui.EndTabItem();

                            ImGui.InputText("Yandex Key", ref yandex, 999);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Key to allow the translator to use the Yandex service");
                            }

                            ImGui.Text("Translator");
                            if (translator == 1)
                            {
                                ImGui.Text("[Google] is set.");
                                if (ImGui.Button("Switch to Yandex"))
                                {
                                    translator = 2;
                                }
                            }

                            if (translator == 2)
                            {
                                ImGui.Text("[Yandex] is set.");
                                if (ImGui.Button("Switch to Google"))
                                {
                                    translator = 1;
                                }
                            }
                            ImGui.EndTabItem();
                        }
                    }

                    if (ImGui.BeginTabItem("Font"))
                    {
                        ImGui.Columns(3);
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("H Space", ref space_hor);
                        ImGui.PopItemWidth();
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Horizontal spacing of chat text");
                        }
                        ImGui.NextColumn();
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("V Space", ref space_ver);
                        ImGui.PopItemWidth();
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Vertical spacing of cha text");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();
                        ImGui.Columns(1);
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("Font Size", ref fontsize); ImGui.SameLine();
                        ImGui.PopItemWidth();
                        if (ImGui.SmallButton("Apply"))
                        {
                            UpdateFont();
                        }
                        ImGui.Checkbox("Font Shadow", ref fontShadow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("WARNING! This is a large tax on processing.\nIf you encounter slowdown, disable this!");
                        }
                        ImGui.EndTabItem();
                    }
                    if (bubblesWindow)
                    {
                        if (ImGui.BeginTabItem("Bubbles"))
                        {
                            ImGui.Columns(3);
                            //ImGui.Checkbox("Debug", ref drawDebug);
                            ImGui.Checkbox("Displacement Up", ref boolUp); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("When bubbles collide, move the newest one Up instead of Down.");
                            }
                            //ImGui.InputFloat("MinH", ref minH);
                            //ImGui.InputFloat("MaxH", ref maxH);
                            ImGui.Checkbox("Show Channel", ref bubblesChannel); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Show Channel in the bubble.");
                            }
                            ImGui.PushItemWidth(80);
                            ImGui.InputInt("Duration", ref bubbleTime);
                            ImGui.PopItemWidth(); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Seconds the bubbles exist for.");
                            }
                            //ImGui.InputInt("X Disp", ref xDisp);
                            //ImGui.InputInt("Y Disp", ref yDisp);
                            //ImGui.InputInt("X Cut", ref xCut);
                            //ImGui.InputInt("Y Cut", ref yCut);
                            //ImGui.ColorEdit4("Bubble Colour", ref bubbleColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel);
                            //ImGui.InputFloat("Rounding", ref bubbleRounding);
                            ImGui.Separator();
                            ImGui.Text("Channel"); ImGui.NextColumn();
                            ImGui.Text("Enabled"); ImGui.NextColumn();
                            ImGui.Text("Colour"); ImGui.NextColumn();
                            for (int i = 0; i < (Channels.Length); i++)
                            {
                                ImGui.Text(Channels[i]); ImGui.SameLine(); ImGui.NextColumn();
                                ImGui.Checkbox("##" + Channels[i], ref bubbleEnable[i]); ImGui.NextColumn();
                                ImGui.ColorEdit4(Channels[i] + " ColourBubble", ref bubbleColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            ImGui.EndTabItem();
                        }
                    }
                }

                ImGui.EndTabBar();
                ImGui.EndChild();

                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();

                    configWindow = false;
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                }
                ImGui.End();
            }
        }
Exemplo n.º 16
0
        void NewHardpoint(PopupData data)
        {
            ImGui.Text("Name: ");
            ImGui.SameLine();
            newHpBuffer.InputText("##hpname", ImGuiInputTextFlags.None);
            ImGui.SameLine();
            if (ImGui.Button(".."))
            {
                ImGui.OpenPopup("names");
            }
            if (ImGui.BeginPopupContextItem("names"))
            {
                var infos = newIsFixed ? HardpointInformation.Fix : HardpointInformation.Rev;
                foreach (var item in infos)
                {
                    if (Theme.IconMenuItem(item.Name, item.Icon, item.Color, true))
                    {
                        switch (item.Autoname)
                        {
                        case HpNaming.None:
                            newHpBuffer.SetText(item.Name);
                            break;

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

                        case HpNaming.Letter:
                            newHpBuffer.SetText(item.Name + GetHpLettering(item.Name));
                            break;
                        }
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.Text("Type: " + (newIsFixed ? "Fixed" : "Revolute"));
            if (newErrorTimer > 0)
            {
                ImGui.TextColored(new Vector4(1, 0, 0, 1), "Hardpoint with that name already exists.");
            }
            if (ImGui.Button("Ok"))
            {
                var txt = newHpBuffer.GetText();
                if (txt.Length == 0)
                {
                    return;
                }
                if (gizmos.Any((x) => x.Hardpoint.Definition.Name.Equals(txt, StringComparison.OrdinalIgnoreCase)))
                {
                    newErrorTimer = 6;
                }
                else
                {
                    HardpointDefinition def;
                    if (newIsFixed)
                    {
                        def = new FixedHardpointDefinition(txt);
                    }
                    else
                    {
                        def = new RevoluteHardpointDefinition(txt);
                    }
                    gizmos.Add(new HardpointGizmo(new Hardpoint(def, addTo), addTo));
                    addTo.Hardpoints.Add(new Hardpoint(def, addTo));
                    OnDirtyHp();
                    ImGui.CloseCurrentPopup();
                }
            }
            ImGui.SameLine();
            if (ImGui.Button("Cancel"))
            {
                ImGui.CloseCurrentPopup();
            }
        }
    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);
    }
Exemplo n.º 18
0
 unsafe void HardpointEditor()
 {
     if (hpEditing == null)
     {
         hpEditOpen = false;
         return;
     }
     if (hpEditing != null && hpEditOpen == false)
     {
         editingGizmo = gizmos.First((x) => x.Hardpoint == hpEditing);
         hpEditOpen   = true;
         hpFirst      = true;
         SetHardpointValues();
     }
     if (ImGui.Begin("Hardpoint Editor##" + Unique, ref hpEditOpen, hpFirst ? ImGuiWindowFlags.AlwaysAutoResize : ImGuiWindowFlags.None))
     {
         hpFirst = false;
         ImGui.Text(hpEditing.Name);
         bool isFix = hpEditing.Definition is FixedHardpointDefinition;
         ImGui.Text("Type: " + (isFix ? "Fixed" : "Revolute"));
         if (ImGui.Button("Reset"))
         {
             SetHardpointValues();
         }
         ImGui.Separator();
         ImGui.Text("Position");
         ImGui.InputFloat("X##posX", ref HPx, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Y##posY", ref HPy, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Z##posZ", ref HPz, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.Separator();
         ImGui.Text("Rotation");
         ImGui.InputFloat("Pitch", ref HPpitch, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Yaw", ref HPyaw, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Roll", ref HProll, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.Separator();
         if (!isFix)
         {
             ImGui.Text("Axis");
             ImGui.InputFloat("X##axisX", ref HPaxisX, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Y##axisY", ref HPaxisY, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Z##axisZ", ref HPaxisZ, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Min", ref HPmin, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Max", ref HPmax, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.Separator();
         }
         if (ImGui.Button("Apply"))
         {
             var hp = hpEditing.Definition;
             hp.Position    = new Vector3(HPx, HPy, HPz);
             hp.Orientation = Matrix4x4.CreateFromYawPitchRoll(
                 MathHelper.DegreesToRadians(HPyaw),
                 MathHelper.DegreesToRadians(HPpitch),
                 MathHelper.DegreesToRadians(HProll)
                 );
             if (!isFix)
             {
                 var rev = (RevoluteHardpointDefinition)hp;
                 if (HPmin > HPmax)
                 {
                     var t = HPmin;
                     HPmin = HPmax;
                     HPmax = t;
                     popups.OpenPopup("Warning");
                 }
                 rev.Min  = MathHelper.DegreesToRadians(HPmin);
                 rev.Max  = MathHelper.DegreesToRadians(HPmax);
                 rev.Axis = new Vector3(HPaxisX, HPaxisY, HPaxisZ);
             }
             hpEditOpen = false;
             OnDirtyHp();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             hpEditOpen = false;
         }
         editingGizmo.Override = Matrix4x4.CreateFromYawPitchRoll(
             MathHelper.DegreesToRadians(HPyaw),
             MathHelper.DegreesToRadians(HPpitch),
             MathHelper.DegreesToRadians(HProll)
             ) * Matrix4x4.CreateTranslation(HPx, HPy, HPz);
         editingGizmo.EditingMin = MathHelper.DegreesToRadians(HPmin);
         editingGizmo.EditingMax = MathHelper.DegreesToRadians(HPmax);
         ImGui.End();
     }
     if (hpEditOpen == false)
     {
         hpEditing             = null;
         editingGizmo.Override = null;
         editingGizmo          = null;
     }
 }
Exemplo n.º 19
0
        public bool ShowFilePickerDialog(string title, out string selectedFile)
        {
            selectedFile = null;
            bool result = false;

            if (_isVisible)
            {
                ImGui.OpenPopup(title);
            }

            if (ImGui.BeginPopupModal(title))
            {
                if (!_isVisible)
                {
                    ImGui.CloseCurrentPopup();
                    ImGui.EndPopup();
                    return(false);
                }
                DirectoryInfo di;
                try
                {
                    di = new DirectoryInfo(_currentDirectory);
                }
                catch
                {
                    selectedFile = null;
                    ImGui.EndPopup();
                    return(false);
                }

                ImGui.LabelText("Directory", di.FullName);

                if (di.Parent != null && ImGui.Button(".."))
                {
                    _currentDirectory = di.Parent.FullName;
                }

                FileSystemInfo[] children;
                try
                {
                    children = di.GetFileSystemInfos();
                }
                catch (UnauthorizedAccessException)
                {
                    children = Array.Empty <FileSystemInfo>();
                }
                foreach (var fsi in children)
                {
                    if (ImGui.Button(fsi.Name))
                    {
                        if (fsi is DirectoryInfo)
                        {
                            _currentDirectory = fsi.FullName;
                        }
                        else if (fsi is FileInfo)
                        {
                            selectedFile = fsi.FullName;
                            result       = true;
                        }
                        else
                        {
                            throw new NotImplementedException($"Handling {fsi.GetType().Name} files is not supported.");
                        }
                    }
                }

                ImGui.EndPopup();
            }

            return(result);
        }
Exemplo n.º 20
0
        public void Draw(ref bool isGameViewFocused)
        {
            var viewport = ImGui.GetMainViewport();

            ImGui.SetNextWindowPos(viewport.GetWorkPos());
            ImGui.SetNextWindowSize(viewport.GetWorkSize());
            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))
                    {
                        foreach (var side in _playableSides)
                        {
                            if (ImGui.MenuItem(side.Side))
                            {
                                _faction = side;
                                ImGui.SetWindowFocus(side.Name);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Map: " + _map.Item1.Name))
                    {
                        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.StartMultiPlayerGame(
                                _map.Item1.Name,
                                new EchoConnection(),
                                new PlayerSetting?[]
                            {
                                new PlayerSetting(null, _faction, new ColorRgb(255, 0, 0), PlayerOwner.Player),
                                new PlayerSetting(null, faction2, new ColorRgb(255, 255, 255), PlayerOwner.EasyAi),
                            },
                                0
                                );
                        }
                        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.Game.Window.Fullscreen;
                    if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true))
                    {
                        _context.Game.Window.Fullscreen = isFullscreen;
                    }
                    ImGui.EndMenu();
                }

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

                    if (ImGui.MenuItem("Trigger Capture"))
                    {
                        renderDoc.TriggerCapture();
                    }
                    if (ImGui.BeginMenu("Options"))
                    {
                        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"))
                    {
                        renderDoc.LaunchReplayUI();
                    }

                    ImGui.EndMenu();
                }

                DrawTimingControls();

                var fpsText     = $"{ImGui.GetIO().Framerate:N2} FPS";
                var fpsTextSize = ImGui.CalcTextSize(fpsText).X;
                ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - 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.Game.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();
        }
Exemplo n.º 21
0
        private static void BuildComponentPropertiesList(IComponent component, Entity entity, ref object clipboard)
        {
            var isAlive = true;

            if (component != null && ImGui.CollapsingHeader(component.GetType().Name, ref isAlive))
            {
                if (ImGui.IsItemHovered())
                {
                    var io = ImGui.GetIO();

                    if (io.KeyCtrl && ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.C)))
                    {
                        ImGui.BeginTooltip();
                        ImGui.Text("Copied: " + component.GetHashCode());
                        clipboard = component;
                        ImGui.EndTooltip();
                    }
                }
                foreach (var property in component.GetType().GetProperties())
                {
                    var propertyValue = property.GetValue(component, null);

                    if (ImGui.TreeNode(property.Name))
                    {
                        if (property.CanWrite)
                        {
                            switch (propertyValue)
                            {
                            case Vector3 vector:
                            {
                                var x = vector.X;
                                var y = vector.Y;
                                var z = vector.Z;

                                ImGui.InputFloat("x###" + "PropertyVector3X:" + property.Name + ":" + component.GetType().Name, ref x);
                                ImGui.InputFloat("y###" + "PropertyVector3Y:" + property.Name + ":" + component.GetType().Name, ref y);
                                ImGui.InputFloat("z###" + "PropertyVector3Z:" + property.Name + ":" + component.GetType().Name, ref z);

                                propertyValue = new Vector3(x, y, z);
                                property.SetValue(component, propertyValue);
                                break;
                            }

                            case Quaternion quaternion:
                            {
                                var x = quaternion.X;
                                var y = quaternion.Y;
                                var z = quaternion.Z;
                                var w = quaternion.W;

                                ImGui.InputFloat("x###" + "PropertyQuaternionX:" + property.Name + ":" + component.GetType().Name, ref x);
                                ImGui.InputFloat("y###" + "PropertyQuaternionY:" + property.Name + ":" + component.GetType().Name, ref y);
                                ImGui.InputFloat("z###" + "PropertyQuaternionZ:" + property.Name + ":" + component.GetType().Name, ref z);
                                ImGui.InputFloat("w###" + "PropertyQuaternionW:" + property.Name + ":" + component.GetType().Name, ref w);

                                propertyValue = new Quaternion(x, y, z, w);
                                property.SetValue(component, propertyValue);
                                break;
                            }

                            case PrimitiveType type:
                            {
                                var intType = (int)type;
                                ImGui.SliderInt("Type###PropertyPrimitiveType:" + property.Name + ":" + component.GetType().Name, ref intType, 0, 2, type.ToString());

                                propertyValue = (PrimitiveType)intType;
                                property.SetValue(component, propertyValue);
                                break;
                            }

                            case Color color:
                            {
                                var vec4Color = color.ToVector4();
                                var inColor   = new global::System.Numerics.Vector4(vec4Color.X, vec4Color.Y, vec4Color.Z, vec4Color.W);

                                ImGui.ColorEdit4("Color###PropertyColor:" + property.Name + ":" + component.GetType().Name, ref inColor);

                                propertyValue = new Color(inColor.X, inColor.Y, inColor.Z, inColor.W);
                                property.SetValue(component, propertyValue);
                                break;
                            }

                            case float value:
                            {
                                var floatValue = value;

                                ImGui.InputFloat("value###" + "PropertyFloatValue:" + property.Name + ":" + component.GetType().Name, ref floatValue);

                                property.SetValue(component, floatValue);
                                break;
                            }

                            case Model model:
                                ImGui.Text("Root: " + model.Root.Name);
                                ImGui.Text("Hash: " + model.GetHashCode());
                                break;

                            case bool boolean:
                            {
                                var boolValue = boolean;
                                ImGui.Checkbox("###PropertyBooleanValue:" + property.Name + ":" + component.GetType().Name, ref boolValue);
                                property.SetValue(component, boolValue);
                                break;
                            }

                            case DPModel dpModel:
                                ImGui.Text("Name: " + dpModel.Name);
                                ImGui.Text("Triangle Count: " + dpModel.PrimitiveCount);
                                ImGui.Text("BoundingBox: " + dpModel.BoundingBox);
                                break;

                            case TransformComponent transformComponent:
                            {
                                if (property.PropertyType == typeof(TransformComponent) && clipboard != null && clipboard.GetType() == typeof(TransformComponent) && component != clipboard)
                                {
                                    if (ImGui.Button("Replace with clipboard"))
                                    {
                                        property.SetValue(component, clipboard);
                                    }
                                }
                                ImGui.Text("Position: " + transformComponent.Position);
                                ImGui.Text("Scale: " + transformComponent.Scale);
                                ImGui.Text("Rotation: " + transformComponent.Rotation);
                                break;
                            }

                            case null when property.PropertyType == typeof(TransformComponent) && clipboard != null && clipboard.GetType() == typeof(TransformComponent) && component != clipboard:
                            {
                                if (ImGui.Button("Paste TransformComponent"))
                                {
                                    property.SetValue(component, clipboard);
                                }
                                break;
                            }

                            case null:
                                ImGui.Text("None");
                                break;
                            }
                        }
                        else
                        {
                            ImGui.Text(propertyValue.ToString());
                        }

                        ImGui.TreePop();
                    }
                }
            }

            if (!isAlive)
            {
                var detachMethod        = typeof(Entity).GetMethod("Detach");
                var detachGenericMethod = detachMethod.MakeGenericMethod(component.GetType());
                detachGenericMethod.Invoke(entity, null);
            }
        }
Exemplo n.º 22
0
        private static void SubmitDockableUi()
        {
            { //Declare Standalone Windows here
#if DEBUG
                //Debug Window
                {
                    if (ImGui.Button("Throw Another Exception"))
                    {
                        ExceptionManager.PushExceptionForRendering
                        (
                            $"DummyException:{new Random().Next()}",
                            new Exception("hAaaaa")
                        );
                    }
                }
#endif
                // Color Picker
                if (CPickerIsEnable)
                {
                    ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver);
                    if (ImGui.Begin("FFX Color Picker", ref CPickerIsEnable))
                    {
                        Vector2 mEme = ImGui.GetWindowSize();
                        if (mEme.X > mEme.Y)
                        {
                            ImGui.SetNextItemWidth(mEme.Y * 0.80f);
                        }
                        ImGui.ColorPicker4("CPicker", ref CPicker, ImGuiColorEditFlags.AlphaPreviewHalf | ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.NoTooltip);
                        if (ImGui.IsItemDeactivatedAfterEdit())
                        {
                            var actionList = new List <Action>();

                            if (CPickerRed.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerGreen.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerBlue.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerAlpha.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt")
                            {
                                actionList.Add(new ModifyXAttributeString(CPickerRed.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat"));
                                actionList.Add(new ModifyXAttributeString(CPickerGreen.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat"));
                                actionList.Add(new ModifyXAttributeString(CPickerBlue.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat"));
                                actionList.Add(new ModifyXAttributeString(CPickerAlpha.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat"));
                            }
                            actionList.Add(new ModifyXAttributeFloat(CPickerRed.Attribute("Value"), CPicker.X));
                            actionList.Add(new ModifyXAttributeFloat(CPickerGreen.Attribute("Value"), CPicker.Y));
                            actionList.Add(new ModifyXAttributeFloat(CPickerBlue.Attribute("Value"), CPicker.Z));
                            actionList.Add(new ModifyXAttributeFloat(CPickerAlpha.Attribute("Value"), CPicker.W));

                            SelectedFfxWindow.ActionManager.ExecuteAction(new CompoundAction(actionList));
                        }
                        ImGui.Separator();
                        ImGui.Text("Brightness Multiplier");
                        ImGui.SliderFloat("###Brightness Multiplier", ref ColorOverload, 0, 10f);
                        ImGui.SameLine();
                        if (ImGuiAddons.ButtonGradient("Multiply Color"))
                        {
                            List <Action> actions = new List <Action>();
                            CPicker.X *= ColorOverload;
                            CPicker.Y *= ColorOverload;
                            CPicker.Z *= ColorOverload;
                            actions.Add(new EditPublicCPickerVector4(new Vector4(CPicker.X *= ColorOverload, CPicker.Y *= ColorOverload, CPicker.Z *= ColorOverload, CPicker.W)));
                            actions.Add(new ModifyXAttributeFloat(CPickerRed.Attribute("Value"), CPicker.X));
                            actions.Add(new ModifyXAttributeFloat(CPickerGreen.Attribute("Value"), CPicker.Y));
                            actions.Add(new ModifyXAttributeFloat(CPickerBlue.Attribute("Value"), CPicker.Z));
                            SelectedFfxWindow.ActionManager.ExecuteAction(new CompoundAction(actions));
                        }
                        ImGui.End();
                    }
                }
                // Keyboard Guide
                if (_keyboardInputGuide)
                {
                    ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver);
                    ImGui.Begin("Keyboard Guide", ref _keyboardInputGuide, ImGuiWindowFlags.MenuBar);
                    ImGui.BeginMenuBar();
                    ImGui.EndMenuBar();
                    ImGui.ShowUserGuide();
                    ImGui.End();
                }
                if (_axbyDebugger)
                {
                    ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver);
                    ImGui.Begin("axbxDebug", ref _axbyDebugger);
                    if (SelectedFfxWindow.NodeListEditor != null)
                    {
                        if (SelectedFfxWindow.NodeListEditor.Any() & (SelectedFfxWindow.ShowFfxEditorFields || SelectedFfxWindow.ShowFfxEditorProperties))
                        {
                            int integer = 0;
                            foreach (XNode node in SelectedFfxWindow.NodeListEditor.ElementAt(0).Parent.Nodes())
                            {
                                ImGui.Text($"Index = '{integer} Node = '{node}')");
                                integer++;
                            }
                        }
                    }
                    ImGui.End();
                }
                if (MainUserInterface.IsSearchBarOpen)
                {
                    var viewport = ImGui.GetMainViewport();

                    ImGui.SetNextWindowSize(new Vector2(300, 80));
                    ImGui.SetNextWindowPos(new Vector2(viewport.Pos.X + viewport.Size.X - 15, viewport.Pos.Y + 38), ImGuiCond.None, new Vector2(1, 0));
                    ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0);
                    if (ImGui.Begin("Action Search", ref MainUserInterface.IsSearchBarOpen, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove))
                    {
                        ImGui.SetNextItemWidth(190);
                        ImGui.InputText("Action Search", ref MainUserInterface.SearchBarString, 1024);
                        ImGui.Checkbox("Search By ID", ref MainUserInterface.IsSearchById);

                        ImGui.End();
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void RenderGameSettings()
        {
            bool useRecursiveOpen = _field.UseRecursiveOpen;

            ImGui.Begin("Game Settings");
            ImGui.Text($"TIME: {_gameTimeHandler.SecondsElapsed.ToString("F1", CultureInfo.InvariantCulture)}");
            ImGui.Text($"Total Mines: {_field.TotalMines}");
            ImGui.Text($"Total Cells: {_field.TotalCells}");
            ImGui.Text($"Field Resolution: {_field.Width}x{_field.Height}");
            ImGui.Text($"Mines Left: {_field.MinesLeft}");
            ImGui.Text($"Free cells: {_field.FreeCellsLeft}");
            ImGui.Text($"Total open cells: {_field.TotalOpenCells}");

            /*int seed = _field.Seed;
             * ImGui.InputInt("Seed", ref seed, 1, 10);*/

            ImGui.Checkbox($"Use recursive open", ref useRecursiveOpen);
            ImGui.SameLine();
            HelpMarker("Recursively opens cells around the clicked cell if its number value is the same as flags around");

            if (ImGui.Button("New Game"))
            {
                Start();
            }
            ImGui.SameLine();
            if (ImGui.Button("Restart"))
            {
                _field.Reset();
            }

            if (_playerTurnsContainer.IsUndoAvailable)
            {
                ImGui.SameLine();
                if (ImGui.Button("Undo"))
                {
                    _playerTurnsContainer.UndoTurn();
                }
            }
            if (_playerTurnsContainer.IsRedoAvailable)
            {
                ImGui.SameLine();
                if (ImGui.Button("Redo"))
                {
                    _playerTurnsContainer.RedoTurn();
                }
            }

            if (_gameStateManager.CurrentState != GameState.NewGame)
            {
                ImGui.SameLine();
                if (ImGui.Button("Solve"))
                {
                    var snapshot = _field.CreateSnapshot();
                    _field.Solve();
                    _playerTurnsContainer.AddTurn(
                        snapshot, null, "Solved the board automatically",
                        _gameTimeHandler.SecondsElapsed
                        );
                    _gameStateManager.CurrentState = GameState.Won;
                }
            }

            ImGui.Separator();
            ImGui.SetNextItemWidth(ImGui.GetFontSize() * 6f);
            ImGui.InputInt("Field Width", ref _fieldWidth);
            ImGui.SetNextItemWidth(ImGui.GetFontSize() * 6f);
            ImGui.InputInt("Field Height", ref _fieldHeight);
            ImGui.SetNextItemWidth(ImGui.GetFontSize() * 6f);
            ImGui.InputInt("Total Mines", ref _totalMines);
            ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8f);
            var names = Enum.GetNames(typeof(MinePutterDifficulty));

            ImGui.ListBox("Mine Putter Difficulty", ref _minePutterDifficulty,
                          names, names.Length);

            if (ImGui.Button("Submit"))
            {
                Start();
            }

            ImGui.Separator();

            ImGui.Text("Difficulty Presets:");
            if (ImGui.Button("Easy"))
            {
                _fieldWidth  = 9;
                _fieldHeight = 9;
                _totalMines  = 10;
                Start();
            }
            ImGui.SameLine();
            HelpMarker("9x9, 10 mines");
            ImGui.SameLine();
            if (ImGui.Button("Medium"))
            {
                _fieldWidth  = 16;
                _fieldHeight = 16;
                _totalMines  = 40;
                Start();
            }

            ImGui.SameLine();
            HelpMarker("16x16, 40 mines");
            ImGui.SameLine();
            if (ImGui.Button("Hard"))
            {
                _fieldWidth  = 30;
                _fieldHeight = 16;
                _totalMines  = 99;
                Start();
            }
            ImGui.SameLine();
            HelpMarker("30x16, 99 mines");

            ImGui.End();

            _field.UseRecursiveOpen = useRecursiveOpen;
        }
Exemplo n.º 24
0
        /// <summary>
        /// </summary>
        private void HandleAddRemoveButtons()
        {
            if (ImGui.Button("Add"))
            {
                var sv = new SliderVelocityInfo()
                {
                    StartTime  = (int)AudioEngine.Track.Time,
                    Multiplier = 1.0f
                };

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;
                screen?.Ruleset.ActionManager.Perform(new EditorActionAddSliderVelocity(WorkingMap, sv));

                SelectedVelocities.Clear();
                SelectedVelocities.Add(sv);
                NeedsToScroll = true;

                TextTime       = sv.StartTime.ToString(CultureInfo.InvariantCulture);
                TextMultiplier = $"{sv.Multiplier:0.00}";
            }

            ImGui.SameLine();

            if (ImGui.Button("Remove"))
            {
                if (SelectedVelocities.Count == 0)
                {
                    return;
                }

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;

                var lastSv = SelectedVelocities.Last();

                screen?.Ruleset.ActionManager.Perform(new EditorActionRemoveSliderVelocities(WorkingMap, new List <SliderVelocityInfo>(SelectedVelocities)));

                SelectedVelocities.Clear();

                if (WorkingMap.SliderVelocities.Count != 0)
                {
                    var sv = WorkingMap.SliderVelocities.FindLast(x => x.StartTime <= lastSv.StartTime);

                    if (sv != null)
                    {
                        TextTime       = sv.StartTime.ToString(CultureInfo.InvariantCulture);
                        TextMultiplier = $"{sv.Multiplier:0.00}";
                        SelectedVelocities.Add(sv);
                    }
                    else
                    {
                        TextTime       = "";
                        TextMultiplier = $"";
                    }
                }
                else
                {
                    TextTime       = "";
                    TextMultiplier = $"";
                }

                NeedsToScroll = true;
            }
        }
        public void UpdateUI()
        {
            const int MenuWidth = 180;

            if (_game.DebugDrawer.ShowUI)
            {
                _game.Test.Render();
                ImGui.SetNextWindowPos(new Vector2((float)Global.Camera.Width - MenuWidth - 10, 10));
                ImGui.SetNextWindowSize(new Vector2(MenuWidth, (float)Global.Camera.Height - 20));

                ImGui.Begin("Tools", ref _game.DebugDrawer.ShowUI, ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse);

                if (ImGui.BeginTabBar("ControlTabs", ImGuiTabBarFlags.None))
                {
                    if (ImGui.BeginTabItem("Controls"))
                    {
                        ImGui.SliderInt("Vel Iters", ref Global.Settings.VelocityIterations, 0, 50);
                        ImGui.SliderInt("Pos Iters", ref Global.Settings.PositionIterations, 0, 50);
                        ImGui.SliderFloat("Hertz", ref Global.Settings.Hertz, 5.0f, 120.0f, "%.0f hz");

                        ImGui.Separator();

                        ImGui.Checkbox("Sleep", ref Global.Settings.EnableSleep);
                        ImGui.Checkbox("Warm Starting", ref Global.Settings.EnableWarmStarting);
                        ImGui.Checkbox("Time of Impact", ref Global.Settings.EnableContinuous);
                        ImGui.Checkbox("Sub-Stepping", ref Global.Settings.EnableSubStepping);

                        ImGui.Separator();

                        ImGui.Checkbox("Shapes", ref Global.Settings.DrawShapes);
                        ImGui.Checkbox("Joints", ref Global.Settings.DrawJoints);
                        ImGui.Checkbox("AABBs", ref Global.Settings.DrawAABBs);
                        ImGui.Checkbox("Contact Points", ref Global.Settings.DrawContactPoints);
                        ImGui.Checkbox("Contact Normals", ref Global.Settings.DrawContactNormals);
                        ImGui.Checkbox("Contact Impulses", ref Global.Settings.DrawContactImpulse);
                        ImGui.Checkbox("Friction Impulses", ref Global.Settings.DrawFrictionImpulse);
                        ImGui.Checkbox("Center of Masses", ref Global.Settings.DrawCOMs);
                        ImGui.Checkbox("Statistics", ref Global.Settings.DrawStats);
                        ImGui.Checkbox("Profile", ref Global.Settings.DrawProfile);

                        var buttonSz = new Vector2(-1, 0);
                        if (ImGui.Button("Pause (P)", buttonSz))
                        {
                            Global.Settings.Pause = !Global.Settings.Pause;
                        }

                        if (ImGui.Button("Single Step (O)", buttonSz))
                        {
                            Global.Settings.SingleStep = !Global.Settings.SingleStep;
                        }

                        if (ImGui.Button("Restart (R)", buttonSz))
                        {
                            _game.RestartTest();
                        }

                        if (ImGui.Button("Quit", buttonSz))
                        {
                            Application.Quit();
                        }

                        ImGui.EndTabItem();
                    }

                    var leafNodeFlags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick;
                    leafNodeFlags |= ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen;

                    const ImGuiTreeNodeFlags NodeFlags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick;

                    if (ImGui.BeginTabItem("Tests"))
                    {
                        var categoryIndex = 0;
                        var category      = Global.Tests[categoryIndex].Category;
                        var i             = 0;
                        while (i < Global.Tests.Count)
                        {
                            var categorySelected   = string.CompareOrdinal(category, Global.Tests[Global.Settings.TestIndex].Category) == 0;
                            var nodeSelectionFlags = categorySelected ? ImGuiTreeNodeFlags.Selected : 0;
                            var nodeOpen           = ImGui.TreeNodeEx(category, NodeFlags | nodeSelectionFlags);

                            if (nodeOpen)
                            {
                                while (i < Global.Tests.Count && string.CompareOrdinal(category, Global.Tests[i].Category) == 0)
                                {
                                    ImGuiTreeNodeFlags selectionFlags = 0;
                                    if (Global.Settings.TestIndex == i)
                                    {
                                        selectionFlags = ImGuiTreeNodeFlags.Selected;
                                    }

                                    ImGui.TreeNodeEx((IntPtr)i, leafNodeFlags | selectionFlags, Global.Tests[i].Name);
                                    if (ImGui.IsItemClicked())
                                    {
                                        _game.SetTest(i);
                                    }

                                    ++i;
                                }

                                ImGui.TreePop();
                            }
                            else
                            {
                                while (i < Global.Tests.Count && string.CompareOrdinal(category, Global.Tests[i].Category) == 0)
                                {
                                    ++i;
                                }
                            }

                            if (i < Global.Tests.Count)
                            {
                                category      = Global.Tests[i].Category;
                                categoryIndex = i;
                            }
                        }

                        ImGui.EndTabItem();
                    }

                    ImGui.EndTabBar();
                }

                ImGui.End();
            }
        }
Exemplo n.º 26
0
        public FilePickerResult Draw()
        {
            ImGui.Text("Current Folder: " + Path.GetFileName(RootFolder) + CurrentFolder.Replace(RootFolder, ""));
            var result = FilePickerResult.Unfinished;

            if (ImGui.BeginChildFrame(1, new Vector2(400, 400)))
            {
                var di = new DirectoryInfo(CurrentFolder);
                if (di.Exists)
                {
                    var yellow = new Vector4(1, 1, 0, 1);
                    if (di.Parent != null && CurrentFolder != RootFolder)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, yellow);
                        if (ImGui.Selectable("../", false, ImGuiSelectableFlags.DontClosePopups))
                        {
                            CurrentFolder = di.Parent.FullName;
                        }

                        ImGui.PopStyleColor();
                    }

                    var fileSystemEntries = GetFileSystemEntries(di.FullName);
                    foreach (var fse in fileSystemEntries)
                    {
                        if (Directory.Exists(fse))
                        {
                            var name = Path.GetFileName(fse);
                            ImGui.PushStyleColor(ImGuiCol.Text, yellow);
                            if (ImGui.Selectable(name + "/", false, ImGuiSelectableFlags.DontClosePopups))
                            {
                                CurrentFolder = fse;
                            }
                            ImGui.PopStyleColor();
                        }
                        else
                        {
                            var  name       = Path.GetFileName(fse);
                            bool isSelected = SelectedFile == fse;
                            if (ImGui.Selectable(name, isSelected, ImGuiSelectableFlags.DontClosePopups))
                            {
                                SelectedFile = fse;
                            }

                            if (ImGui.IsMouseDoubleClicked(0))
                            {
                                result = FilePickerResult.Finished;
                                ImGui.CloseCurrentPopup();
                            }
                        }
                    }
                }
            }
            ImGui.EndChildFrame();


            if (ImGui.Button("Cancel"))
            {
                result = FilePickerResult.Cancelled;
                ImGui.CloseCurrentPopup();
            }

            if (OnlyAllowFolders)
            {
                ImGui.SameLine();
                if (ImGui.Button("Open"))
                {
                    result       = FilePickerResult.Finished;
                    SelectedFile = CurrentFolder;
                    ImGui.CloseCurrentPopup();
                }
            }
            else if (SelectedFile != null)
            {
                ImGui.SameLine();
                if (ImGui.Button("Open"))
                {
                    result = FilePickerResult.Finished;
                    ImGui.CloseCurrentPopup();
                }
            }

            return(result);
        }
Exemplo n.º 27
0
        public void Draw()
        {
            if (!Visible)
            {
                Reset(null);
                return;
            }
            ImGui.SetNextWindowPos(new Vector2(_window.ClientBounds.Width * 2 / 3, 45), ImGuiCond.Always, Vector2.Zero);
            ImGui.SetNextWindowSize(new Vector2(_window.ClientBounds.Width / 3, 0), ImGuiCond.Always);

            var draw = ImGui.Begin("File List", ref Visible);

            if (draw)
            {
                TryGetFiles();

                if (_list.Count >= _truncatedTo && _list.Any())
                {
                    ImGui.SameLine();
                    var message = $"File count exceeded {_truncatedTo}! Only first {_truncatedTo} files will be loaded";
                    ImGui.TextColored(ColorRgbaF.Red.ToVector4(), message);
                }

                if (_loadingTask?.IsCompleted != false && _list.Any())
                {
                    if (ImGui.Button("Enable Autoload in following files"))
                    {
                        // _inputBox.Value is valid, becasue TryGetFiles() is called after _inputBox.Draw()s
                        _autoDetect.UnionWith(_list.Select(path => Path.Combine(_rootDirectory, path)));
                    }
                    if (_autoDetect.Any())
                    {
                        ImGui.SameLine();
                    }
                }
                if (_autoDetect.Any())
                {
                    if (ImGui.Button($"Clear {_autoDetect.Count} items in autoload list"))
                    {
                        _autoDetect.Clear();
                    }
                }

                ImGui.Text("Apt Files");
                ImGui.Separator();

                var beginY     = ImGui.GetCursorPosY();
                var list       = _list.Take(MaxCount);
                var wasVisible = true;
                foreach (var path in list)
                {
                    if (ImGui.Button(wasVisible ? path : string.Empty))
                    {
                        _aptFileSelector.SetValue(path);
                    }

                    wasVisible = ImGui.IsItemVisible();
                }
            }
            ImGui.End();
        }
Exemplo n.º 28
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!loadingSpinnerActive && !guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                    Theme.IconMenuItem("Save As", "saveas", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "saveas", Color4.White, true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem("Save As", "saveas", Color4.White, true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    options.Show();
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        StartLoadingSpinner();
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem("Generate Icon", "genicon", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImageFilter)) != null)
                    {
                        gen3dbDlg.Open(input);
                    }
                }
                if (Theme.IconMenuItem("Infocard Browser", "browse", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                if (ImGui.MenuItem("Projectile Viewer"))
                {
                    if (ProjectileViewer.Create(this, out var pj))
                    {
                        tabs.Add(pj);
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }

            options.Draw();
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }

            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
                openLoading = false;
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2020");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGuiExt.BeginModalNoClose("Processing", ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            gen3dbDlg.Draw();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            #if DEBUG
            const string statusFormat = "FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}";
            #else
            const string statusFormat = "{1} Materials | {2} Textures | Active: {3} - {4}";
            #endif
            ImGui.Text(string.Format(statusFormat,
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            RenderState.RenderTarget = lastFrame;
            RenderState.ClearColor   = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.Render(RenderState);
            RenderState.RenderTarget = null;
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Exemplo n.º 29
0
        public void Draw()
        {
            if (!IsVisible)
            {
                return;
            }
            var flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize;

            ImGui.SetNextWindowSizeConstraints(new Vector2(250, 100), new Vector2(400, 300));
            ImGui.Begin("config", flags);
            if (ImGui.SliderFloat("Opacity", ref opacity, 0.0f, 1.0f))
            {
                config.Opacity = opacity;
            }
            if (ImGui.Checkbox("Enable clickthrough", ref isClickthrough))
            {
                config.IsClickthrough = isClickthrough;
            }
            if (ImGui.Checkbox("Hide vulnerabilities that can't be inflicted", ref HideRedVulns))
            {
                config.HideRedVulns = HideRedVulns;
            }
            if (ImGui.Checkbox("Hide vulnerabilities based on current class/job", ref HideBasedOnJob))
            {
                config.HideBasedOnJob = HideBasedOnJob;
            }
            ImGui.NewLine();
            if (ImGui.Button("Save"))
            {
                IsVisible = false;
                config.Save();
            }
            ImGui.SameLine();
            var c = ImGui.GetCursorPos();

            ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize("<3    Sponsor on GitHub").X);
            ImGui.SmallButton("<3");
            ImGui.SetCursorPos(c);
            if (ImGui.IsItemHovered())
            {
                ImGui.BeginTooltip();
                ImGui.PushTextWrapPos(400f);
                ImGui.TextWrapped("Thanks to the Deep Dungeons Discord server for a lot of community resources. Thanks to everyone who's taken the time to report incorrect or missing data! Special shoutouts to Maygi for writing the best Deep Dungeon guides out there!");
                ImGui.PopTextWrapPos();
                ImGui.EndTooltip();
            }
            ;
            ImGui.SameLine();
            ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF);
            ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA);
            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD);
            c = ImGui.GetCursorPos();
            ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize("Sponsor on GitHub").X);
            if (ImGui.SmallButton("Sponsor on GitHub"))
            {
                Process.Start(new ProcessStartInfo()
                {
                    FileName        = "https://github.com/sponsors/Strati",
                    UseShellExecute = true
                });
            }
            ImGui.SetCursorPos(c);
            ImGui.PopStyleColor(3);
            ImGui.End();
        }
Exemplo n.º 30
0
        private void DrawPluginList(List <PluginDefinition> pluginDefinitions, bool installed)
        {
            var didAny           = false;
            var didAnyWithSearch = false;
            var hasSearchString  = !string.IsNullOrWhiteSpace(this.searchText);

            for (var index = 0; index < pluginDefinitions.Count; index++)
            {
                var pluginDefinition = pluginDefinitions[index];

                if (pluginDefinition.ApplicableVersion != this.gameVersion &&
                    pluginDefinition.ApplicableVersion != "any")
                {
                    continue;
                }

                if (pluginDefinition.IsHide)
                {
                    continue;
                }

                if (pluginDefinition.DalamudApiLevel < PluginManager.DalamudApiLevel)
                {
                    continue;
                }

                if (this.dalamud.Configuration.HiddenPluginInternalName.Contains(pluginDefinition.InternalName))
                {
                    continue;
                }

                didAny = true;

                if (hasSearchString &&
                    !(pluginDefinition.Name.ToLowerInvariant().Contains(this.searchText.ToLowerInvariant()) ||
                      string.Equals(pluginDefinition.Author, this.searchText, StringComparison.InvariantCultureIgnoreCase) ||
                      (pluginDefinition.Tags != null && pluginDefinition.Tags.Contains(
                           this.searchText.ToLowerInvariant(),
                           StringComparer.InvariantCultureIgnoreCase))))
                {
                    continue;
                }

                didAnyWithSearch = true;

                var isInstalled = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
                    x => x.Definition.InternalName == pluginDefinition.InternalName);

                var isTestingAvailable = false;
                if (Version.TryParse(pluginDefinition.AssemblyVersion, out var assemblyVersion) &&
                    Version.TryParse(pluginDefinition.TestingAssemblyVersion, out var testingAssemblyVersion))
                {
                    isTestingAvailable = this.dalamud.Configuration.DoPluginTest &&
                                         testingAssemblyVersion > assemblyVersion;
                }

                if (this.dalamud.Configuration.DoPluginTest && pluginDefinition.IsTestingExclusive)
                {
                    isTestingAvailable = true;
                }
                else if (!installed && !this.dalamud.Configuration.DoPluginTest && pluginDefinition.IsTestingExclusive)
                {
                    continue;
                }

                var label = string.Empty;
                if (isInstalled && !installed)
                {
                    label += Loc.Localize("InstallerInstalled", " (installed)");
                }
                else if (!isInstalled && installed)
                {
                    label += Loc.Localize("InstallerDisabled", " (disabled)");
                }

                if (this.updatedPlugins != null &&
                    this.updatedPlugins.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated))
                {
                    label += Loc.Localize("InstallerUpdated", " (updated)");
                }
                else if (this.updatedPlugins != null &&
                         this.updatedPlugins.Any(x => x.InternalName == pluginDefinition.InternalName &&
                                                 x.WasUpdated == false))
                {
                    label += Loc.Localize("InstallerUpdateFailed", " (update failed)");
                }

                if (isTestingAvailable)
                {
                    label += Loc.Localize("InstallerTestingVersion", " (testing version)");
                }

                ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion + installed + index);

                if (ImGui.CollapsingHeader(pluginDefinition.Name + label + "###Header" + pluginDefinition.InternalName))
                {
                    ImGui.Indent();

                    ImGui.Text(pluginDefinition.Name);

                    ImGui.SameLine();

                    var info = $" by {pluginDefinition.Author}";
                    info += pluginDefinition.DownloadCount != 0
                                ? $", {pluginDefinition.DownloadCount} downloads"
                                : ", download count unavailable";
                    if (pluginDefinition.RepoNumber != 0)
                    {
                        info += $", from custom plugin repository #{pluginDefinition.RepoNumber}";
                    }
                    ImGui.TextColored(ImGuiColors.DalamudGrey3, info);

                    if (!string.IsNullOrWhiteSpace(pluginDefinition.Description))
                    {
                        ImGui.TextWrapped(pluginDefinition.Description);
                    }

                    if (!isInstalled)
                    {
                        if (this.installStatus == PluginInstallStatus.InProgress)
                        {
                            ImGui.Button(Loc.Localize("InstallerInProgress", "Install in progress..."));
                        }
                        else
                        {
                            var versionString = isTestingAvailable
                                                    ? pluginDefinition.TestingAssemblyVersion + " (testing version)"
                                                    : pluginDefinition.AssemblyVersion;

                            if (ImGui.Button($"Install v{versionString}"))
                            {
                                this.installStatus = PluginInstallStatus.InProgress;

                                Task.Run(() => this.dalamud.PluginRepository.InstallPlugin(pluginDefinition, true, false, isTestingAvailable)).ContinueWith(t =>
                                {
                                    this.installStatus =
                                        t.Result ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
                                    this.installStatus =
                                        t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus;

                                    this.errorModalDrawing     = this.installStatus == PluginInstallStatus.Fail;
                                    this.errorModalOnNextFrame = this.installStatus == PluginInstallStatus.Fail;
                                });
                            }
                        }

                        if (!string.IsNullOrEmpty(pluginDefinition.RepoUrl))
                        {
                            ImGui.PushFont(InterfaceManager.IconFont);

                            ImGui.SameLine();
                            if (ImGui.Button(FontAwesomeIcon.Globe.ToIconString()) &&
                                pluginDefinition.RepoUrl.StartsWith("https://"))
                            {
                                Process.Start(pluginDefinition.RepoUrl);
                            }

                            ImGui.PopFont();
                        }
                    }
                    else
                    {
                        var installedPlugin = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).First(
                            x => x.Definition.InternalName ==
                            pluginDefinition.InternalName);

                        var commands = this.dalamud.CommandManager.Commands.Where(
                            x => x.Value.LoaderAssemblyName == installedPlugin.Definition?.InternalName &&
                            x.Value.ShowInHelp);
                        if (commands.Any())
                        {
                            ImGui.Dummy(new Vector2(10f, 10f) * ImGui.GetIO().FontGlobalScale);
                            foreach (var command in commands)
                            {
                                ImGui.TextWrapped($"{command.Key} → {command.Value.HelpMessage}");
                            }
                        }

                        ImGui.NewLine();

                        if (!installedPlugin.IsRaw)
                        {
                            ImGui.SameLine();

                            if (ImGui.Button(Loc.Localize("InstallerDisable", "Disable")))
                            {
                                try
                                {
                                    this.dalamud.PluginManager.DisablePlugin(installedPlugin.Definition);
                                }
                                catch (Exception exception)
                                {
                                    Log.Error(exception, "Could not disable plugin.");
                                    this.errorModalDrawing     = true;
                                    this.errorModalOnNextFrame = true;
                                }
                            }
                        }

                        if (installedPlugin.PluginInterface.UiBuilder.HasConfigUi)
                        {
                            ImGui.SameLine();

                            if (ImGui.Button(Loc.Localize("InstallerOpenConfig", "Open Configuration")))
                            {
                                installedPlugin.PluginInterface.UiBuilder.OpenConfigUi();
                            }
                        }

                        if (!string.IsNullOrEmpty(installedPlugin.Definition.RepoUrl))
                        {
                            ImGui.PushFont(InterfaceManager.IconFont);

                            ImGui.SameLine();
                            if (ImGui.Button(FontAwesomeIcon.Globe.ToIconString()) &&
                                installedPlugin.Definition.RepoUrl.StartsWith("https://"))
                            {
                                Process.Start(installedPlugin.Definition.RepoUrl);
                            }

                            ImGui.PopFont();
                        }

                        ImGui.SameLine();
                        ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{installedPlugin.Definition.AssemblyVersion}");

                        if (installedPlugin.IsRaw)
                        {
                            ImGui.SameLine();
                            ImGui.TextColored(
                                ImGuiColors.DalamudRed,
                                this.dalamud.PluginRepository.PluginMaster.Any(x => x.InternalName == installedPlugin.Definition.InternalName)
                                                   ? " This plugin is available in one of your repos, please remove it from the devPlugins folder."
                                                   : " To disable this plugin, please remove it from the devPlugins folder.");
                        }
                    }

                    ImGui.Unindent();
                }

                if (ImGui.BeginPopupContextItem("item context menu"))
                {
                    if (ImGui.Selectable("Hide from installer"))
                    {
                        this.dalamud.Configuration.HiddenPluginInternalName.Add(pluginDefinition.InternalName);
                    }
                    ImGui.EndPopup();
                }

                ImGui.PopID();
            }

            if (!didAny)
            {
                if (installed)
                {
                    ImGui.TextColored(
                        ImGuiColors.DalamudGrey,
                        Loc.Localize(
                            "InstallerNoInstalled",
                            "No plugins are currently installed. You can install them from the Available Plugins tab."));
                }
                else
                {
                    ImGui.TextColored(
                        ImGuiColors.DalamudGrey,
                        Loc.Localize(
                            "InstallerNoCompatible",
                            "No compatible plugins were found :( Please restart your game and try again."));
                }
            }
            else if (!didAnyWithSearch)
            {
                ImGui.TextColored(
                    ImGuiColors.DalamudGrey2,
                    Loc.Localize("InstallNoMatching", "No plugins were found matching your search."));
            }
        }