예제 #1
0
        public override void OnGuiRender()
        {
            ImGui.Begin("Scene Hierarchy");

            const ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.SpanAvailWidth;

            foreach (var entityId in _hierarchyFilter)
            {
                DrawEntitynode(entityId, flags);
            }

            if (ImGui.IsMouseDown(0) && ImGui.IsWindowHovered())
            {
                _guiService.SelectedEntity = default;
            }

            if (ImGui.BeginPopupContextWindow("", ImGuiPopupFlags.MouseButtonRight | ImGuiPopupFlags.NoOpenOverItems))
            {
                if (ImGui.MenuItem("Create Entity"))
                {
                    _guiService.SelectedEntity = _scene.CreateEntity("New Entity").EntityHandle;
                }

                ImGui.EndPopup();
            }

            ImGui.End();
        }
예제 #2
0
        //GameObject deletedObject;

        //private readonly Debug.SlowDebugger slowDebugger = new Debug.SlowDebugger(1f);

        private void DrawEntity(GameObject entity)
        {
            var  flags  = (Inspector.instance.currentObject != entity) ? ImGuiTreeNodeFlags.OpenOnArrow : 0 | ImGuiTreeNodeFlags.Selected;
            bool opened = ImGui.TreeNodeEx(entity.name, flags);

            if (ImGui.IsItemClicked())
            {
                Inspector.instance.currentObject = entity;
            }

            if (opened)
            {
                ImGui.TreePop();
            }

            if (ImGui.BeginPopupContextWindow())
            {
                if (ImGui.MenuItem("Delete"))
                {
                    Debug.LogError("delete clicked: " + entity.name);
                }
                ImGui.EndPopup();
            }

            // slowDebugger.LogSlow("drawing entity: " + entity.name);
        }
