コード例 #1
0
ファイル: ImNode.cs プロジェクト: tesfabpel/BurningKnight
        public virtual void Render()
        {
            if (!New)
            {
                Position = RealPosition + Offset;
            }

            if (readPosition && Camera.Instance != null && (Position.X + Size.X < 0 || Position.X > Camera.Instance.Width || Position.Y + Size.Y < 0 || Position.Y > Camera.Instance.Height))
            {
                OnScreen = false;
                RenderConnections();
                return;
            }

            OnScreen = true;

            if (outputs != null)
            {
                ReadOutputs();
            }

            if (Focused != this)
            {
                focused    = false;
                ForceFocus = false;
            }

            if (focused || ForceFocus)
            {
                ImGui.PushStyleColor(ImGuiCol.WindowBg, activeNodeBg.PackedValue);
            }
            else if (hovered)
            {
                ImGui.PushStyleColor(ImGuiCol.WindowBg, hoveredNodeBg.PackedValue);
            }
            else
            {
                ImGui.PushStyleColor(ImGuiCol.WindowBg, nodeBg.PackedValue);
            }

            if (New)
            {
                ImGui.SetNextWindowPos(Position, ImGuiCond.Always);
                RealPosition = Position - Offset;                 // fixme
            }
            else if (readPosition)
            {
                ImGui.SetNextWindowPos(RealPosition + Offset, ImGuiCond.Always);
            }

            ImGui.Begin($"node_{Tip}_{Id}", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize);
            var old = ImGuiHelper.CurrentMenu;

            ImGuiHelper.CurrentMenu = this;
            ImGuiHelper.RenderMenu(true);

            RenderElements();
            RenderConnections();

            hovered = ImGui.IsWindowHovered();
            focused = ImGui.IsWindowFocused();

            if (focused)
            {
                Focused = this;
            }

            if (New)
            {
                New = false;
            }
            else
            {
                readPosition = true;
                Size         = ImGui.GetWindowSize();
            }

            Moved = false;

            if (hovered)
            {
                if (ImGui.IsMouseDragging(0) || Input.Keyboard.IsDown(Keys.LeftControl, true))
                {
                    var d = ImGui.GetIO().MouseDelta;
                    RealPosition += d;
                }
                else if (Input.Keyboard.IsDown(Keys.LeftShift, true))
                {
                    Move(ImGui.GetIO().MouseDelta);
                }
                else if (Input.Keyboard.IsDown(Keys.LeftWindows, true))
                {
                    MoveBoth(ImGui.GetIO().MouseDelta);
                }
            }

            ImGui.End();
            ImGui.PopStyleColor();
            ImGuiHelper.CurrentMenu = old;

            if (Done)
            {
                Remove();
            }
        }
コード例 #2
0
 public static string GetName(ImNode node)
 {
     return(node.Tip);
 }