Exemplo n.º 1
0
        public void Render()
        {
            ImGui.BeginChild("Log", Vector2.Zero, false);
            ReadOnlySpan <LogEvent> logEvents = _logEventRecorder.LogEvents;
            ImDrawListPtr           drawList  = ImGui.GetWindowDrawList();

            foreach (LogEvent logEvent in logEvents)
            {
                Vector4 color = logEvent.LogLevel switch
                {
                    LogLevel.Information => Vector4.One,
                    LogLevel.Warning => new Vector4(1, 1, 0, 1),
                    LogLevel.Error => new Vector4(1, 0, 0, 1),
                    _ => ThrowHelper.Unreachable <Vector4>()
                };

                Vector2 topLeft  = ImGui.GetCursorScreenPos();
                Vector2 textSize = ImGui.CalcTextSize(logEvent.Message);
                ImGui.TextColored(color, logEvent.Message);
                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.Text("Copy to clipboard");
                    ImGui.EndTooltip();
                    drawList.AddRectFilled(
                        a: topLeft,
                        b: topLeft + textSize,
                        ImGui.GetColorU32(ImGuiCol.FrameBgHovered)
                        );
                }
                if (ImGui.IsItemClicked())
                {
                    ImGui.SetClipboardText(logEvent.Message);
                }
            }

            if (logEvents.Length > _prevEventCount)
            {
                ImGui.SetScrollHereY();
            }

            _prevEventCount = logEvents.Length;
            ImGui.EndChild();
        }
    }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override void Draw()
        {
            var screenSize = ImGui.GetMainViewport().Size;
            var windowSize = ImGui.GetWindowSize();

            this.Position = (screenSize - windowSize) / 2;

            ImGui.BeginChild("scrolling", Vector2.Zero, false, ImGuiWindowFlags.NoScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);

            ImGuiHelpers.ScaledDummy(0, 340f);
            ImGui.Text(string.Empty);

            ImGui.SameLine(150f);
            ImGui.Image(this.logoTexture.ImGuiHandle, ImGuiHelpers.ScaledVector2(190f, 190f));

            ImGuiHelpers.ScaledDummy(0, 20f);

            var windowX = ImGui.GetWindowSize().X;

            foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
            {
                var lineLenX = ImGui.CalcTextSize(creditsLine).X;

                ImGui.Dummy(new Vector2((windowX / 2) - (lineLenX / 2), 0f));
                ImGui.SameLine();
                ImGui.TextUnformatted(creditsLine);
            }

            ImGui.PopStyleVar();

            if (this.creditsThrottler.Elapsed.TotalMilliseconds > (1000.0f / CreditFPS))
            {
                var curY = ImGui.GetScrollY();
                var maxY = ImGui.GetScrollMaxY();

                if (curY < maxY - 1)
                {
                    ImGui.SetScrollY(curY + 1);
                }
            }

            ImGui.EndChild();
        }
        // Update all mod header data. Should someone change frame padding or item spacing,
        // or his default font, this will break, but he will just have to select a different mod to restore.
        private void UpdateModData()
        {
            // Name
            var name = $" {_mod.Name} ";

            if (name != _modName)
            {
                using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
                _modName       = name;
                _modNameWidth  = ImGui.CalcTextSize(name).X + 2 * (ImGui.GetStyle().FramePadding.X + 2 * ImGuiHelpers.GlobalScale);
            }

            // Author
            var author = _mod.Author.IsEmpty ? string.Empty : $"by  {_mod.Author}";

            if (author != _modAuthor)
            {
                _modAuthor      = author;
                _modAuthorWidth = ImGui.CalcTextSize(author).X;
                _secondRowWidth = _modAuthorWidth + _modWebsiteButtonWidth + ImGui.GetStyle().ItemSpacing.X;
            }

            // Version
            var version = _mod.Version.Length > 0 ? $"({_mod.Version})" : string.Empty;

            if (version != _modVersion)
            {
                _modVersion      = version;
                _modVersionWidth = ImGui.CalcTextSize(version).X;
            }

            // Website
            if (_modWebsite != _mod.Website)
            {
                _modWebsite   = _mod.Website;
                _websiteValid = Uri.TryCreate(_modWebsite, UriKind.Absolute, out var uriResult) &&
                                (uriResult.Scheme == Uri.UriSchemeHttps || uriResult.Scheme == Uri.UriSchemeHttp);
                _modWebsiteButton      = _websiteValid ? "Open Website" : _modWebsite.Length == 0 ? string.Empty : $"from  {_modWebsite}";
                _modWebsiteButtonWidth = _websiteValid
                    ? ImGui.CalcTextSize(_modWebsiteButton).X + 2 * ImGui.GetStyle().FramePadding.X
                    : ImGui.CalcTextSize(_modWebsiteButton).X;
                _secondRowWidth = _modAuthorWidth + _modWebsiteButtonWidth + ImGui.GetStyle().ItemSpacing.X;
            }
        }
Exemplo n.º 4
0
            private int FindIndexUnderWidth(string s, int startIndex, int substringLength, float remainingWidth)
            {
                if (substringLength == 0 || remainingWidth <= 0 || startIndex >= s.Length)
                {
                    return(startIndex);
                }

                var substring      = s.Substring(startIndex, substringLength);
                var substringWidth = ImGui.CalcTextSize(substring).X;

                if (substringWidth > remainingWidth)
                {
                    return(FindIndexUnderWidth(s, startIndex, substringLength / 2, remainingWidth));
                }
                else
                {
                    return(FindIndexUnderWidth(s, startIndex + substringLength, substringLength / 2, remainingWidth - substringWidth));
                }
            }
Exemplo n.º 5
0
        private void DrawGroupSelectors()
        {
            var hasTopTypes    = (_selectedMod.Mod.Meta.Groups.TopTypes?.Count ?? 0) > 1;
            var hasBottomTypes = (_selectedMod.Mod.Meta.Groups.BottomTypes?.Count ?? 0) > 1;
            var hasGroups      = (_selectedMod.Mod.Meta.Groups.OtherGroups?.Count ?? 0) > 1;
            var numSelectors   = (hasTopTypes ? 1 : 0) + (hasBottomTypes ? 1 : 0) + (hasGroups ? 1 : 0);
            var selectorWidth  = (ImGui.GetWindowWidth()
                                  - (hasTopTypes ? ImGui.CalcTextSize("Top       ").X : 0)
                                  - (hasBottomTypes ? ImGui.CalcTextSize("Bottom       ").X : 0)
                                  - (hasGroups ? ImGui.CalcTextSize("Group       ").X : 0)) / numSelectors;

            void DrawSelector(string label, string propertyName, System.Collections.Generic.List <string> list, bool sameLine)
            {
                var current = ( int )_selectedMod.GetType().GetProperty(propertyName).GetValue(_selectedMod);

                ImGui.SetNextItemWidth(selectorWidth);
                if (sameLine)
                {
                    ImGui.SameLine();
                }
                if (ImGui.Combo(label, ref current, list.ToArray(), list.Count()))
                {
                    _selectedMod.GetType().GetProperty(propertyName).SetValue(_selectedMod, current);
                    _plugin.ModManager.Mods.Save();
                    _plugin.ModManager.CalculateEffectiveFileList();
                }
            }

            if (hasTopTypes)
            {
                DrawSelector("Top", "CurrentTop", _selectedMod.Mod.Meta.Groups.TopTypes, false);
            }

            if (hasBottomTypes)
            {
                DrawSelector("Bottom", "CurrentBottom", _selectedMod.Mod.Meta.Groups.BottomTypes, hasTopTypes);
            }

            if (hasGroups)
            {
                DrawSelector("Group", "CurrentGroup", _selectedMod.Mod.Meta.Groups.OtherGroups, numSelectors > 1);
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public override void Draw()
        {
            var screenSize = ImGui.GetMainViewport().Size;
            var windowSize = ImGui.GetWindowSize();

            this.Position = new Vector2((screenSize.X / 2) - (windowSize.X / 2), (screenSize.Y / 2) - (windowSize.Y / 2));

            ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.NoScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

            ImGui.Dummy(new Vector2(0, 340f) * ImGui.GetIO().FontGlobalScale);
            ImGui.Text(string.Empty);

            ImGui.SameLine(150f);
            ImGui.Image(this.logoTexture.ImGuiHandle, new Vector2(190f, 190f) * ImGui.GetIO().FontGlobalScale);

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

            var windowX = ImGui.GetWindowSize().X;

            foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
            {
                var lineLenX = ImGui.CalcTextSize(creditsLine).X;

                ImGui.Dummy(new Vector2((windowX / 2) - (lineLenX / 2), 0f));
                ImGui.SameLine();
                ImGui.TextUnformatted(creditsLine);
            }

            ImGui.PopStyleVar();

            var curY = ImGui.GetScrollY();
            var maxY = ImGui.GetScrollMaxY();

            if (curY < maxY - 1)
            {
                ImGui.SetScrollY(curY + 1);
            }

            ImGui.EndChild();
        }
        public override void DrawMutable()
        {
            if (ImGui.Button(_name))
            {
                OnButtonClicked();
            }

            if (_parameterType != null)
            {
                ImGui.SameLine();
            }

            ImGui.PushItemWidth(-ImGui.CalcTextSize(_parameterName).X);             // spacing on the right for the label
            if (_parameterType == typeof(float))
            {
                ImGui.DragFloat($"{_parameterName}##", ref _floatParam);
            }
            else if (_parameterType == typeof(int))
            {
                ImGui.DragInt($"{_parameterName}##", ref _intParam);
            }
            else if (_parameterType == typeof(bool))
            {
                ImGui.Checkbox($"{_parameterName}##", ref _boolParam);
            }
            else if (_parameterType == typeof(string))
            {
                ImGui.InputText($"{_parameterName}##", ref _stringParam, 100);
            }
            else if (_parameterType == typeof(Vector2))
            {
                ImGui.DragFloat2($"{_parameterName}##", ref _vec2Param);
            }
            else if (_parameterType == typeof(Vector3))
            {
                ImGui.DragFloat3($"{_parameterName}##", ref _vec3Param);
            }

            ImGui.PopItemWidth();

            HandleTooltip();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Draw main overlay buttons.
        /// </summary>
        private float DrawMainOverlay()
        {
            float overlayHeight = 0;

            ImGui.Begin("MainOverlay", ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoCollapse
                        | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize);

            ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0.1f, 0.1f, 0.1f, 1));

            int intColor = (36 << 16) | (36 << 8) | (36);

            ImGui.PushStyleColor(ImGuiCol.Button, (uint)intColor);
            ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 1));

            ImGui.PushFont((ImFontPtr)Frame.Fonts.NormalFont);
            Vector2 CloseButtonSize = ImGui.CalcTextSize("X");

            if (Platform == Platform.Android)
            {
                ImGui.SetCursorPosX(30);
            }

            if (ImGui.Button("Log Out"))
            {
                LogOut();
            }

            ImGui.PopFont();
            ImGui.PopStyleColor();

            ImGui.SameLine();

            ImGui.SetWindowSize(new Vector2(Frame.Width, (CloseButtonSize.Y) + ImGui.GetFrameHeightWithSpacing()));
            ImGui.SetWindowPos(new Vector2(0, 0));

            overlayHeight = ImGui.GetWindowHeight();

            ImGui.End();

            return(overlayHeight);
        }
Exemplo n.º 9
0
        // Draw a button to remove the current settings and inherit them instead
        // on the top-right corner of the window/tab.
        private void DrawRemoveSettings()
        {
            const string text = "Inherit Settings";

            if (_inherited || _emptySetting)
            {
                return;
            }

            var scroll = ImGui.GetScrollMaxY() > 0 ? ImGui.GetStyle().ScrollbarSize : 0;

            ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(text).X - ImGui.GetStyle().FramePadding.X * 2 - scroll);
            if (ImGui.Button(text))
            {
                Penumbra.CollectionManager.Current.SetModInheritance(_mod.Index, true);
            }

            ImGuiUtil.HoverTooltip("Remove current settings from this collection so that it can inherit them.\n"
                                   + "If no inherited collection has settings for this mod, it will be disabled.");
        }
Exemplo n.º 10
0
        private void UpdateBgmDescription(ushort currentBgmId, BgmInfo currentBgm)
        {
            string songDescription = $"({currentBgmId}) {currentBgm.Title}";
            string truncateFormat  = "{0} ... (?)";

            if (ImGui.CalcTextSize(songDescription).X < 280f)
            {
                _songDescription = songDescription;
            }
            else
            {
                string tmpDesc;
                int    substring = songDescription.Length;
                do
                {
                    tmpDesc = string.Format(truncateFormat, songDescription.Substring(0, substring--));
                } while (ImGui.CalcTextSize(tmpDesc).X > 280f);
                _songDescription = tmpDesc;
            }
        }
Exemplo n.º 11
0
        public static bool ButtonGradient(string strId)
        {
            String[]      strIdArray   = strId.Split("##");
            Vector2       p            = ImGuiNET.ImGui.GetCursorScreenPos();
            Vector2       sizeText     = ImGui.CalcTextSize(strIdArray[0]);
            ImDrawListPtr drawList     = ImGuiNET.ImGui.GetWindowDrawList();
            float         buttonHeight = ImGuiNET.ImGui.GetFrameHeight();
            float         buttonWidth  = sizeText.X + sizeText.X * 0.20f;
            Vector2       buttonSize   = new Vector2(p.X + buttonWidth, p.Y + buttonHeight);
            uint          colTop;
            uint          colBottom;

            if (strIdArray.Length > 1)
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[1], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            else
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[0], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            if (ImGuiNET.ImGui.IsItemHovered())
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1.50f);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.50f);
            }
            else
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.20f);
            }
            drawList.AddRectFilledMultiColor(p, buttonSize, colTop, colTop, colBottom, colBottom);
            drawList.AddRect(p, buttonSize, ImGuiNET.ImGui.GetColorU32(ImGuiCol.Separator));
            drawList.AddText(new Vector2(p.X + (buttonWidth / 2) - (sizeText.X / 2), p.Y + (buttonHeight / 2) - (sizeText.Y / 2)), ImGui.GetColorU32(ImGuiCol.Text), strIdArray[0]);
            return(false);
        }
Exemplo n.º 12
0
            private void DrawFilters()
            {
                if (_arrowLength == 0)
                {
                    using var font = ImGuiRaii.PushFont(UiBuilder.IconFont);
                    _arrowLength   = ImGui.CalcTextSize(FontAwesomeIcon.LongArrowAltLeft.ToIconString()).X / ImGuiHelpers.GlobalScale;
                }

                ImGui.SetNextItemWidth(_leftTextLength * ImGuiHelpers.GlobalScale);
                if (ImGui.InputTextWithHint("##effective_changes_gfilter", "Filter game path...", ref _gamePathFilter, 256))
                {
                    _gamePathFilterLower = _gamePathFilter.ToLowerInvariant();
                }

                ImGui.SameLine((_leftTextLength + _arrowLength) * ImGuiHelpers.GlobalScale + 3 * ImGui.GetStyle().ItemSpacing.X);
                ImGui.SetNextItemWidth(-1);
                if (ImGui.InputTextWithHint("##effective_changes_ffilter", "Filter file path...", ref _filePathFilter, 256))
                {
                    _filePathFilterLower = _filePathFilter.ToLowerInvariant();
                }
            }
        public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options)
        {
            ImGui.PushID(id);
            bool         clicked = false;
            const string PADDING = "       ";
            string       text    = PADDING + ImGuiExt.IDSafe(options[selected].Name) + "   ";
            var          w       = ImGui.CalcTextSize(text).X;

            clicked = ImGui.Button(text);
            ImGui.SameLine();
            var cpos  = ImGuiNative.igGetCursorPosX();
            var cposY = ImGuiNative.igGetCursorPosY();

            Theme.TinyTriangle(cpos - 15, cposY + 15);
            ImGuiNative.igSetCursorPosX(cpos - w - 13);
            ImGuiNative.igSetCursorPosY(cposY + 2);
            Theme.Icon(options[selected].Icon, Color4.White);
            ImGui.SameLine();
            ImGuiNative.igSetCursorPosY(cposY);
            ImGui.SetCursorPosX(cpos - 6);
            ImGui.Dummy(Vector2.Zero);
            if (clicked)
            {
                ImGui.OpenPopup(id + "#popup");
            }
            if (ImGui.BeginPopup(id + "#popup"))
            {
                ImGui.MenuItem(id, false);
                for (int i = 0; i < options.Count; i++)
                {
                    var opt = options[i];
                    if (Theme.IconMenuItem(opt.Name, opt.Icon, Color4.White, true))
                    {
                        selected = i;
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.PopID();
        }
Exemplo n.º 14
0
        public string GetSelectedFilesAsString(Vector2 sizeOfFrame)
        {
            string s = "";

            if (ImGui.CalcTextSize(s).X > sizeOfFrame.X - 20)
            {
                return(SelectedFiles.Count.ToString() + " selected files");
            }

            foreach (string file in SelectedFiles)
            {
                s += "'" + Path.GetFileName(file) + "'";

                if (file != SelectedFiles[SelectedFiles.Count - 1])
                {
                    s += ", ";
                }
            }


            return(s);
        }
Exemplo n.º 15
0
        public static unsafe void ToastText(string text, Color4 background, Color4 foreground)
        {
            var displaySize = (Vector2)(ImGui.GetIO().DisplaySize);
            var textSize    = (Vector2)ImGui.CalcTextSize(text);
            var drawlist    = ImGuiNative.igGetOverlayDrawList();
            var textbytes   = System.Text.Encoding.UTF8.GetBytes(text);

            ImGuiNative.ImDrawList_AddRectFilled(
                drawlist,
                new Vector2(displaySize.X - textSize.X - 9, 2),
                new Vector2(displaySize.X, textSize.Y + 9),
                GetUint(background), 2, ImDrawCornerFlags_All
                );
            fixed(byte *ptr = textbytes)
            {
                ImGuiNative.ImDrawList_AddText(
                    drawlist,
                    new Vector2(displaySize.X - textSize.X - 3, 2),
                    GetUint(foreground), ptr,
                    (byte *)0
                    );
            }
        }
Exemplo n.º 16
0
        public Vector2 CalcTextSize(FontType type, string text)
        {
            switch (type)
            {
            case FontType.Normal:
                return(ImGui.CalcTextSize(text));

            case FontType.Bold:
                ImGui.PushFont(_controller.BoldFont);
                var bs = ImGui.CalcTextSize(text);
                ImGui.PopFont();
                return(bs);

            case FontType.Large:
                ImGui.PushFont(_controller.LargeFont);
                var ls = ImGui.CalcTextSize(text);
                ImGui.PopFont();
                return(ls);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Exemplo n.º 17
0
        public override void Draw()
        {
            var debugText = "XLGE\n" +
                            "F1 for editor\n" +
                            "F2 for cursor lock toggle\n" +
                            "F3 for console toggle";

            ImGui.Begin("perfOverlayGraphs##hidelabel", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoInputs);

            ImGui.PlotHistogram(
                $"{RenderManager.Instance.LastFrameTime}ms",
                ref RenderManager.Instance.FrametimeHistory[0],
                RenderManager.Instance.FrametimeHistory.Length,
                0,
                "",
                0
                );

            ImGui.PlotLines(
                $"{RenderManager.Instance.CalculatedFramerate}fps",
                ref RenderManager.Instance.FramerateHistory[0],
                RenderManager.Instance.FramerateHistory.Length,
                0,
                "",
                0
                );

            ImGui.End();

            var labelPosition = new Vector2(GameSettings.GameResolutionX - 192, ImGui.GetStyle().WindowPadding.Y);

            DrawShadowLabel(debugText, labelPosition);
            var labelEnd = ImGui.CalcTextSize(debugText) + labelPosition;

            ImGui.SetWindowSize("perfOverlayGraphs##hidelabel", new Vector2(0, 0));
            ImGui.SetWindowPos("perfOverlayGraphs##hidelabel", new Vector2(labelPosition.X - ImGui.GetStyle().WindowPadding.X - ImGui.GetStyle().FramePadding.X, labelEnd.Y));
        }
Exemplo n.º 18
0
        private void DrawActorTable()
        {
            var stateString = string.Empty;

            // LocalPlayer is null in a number of situations (at least with the current visible-actors list)
            // which would crash here.
            if (this.dalamud.ClientState.Actors.Length == 0)
            {
                ImGui.TextUnformatted("Data not ready.");
            }
            else if (this.dalamud.ClientState.LocalPlayer == null)
            {
                ImGui.TextUnformatted("LocalPlayer null.");
            }
            else
            {
                stateString +=
                    $"FrameworkBase: {this.dalamud.Framework.Address.BaseAddress.ToInt64():X}\n";

                stateString += $"ActorTableLen: {this.dalamud.ClientState.Actors.Length}\n";
                stateString += $"LocalPlayerName: {this.dalamud.ClientState.LocalPlayer.Name}\n";
                stateString +=
                    $"CurrentWorldName: {(this.resolveGameData ? this.dalamud.ClientState.LocalPlayer.CurrentWorld.GameData.Name : this.dalamud.ClientState.LocalPlayer.CurrentWorld.Id.ToString())}\n";
                stateString +=
                    $"HomeWorldName: {(this.resolveGameData ? this.dalamud.ClientState.LocalPlayer.HomeWorld.GameData.Name : this.dalamud.ClientState.LocalPlayer.HomeWorld.Id.ToString())}\n";
                stateString += $"LocalCID: {this.dalamud.ClientState.LocalContentId:X}\n";
                stateString +=
                    $"LastLinkedItem: {this.dalamud.Framework.Gui.Chat.LastLinkedItemId.ToString()}\n";
                stateString += $"TerritoryType: {this.dalamud.ClientState.TerritoryType}\n\n";

                ImGui.TextUnformatted(stateString);

                ImGui.Checkbox("Draw actors on screen", ref this.drawActors);
                ImGui.SliderFloat("Draw Distance", ref this.maxActorDrawDistance, 2f, 40f);

                for (var i = 0; i < this.dalamud.ClientState.Actors.Length; i++)
                {
                    var actor = this.dalamud.ClientState.Actors[i];

                    if (actor == null)
                    {
                        continue;
                    }

                    this.PrintActor(actor, i.ToString());

                    if (this.drawActors && this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords))
                    {
                        // So, while WorldToScreen will return false if the point is off of game client screen, to
                        // to avoid performance issues, we have to manually determine if creating a window would
                        // produce a new viewport, and skip rendering it if so
                        var actorText =
                            $"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name}";

                        var screenPos  = ImGui.GetMainViewport().Pos;
                        var screenSize = ImGui.GetMainViewport().Size;

                        var windowSize = ImGui.CalcTextSize(actorText);

                        // Add some extra safety padding
                        windowSize.X += ImGui.GetStyle().WindowPadding.X + 10;
                        windowSize.Y += ImGui.GetStyle().WindowPadding.Y + 10;

                        if (screenCoords.X + windowSize.X > screenPos.X + screenSize.X ||
                            screenCoords.Y + windowSize.Y > screenPos.Y + screenSize.Y)
                        {
                            continue;
                        }

                        if (actor.YalmDistanceX > this.maxActorDrawDistance)
                        {
                            continue;
                        }

                        ImGui.SetNextWindowPos(new Vector2(screenCoords.X, screenCoords.Y));

                        ImGui.SetNextWindowBgAlpha(Math.Max(1f - actor.YalmDistanceX / this.maxActorDrawDistance,
                                                            0.2f));
                        if (ImGui.Begin($"Actor{i}##ActorWindow{i}",
                                        ImGuiWindowFlags.NoDecoration |
                                        ImGuiWindowFlags.AlwaysAutoResize |
                                        ImGuiWindowFlags.NoSavedSettings |
                                        ImGuiWindowFlags.NoMove |
                                        ImGuiWindowFlags.NoMouseInputs |
                                        ImGuiWindowFlags.NoDocking |
                                        ImGuiWindowFlags.NoFocusOnAppearing |
                                        ImGuiWindowFlags.NoNav))
                        {
                            ImGui.Text(actorText);
                        }
                        ImGui.End();
                    }
                }
            }
        }
Exemplo n.º 19
0
        private void LoadFileMenu()
        {
            float framerate = ImGui.GetIO().Framerate;

            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open", "Ctrl+O", false, initGlobalShaders))
                    {
                        OpenFileWithDialog();
                    }
                    if (ImGui.BeginMenu("Recent"))
                    {
                        for (int i = 0; i < recentFiles.Count; i++)
                        {
                            if (ImGui.Selectable(recentFiles[i]))
                            {
                                LoadFileFormat(recentFiles[i]);
                            }
                        }
                        ImGui.EndMenu();
                    }

                    var canSave = Outliner.ActiveFileFormat != null && Outliner.ActiveFileFormat.CanSave;
                    if (ImGui.MenuItem("Save", "Ctrl+S", false, canSave))
                    {
                        SaveFileWithCurrentPath();
                    }
                    if (ImGui.MenuItem("Save As", "Ctrl+Shift+S", false, canSave))
                    {
                        SaveFileWithDialog();
                    }

                    if (ImGui.MenuItem("Clear Workspace"))
                    {
                        ClearWorkspace();
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Setting"))
                {
                    ImGui.InputFloat("Font Size", ref font_scale, 0.1f);

                    _config.RenderUI();

                    ImGui.EndMenu();
                }
                if (ImGui.MenuItem("Style Editor"))
                {
                    showStyleEditor = true;
                }

                if (_config.HasValidSMOPath)
                {
                    if (ImGui.MenuItem("Mario Viewer", initGlobalShaders))
                    {
                        TryLoadPartInfo();
                    }
                }

                /*    if (ImGui.MenuItem("Lighting"))
                 * {
                 *   showLightingEditor = true;
                 * }*/

                if (ImGui.MenuItem("Batch Render"))
                {
                    showBatchWindow = true;
                }

                if (ImGui.BeginMenu("Help"))
                {
                    if (ImGui.Selectable($"About"))
                    {
                        showAboutPage = true;
                    }
                    if (ImGui.Selectable($"Donate"))
                    {
                        BrowserHelper.OpenDonation();
                    }
                    ImGui.EndMenu();
                }

                float size = ImGui.GetWindowWidth();
                if (!string.IsNullOrEmpty(status))
                {
                    string statusLabel = $"Status: {status}";
                    float  lbSize      = ImGui.CalcTextSize(statusLabel).X;

                    ImGui.SetCursorPosX((size - (lbSize)) / 2);
                    ImGui.Text($"Status: {status}");
                }

                ImGui.SetCursorPosX(size - 100);
                ImGui.Text($"({framerate:0.#} FPS)");
                ImGui.EndMainMenuBar();
            }
            if (showBatchWindow)
            {
                if (ImGui.Begin("Batch Window", ref showBatchWindow))
                {
                    ImguiCustomWidgets.PathSelector("Input Folder", ref BatchRenderingTool.InputFolder);
                    ImguiCustomWidgets.PathSelector("Output Folder", ref BatchRenderingTool.OutputFolder);
                    ImGui.Checkbox("Odyssey Actor", ref BatchRenderingTool.OdysseyActor);
                    ImGui.InputInt("Image Width", ref BatchRenderingTool.ImageWidth);
                    ImGui.InputInt("Image Height", ref BatchRenderingTool.ImageHeight);
                    if (BatchRenderingTool.IsOperationActive)
                    {
                        float progress = (float)BatchRenderingTool.ProcessAmount / BatchRenderingTool.ProcessTotal;
                        ImGui.ProgressBar(progress, new System.Numerics.Vector2(300, 20));

                        ImGui.Text($"{BatchRenderingTool.ProcessName}");
                        if (ImGui.Button("Cancel Render"))
                        {
                            BatchRenderingTool.CancelOperation = true;
                        }
                    }
                    if (Directory.Exists(BatchRenderingTool.InputFolder) &&
                        Directory.Exists(BatchRenderingTool.OutputFolder) &&
                        !BatchRenderingTool.IsOperationActive)
                    {
                        if (ImGui.Button("Start Render"))
                        {
                            string path = BatchRenderingTool.InputFolder;
                            string output = BatchRenderingTool.OutputFolder;
                            int    width = BatchRenderingTool.ImageWidth; int height = BatchRenderingTool.ImageHeight;

                            var Thread3 = new Thread((ThreadStart)(() =>
                            {
                                BatchRenderingTool batchTool = new BatchRenderingTool();
                                batchTool.StartRender(path, output, width, height);
                            }));
                            Thread3.Start();
                        }
                    }
                    ImGui.End();
                }
            }

            if (ProbeDebugger.DEBUG_MODE)
            {
                ProbeDebugger.DrawWindow();
            }

            if (showStyleEditor)
            {
                if (ImGui.Begin("Style Editor", ref showStyleEditor))
                {
                    ImGui.ShowStyleEditor();
                    ImGui.End();
                }
            }
            if (showLightingEditor)
            {
                if (lightingEditor == null)
                {
                    lightingEditor = new BfresEditor.LightingEditor();
                }

                lightingEditor.Render(this.Pipeline._context);
            }
            if (showAboutPage)
            {
                if (ImGui.Begin($"About", ref showAboutPage))
                {
                    if (ImGui.CollapsingHeader($"Credits", ImGuiTreeNodeFlags.DefaultOpen))
                    {
                        ImGui.BulletText("KillzXGaming - main developer");
                        ImGui.BulletText("JuPaHe64 - created animation timeline");
                        ImGui.BulletText("Ryujinx - for shader libraries used to decompile and translate switch binaries into glsl code.");
                        ImGui.BulletText("OpenTK Team - for opengl c# bindings.");
                        ImGui.BulletText("mellinoe and IMGUI Team - for c# port and creating the IMGUI library");
                        ImGui.BulletText("Syroot - for bfres library and binary IO");
                    }
                    ImGui.End();
                }
            }
        }
Exemplo n.º 20
0
        public void Draw(ref bool isGameViewFocused)
        {
            float menuBarHeight = 0;

            if (ImGui.BeginMainMenuBar())
            {
                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("Map"))
                    {
                        foreach (var mapCache in _context.Game.AssetStore.MapCaches)
                        {
                            var mapName = mapCache.GetNameKey().Translate();

                            if (ImGui.MenuItem($"{mapName} ({mapCache.Name})"))
                            {
                                var playableSides = _context.Game.GetPlayableSides();
                                var faction1      = playableSides.First();
                                var faction2      = playableSides.Last();

                                _context.Game.StartMultiPlayerGame(
                                    mapCache.Name,
                                    new EchoConnection(),
                                    new PlayerSetting?[]
                                {
                                    new PlayerSetting(null, faction1, new ColorRgb(255, 0, 0)),
                                    new PlayerSetting(null, faction2, new ColorRgb(255, 255, 255)),
                                },
                                    0);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    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.EndMainMenuBar();
            }

            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();
            }
        }
Exemplo n.º 21
0
        private void DrawElementSelector()
        {
            ImGui.GetIO().WantCaptureKeyboard = true;
            ImGui.GetIO().WantCaptureMouse    = true;
            ImGui.GetIO().WantTextInput       = true;
            if (ImGui.IsKeyPressed((int)VirtualKey.ESCAPE))
            {
                elementSelectorActive = false;
                FreeExclusiveDraw();
                return;
            }

            ImGui.SetNextWindowPos(Vector2.Zero);
            ImGui.SetNextWindowSize(ImGui.GetIO().DisplaySize);
            ImGui.SetNextWindowBgAlpha(0.3f);
            ImGui.Begin("ElementSelectorWindow", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoScrollbar);
            var drawList = ImGui.GetWindowDrawList();

            var y = 100f;

            foreach (var s in new[] { "Select an Element", "Press ESCAPE to cancel" })
            {
                var size = ImGui.CalcTextSize(s);
                var x    = ImGui.GetWindowContentRegionWidth() / 2f - size.X / 2;
                drawList.AddText(new Vector2(x, y), 0xFFFFFFFF, s);
                y += size.Y;
            }

            var mousePos = ImGui.GetMousePos();
            var windows  = GetAtkUnitBaseAtPosition(mousePos);

            ImGui.SetCursorPosX(100);
            ImGui.SetCursorPosY(100);
            ImGui.BeginChild("noClick", new Vector2(800, 2000), false, ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoScrollWithMouse);
            ImGui.BeginGroup();

            ImGui.Text($"Mouse Position: {mousePos.X}, {mousePos.Y}\n");
            var i = 0;

            foreach (var a in windows)
            {
                var name = Helper.Common.PtrToUTF8(new IntPtr(a.UnitBase->Name));
                ImGui.Text($"[Addon] {name}");
                ImGui.Indent(15);
                foreach (var n in a.Nodes)
                {
                    var nSelected = i++ == elementSelectorIndex;
                    if (nSelected)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, 0xFF00FFFF);
                    }
                    // ImGui.Text($"{((int)n.ResNode->Type >= 1000 ? ((ULDComponentInfo*)((AtkComponentNode*) n.ResNode)->Component->UldManager.Objects)->ComponentType.ToString() + "ComponentNode" : n.ResNode->Type.ToString() + "Node")}");

                    PrintNode(n.ResNode, false, null, true);


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

                    if (nSelected && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
                    {
                        elementSelectorActive = false;
                        FreeExclusiveDraw();

                        selectedUnitBase = a.UnitBase;

                        var l = new List <ulong>();

                        l.Add((ulong)n.ResNode);
                        var nextNode = n.ResNode->ParentNode;
                        while (nextNode != null)
                        {
                            l.Add((ulong)nextNode);
                            nextNode = nextNode->ParentNode;
                        }

                        elementSelectorFind      = l.ToArray();
                        elementSelectorCountdown = 100;
                        elementSelectorScrolled  = false;
                    }


                    drawList.AddRectFilled(n.State.Position, n.State.SecondPosition, (uint)(nSelected ? 0x4400FFFF: 0x0000FF00));
                }
                ImGui.Indent(-15);
            }

            if (i != 0)
            {
                elementSelectorIndex -= (int)ImGui.GetIO().MouseWheel;
                while (elementSelectorIndex < 0)
                {
                    elementSelectorIndex += i;
                }
                while (elementSelectorIndex >= i)
                {
                    elementSelectorIndex -= i;
                }
            }

            ImGui.EndGroup();
            ImGui.EndChild();
            ImGui.End();
        }
Exemplo n.º 22
0
        private void DrawWindow()
        {
            ImGuiWindowFlags windowFlags = 0;

            windowFlags |= ImGuiWindowFlags.NoTitleBar;
            windowFlags |= ImGuiWindowFlags.NoScrollbar;
            windowFlags |= ImGuiWindowFlags.NoScrollbar;
            if (_noMove)
            {
                windowFlags |= ImGuiWindowFlags.NoMove;
                windowFlags |= ImGuiWindowFlags.NoMouseInputs;
                windowFlags |= ImGuiWindowFlags.NoNav;
            }
            windowFlags |= ImGuiWindowFlags.AlwaysAutoResize;
            if (!_debug)
            {
                windowFlags |= ImGuiWindowFlags.NoBackground;
            }


            if (_config)
            {
                ImGui.SetNextWindowSize(new Num.Vector2(200, 160), ImGuiCond.FirstUseEver);
                ImGui.Begin("Where's WOLdo Config", ref _config, ImGuiWindowFlags.AlwaysAutoResize);
                ImGui.Checkbox("Enabled", ref _enabled);
                ImGui.ColorEdit4("Colour", ref _col.Value, ImGuiColorEditFlags.NoInputs);
                ImGui.InputFloat("Size", ref _scale);
                ImGui.Checkbox("Locked", ref _noMove);
                ImGui.Checkbox("Debug", ref _debug);
                //ImGui.ListBox("Alignment", ref align, alignStr, 3);

                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();
                    _config = false;
                }
                ImGui.End();
            }

            _location = "";
            if (ClientState.LocalPlayer != null)
            {
                _location = "Uhoh";
                try
                {
                    _location = _terr.GetRow(ClientState.TerritoryType).PlaceName.Value.Name;
                }
                catch (Exception)
                {
                    _location = "Change zone to load";
                }
            }


            if (!_enabled)
            {
                return;
            }
            ImGui.PushStyleColor(ImGuiCol.Text, _col.Value);
            ImGui.Begin("WOLdo", ref _enabled, windowFlags);
            ImGui.SetWindowFontScale(_scale);

            if (_debug)
            {
                ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X + _adjustX, ImGui.GetWindowPos().Y));
                if (_align == 0)
                {
                    _adjustX = 0;
                    ImGui.Text("Left Align");
                }
                if (_align == 1)
                {
                    _adjustX = (float)Math.Floor((ImGui.CalcTextSize("Middle Align").X) / 2);
                    ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X - _adjustX, ImGui.GetWindowPos().Y));
                    ImGui.Text("Middle Align");
                }
                if (_align == 2)
                {
                    _adjustX = ImGui.CalcTextSize("Right Align").X;
                    ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X - _adjustX, ImGui.GetWindowPos().Y));
                    ImGui.Text("Right Align");
                }
            }
            else
            {
                ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X + _adjustX, ImGui.GetWindowPos().Y));
                if (_align == 0)
                {
                    _adjustX = 0;
                }
                if (_align == 1)
                {
                    _adjustX = (float)Math.Floor((ImGui.CalcTextSize(_location).X) / 2);
                    ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X - _adjustX, ImGui.GetWindowPos().Y));
                }
                if (_align == 2)
                {
                    _adjustX = ImGui.CalcTextSize(_location).X;

                    if (_first)
                    {
                        if (Math.Abs(_adjustX) > 0)
                        {
                            _first = false;
                        }
                    }
                    else
                    {
                        ImGui.SetWindowPos(new Num.Vector2(ImGui.GetWindowPos().X - _adjustX, ImGui.GetWindowPos().Y));
                    }
                }
                ImGui.Text(_location);
            }
            ImGui.End();
            ImGui.PopStyleColor();
        }
Exemplo n.º 23
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;
            }
        }
Exemplo n.º 24
0
        private void DrawSplash(rgatSettings.PathRecord[] recentBins, rgatSettings.PathRecord[] recentTraces)
        {
            ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemInnerSpacing, Vector2.Zero);

            float regionHeight     = ImGui.GetContentRegionAvail().Y;
            float regionWidth      = ImGui.GetContentRegionAvail().X;
            float buttonBlockWidth = Math.Min(400f, regionWidth / 2.1f);
            float headerHeight     = ImGui.GetWindowSize().Y / 3;
            float blockHeight      = (regionHeight * 0.95f) - headerHeight;
            float blockStart       = headerHeight + 40f;

            ImFontPtr titleFont = Controller.rgatLargeFont ?? Controller._originalFont !.Value;

            ImGui.PushFont(titleFont);
            Vector2 titleSize = ImGui.CalcTextSize("rgat");

            ImGui.SetCursorScreenPos(new Vector2((ImGui.GetWindowContentRegionMax().X / 2) - (titleSize.X / 2), (ImGui.GetWindowContentRegionMax().Y / 5) - (titleSize.Y / 2)));
            ImGui.Text("rgat");
            ImGui.PopFont();


            //ImGui.PushStyleColor(ImGuiCol.ChildBg, 0xff0000ff);
            //ImGui.PushStyleColor(ImGuiCol.ChildBg, new WritableRgbaFloat(0, 0, 0, 255).ToUint());

            bool boxBorders = false;

            //ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x45ffffff);

            _splashHeaderHover = ImGui.GetMousePos().Y < (ImGui.GetWindowSize().Y / 3f);
            //ImGui.PopStyleColor();

            //Run group
            float voidspace     = Math.Max(0, (regionWidth - (2 * buttonBlockWidth)) / 3);
            float runGrpX       = voidspace;
            float iconTableYSep = 18;
            float iconTitleYSep = 10;

            ImGuiTableFlags tblflags = ImGuiTableFlags.NoHostExtendX;

            if (boxBorders)
            {
                tblflags |= ImGuiTableFlags.Borders;
            }

            ImGui.SetCursorPos(new Vector2(runGrpX, blockStart));
            ImGui.PushStyleColor(ImGuiCol.ChildBg, Themes.GetThemeColourUINT(Themes.eThemeColour.WindowBackground));
            if (ImGui.BeginChild("##RunGroup", new Vector2(buttonBlockWidth, blockHeight), boxBorders))
            {
                ImGui.PushFont(Controller.SplashLargeFont ?? Controller._originalFont !.Value);
                float captionHeight = ImGui.CalcTextSize("Load Binary").Y;
                if (ImGui.BeginTable("##LoadBinBtnBox", 3, tblflags))
                {
                    Vector2 LargeIconSize   = Controller.LargeIconSize;
                    float   iconColumnWidth = 200;
                    float   paddingX        = (buttonBlockWidth - iconColumnWidth) / 2;
                    ImGui.TableSetupColumn("##BBSPadL", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableSetupColumn("##LoadBinBtnIcn", ImGuiTableColumnFlags.WidthFixed, iconColumnWidth);
                    ImGui.TableSetupColumn("##BBSPadR", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(1);

                    Vector2 selectableSize = new Vector2(iconColumnWidth, captionHeight + LargeIconSize.Y + iconTitleYSep + 12);

                    if (ImGui.Selectable("##Load Binary", false, ImGuiSelectableFlags.None, selectableSize))
                    {
                        ToggleLoadExeWindow();
                    }
                    Controller.PushUnicodeFont();
                    Widgets.SmallWidgets.MouseoverText("Load an executable or DLL for examination. It will not be executed at this stage.");
                    ImGui.PopFont();
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetItemRectSize().Y);
                    ImGuiUtils.DrawHorizCenteredText("Load Binary");
                    ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (iconColumnWidth / 2) - (LargeIconSize.X / 2));
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTitleYSep);

                    Controller.PushBigIconFont();
                    ImGui.Text($"{ImGuiController.FA_ICON_SAMPLE}"); //If you change this be sure to update ImGuiController.BuildFonts
                    ImGui.PopFont();

                    ImGui.EndTable();
                }
                ImGui.PopFont();

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTableYSep);
                Vector2 tableSz = new Vector2(buttonBlockWidth, ImGui.GetContentRegionAvail().Y - 25);

                ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 2));
                if (ImGui.BeginTable("#RecentBinTableList", 1, ImGuiTableFlags.ScrollY, tableSz))
                {
                    ImGui.Indent(5);
                    ImGui.TableSetupColumn("Recent Binaries" + $"{(rgatState.ConnectedToRemote ? " (Remote Files)" : "")}");
                    ImGui.TableSetupScrollFreeze(0, 1);
                    ImGui.TableHeadersRow();
                    if (recentBins?.Length > 0)
                    {
                        int bincount = Math.Min(GlobalConfig.Settings.UI.MaxStoredRecentPaths, recentBins.Length);
                        for (var bini = 0; bini < bincount; bini++)
                        {
                            var entry = recentBins[bini];
                            ImGui.TableNextRow();
                            if (ImGui.TableNextColumn())
                            {
                                if (DrawRecentPathEntry(entry, menu: false))
                                {
                                    if (File.Exists(entry.Path) || rgatState.ConnectedToRemote)
                                    {
                                        if (!LoadSelectedBinary(entry.Path, rgatState.ConnectedToRemote) && !_badPaths.Contains(entry.Path))
                                        {
                                            _badPaths.Add(entry.Path);
                                        }
                                    }
                                    else if (!_missingPaths.Contains(entry.Path) && rgatState.ConnectedToRemote is false)
                                    {
                                        _scheduleMissingPathCheck = true;
                                        _missingPaths.Add(entry.Path);
                                    }
                                }
                            }
                        }
                    }
                    ImGui.EndTable();
                }
                ImGui.PopStyleVar();

                ImGui.EndChild();
            }

            ImGui.SetCursorPosY(blockStart);
            ImGui.SetCursorPosX(runGrpX + buttonBlockWidth + voidspace);
            if (ImGui.BeginChild("##LoadGroup", new Vector2(buttonBlockWidth, blockHeight), boxBorders))
            {
                ImGui.PushFont(Controller.SplashLargeFont ?? Controller._originalFont !.Value);
                float captionHeight = ImGui.CalcTextSize("Load Trace").Y;
                if (ImGui.BeginTable("##LoadBtnBox", 3, tblflags))
                {
                    Vector2 LargeIconSize   = Controller.LargeIconSize;
                    float   iconColumnWidth = 200;
                    float   paddingX        = (buttonBlockWidth - iconColumnWidth) / 2;
                    ImGui.TableSetupColumn("##LBSPadL", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableSetupColumn("##LoadBtnIcn", ImGuiTableColumnFlags.WidthFixed, iconColumnWidth);
                    ImGui.TableSetupColumn("##LBSPadR", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(1);
                    Vector2 selectableSize = new Vector2(iconColumnWidth, captionHeight + LargeIconSize.Y + iconTitleYSep + 12);
                    if (ImGui.Selectable("##Load Trace", false, ImGuiSelectableFlags.None, selectableSize))
                    {
                        ToggleLoadTraceWindow();
                    }
                    Controller.PushUnicodeFont();
                    Widgets.SmallWidgets.MouseoverText("Load a previously generated trace");
                    ImGui.PopFont();
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetItemRectSize().Y);
                    ImGuiUtils.DrawHorizCenteredText("Load Trace");
                    ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (iconColumnWidth / 2) - (LargeIconSize.X / 2) + 8); //shift a bit to the right to balance it
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTitleYSep);

                    Controller.PushBigIconFont();
                    ImGui.Text($"{ImGuiController.FA_ICON_LOADFILE}");//If you change this be sure to update ImGuiController.BuildFonts
                    ImGui.PopFont();

                    ImGui.EndTable();
                }
                ImGui.PopFont();

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTableYSep);

                Vector2 tableSz = new Vector2(buttonBlockWidth, ImGui.GetContentRegionAvail().Y - 25);


                ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 2));
                if (ImGui.BeginTable("#RecentTraceTableList", 1, ImGuiTableFlags.ScrollY, tableSz))
                {
                    ImGui.Indent(5);
                    ImGui.TableSetupColumn("Recent Traces");
                    ImGui.TableSetupScrollFreeze(0, 1);
                    ImGui.TableHeadersRow();
                    if (recentTraces?.Length > 0)
                    {
                        int traceCount = Math.Min(GlobalConfig.Settings.UI.MaxStoredRecentPaths, recentTraces.Length);
                        for (var traceI = 0; traceI < traceCount; traceI++)
                        {
                            var entry = recentTraces[traceI];
                            ImGui.TableNextRow();
                            if (ImGui.TableNextColumn())
                            {
                                if (DrawRecentPathEntry(entry, false))
                                {
                                    if (File.Exists(entry.Path))
                                    {
                                        System.Threading.Tasks.Task.Run(() => LoadTraceByPath(entry.Path));

                                        /*
                                         * if (!LoadTraceByPath(entry.Path) && !_badPaths.Contains(entry.Path))
                                         * {
                                         *  _badPaths.Add(entry.Path);
                                         * }*/
                                    }
                                    else if (!_missingPaths.Contains(entry.Path))
                                    {
                                        _scheduleMissingPathCheck = true;
                                        _missingPaths.Add(entry.Path);
                                    }
                                }
                            }
                        }
                    }
                    ImGui.EndTable();
                }
                ImGui.PopStyleVar();

                ImGui.EndChild();
            }

            ImGui.PopStyleVar(5);

            ImGui.BeginGroup();
            string versionString = $"rgat {CONSTANTS.PROGRAMVERSION.RGAT_VERSION}";
            float  width         = ImGui.CalcTextSize(versionString).X;

            ImGui.SetCursorPos(ImGui.GetContentRegionMax() - new Vector2(width + 25, 40));
            ImGui.Text(versionString);


            if (GlobalConfig.NewVersionAvailable)
            {
                Version currentVersion = CONSTANTS.PROGRAMVERSION.RGAT_VERSION_SEMANTIC;
                Version newVersion     = GlobalConfig.Settings.Updates.UpdateLastCheckVersion;
                string  updateString;
                if (newVersion.Major > currentVersion.Major ||
                    (newVersion.Major == currentVersion.Major && newVersion.Minor > currentVersion.Minor))
                {
                    updateString = "New version available ";
                }
                else
                {
                    updateString = "Updates available ";
                }
                updateString += $"({newVersion})";

                Vector2 textSize = ImGui.CalcTextSize(updateString);
                ImGui.SetCursorPos(ImGui.GetContentRegionMax() - new Vector2(textSize.X + 25, 55));

                if (ImGui.Selectable(updateString, false, flags: ImGuiSelectableFlags.None, size: new Vector2(textSize.X, textSize.Y)))
                {
                    ImGui.OpenPopup("New Version Available");
                }
                if (ImGui.IsItemHovered())
                {
                    Updates.ChangesCounts(out int changes, out int versions);
                    if (changes > 0)
                    {
                        ImGui.BeginTooltip();
                        ImGui.Text($"Click to see {changes} changes in {versions} newer rgat versions");
                        ImGui.EndTooltip();
                    }
                }
            }
            ImGui.EndGroup();

            ImGui.PopStyleColor();
            if (GlobalConfig.Settings.UI.EnableTortoise)
            {
                _splashRenderer?.Draw();
            }

            if (StartupProgress < 1)
            {
                float originalY = ImGui.GetCursorPosY();
                float ypos      = ImGui.GetWindowSize().Y - 12;
                ImGui.SetCursorPosY(ypos);
                ImGui.ProgressBar((float)StartupProgress, new Vector2(-1, 4f));
                ImGui.SetCursorPosY(originalY);
            }

            if (ImGui.IsPopupOpen("New Version Available"))
            {
                ImGui.SetNextWindowSize(new Vector2(600, 500), ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos((ImGui.GetWindowSize() / 2) - new Vector2(600f / 2f, 500f / 2f), ImGuiCond.Appearing);
                bool isopen = true;
                if (ImGui.BeginPopupModal("New Version Available", ref isopen, flags: ImGuiWindowFlags.Modal))
                {
                    Updates.DrawChangesDialog();
                    isopen = isopen && !ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape));
                    if (!isopen)
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
            }
        }