예제 #3
0
        public override void OnGuiRender()
        {
            ImGui.Begin(FontAwesome5.Cubes + " Properties");
            if (_guiService.SelectedEntity != default)
            {
                DrawComponents(_guiService.SelectedEntity);
                if (ImGui.BeginPopupContextWindow("", ImGuiPopupFlags.MouseButtonRight | ImGuiPopupFlags.NoOpenOverItems))
                {
                    if (ImGui.BeginMenu("Add Component"))
                    {
                        if (!_guiService.SelectedEntity.Has <TransformComponent>() && ImGui.MenuItem("Transform"))
                        {
                            _guiService.SelectedEntity.Get <TransformComponent>();
                        }

                        if (!_guiService.SelectedEntity.Has <SpriteRendererComponent>() && ImGui.MenuItem("Sprite Renderer"))
                        {
                            ref var sc = ref _guiService.SelectedEntity.Get <SpriteRendererComponent>();
                            sc.Material   = new Material("Standard2D");
                            sc.SpriteData = RenderData2D.QuadData;
                        }

                        if (!_guiService.SelectedEntity.Has <VelocityComponent>() && ImGui.MenuItem("Velocity"))
                        {
                            _guiService.SelectedEntity.Get <VelocityComponent>();
                        }

                        if (!_guiService.SelectedEntity.Has <CameraComponent>() && ImGui.MenuItem("Camera"))
                        {
                            CameraComponent cam = new CameraComponent()
                            {
                                Camera = new Camera(true)
                            };
                            _guiService.SelectedEntity.Replace(in cam);
                        }

#if false
                        // Script components currently can't be added from the Editor.
                        if (!_guiService.SelectedEntity.Has <ScriptingComponent>() && ImGui.MenuItem("Script"))
                        {
                            _guiService.SelectedEntity.Get <ScriptingComponent>();
                        }
#endif
                        ImGui.EndMenu();
                    }

                    ImGui.EndPopup();
                }
            }
예제 #4
0
        protected override void DrawInternal()
        {
            var io = ImGui.GetIO();

            ImGui.Text($"MSPF \n{(int)(1000.0f / io.Framerate)} FPS {(int)io.Framerate} DT {io.DeltaTime:F}");
            ImGui.Separator();
            ImGui.Text(ImGui.IsMousePosValid()
                ? $"Mouse Position: ({io.MousePos.X},{io.MousePos.Y})"
                : "Mouse Position: <invalid>");

            if (ImGui.BeginPopupContextWindow())
            {
                if (ImGui.MenuItem("Custom", null, _position == Position.Custom))
                {
                    _position = Position.Custom;
                }

                if (ImGui.MenuItem("Top-left", null, _position == Position.TopLeft))
                {
                    _position = Position.TopLeft;
                }

                if (ImGui.MenuItem("Top-right", null, _position == Position.TopRight))
                {
                    _position = Position.TopRight;
                }

                if (ImGui.MenuItem("Bottom-left", null, _position == Position.BottomLeft))
                {
                    _position = Position.BottomLeft;
                }

                if (ImGui.MenuItem("Bottom-right", null, _position == Position.BottomRight))
                {
                    _position = Position.BottomRight;
                }

                if (IsVisible && ImGui.MenuItem("Close"))
                {
                    Hide();
                }

                ImGui.EndPopup();
            }
        }
        void _RightButtonMenu()
        {
            if (ImGui.BeginPopupContextWindow())
            {
                if (ImGui.MenuItem("Top-left", null, _corner == 0))
                {
                    _corner = 0;
                }
                if (ImGui.MenuItem("Top-right", null, _corner == 1))
                {
                    _corner = 1;
                }
                if (ImGui.MenuItem("Bottom-left", null, _corner == 2))
                {
                    _corner = 2;
                }
                if (ImGui.MenuItem("Bottom-right", null, _corner == 3))
                {
                    _corner = 3;
                }
                ImGui.Separator();

                if (ImGui.MenuItem("Hide Ovarlay"))
                {
                    _debugUI.showOverlayWindow = false;
                }
                if (ImGui.MenuItem("Show Debug Window", null, _debugUI.showDebugWindow))
                {
                    _debugUI.showDebugWindow = !_debugUI.showDebugWindow;
                }
                if (ImGui.MenuItem("Show ImGUI Demo Window", null, _debugUI.showDemoWindow))
                {
                    _debugUI.showDemoWindow = !_debugUI.showDemoWindow;
                }
                ImGui.Separator();

                if (ImGui.MenuItem("Exit"))
                {
                    Application.Quit();
                }
                ImGui.EndPopup();
            }
        }
예제 #6
0
        void DoObject()
        {
            var c = Editor.SelectedObject;

            if (c == null)
            {
                ImGui.Text("Select an item from the scene view.");
            }
            else
            {
                ImGui.SetNextItemWidth(-1);
                ImGui.Text($"{c.Name}");
                if (ImGui.BeginPopupContextWindow("Edit name", ImGuiPopupFlags.MouseButtonLeft | ImGuiPopupFlags.MouseButtonRight))
                {
                    ImGui.InputTextWithHint("", "object name", ref c.Name, 65536);
                    ImGui.EndPopup();
                }

                ImGui.Separator();

                var sf = Engine.Playing ? ImGuiSliderFlags.NoInput : 0;

                ImGui.DragFloat3("Position", ref c.Position, 1.0f, float.NegativeInfinity, float.PositiveInfinity, "%.3f", sf);
                var a = c.Euler;
                ImGui.DragFloat3("Rotation", ref a, 1.0f, float.NegativeInfinity, float.PositiveInfinity, "%.3f", sf);
                c.Euler = a;

                ImGui.Separator();

                foreach (var i in c.Components)
                {
                    ImGui.SetNextItemWidth(-1);

                    if (ImGui.Selectable($"{i.GetType().Name}##{i.ID}"))
                    {
                        Editor.ObjectSelected    = false;
                        Editor.CurrentlySelected = i;
                    }

                    ImGui.Separator();
                }
            }
        }
예제 #7
0
        public static void RenderMenu(bool window = false)
        {
            if (window ? ImGui.BeginPopupContextWindow("window_node_menu", 1) : ImGui.BeginPopupContextItem("node_menu", 1))
            {
                if (ImGui.Selectable("Copy (Ctrl+C)"))
                {
                    Copy();
                }

                RenderPaste();

                if (ImGui.Selectable("Delete (Ctrl+D)"))
                {
                    CurrentMenu.Remove();
                }

                RenderAddNew();
                ImGui.EndPopup();
            }
        }
예제 #8
0
        public void Draw(float screenWidth, float screenHeight)
        {
            if (!m_bIsOpen)
            {
                m_bOpenLastFrame = m_bIsOpen;
                return;
            }

            PushGeneralStyle();
            Vector2 windowPos  = Vector2.Zero;
            Vector2 windowSize = new Vector2(screenWidth, screenHeight * 0.3f);

            ImGui.SetNextWindowSize(windowSize);
            ImGui.SetNextWindowPos(windowPos);

            ImGui.Begin("GameConsole", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize);
            float footerSize = ImGui.GetStyle().ItemSpacing.Y + ImGui.GetFrameHeightWithSpacing();             // 1 seperator + 1 inputText


            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 1));
            ImGui.BeginChild("TextRegion", new Vector2(0.0f, -footerSize), false, ImGuiWindowFlags.HorizontalScrollbar);

            if (ImGui.BeginPopupContextWindow())
            {
                if (ImGui.Selectable("Clear"))
                {
                    m_logHistory.Clear();
                }
                if (ImGui.Selectable("Close"))
                {
                    Close();
                }
                ImGui.Selectable("Auto Scroll", ref m_bAutoScroll);
                ImGui.EndPopup();
            }

            for (int i = 0; i < m_logHistory.Count; i++)
            {
                ImGui.Text(m_logHistory[i]);
            }

            if (m_bScrollToBottom)
            {
                ImGui.SetScrollHere(1.0f);
                m_bScrollToBottom = false;
            }

            ImGui.EndChild();
            ImGui.PopStyleVar();

            ImGui.Separator();

            unsafe
            {
                byte[] inputBuffer = new byte[512];
                bool   bRefocus    = false;
                if (ImGui.InputText("Enter Command", inputBuffer, 512, ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CallbackCompletion | ImGuiInputTextFlags.CallbackHistory | ImGuiInputTextFlags.CallbackAlways, TextEditCallback))
                {
                    string encodedInput = Encoding.UTF8.GetString(inputBuffer);
                    encodedInput = encodedInput.Trim('\0');                     // String is null terminated
                    ExecCommand(encodedInput);
                    bRefocus          = true;
                    m_bScrollToBottom = m_bAutoScroll;
                }
                ImGui.SetItemDefaultFocus();

                if (!m_bOpenLastFrame)
                {
                    ImGui.SetKeyboardFocusHere();
                }

                if (bRefocus)
                {
                    ImGui.SetKeyboardFocusHere(-1);
                }
            }

            ImGui.End();
            PopGeneralStyle();

            m_bOpenLastFrame = m_bIsOpen;
        }
