Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace T4.Plugins.DAV;
- public class HealthResourceGlobe : BasePlugin, IGameUserInterfacePainter {
- public Feature FontSetting { get; private set; }
- public float OffsetX { get; set; } = 0.2f;
- public IFont HealthFont { get; set; } = Services.Render.GetFont(255, 255, 51, 51, fontFamily: "Calibri", bold: true, size: 10, shadowMode: FontShadowMode.None).SetShadowColor(255, 0, 0, 0);
- public IFont BarrierFont { get; set; } = Services.Render.GetFont(255, 255, 255, 255, fontFamily: "Calibri", bold: true, size: 10, shadowMode: FontShadowMode.None).SetShadowColor(255, 0, 0, 0);
- public IFont ResourceFont { get; set; } = Services.Render.GetFont(255, 51, 51, 255, fontFamily: "Calibri", bold: true, size: 10, shadowMode: FontShadowMode.Heavy).SetShadowColor(255, 0, 0, 0);
- // pluginFunction
- public HealthResourceGlobe() : base(PluginCategory.ActionBar, "display the information of health, barrier & resources") {
- FontSetting = AddFeature(nameof(FontSetting), "FontSetting")
- .AddFontResource(nameof(HealthFont), HealthFont, "font - health")
- .AddFontResource(nameof(BarrierFont), BarrierFont, "font - barrier")
- .AddFontResource(nameof(ResourceFont), ResourceFont, "font - resource")
- .AddFloatResource(nameof(OffsetX), "horizontal offset", 0f, 0.5f,
- getter: () => OffsetX,
- setter: newValue => OffsetX = MathF.Round(newValue, 2));
- }
- public void PaintGameUserInterface(GameUserInterfaceLayer layer) {
- if (layer != GameUserInterfaceLayer.OverActionBar) return;
- var me = Services.Game.MyPlayerActor;
- if (me.HitpointsCur <= 0) return;
- var hpControl = Services.UserInterface.HealthBallControl;
- var outMessage = HealthFont.GetTextLayout(ToText(me.HitpointsCur, me.HitpointsMax, me.LifeRegen));
- outMessage.DrawText(hpControl.Left + hpControl.Width * OffsetX, hpControl.Top + hpControl.Height * 0.5f - outMessage.Height);
- if (me.BarrierOn && me.BarrierAmount > 0) {
- outMessage = BarrierFont.GetTextLayout(ToText(me.BarrierAmount, me.HitpointsMax, -1f));
- outMessage.DrawText(hpControl.Left + hpControl.Width * OffsetX, hpControl.Top + hpControl.Height * 0.5f);
- }
- if (me.PrimaryResourceType != ResourceType.None) {
- var resControl = Services.UserInterface.ResourceBallControl;
- outMessage = ResourceFont.GetTextLayout(ToText(me.PrimaryResourceCur, me.PrimaryResourceMax, me.PrimaryResourceRegen));
- outMessage.DrawText(resControl.Left + resControl.Width * OffsetX, resControl.Top + (resControl.Height - outMessage.Height) / 2);
- }
- }
- // pluginFunction end
- private string ToText(float curValue, float maxValue, float regValue) {
- var output = curValue.ToString("#,##0") + "\n" + (curValue / maxValue).ToString("0%") + "\n";
- if (regValue > 0 && curValue < maxValue)
- output += "+" + regValue.ToString("#,##0") + "/s";
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement