Ejemplo n.º 1
0
        internal void Render(Sprite sprite)
        {
            Vector2 window_pos  = new Vector2();
            var     window_size = new Vector2(320, 320);

            var draw_list = ImGui.GetOverlayDrawList();

            if (Services.CompassSettings.OverlayCorner != -1)
            {
                window_pos =
                    new Vector2(
                        Services.CompassSettings.OverlayCorner == 1 ? ImGui.GetIO().DisplaySize.X - Services.CompassSettings.DISTANCE : Services.CompassSettings.DISTANCE,
                        Services.CompassSettings.OverlayCorner == 2
                            ? ImGui.GetIO().DisplaySize.Y - Services.CompassSettings.DISTANCE
                            : Services.CompassSettings.DISTANCE);

                ImGui.SetNextWindowPos(window_pos, Condition.Always);
            }

            ImGui.SetNextWindowSize(window_size, Condition.Always);
            if (ImGui.BeginWindow("Overlay", ref Services.CompassSettings.OverlayOpened, window_size, 0,
                                  (Services.CompassSettings.OverlayCorner != -1 ? WindowFlags.NoMove : 0) | WindowFlags.NoTitleBar | WindowFlags.NoResize | WindowFlags.NoFocusOnAppearing))
            {
                window_pos = ImGui.GetWindowPosition();
                if (ImGuiNative.igBeginPopupContextWindow("Options", 1, true))
                {
                    if (ImGui.MenuItem("Custom position", null, Services.CompassSettings.OverlayCorner == -1, true))
                    {
                        Services.CompassSettings.OverlayCorner = -1;
                    }
                    if (ImGui.MenuItem("Top right", null, Services.CompassSettings.OverlayCorner == 0, true))
                    {
                        Services.CompassSettings.OverlayCorner = 0;
                    }
                    if (ImGui.MenuItem("Settings", null, Services.CompassSettings.SettingsOpened, true))
                    {
                        Services.CompassSettings.SettingsOpened = !Services.CompassSettings.SettingsOpened;
                    }

                    ImGuiNative.igEndPopup();
                }

                draw_list.AddCircleFilled(
                    new Vector2(window_pos.X + window_size.X * 0.5f, window_size.Y * 0.5f + window_pos.Y),
                    160, Color.FromArgb(76, 15, 15, 15).ToDx9ARGB(), 128
                    );
                draw_list.AddLine(new Vector2(window_pos.X + window_size.X * 0.5f, window_pos.Y),
                                  new Vector2(window_pos.X + window_size.X * 0.5f, window_pos.Y + window_size.Y),
                                  Color.FromArgb(90, 70, 70, 255).ToDx9ARGB(), 1f);

                draw_list.AddLine(new Vector2(window_pos.X, window_pos.Y + window_size.Y * 0.5f),
                                  new Vector2(window_pos.X + window_size.X, window_pos.Y + window_size.Y * 0.5f),
                                  Color.FromArgb(89, 70, 70, 255).ToDx9ARGB(), 1f);

                var dot1 = new Vector2(window_pos.X + window_size.X * 0.5f, window_pos.Y + window_size.Y * 0.5f);

                var dot2 = new Vector2(window_pos.X + window_size.X - 30, window_pos.Y + window_size.Y * 0.5f);

                var final = CameraScanner.CameraAddress != 0
                    ? RotatePoint(dot2, dot1, new Angle(CameraScanner.Angle()).Gradus - 90)
                    : RotatePoint(dot2, dot1,
                                  PacketProcessor.Instance.EntityTracker.CompassUser.Heading.Gradus - 90);

                draw_list.AddLine(dot1, final, Color.FromArgb(120, 255, 255, 255).ToDx9ARGB(), 1f);

                var values = PlayerModels.Values.ToArray();
                for (var i = 0; i < values.Length; i++)
                {
                    if (Services.CompassSettings.CaptureOnlyEnemy && Services.CompassSettings.FriendlyTypes.Contains(values[i].Relation))
                    {
                        continue;
                    }
                    if (Services.CompassSettings.FilterByClasses && Services.CompassSettings.FilteredClasses.Contains(values[i].PlayerClass))
                    {
                        continue;
                    }
                    uint color;
                    if (values[i].Dead)
                    {
                        Services.CompassSettings.RelationColors.TryGetValue(RelationType.Dead, out color);
                    }
                    else
                    {
                        if (!Services.CompassSettings.RelationColors.TryGetValue(values[i].Relation, out color))
                        {
                            Services.CompassSettings.RelationColors.TryGetValue(RelationType.Unknown, out color);
                        }
                    }


                    var ScreenPosition = GetScreenPos(values[i]);

                    color = color.ToDx9ARGB();

                    draw_list.AddCircleFilled(
                        new Vector2(window_pos.X + ScreenPosition.X, window_pos.Y + ScreenPosition.Y),
                        Services.CompassSettings.PlayerSize, color, Services.CompassSettings.PlayerSize * 2);

                    if (Services.CompassSettings.ShowNicknames)
                    {
                        draw_list.AddText(
                            new Vector2(window_pos.X + ScreenPosition.X - values[i].Name.Length * 4 / 2f,
                                        window_pos.Y + ScreenPosition.Y + Services.CompassSettings.PlayerSize), $"{values[i].Name}",
                            color);
                    }
                }
            }

            ImGui.EndWindow();
            if (PacketProcessor.Instance.EntityTracker.CompassUser.Status == 1 && DXHookD3D9._imageCache.TryGetValue("incombat.png", out var texture))
            {
                sprite.Draw(texture, new SharpDX.Mathematics.Interop.RawColorBGRA(255, 255, 255, 255), null, null,
                            new SharpDX.Mathematics.Interop.RawVector3(window_pos.X + window_size.X - 32, window_pos.Y + window_size.Y - 64, 0));
            }
            if (PlayerModels.Count > 0)
            {
                if (Services.CompassSettings.StatisticsOpened)
                {
                    var GuldList = PlayerModels.Values
                                   .ToArray()
                                   .GroupBy(x => x.GuildName.Length == 0 ? "Without Guild" : x.GuildName,
                                            (key, g) => new { GuildName = key, Players = g.ToList() })
                                   .OrderByDescending(x => x.Players.Count).ToHashSet();

                    if (GuldList.Count > 0)
                    {
                        ImGui.SetNextWindowPos(new Vector2(window_pos.X, window_pos.Y + window_size.Y), Condition.Always);
                        if (ImGui.BeginWindow("Guilds", ref Services.CompassSettings.OverlayOpened, new Vector2(350, 200), 0.3f,
                                              WindowFlags.NoTitleBar | WindowFlags.NoFocusOnAppearing))
                        {
                            ImGui.BeginChild("left pane", new Vector2(150, 0), true);

                            foreach (var i in GuldList)
                            {
                                if (ImGui.Selectable($"{i.GuildName} ({i.Players.Count})",
                                                     Services.CompassSettings.SelectedGuildName == i.GuildName))
                                {
                                    Services.CompassSettings.SelectedGuildName = i.GuildName;
                                }
                            }

                            ImGui.EndChild();
                            ImGui.SameLine();
                            ImGuiNative.igBeginGroup();
                            ImGui.BeginChild("item view", new Vector2(0, -ImGui.GetFrameHeightWithSpacing()), true); // Leave room for 1 line below us

                            ImGui.TextUnformatted($"Guild name {Services.CompassSettings.SelectedGuildName}\n");
                            ImGui.Columns(3, null, true);

                            var players = GuldList.SingleOrDefault(x => x.GuildName == Services.CompassSettings.SelectedGuildName)
                                          ?.Players?.GroupBy(x => x.PlayerClass,
                                                             (key, g) => new { Class = key, Players = g.ToList() });

                            if (players != null)
                            {
                                foreach (var details in players)
                                {
                                    if (ImGui.GetColumnIndex() == 0)
                                    {
                                        ImGui.Separator();
                                    }
                                    ImGui.TextUnformatted($"{details.Class.ToString()} ({details.Players.Count})\n");

                                    if (details.Players?.Count > 0)
                                    {
                                        foreach (var name in details.Players)
                                        {
                                            ImGui.TextUnformatted($"{name.Name}\n");
                                        }
                                    }
                                    ImGui.NextColumn();
                                }
                            }

                            ImGui.Columns(1, null, true);

                            ImGui.Separator();
                            ImGui.EndChild();
                            ImGuiNative.igEndGroup();
                        }

                        ImGui.EndWindow();
                    }
                }
            }

            if (Services.CompassSettings.SettingsOpened)
            {
                if (ImGui.BeginWindow("Settings", ref Services.CompassSettings.SettingsOpened, new Vector2(350, 400), 0.3f,
                                      WindowFlags.NoFocusOnAppearing | WindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Guild statistic", ref Services.CompassSettings.StatisticsOpened);
                    ImGui.Checkbox("Show only enemy players", ref Services.CompassSettings.CaptureOnlyEnemy);
                    ImGui.Checkbox("Filter by classes", ref Services.CompassSettings._filterByClasses);
                    ImGui.Checkbox("Show nicknames", ref Services.CompassSettings._showNicknames);
                    ImGui.Checkbox("Perfomance test", ref Services.CompassSettings._showFps);
                    ImGui.SliderFloat("Zoom", ref Services.CompassSettings._zoom, 1, 20, $"Zoom={Services.CompassSettings.Zoom}", 2f);
                    if (ImGui.IsLastItemActive() || ImGui.IsItemHovered(HoveredFlags.Default))
                    {
                        ImGui.SetTooltip($"{Services.CompassSettings.Zoom:F2}");
                    }
                    ImGui.SliderInt("PlayerSize", ref Services.CompassSettings._playerSize, 1, 10, $"PlayerSize = {Services.CompassSettings.PlayerSize}");
                    if (ImGui.IsLastItemActive() || ImGui.IsItemHovered(HoveredFlags.Default))
                    {
                        ImGui.SetTooltip($"{Services.CompassSettings.PlayerSize}");
                    }
                    if (ImGui.CollapsingHeader("Settings for filter by class            ", TreeNodeFlags.CollapsingHeader | TreeNodeFlags.AllowItemOverlap))
                    {
                        ImGui.TextUnformatted("Common ignored");
                        ImGui.Columns(3, null, false);
                        foreach (PlayerClass i in Enum.GetValues(typeof(PlayerClass)))
                        {
                            var flag = Services.CompassSettings.FilteredClasses.Contains(i);
                            ImGui.Checkbox(i.ToString(), ref flag);
                            if (flag)
                            {
                                Services.CompassSettings.FilteredClasses.Add(i);
                            }
                            else if (Services.CompassSettings.FilteredClasses.Contains(i))
                            {
                                Services.CompassSettings.FilteredClasses.Remove(i);
                            }
                            ImGui.NextColumn();
                        }

                        ImGui.Columns(1, null, false);
                    }

                    if (ImGui.CollapsingHeader("Colors for player relation", TreeNodeFlags.CollapsingHeader))
                    {
                        var keys = Services.CompassSettings.RelationColors.Keys.ToArray();
                        for (var i = 0; i < keys.Length; i++)
                        {
                            Services.CompassSettings.RelationColors.TryGetValue(keys[i], out var color);
                            Services.CompassSettings.R[i] = ((color >> 16) & 255) / 255f;
                            Services.CompassSettings.G[i] = ((color >> 8) & 255) / 255f;
                            Services.CompassSettings.B[i] = ((color >> 0) & 255) / 255f;
                            Services.CompassSettings.A[i] = ((color >> 24) & 255) / 255f;
                            ImGui.TextUnformatted(keys[i].ToString());
                            ImGui.SameLine();
                            ImGui.ColorEdit4(keys[i].ToString(), ref Services.CompassSettings.R[i], ref Services.CompassSettings.G[i], ref Services.CompassSettings.B[i],
                                             ref Services.CompassSettings.A[i],
                                             ColorEditFlags.NoInputs | ColorEditFlags.RGB | ColorEditFlags.NoLabel);

                            uint mr = Services.CompassSettings.R[i] >= 1.0 ? 255 :
                                      Services.CompassSettings.R[i] <= 0.0 ? 0 : (uint)Math.Round(Services.CompassSettings.R[i] * 255f),
                                 mg = Services.CompassSettings.G[i] >= 1.0 ? 255 :
                                      Services.CompassSettings.G[i] <= 0.0 ? 0 : (uint)Math.Round(Services.CompassSettings.G[i] * 255f),
                                 mb = Services.CompassSettings.B[i] >= 1.0 ? 255 :
                                      Services.CompassSettings.B[i] <= 0.0 ? 0 : (uint)Math.Round(Services.CompassSettings.B[i] * 255f),
                                 ma = Services.CompassSettings.A[i] >= 1.0 ? 255 :
                                      Services.CompassSettings.A[i] <= 0.0 ? 0 : (uint)Math.Round(Services.CompassSettings.A[i] * 255f);

                            Services.CompassSettings.RelationColors[keys[i]] = (ma << 24) | (mr << 16) | (mg << 8) | (mb << 0);
                        }
                    }

                    if (ImGui.Button("Save settings"))
                    {
                        Services.Tracker.RunAutoPersist();
                    }

                    ImGui.SameLine();
                    if (ImGui.Button("Reset to default"))
                    {
                        Services.CompassSettings.ResetSettings();
                        Services.Tracker.RunAutoPersist();
                    }

                    //if (ImGuiRender.Icons.TryGetValue("incombat.png", out var intPtr))
                    //{
                    //    ImGui.TextUnformatted(ImGuiRender.Icons.Keys.First());
                    //    ImGui.Image(intPtr, new Vector2(64, 64), new Vector2(0, 0), new Vector2(1, 1),
                    //        new Vector4(0, 0, 0, 0), new Vector4(1, 1, 1, 1));
                    //}
                }

                ImGui.EndWindow();
            }
        }
Ejemplo n.º 2
0
        internal void Render(Sprite sprite)
        {
            if (Services.GameState != GameState.InGame)
            {
                return;
            }
            Vector2 CompassPosition = new Vector2();
            Vector2 CompassSize     = new Vector2(320, 320);

            if (Services.CompassSettings.OverlayCorner != -1)
            {
                CompassPosition = new Vector2(Services.CompassSettings.DISTANCE, Services.CompassSettings.DISTANCE);
                ImGui.SetNextWindowPos(CompassPosition, ImGuiCond.Always);
            }

            ImGui.SetNextWindowSize(CompassSize, ImGuiCond.Always);
            ImGuiNative.igSetNextWindowContentSize(CompassSize);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
            ImGui.SetNextWindowBgAlpha(0);
            if (ImGui.Begin("Overlay", ref Services.CompassSettings.OverlayOpened,
                            (Services.CompassSettings.OverlayCorner != -1 ? ImGuiWindowFlags.NoMove : 0) | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize |
                            ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoScrollbar))
            {
                var draw_list = ImGui.GetWindowDrawList();
                CompassPosition = ImGui.GetWindowPos();
                ImGui.PopStyleVar();
                if (ImGui.BeginPopupContextWindow("Options", 1, true))
                {
                    if (ImGui.MenuItem("Custom position", null, Services.CompassSettings.OverlayCorner == -1, true))
                    {
                        Services.CompassSettings.OverlayCorner = -1;
                    }
                    if (ImGui.MenuItem("Top right", null, Services.CompassSettings.OverlayCorner == 0, true))
                    {
                        Services.CompassSettings.OverlayCorner = 0;
                    }
                    if (ImGui.MenuItem("Settings", null, Services.CompassSettings.SettingsOpened, true))
                    {
                        Services.CompassSettings.SettingsOpened = !Services.CompassSettings.SettingsOpened;
                    }

                    ImGuiNative.igEndPopup();
                }

                Vector2 WindowCenter = new Vector2(CompassPosition.X + CompassSize.X * 0.5f, CompassPosition.Y + CompassSize.Y * 0.5f);

                draw_list.AddCircleFilled(
                    WindowCenter,
                    CompassSize.X / 2, Color.FromArgb(76, 15, 15, 15).ToDx9ARGB(), 128
                    );

                draw_list.AddLine(new Vector2(WindowCenter.X, CompassPosition.Y),
                                  new Vector2(WindowCenter.X, CompassPosition.Y + CompassSize.Y),
                                  Color.FromArgb(90, 70, 70, 255).ToDx9ARGB(), 1f);

                draw_list.AddLine(new Vector2(CompassPosition.X, WindowCenter.Y),
                                  new Vector2(CompassPosition.X + CompassSize.X, WindowCenter.Y),
                                  Color.FromArgb(89, 70, 70, 255).ToDx9ARGB(), 1f);


                var dot2  = new Vector2(CompassPosition.X + CompassSize.X - 30, WindowCenter.Y);
                var final = CameraScanner.CameraAddress != 0
                    ? RotatePoint(dot2, WindowCenter, new Angle(CameraScanner.Angle()).Gradus - 90)
                    : RotatePoint(dot2, WindowCenter,
                                  PacketProcessor.Instance.EntityTracker.CompassUser.Heading.Gradus - 90);
                draw_list.AddLine(WindowCenter, final, Color.FromArgb(120, 255, 255, 255).ToDx9ARGB(), 1f);

                int deadenemy = 0, deadally = 0, enemy = 0, ally = 0;
                foreach (var player in PlayerModels)
                {
                    if (Services.CompassSettings.FilterByClasses && Services.CompassSettings.FilteredClasses.Contains(player.Value.RaceGenderClass.Class))
                    {
                        continue;
                    }
                    uint color;
                    var  friendly = Services.CompassSettings.FriendlyTypes.Contains(player.Value.Relation);
                    if (player.Value.Dead)
                    {
                        Services.CompassSettings.RelationColors.TryGetValue(RelationType.Dead, out color);
                        if (friendly)
                        {
                            deadally++;
                        }
                        else
                        {
                            deadenemy++;
                        }
                    }
                    else
                    {
                        if (friendly)
                        {
                            ally++;
                        }
                        else
                        {
                            enemy++;
                        }
                        if (!Services.CompassSettings.RelationColors.TryGetValue(player.Value.Relation, out color))
                        {
                            Services.CompassSettings.RelationColors.TryGetValue(RelationType.Unknown, out color);
                        }
                    }

                    if (friendly && Services.CompassSettings.CaptureOnlyEnemy)
                    {
                        continue;
                    }
                    var ScreenPosition = GetScreenPos(player.Value);

                    color = color.ToDx9ARGB();

                    draw_list.AddCircleFilled(
                        new Vector2(CompassPosition.X + ScreenPosition.X, CompassPosition.Y + ScreenPosition.Y),
                        Services.CompassSettings.PlayerSize, color, Services.CompassSettings.PlayerSize * 2);
                    if (Services.CompassSettings.ShowNicknames)
                    {
                        Vector2 pos = new Vector2(CompassPosition.X + ScreenPosition.X - player.Value.Name.Length * 4 / 2f,
                                                  CompassPosition.Y + ScreenPosition.Y + Services.CompassSettings.PlayerSize);
                        if (!float.IsNaN(pos.X))
                        {
                            draw_list.AddText(pos, $"{player.Value.Name}", color);
                        }
                    }
                }

                if (Services.CompassSettings.ShowGatherting)
                {
                    foreach (var i in CollectionModels)
                    {
                        Texture CollectionIcon = null;
                        switch (i.Value.ColorType)
                        {
                        case ColorType.Blue:
                            DXHookD3D9._imageCache.TryGetValue("blue.png", out CollectionIcon);
                            break;

                        case ColorType.Green:
                            DXHookD3D9._imageCache.TryGetValue("green.png", out CollectionIcon);
                            break;

                        case ColorType.Yellow:
                            DXHookD3D9._imageCache.TryGetValue("yellow.png", out CollectionIcon);
                            break;
                        }

                        if (CollectionIcon != null)
                        {
                            var ScreenPosition = GetScreenPos(i.Value);
                            sprite.Draw(CollectionIcon, new SharpDX.Mathematics.Interop.RawColorBGRA(255, 255, 255, 255), null, null,
                                        new SharpDX.Mathematics.Interop.RawVector3(CompassPosition.X + ScreenPosition.X - 8, CompassPosition.Y + ScreenPosition.Y - 8, 0));
                        }
                    }
                }

                ImGuiNative.igSetCursorPosY(CompassSize.Y - ImGuiNative.igGetTextLineHeight());

                ImGui.TextColored(Color.Green.ToVector4(), $"{ally}");
                ImGui.SameLine();
                ImGui.TextColored(Color.Red.ToVector4(), $"{enemy}");
                ImGui.SameLine();
                ImGui.TextColored(Color.Gray.ToVector4(), $"{deadally}|{deadenemy}");
            }

            ImGui.End();
            if (PacketProcessor.Instance.EntityTracker.CompassUser.Status == 1 && DXHookD3D9._imageCache.TryGetValue("incombat.png", out var texture))
            {
                sprite.Draw(texture, new SharpDX.Mathematics.Interop.RawColorBGRA(255, 255, 255, 255), null, null,
                            new SharpDX.Mathematics.Interop.RawVector3(CompassPosition.X + CompassSize.X - 32, CompassPosition.Y + CompassSize.Y - 64, 0));
            }
            if (PlayerModels.Count > 0)
            {
                if (Services.CompassSettings.StatisticsOpened)
                {
                    var GuldList = PlayerModels.Select(x => x.Value)
                                   .GroupBy(x => x.GuildName.Length == 0 ? "Without Guild" : x.GuildName,
                                            (key, g) => new { GuildName = key, Players = g.ToList() })
                                   .OrderByDescending(x => x.Players.Count).ToHashSet();

                    if (GuldList.Count > 0)
                    {
                        ImGui.SetNextWindowPos(new Vector2(CompassPosition.X, CompassPosition.Y + CompassSize.Y), ImGuiCond.Always);
                        ImGui.SetNextWindowBgAlpha(0.3f);
                        //ImGui.SetNextWindowSize(new Vector2(350, 200));
                        if (ImGui.Begin("Guilds", ref Services.CompassSettings.OverlayOpened, ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoFocusOnAppearing))
                        {
                            ImGui.BeginChild("left pane", new Vector2(150, 0), true);

                            foreach (var i in GuldList)
                            {
                                if (ImGui.Selectable($"{i.GuildName} ({i.Players.Count})",
                                                     Services.CompassSettings.SelectedGuildName == i.GuildName))
                                {
                                    Services.CompassSettings.SelectedGuildName = i.GuildName;
                                }
                            }

                            ImGui.EndChild();
                            ImGui.SameLine();
                            ImGuiNative.igBeginGroup();
                            ImGui.BeginChild("item view", new Vector2(0, -ImGui.GetFrameHeightWithSpacing()), true); // Leave room for 1 line below us

                            ImGui.TextUnformatted($"Guild name {Services.CompassSettings.SelectedGuildName}\n");
                            ImGui.Columns(3, null, true);

                            var players = GuldList.SingleOrDefault(x => x.GuildName == Services.CompassSettings.SelectedGuildName)
                                          ?.Players?.GroupBy(x => x.RaceGenderClass.Class,
                                                             (key, g) => new { Class = key, Players = g.ToList() });

                            if (players != null)
                            {
                                foreach (var details in players)
                                {
                                    if (ImGui.GetColumnIndex() == 0)
                                    {
                                        ImGui.Separator();
                                    }
                                    ImGui.TextUnformatted($"{details.Class.ToString()} ({details.Players.Count})\n");

                                    if (details.Players?.Count > 0)
                                    {
                                        foreach (var name in details.Players)
                                        {
                                            ImGui.TextUnformatted($"{name.Name}\n");
                                        }
                                    }
                                    ImGui.NextColumn();
                                }
                            }

                            ImGui.Columns(1, null, true);

                            ImGui.Separator();
                            ImGui.EndChild();
                            ImGuiNative.igEndGroup();
                        }

                        ImGui.End();
                    }
                }
            }

            if (Services.CompassSettings.SettingsOpened)
            {
                ImGui.SetNextWindowBgAlpha(0.3f);
                ImGui.SetNextWindowSize(new Vector2(350, 400));
                ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 1);
                if (ImGui.Begin("Settings", ref Services.CompassSettings.SettingsOpened,
                                ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Guild statistic", ref Services.CompassSettings.StatisticsOpened);
                    ImGui.Checkbox("Show only enemy players", ref Services.CompassSettings.CaptureOnlyEnemy);
                    ImGui.Checkbox("Filter by classes", ref Services.CompassSettings._filterByClasses);
                    ImGui.Checkbox("Show nicknames", ref Services.CompassSettings._showNicknames);


                    ImGui.SliderFloat("Zoom", ref Services.CompassSettings._zoom, 1, 20, $"Zoom={Services.CompassSettings.Zoom}", 2f);
                    if (ImGui.IsItemActive() || ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip($"{Services.CompassSettings.Zoom:F2}");
                    }
                    ImGui.SliderInt("PlayerSize", ref Services.CompassSettings._playerSize, 1, 10, $"PlayerSize = {Services.CompassSettings.PlayerSize}");
                    if (ImGui.IsItemActive() || ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip($"{Services.CompassSettings.PlayerSize}");
                    }
                    ImGui.Checkbox("Show nicknames", ref Services.CompassSettings._showGatherting);
                    if (ImGui.CollapsingHeader("Customize relations", ImGuiTreeNodeFlags.CollapsingHeader))
                    {
                        byte[] buffer = Encoding.UTF8.GetBytes(Services.CompassSettings.MyGuildName);
                        Array.Resize <byte>(ref buffer, 20);
                        if (ImGui.InputText("MyGuildName", buffer, 20))
                        {
                            Services.CompassSettings.MyGuildName = Encoding.UTF8.GetString(buffer).TrimEnd('\0');
                        }

                        ImGui.Checkbox("Guild members always friendly", ref Services.CompassSettings._markGuildAsAlly);
                    }

                    if (ImGui.CollapsingHeader("Settings for filter by class            ", ImGuiTreeNodeFlags.CollapsingHeader | ImGuiTreeNodeFlags.AllowItemOverlap))
                    {
                        ImGui.TextUnformatted("Common ignored");
                        ImGui.Columns(3, null, false);
                        foreach (PlayerClass i in Enum.GetValues(typeof(PlayerClass)))
                        {
                            var flag = Services.CompassSettings.FilteredClasses.Contains(i);
                            ImGui.Checkbox(i.ToString(), ref flag);
                            if (flag)
                            {
                                Services.CompassSettings.FilteredClasses.Add(i);
                            }
                            else if (Services.CompassSettings.FilteredClasses.Contains(i))
                            {
                                Services.CompassSettings.FilteredClasses.Remove(i);
                            }
                            ImGui.NextColumn();
                        }

                        ImGui.Columns(1, null, false);
                    }

                    if (ImGui.CollapsingHeader("Colors for player relation", ImGuiTreeNodeFlags.CollapsingHeader))
                    {
                        var keys = Services.CompassSettings.RelationColors.Keys.ToArray();
                        for (var i = 0; i < keys.Length; i++)
                        {
                            Services.CompassSettings.RelationColors.TryGetValue(keys[i], out var color);
                            ImGui.TextUnformatted(keys[i].ToString());
                            ImGui.SameLine();
                            Vector4 vector4 = new Vector4(((color >> 16) & 255) / 255f, ((color >> 8) & 255) / 255f,
                                                          ((color >> 0) & 255) / 255f, ((color >> 24) & 255) / 255f);
                            ImGui.ColorEdit4(keys[i].ToString(), ref vector4,
                                             ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.RGB | ImGuiColorEditFlags.NoLabel);

                            uint mr = vector4.X >= 1.0 ? 255 :
                                      vector4.X <= 0.0 ? 0 : (uint)Math.Round(vector4.X * 255f),
                                 mg = vector4.Y >= 1.0 ? 255 :
                                      vector4.Y <= 0.0 ? 0 : (uint)Math.Round(vector4.Y * 255f),
                                 mb = vector4.Z >= 1.0 ? 255 :
                                      vector4.Z <= 0.0 ? 0 : (uint)Math.Round(vector4.Z * 255f),
                                 ma = vector4.W >= 1.0 ? 255 :
                                      vector4.W <= 0.0 ? 0 : (uint)Math.Round(vector4.W * 255f);

                            Services.CompassSettings.RelationColors[keys[i]] = (ma << 24) | (mr << 16) | (mg << 8) | (mb << 0);
                        }
                    }

                    if (ImGui.CollapsingHeader("Debug options", ImGuiTreeNodeFlags.CollapsingHeader))
                    {
                        ImGui.Checkbox("Show fps", ref Services.CompassSettings._showFps);
                        ImGui.Checkbox("Show render time", ref Services.CompassSettings._showRenderTime);
                    }

                    if (ImGui.Button("Save settings"))
                    {
                        Services.Tracker.RunAutoPersist();
                    }

                    ImGui.SameLine();
                    if (ImGui.Button("Reset to default"))
                    {
                        Services.CompassSettings.ResetSettings();
                        Services.Tracker.RunAutoPersist();
                    }
                }

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