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 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(); }