Exemplo n.º 25
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();
        }
    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);
    }
            private void DrawFileSwapTabEdit()
            {
                if (!ImGui.BeginTabItem(LabelFileSwapTab))
                {
                    return;
                }

                ImGui.SetNextItemWidth(-1);
                if (ImGui.BeginListBox(LabelFileSwapHeader, AutoFillSize))
                {
                    var swaps = Meta.FileSwaps.Keys.ToArray();

                    var arrow = $"{( char )FontAwesomeIcon.LongArrowAltRight}";
                    ImGui.PushFont(UiBuilder.IconFont);
                    var arrowWidth = ImGui.CalcTextSize(arrow).X;
                    ImGui.PopFont();


                    var width = (ImGui.GetWindowWidth() - arrowWidth - 4 * ImGui.GetStyle().ItemSpacing.X) / 2;
                    for (var idx = 0; idx < swaps.Length + 1; ++idx)
                    {
                        var    key         = idx == swaps.Length ? GamePath.GenerateUnchecked("") : swaps[idx];
                        var    value       = idx == swaps.Length ? GamePath.GenerateUnchecked("") : Meta.FileSwaps[key];
                        string keyString   = key;
                        string valueString = value;

                        ImGui.SetNextItemWidth(width);
                        if (ImGui.InputTextWithHint($"##swapLhs_{idx}", "Enter new file to be replaced...", ref keyString,
                                                    GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue))
                        {
                            var newKey = new GamePath(keyString);
                            if (newKey.CompareTo(key) != 0)
                            {
                                if (idx < swaps.Length)
                                {
                                    Meta.FileSwaps.Remove(key);
                                }

                                if (newKey != string.Empty)
                                {
                                    Meta.FileSwaps[newKey] = value;
                                }

                                _selector.SaveCurrentMod();
                                if (Mod.Enabled)
                                {
                                    _selector.ReloadCurrentMod();
                                }
                            }
                        }

                        if (idx < swaps.Length)
                        {
                            ImGui.SameLine();
                            ImGui.PushFont(UiBuilder.IconFont);
                            ImGui.TextUnformatted(arrow);
                            ImGui.PopFont();
                            ImGui.SameLine();

                            ImGui.SetNextItemWidth(width);
                            if (ImGui.InputTextWithHint($"##swapRhs_{idx}", "Enter new replacement path...", ref valueString,
                                                        GamePath.MaxGamePathLength,
                                                        ImGuiInputTextFlags.EnterReturnsTrue))
                            {
                                var newValue = new GamePath(valueString);
                                if (newValue.CompareTo(value) != 0)
                                {
                                    Meta.FileSwaps[key] = newValue;
                                    _selector.SaveCurrentMod();
                                    if (Mod.Enabled)
                                    {
                                        _selector.ReloadCurrentMod();
                                    }
                                }
                            }
                        }
                    }

                    ImGui.EndListBox();
                }

                ImGui.EndTabItem();
            }
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 override void Draw()
        {
            var windowSize = ImGui.GetWindowSize();

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

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

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

                    ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel"));
                    if (ImGui.BeginCombo("##XlChatTypeCombo", this.dalamudMessagesChatType.ToString()))
                    {
                        foreach (var type in Enum.GetValues(typeof(XivChatType)).Cast <XivChatType>())
                        {
                            if (ImGui.Selectable(type.ToString(), type == this.dalamudMessagesChatType))
                            {
                                this.dalamudMessagesChatType = type;
                            }
                        }
                        ImGui.EndCombo();
                    }
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."));

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

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

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

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

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

                    ImGui.Checkbox(Loc.Localize("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"), ref this.doButtonsSystemMenu);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsSystemMenuMsgHint", "Add buttons for Dalamud plugins and settings to the system menu."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsVisual", "Look & Feel")))
                {
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
                    ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI Scale"));
                    ImGui.SameLine();
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3);
                    if (ImGui.Button("Reset"))
                    {
                        this.globalUiScale = 1.0f;
                        ImGui.GetIO().FontGlobalScale = this.globalUiScale;
                    }

                    if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f"))
                    {
                        ImGui.GetIO().FontGlobalScale = this.globalUiScale;
                    }

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

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

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

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

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

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

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

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"), ref this.doViewport);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"), ref this.doDocking);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."));

                    ImGui.Checkbox(Loc.Localize("DalamudSettingToggleGamepadNavigation", "Enable navigation of ImGui windows via gamepad."), ref this.doGamepad);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and ImGui navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."));

                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental")))
                {
                    ImGui.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for plugins."));
                    ImGui.TextColored(this.warnTextColor, Loc.Localize("DalamudSettingsPluginTestWarning", "Testing plugins may not have been vetted before being published. Please only enable this if you are aware of the risks."));

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

                    if (ImGui.Button(Loc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins")))
                    {
                        this.dalamud.Configuration.HiddenPluginInternalName.Clear();
                    }
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsClearHiddenHint", "Restore plugins you have previously hidden from the plugin installer."));

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

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

                    ImGui.Text(Loc.Localize("DalamudSettingsCustomRepo", "Custom Plugin Repositories"));
                    ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingCustomRepoHint", "Add custom plugin repositories."));
                    ImGui.TextColored(this.warnTextColor, Loc.Localize("DalamudSettingCustomRepoWarning", "We cannot take any responsibility for third-party plugins and repositories.\nTake care when installing third-party plugins from untrusted sources."));

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

                    ImGui.Columns(4);
                    ImGui.SetColumnWidth(0, 18 + 5 * ImGui.GetIO().FontGlobalScale);
                    ImGui.SetColumnWidth(1, ImGui.GetWindowWidth() - (18 + 16 + 14) - (5 + 45 + 26) * ImGui.GetIO().FontGlobalScale);
                    ImGui.SetColumnWidth(2, 16 + (45 * ImGui.GetIO().FontGlobalScale));
                    ImGui.SetColumnWidth(3, 14 + (26 * ImGui.GetIO().FontGlobalScale));

                    ImGui.Separator();

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

                    ImGui.Separator();

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

                    ThirdRepoSetting toRemove = null;

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

                        ImGui.PushID($"thirdRepo_{thirdRepoSetting.Url}");

                        ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 8 - (ImGui.CalcTextSize(repoNumber.ToString()).X / 2));
                        ImGui.Text(repoNumber.ToString());
                        ImGui.NextColumn();

                        ImGui.TextWrapped(thirdRepoSetting.Url);
                        ImGui.NextColumn();

                        ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 7 - 12 * ImGui.GetIO().FontGlobalScale);
                        ImGui.Checkbox("##thirdRepoCheck", ref isEnabled);
                        ImGui.NextColumn();

                        ImGui.PushFont(InterfaceManager.IconFont);
                        if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString()))
                        {
                            toRemove = thirdRepoSetting;
                        }
                        ImGui.PopFont();
                        ImGui.NextColumn();
                        ImGui.Separator();

                        thirdRepoSetting.IsEnabled = isEnabled;

                        repoNumber++;
                    }

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

                    ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 8 - (ImGui.CalcTextSize(repoNumber.ToString()).X / 2));
                    ImGui.Text(repoNumber.ToString());
                    ImGui.NextColumn();
                    ImGui.SetNextItemWidth(-1);
                    ImGui.InputText("##thirdRepoUrlInput", ref this.thirdRepoTempUrl, 300);
                    ImGui.NextColumn();
                    ImGui.NextColumn();
                    ImGui.PushFont(InterfaceManager.IconFont);
                    if (!string.IsNullOrEmpty(this.thirdRepoTempUrl) && ImGui.Button(FontAwesomeIcon.Plus.ToIconString()))
                    {
                        if (this.thirdRepoList.Any(r => string.Equals(r.Url, this.thirdRepoTempUrl, StringComparison.InvariantCultureIgnoreCase)))
                        {
                            this.thirdRepoAddError = Loc.Localize("DalamudThirdRepoExists", "Repo already exists.");
                            Task.Delay(5000).ContinueWith(t => this.thirdRepoAddError = string.Empty);
                        }
                        else
                        {
                            this.thirdRepoList.Add(new ThirdRepoSetting {
                                Url       = this.thirdRepoTempUrl,
                                IsEnabled = true
                            });

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

                    ImGui.EndTabItem();

                    if (!string.IsNullOrEmpty(this.thirdRepoAddError))
                    {
                        ImGui.TextColored(new Vector4(1, 0, 0, 1), this.thirdRepoAddError);
                    }
                }

                ImGui.EndTabBar();
            }

            ImGui.EndChild();

            if (ImGui.Button(Loc.Localize("Save", "Save")))
            {
                Save();
            }

            ImGui.SameLine();

            if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
            {
                Save();
                this.IsOpen = false;
            }
        }
Exemplo n.º 30
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();
            }
        }