示例#1
0
        public void Draw(ImDrawListPtr drawList, float percent, Vector2 position, int segments, float scale = 1f)
        {
            if (segments < 1)
            {
                segments = 1;
            }
            if (segments > 4)
            {
                segments = 4;
            }

            int size     = (int)Math.Ceiling(256 * scale);
            int sizeHalf = (int)Math.Floor(size / 2f);

            percent = Math.Max(percent > 0 ? 0.002f : 0, percent);
            var color = ImGui.GetColorU32(new Vector4(Color.X, Color.Y, Color.Z, Alpha));

            drawList.PushClipRect(position, position + new Vector2(sizeHalf, sizeHalf));

            ImageDrawing.ImageRotated(drawList, Image.ImGuiHandle, new Vector2(position.X + sizeHalf, position.Y + sizeHalf), new Vector2(size, size), (-0.25f + (Flip ? 0.5f : 0) + Math.Min(percent * 0.25f * segments, 0.25f)) * (float)Math.PI * 2, color);

            drawList.PopClipRect();

            if (segments < 2)
            {
                return;
            }

            drawList.PushClipRect(position + new Vector2(sizeHalf, 0), position + new Vector2(sizeHalf * 2, sizeHalf));

            ImageDrawing.ImageRotated(drawList, Image.ImGuiHandle, new Vector2(position.X + sizeHalf, position.Y + sizeHalf), new Vector2(size, size), (-0.25f + (Flip ? 0.5f : 0) + Math.Min(Math.Max(percent * 0.25f * segments, 0.25f), 0.5f)) * (float)Math.PI * 2, color);

            drawList.PopClipRect();

            if (segments < 3)
            {
                return;
            }

            drawList.PushClipRect(position + new Vector2(sizeHalf, sizeHalf), position + new Vector2(sizeHalf * 2, sizeHalf * 2));

            ImageDrawing.ImageRotated(drawList, Image.ImGuiHandle, new Vector2(position.X + sizeHalf, position.Y + sizeHalf), new Vector2(size, size), (-0.25f + (Flip ? 0.5f : 0) + Math.Min(Math.Max(percent * 0.25f * segments, 0.5f), 0.75f)) * (float)Math.PI * 2, color);

            drawList.PopClipRect();

            if (segments < 4)
            {
                return;
            }

            drawList.PushClipRect(position + new Vector2(0, sizeHalf), position + new Vector2(sizeHalf, sizeHalf * 2));

            ImageDrawing.ImageRotated(drawList, Image.ImGuiHandle, new Vector2(position.X + sizeHalf, position.Y + sizeHalf), new Vector2(size, size), (-0.25f + (Flip ? 0.5f : 0) + Math.Min(Math.Max(percent * 0.25f * segments, 0.75f), 1f)) * (float)Math.PI * 2, color);

            drawList.PopClipRect();
        }
        private void DrawMana(ImDrawListPtr drawList, int mp, int maxMp)
        {
            var drawPosition  = ImGui.GetItemRectMin();
            var barHeight     = 20f;
            var outlineHeight = 30f;
            var maxManaLength = (int)Math.Ceiling(maxMp / 25f);
            var manaLength    = (int)Math.Ceiling(mp / 25f);

            var outlineSize   = new Vector2(maxManaLength, outlineHeight);
            var edgeSize      = new Vector2(5, 30);
            var edgeOffset    = new Vector2(-maxManaLength - 5, 0);
            var barOffset     = new Vector2(40, 205);
            var outlineOffset = new Vector2(40, 200);
            var baseSize      = new Vector2(73, 30);

            ImageDrawing.DrawImage(drawList, BarTextures, baseSize, outlineOffset, new Vector4(1, 44, 73, 30));
            ImageDrawing.DrawImage(drawList, BarTextures, -edgeSize, outlineOffset + baseSize + new Vector2(5, 0), new Vector4(23, 1, 5, 30f));

            drawList.PushClipRect(drawPosition + outlineOffset + edgeOffset, drawPosition + outlineOffset + edgeOffset + edgeSize);
            ImageDrawing.DrawImage(drawList, BarTextures, edgeSize, outlineOffset + edgeOffset, new Vector4(23, 1, 5, 30f));
            drawList.PopClipRect();

            if (maxManaLength > 0)
            {
                DrawBar(drawList, drawPosition, outlineOffset, outlineSize, new Vector4(30, 1, 1, 30f));
            }

            if (manaLength > 0)
            {
                DrawBar(drawList, drawPosition, barOffset, new Vector2(manaLength, barHeight), new Vector4(34, 6, 1, 20f));
            }
        }
        private void DrawRingEdgesAndTrack(ImDrawListPtr drawList, float percent, Vector2 position)
        {
            var size = 256;

            drawList.PushClipRect(position, position + new Vector2(size, size));
            drawList.AddImage(RingTrackTexture.ImGuiHandle, position, position + new Vector2(size, size));
            drawList.AddImage(RingBaseTexture.ImGuiHandle, position, position + new Vector2(size, size));
            ImageDrawing.ImageRotated(drawList, RingEndTexture.ImGuiHandle, new Vector2(position.X + size / 2f, position.Y + size / 2f), new Vector2(RingEndTexture.Width, RingEndTexture.Height), Math.Min(percent, 1) * 0.75f * (float)Math.PI * 2);
            drawList.PopClipRect();
        }
        private void DrawExperience(ImDrawListPtr drawList, int experience, int maxExp)
        {
            int size         = (int)Math.Ceiling(256 * Ui.Configuration.Scale);
            var drawPosition = ImGui.GetItemRectMin() + new Vector2(0, (int)HealthY);

            ExperienceRingBg.Draw(drawList, 1, drawPosition, 4, Ui.Configuration.Scale);

            ExperienceRing.Draw(drawList, experience / (float)maxExp, drawPosition, 4, Ui.Configuration.Scale);

            drawList.PushClipRect(drawPosition, drawPosition + new Vector2(size, size));
            drawList.AddImage(RingExperienceBgTexture.ImGuiHandle, drawPosition, drawPosition + new Vector2(size, size));
            drawList.PopClipRect();

            int iconSize = 64;

            ImageDrawing.DrawIcon(Pi, drawList, (ushort)(62000 + Pi.ClientState.LocalPlayer.ClassJob.Id), new Vector2(iconSize, iconSize), new Vector2((int)(size / 2f - iconSize / 2f), (int)(size / 2f - iconSize / 2f)) + new Vector2(0, (int)HealthY));
        }
        private void DrawLongHealthBar(ImDrawListPtr drawList, Vector2 position, int hp, int maxHp)
        {
            var barHeight            = 37f;
            var outlineHeight        = 42f;
            var healthLength         = (int)Math.Ceiling((HpTemp * HpLengthMultiplier - Ui.Configuration.HpForFullRing) / Ui.Configuration.HpPerPixelLongBar);
            var damagedHealthLength  = (int)Math.Ceiling((HpBeforeDamaged * HpLengthMultiplier - Ui.Configuration.HpForFullRing) / Ui.Configuration.HpPerPixelLongBar);
            var restoredHealthLength = (int)Math.Ceiling((hp * HpLengthMultiplier - Ui.Configuration.HpForFullRing) / Ui.Configuration.HpPerPixelLongBar);
            var maxHealthLength      = (int)Math.Ceiling((maxHp * HpLengthMultiplier - Ui.Configuration.HpForFullRing) / Ui.Configuration.HpPerPixelLongBar);
            var outlineSize          = new Vector2(maxHealthLength, outlineHeight);
            var edgeSize             = new Vector2(5, 42);
            var maxHealthSize        = new Vector2(maxHealthLength, barHeight);
            var barOffset            = new Vector2(128, 216) + new Vector2(0, (int)HealthY);
            var outlineOffset        = new Vector2(128, 213) + new Vector2(0, (int)HealthY);


            if (maxHealthLength > 0)
            {
                DrawBar(drawList, position, barOffset, maxHealthSize, new Vector4(10, 1, 1, 37f), ImGui.GetColorU32(new Vector4(0.07843f, 0.07843f, 0.0745f, 1)));
            }

            if (damagedHealthLength > 0)
            {
                DrawBar(drawList, position, barOffset, new Vector2(damagedHealthLength, barHeight), new Vector4(10, 1, 1, 37f), ImGui.GetColorU32(new Vector4(1f, 0f, 0f, DamagedHealthAlpha)));
            }

            if (restoredHealthLength > 0)
            {
                DrawBar(drawList, position, barOffset, new Vector2(restoredHealthLength, barHeight), new Vector4(14, 1, 1, 37f));
            }

            if (healthLength > 0)
            {
                DrawBar(drawList, position, barOffset, new Vector2(healthLength, barHeight), new Vector4(6, 1, 1, 37f));
            }

            if (maxHealthLength > 0)
            {
                DrawBar(drawList, position, outlineOffset, outlineSize, new Vector4(2, 1, 1, 42f));
                var edgeOffset = new Vector2(-maxHealthLength - 5, 0);
                drawList.PushClipRect(position + outlineOffset + edgeOffset, position + outlineOffset + edgeOffset + edgeSize);
                ImageDrawing.DrawImage(drawList, BarTextures, edgeSize, outlineOffset + edgeOffset, new Vector4(17, 1, 5, 42f));
                drawList.PopClipRect();
            }
        }
 private void DrawBar(ImDrawListPtr drawList, Vector2 position, Vector2 offSet, Vector2 size, Vector4 imageArea, uint color = UInt32.MaxValue)
 {
     drawList.PushClipRect(position + offSet - new Vector2(size.X, 0), position + offSet + new Vector2(0, size.Y));
     ImageDrawing.DrawImage(drawList, BarTextures, size, offSet + new Vector2(-size.X, 0), imageArea, color);
     drawList.PopClipRect();
 }