Exemple #1
0
        public void Draw(float width)
        {
            icard.SetRectangle(new Rectangle(0, 0, (int)width, int.MaxValue));

            if (icard.Height != renderHeight || (int)width != renderWidth)
            {
                renderWidth  = (int)width;
                renderHeight = (int)icard.Height;
                if (renderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(renderTarget);
                    renderTarget.Dispose();
                }
                renderTarget = new RenderTarget2D(renderWidth, renderHeight);
                rid          = ImGuiHelper.RegisterTexture(renderTarget);
            }
            renderTarget.BindFramebuffer();
            window.Viewport.Push(0, 0, renderWidth, renderHeight);
            var cc = window.RenderState.ClearColor;

            window.RenderState.ClearColor = Color4.Transparent;
            window.RenderState.ClearAll();
            window.RenderState.ClearColor = cc;
            window.Renderer2D.Start(renderWidth, renderHeight);
            icard.Draw(window.Renderer2D);
            window.Renderer2D.Finish();
            RenderTarget2D.ClearBinding();
            window.Viewport.Pop();

            //ImGui. Base off ImageButton so we can get input for selection later
            var style = ImGui.GetStyle();
            var btn   = style.Colors[(int)ImGuiCol.Button];

            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, btn);
            ImGui.PushStyleColor(ImGuiCol.ButtonActive, btn);
            ImGui.ImageButton((IntPtr)rid, new Vector2(renderWidth, icard.Height),
                              new Vector2(0, 1), new Vector2(1, 0),
                              0,
                              Vector4.Zero, Vector4.One);
            ImGui.PopStyleColor();
            ImGui.PopStyleColor();
            //Somehow keep track of selection? (idk if InfocardDisplay should do this)
        }
Exemple #2
0
        public override void DrawText()
        {
            if (text == null)
            {
                var r = GetInfocardRect();
                oldRect = r;
                text    = new InfocardDisplay(Manager.Game, r, ifc)
                {
                    DropShadow = true
                };
            }
            var rect = GetInfocardRect();

            if (rect != oldRect)
            {
                oldRect = rect;
                text.SetRectangle(rect);
            }
            text.Draw(Manager.Game.Renderer2D);
        }