예제 #9
0
        public bool Show(uint dockSpaceId)
        {
            const float DISTANCE = 10.0f;

            var io = ImGui.GetIO();

            if (_position != Position.Custom)
            {
                var viewport     = ImGui.GetMainViewport();
                var workAreaPos  = viewport.GetWorkPos();
                var workAreaSize = viewport.GetWorkSize();
                var windowPos    = new Num.Vector2(
                    ((_position & Position.TopRight) == Position.TopRight)
                        ? (workAreaPos.X + workAreaSize.X - DISTANCE)
                        : (workAreaPos.X + DISTANCE),
                    ((_position & Position.BottomLeft) == Position.BottomLeft)
                        ? (workAreaPos.Y + workAreaSize.Y - DISTANCE)
                        : (workAreaPos.Y + DISTANCE));
                var windowPosPivot =
                    new Num.Vector2(((_position & Position.TopRight) == Position.TopRight) ? 1.0f : 0.0f,
                                    ((_position & Position.BottomLeft) == Position.BottomLeft) ? 1.0f : 0.0f);
                ImGui.SetNextWindowPos(windowPos, ImGuiCond.Always, windowPosPivot);
                ImGui.SetNextWindowViewport(viewport.ID);
            }

            ImGui.SetNextWindowBgAlpha(0.35f); // Transparent background
            var window_flags = ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking |
                               ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings |
                               ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav;

            if (_position != Position.Custom)
            {
                window_flags |= ImGuiWindowFlags.NoMove;
            }
            if (ImGui.Begin("Info Overlay", ref _isActive, window_flags))
            {
                ImGui.Text($"Application average \n{(int)(1000.0f / ImGui.GetIO().Framerate)} ms/frame ({(int)(ImGui.GetIO().Framerate)} FPS)");
                ImGui.Separator();
                ImGui.Text(ImGui.IsMousePosValid()
                    ? $"Mouse Position: ({io.MousePos.X},{io.MousePos.Y})"
                    : "Mouse Position: <invalid>");
                if (ImGui.BeginPopupContextWindow())
                {
                    if (ImGui.MenuItem("Custom", null, _position == Position.Custom))
                    {
                        _position = Position.Custom;
                    }
                    if (ImGui.MenuItem("Top-left", null, _position == Position.TopLeft))
                    {
                        _position = Position.TopLeft;
                    }
                    if (ImGui.MenuItem("Top-right", null, _position == Position.TopRight))
                    {
                        _position = Position.TopRight;
                    }
                    if (ImGui.MenuItem("Bottom-left", null, _position == Position.BottomLeft))
                    {
                        _position = Position.BottomLeft;
                    }
                    if (ImGui.MenuItem("Bottom-right", null, _position == Position.BottomRight))
                    {
                        _position = Position.BottomRight;
                    }
                    if (IsVisible && ImGui.MenuItem("Close"))
                    {
                        Hide();
                    }

                    ImGui.EndPopup();
                }

                ImGui.End();
                return(true);
            }

            return(false);
        }
예제 #10
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();
            }
        }
예제 #11
0
        public void OnGUI()
        {
            Scene curSelected = null;
            var   _selected   = Selector.GetSelected();

            if (_selected?.Count > 0)
            {
                curSelected = _selected[0] as Scene;
            }

            int count = SceneNative.SceneCount();

            if (ImGui.BeginPopupContextWindow("SceneMenu", ImGuiMouseButton.Right))
            {
                OnGUI_RightMenu(null);
                ImGui.EndPopup();
            }

            //if (ImGui.TreeNodeEx("Scenes##Hierachy", flagsBase))
            {
                bool selected = false;
                for (int i = 0; i < count; ++i)
                {
                    SceneNative.SceneHandle handle = SceneNative.SceneFindByIndex(i);
                    string name  = SceneNative.SceneGetName(handle);
                    string label = string.Format("{0}##_Scene_{1}", name, i);
                    SceneNative.ActiveOption active = SceneNative.SceneGetActive(handle);

                    Scene.Open(handle);

                    int childCount = Scene.current.root.children.Count;

                    ImGuiTreeNodeFlags flags = flagsBase
                                               | (childCount == 0 ? ImGuiTreeNodeFlags.Leaf : ImGuiTreeNodeFlags.None);
                    flags |= curSelected == Scene.current ? ImGuiTreeNodeFlags.Selected : ImGuiTreeNodeFlags.None;

                    if (renameing && curSelected == Scene.current)
                    {
                        label = string.Format("###_{0}", label);
                    }
                    if (ImGui.CollapsingHeader(label, flags))
                    {
                        if (renameing && curSelected == Scene.current)
                        {
                            neo_name = name;
                            ImGuiInputTextFlags inputFlags = ImGuiInputTextFlags.EnterReturnsTrue
                                                             | ImGuiInputTextFlags.AutoSelectAll;
                            if (!ImGui.IsAnyItemActive() && !ImGui.IsMouseClicked(0))
                            {
                                ImGui.SetKeyboardFocusHere(0);
                            }

                            ImGui.SameLine(ImGui.GetCursorPosX());
                            Vector2 padding = ImGui.GetStyle().FramePadding;
                            padding.Y = 0;
                            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, padding);
                            if (ImGui.InputText(string.Format("##Scene_{0}_{1}", name, i), ref neo_name, 64, inputFlags))
                            {
                                SceneNative.SceneSetName(handle, neo_name);
                                renameing = false;
                            }

                            ImGui.PopStyleVar();
                        }

                        OnGUI_SceneMenu(Scene.current, label, active == SceneNative.ActiveOption.Active);

                        bool dragdroped = DragDropManager.DragDropTarget(handle.idx,
                                                                         DragDropWindow.Hierarchy, DragDropTree.Scenes,
                                                                         "_DDTreeWindow", ImGuiDragDropFlags.None,
                                                                         DragDropManager.OnDragDropAction);

                        bool breakif = !OnGUI_TransformTree(Scene.current.root, i, ref selected);

                        //ImGui.TreePop();

                        if (dragdroped || breakif)
                        {
                            break;
                        }
                    }
                    else
                    {
                        OnGUI_SceneMenu(Scene.current, label, active == SceneNative.ActiveOption.Active);
                    }

                    if (!selected)
                    {
                        bool clicked = ImGui.IsItemClicked();
                        //bool focused = childCount == 0 ? ImGui.IsItemFocused() : ImGui.IsItemHovered();
                        if (clicked)
                        {
                            Selector.Select(Scene.current);
                            selected = true;
                        }
                    }

                    if (Scene.current != null)
                    {
                        // F2
                        if (ImGui.GetIO().KeysDown[113])
                        {
                            neo_name  = SceneNative.SceneGetName(Scene.current.handle);
                            renameing = true;
                        }
                    }
                }

                //ImGui.TreePop();
            }
        }
예제 #12
0
        private void MainWindow(PlayerStateStruct playerState, IPlayerProvider currentProvider)
        {
            ImGui.SetNextWindowBgAlpha(_plugin.Configuration.PlayerSettings.Transparency);
            SetDefaultWindowSize(_plugin.Configuration.PlayerSettings);


            var lockFlags = (_plugin.Configuration.PlayerSettings.PlayerLocked)
                ? ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize
                : ImGuiWindowFlags.None;

            var clickThroughFlags = (_plugin.Configuration.PlayerSettings.DisableInput)
                ? ImGuiWindowFlags.NoMouseInputs | ImGuiWindowFlags.NoResize
                : ImGuiWindowFlags.None;

            var playerSettings = _plugin.Configuration.PlayerSettings;

            if (!ImGui.Begin($"Fantasy Player##C{playerSettings.CompactPlayer}&N{playerSettings.NoButtons}",
                             ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | lockFlags |
                             clickThroughFlags))
            {
                return;
            }

            //Disable FirstRun
            if (_plugin.Configuration.PlayerSettings.FirstRunNone)
            {
                _plugin.Configuration.PlayerSettings.FirstRunNone = false;
                _plugin.Configuration.Save();
            }

            //////////////// Right click popup ////////////////

            if (ImGui.BeginPopupContextWindow())
            {
                if (_playerManager.PlayerProviders.Count > 1)
                {
                    if (ImGui.BeginMenu("Switch provider"))
                    {
                        foreach (var provider in _playerManager.PlayerProviders)
                        {
                            if (provider.Value == _playerManager.CurrentPlayerProvider)
                            {
                                continue;
                            }
                            if (ImGui.MenuItem(provider.Key.Name.Replace("Provider", "")))
                            {
                                _playerManager.CurrentPlayerProvider = provider.Value;
                                _plugin.Configuration.PlayerSettings.DefaultProvider = provider.Key.FullName;
                                _plugin.Configuration.Save();
                            }
                        }
                        ImGui.EndMenu();
                    }

                    ImGui.Separator();
                }

                if (!_plugin.Configuration.SpotifySettings.LimitedAccess)
                {
                    if (ImGui.MenuItem("Compact mode", null, ref _plugin.Configuration.PlayerSettings.CompactPlayer))
                    {
                        if (_plugin.Configuration.PlayerSettings.NoButtons)
                        {
                            _plugin.Configuration.PlayerSettings.NoButtons = false;
                        }
                    }

                    if (ImGui.MenuItem("Hide Buttons", null, ref _plugin.Configuration.PlayerSettings.NoButtons))
                    {
                        if (_plugin.Configuration.PlayerSettings.CompactPlayer)
                        {
                            _plugin.Configuration.PlayerSettings.CompactPlayer = false;
                        }
                    }

                    ImGui.Separator();
                }

                ImGui.MenuItem("Lock player", null, ref _plugin.Configuration.PlayerSettings.PlayerLocked);
                ImGui.MenuItem("Show player", null, ref _plugin.Configuration.PlayerSettings.PlayerWindowShown);
                ImGui.MenuItem("Show config", null, ref _plugin.Configuration.ConfigShown);

                ImGui.EndPopup();
            }

            //////////////// Window Basics ////////////////

            if (playerState.CurrentlyPlaying.Id == null)
            {
                InterfaceUtils.TextCentered($"Nothing is playing on {playerState.ServiceName}.");
                return;
            }

            {
                //////////////// Window Setup ////////////////

                ImGui.PushStyleColor(ImGuiCol.Button, InterfaceUtils.TransparentColor);
                ImGui.PushStyleColor(ImGuiCol.ButtonActive, InterfaceUtils.TransparentColor);
                ImGui.PushStyleColor(ImGuiCol.ButtonHovered, InterfaceUtils.DarkenButtonColor);

                var track = playerState.CurrentlyPlaying;

                if (playerState.IsPlaying)
                {
                    _progressDelta += ImGui.GetIO().DeltaTime;
                }

                if (_progressMs != playerState.ProgressMs)
                {
                    _progressDelta = 0;
                }
                _progressMs = playerState.ProgressMs;

                var percent = playerState.ProgressMs * 100f / track.DurationMs +
                              (_progressDelta / (track.DurationMs / 100000f)); //me good maths

                _progressMs = playerState.ProgressMs;

                var artists = track.Artists.Aggregate("", (current, artist) => current + (artist + ", "));

                if (!_plugin.Configuration.PlayerSettings.NoButtons)
                {
                    //////////////// Play and Pause ////////////////

                    var stateIcon = (playerState.IsPlaying)
                        ? FontAwesomeIcon.Pause.ToIconString()
                        : FontAwesomeIcon.Play.ToIconString();

                    ImGui.PushFont(UiBuilder.IconFont);

                    if (ImGui.Button(FontAwesomeIcon.Backward.ToIconString()))
                    {
                        currentProvider.SetSkip(false);
                    }

                    if (InterfaceUtils.ButtonCentered(stateIcon))
                    {
                        currentProvider.SetPauseOrPlay(!playerState.IsPlaying);
                    }

                    //////////////// Shuffle and Repeat ////////////////

                    ImGui.SameLine(ImGui.GetWindowSize().X / 2 +
                                   (ImGui.GetFontSize() + ImGui.CalcTextSize(FontAwesomeIcon.Random.ToIconString()).X));

                    if (playerState.ShuffleState)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, _plugin.Configuration.PlayerSettings.AccentColor);
                    }

                    if (ImGui.Button(FontAwesomeIcon.Random.ToIconString()))
                    {
                        currentProvider.SetShuffle(!playerState.ShuffleState);
                    }

                    if (playerState.ShuffleState)
                    {
                        ImGui.PopStyleColor();
                    }

                    if (playerState.RepeatState != "off")
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, _plugin.Configuration.PlayerSettings.AccentColor);
                    }

                    var buttonIcon = FontAwesomeIcon.Retweet.ToIconString();

                    if (playerState.RepeatState == "track")
                    {
                        buttonIcon = FontAwesomeIcon.Music.ToIconString();
                    }

                    ImGui.SameLine(ImGui.GetWindowSize().X / 2 -
                                   (ImGui.GetFontSize() + ImGui.CalcTextSize(buttonIcon).X +
                                    ImGui.CalcTextSize(FontAwesomeIcon.Random.ToIconString()).X));

                    if (ImGui.Button(buttonIcon))
                    {
                        currentProvider.SwapRepeatState();
                    }

                    if (playerState.RepeatState != "off")
                    {
                        ImGui.PopStyleColor();
                    }

                    ImGui.SameLine(ImGui.GetWindowSize().X -
                                   (ImGui.GetFontSize() +
                                    ImGui.CalcTextSize(FontAwesomeIcon.Forward.ToIconString()).X));
                    if (ImGui.Button(FontAwesomeIcon.Forward.ToIconString()))
                    {
                        currentProvider.SetSkip(true);
                    }

                    ImGui.PopFont();
                }

                if (!_plugin.Configuration.PlayerSettings.CompactPlayer)
                {
                    //////////////// Progress Bar ////////////////

                    ImGui.PushStyleColor(ImGuiCol.PlotHistogram, _plugin.Configuration.PlayerSettings.AccentColor);
                    ImGui.ProgressBar(percent / 100f, new Vector2(-1, 2f));
                    ImGui.PopStyleColor();

                    Vector2 imageSize = new Vector2(100 * ImGui.GetIO().FontGlobalScale,
                                                    100 * ImGui.GetIO().FontGlobalScale);

                    //////////////// Text ////////////////

                    InterfaceUtils.TextCentered(track.Name);

                    ImGui.PushStyleColor(ImGuiCol.Text, InterfaceUtils.DarkenColor);

                    ImGui.Spacing();
                    InterfaceUtils.TextCentered(artists.Remove(artists.Length - 2));


                    ImGui.PopStyleColor();
                }

                ImGui.PopStyleColor(3);
            }

            ImGui.End();
        }
예제 #13
0
 public static bool BeginPopupContextWindow()
 {
     return(ImGui.BeginPopupContextWindow());
 }
예제 #14
0
 public static bool BeginPopupContextWindow(string str_id)
 {
     return(ImGui.BeginPopupContextWindow(str_id));
 }