Exemple #1
0
 /// <summary>Projects the on change project.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">if set to <c>true</c> [e].</param>
 private void Project_OnChangeProject(object sender, bool e)
 {
     image             = Image.LoadPixelData <Rgba32>(Project.Current.VideoGame.PreviewRender(), 512, 512);
     imageSharpTexture = new ImageSharpTexture(image, true);
     texture           = imageSharpTexture.CreateDeviceTexture(imGuiController.graphicsDevice, imGuiController.graphicsDevice.ResourceFactory);
     intPtr            = imGuiController.GetOrCreateImGuiBinding(imGuiController.graphicsDevice.ResourceFactory, texture);
 }
Exemple #2
0
        public static void DrawIcon(ImGuiController controller, string name, int countCaption = 1, Vector2?offset = null)
        {
            Texture btnIcon = controller.GetImage(name);
            IntPtr  CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, btnIcon, $"Icon" + name);

            Vector2 size   = new Vector2(btnIcon.Width, btnIcon.Height);
            Vector2 corner = ImGui.GetCursorScreenPos() + (offset ?? Vector2.Zero);

            ImGui.GetWindowDrawList().AddImage(CPUframeBufferTextureId, corner, corner + size, Vector2.Zero, Vector2.One);
            if (countCaption > 1)
            {
                ImGui.SetCursorScreenPos(corner + new Vector2(size.X * 0.8f, 5));
                ImGui.Text($"{countCaption}");
            }
        }
Exemple #3
0
        public static void DrawSpinner(ImGuiController controller, int count, uint colour)
        {
            if (controller._fontTexture is null)
            {
                return;
            }

            ImFontGlyphPtr glyph = controller.UnicodeFont.FindGlyph(ImGuiController.FA_ICON_ROTATION);

            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
            IntPtr CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, controller._fontTexture, "Spinner");

            ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(3, 3));
            Vector2 size   = new Vector2(18, 18);
            Vector2 corner = ImGui.GetCursorScreenPos() + new Vector2(0, size.Y);
            Vector2 center = corner + new Vector2(size.X * 0.5f, size.Y * -0.5f);

            float rotation = -1 * ((float)DateTime.Now.TimeOfDay.TotalMilliseconds / 360);
            float cos_a    = (float)Math.Cos(rotation);
            float sin_a    = (float)Math.Sin(rotation);

            Vector2[] pos = new Vector2[]
            {
                center + ImRotate(new Vector2(-size.X, -size.Y) * 0.5f, cos_a, sin_a),
                center + ImRotate(new Vector2(+size.X, -size.Y) * 0.5f, cos_a, sin_a),
                center + ImRotate(new Vector2(+size.X, +size.Y) * 0.5f, cos_a, sin_a),
                center + ImRotate(new Vector2(-size.X, +size.Y) * 0.5f, cos_a, sin_a)
            };

            ImGui.GetWindowDrawList().AddImageQuad(CPUframeBufferTextureId, pos[0], pos[1], pos[2], pos[3],
                                                   new Vector2(glyph.U0, glyph.V0), new Vector2(glyph.U1, glyph.V0), new Vector2(glyph.U1, glyph.V1), new Vector2(glyph.U0, glyph.V1), colour);
            if (count > 1)
            {
                ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(size.X, 4));
                ImGui.Text($"{count}");
                ImGui.SetCursorPosY(ImGui.GetCursorPosY() - size.Y);
                ImGui.InvisibleButton($"#invisBtn{rotation}", new Vector2(18, 18));
            }
            else
            {
                //tooltip hover target
                ImGui.InvisibleButton($"#invisBtn{rotation}", new Vector2(18, 24));
            }

            ImGui.PopStyleVar();
        }
Exemple #4
0
        //No longer used
        public static void DrawClickableIcon(ImGuiController controller, string name, int countCaption = 1, Vector2?offset = null)
        {
            Texture btnIcon = controller.GetImage(name);
            IntPtr  CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, btnIcon, $"ClickIcon" + name);

            Vector2 size    = new Vector2(btnIcon.Width, btnIcon.Height);
            Vector2 thispos = ImGui.GetCursorScreenPos();

            ImGui.InvisibleButton($"#{name + ImGui.GetCursorPosY()}", size + new Vector2(-2, -4));

            uint iconcol = ImGui.IsItemHovered() ? 0xaaafafaf : 0xffffffff;

            ImGui.SetCursorScreenPos(thispos);
            Vector2 corner = ImGui.GetCursorScreenPos() + offset ?? Vector2.Zero;

            ImGui.GetWindowDrawList().AddImage(CPUframeBufferTextureId, corner, corner + size, Vector2.Zero, Vector2.One, iconcol);
            if (countCaption > 1)
            {
                ImGui.SetCursorScreenPos(corner + new Vector2(size.X * 0.8f, 5));
                ImGui.Text($"{countCaption}");
            }
        }