Code:
using System.Globalization;
using Turbo.Plugins.Default;
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace Turbo.Plugins.iWin
{
public class iWin_ExperienceOverBarPlugin : BasePlugin, IInGameTopPainter, ICustomizer
{
public TopLabelDecorator BlueThisLevelValueDecorator { get; set; }
public TopLabelDecorator OrangeThisLevelValueDecorator { get; set; }
public TopLabelDecorator BlueNextLevelValueDecorator { get; set; }
public TopLabelDecorator OrangeNextLevelValueDecorator { get; set; }
public TopLabelDecorator BonusValueDecorator { get; set; }
public TopLabelDecorator NormalLevelDecorator { get; set; }
private string NormalLevel;
private bool uiRegister;
public iWin_ExperienceOverBarPlugin()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
BlueThisLevelValueDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
TextFunc = () => Hud.Game.Me.ParagonExpInThisLevel.ToString("#,0", CultureInfo.InvariantCulture),
HintFunc = () => "experience gained in this level",
};
OrangeThisLevelValueDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 200, 160, 140, false, false, 160, 0, 0, 0, true),
TextFunc = () => Hud.Game.Me.ParagonExpInThisLevel.ToString("#,0", CultureInfo.InvariantCulture),
HintFunc = () => "experience gained in this level",
};
BlueNextLevelValueDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
TextFunc = () => Hud.Game.Me.ParagonExpToNextLevel.ToString("#,0", CultureInfo.InvariantCulture),
HintFunc = () => "experience to reach next level",
};
OrangeNextLevelValueDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 200, 160, 140, false, false, 160, 0, 0, 0, true),
TextFunc = () => Hud.Game.Me.ParagonExpToNextLevel.ToString("#,0", CultureInfo.InvariantCulture),
HintFunc = () => "experience to reach next level",
};
BonusValueDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 200, 160, 140, false, false, 160, 0, 0, 0, true),
TextFunc = () => (Hud.Game.Me.BonusPoolRemaining * 5).ToString("#,0", CultureInfo.InvariantCulture),
HintFunc = () => "bonus pool * 5",
};
NormalLevelDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 5.5f, 255, 200, 160, 140, false, false, 160, 0, 0, 0, true),
TextFunc = () => NormalLevel,
HintFunc = () => "temp",
};
}
public void Customize()
{
Hud.TogglePlugin<ExperienceOverBarPlugin>(false);
}
public void PaintTopInGame(ClipState clipState)
{
if (Hud.Render.UiHidden)
return;
if (clipState != ClipState.BeforeClip)
return;
if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map))
return;
var uiRect = Hud.Render.InGameBottomHudUiElement.Rectangle;
var bonusRemaining = Hud.Game.Me.BonusPoolRemaining;
if (Hud.Game.Me.CurrentLevelNormal < Hud.Game.Me.CurrentLevelNormalCap)
{
var builder = new StringBuilder();
var expBuilder = new StringBuilder();
IUiElement ui = Hud.Render.GetUiElement("Root.TopLayer.tooltip_dialog_background.tooltip_2.tooltip");
if (ui == null)
{
builder.Append("null");
if (!uiRegister)
{
uiRegister = true;
Hud.Render.RegisterUiElement("Root.TopLayer.tooltip_dialog_background.tooltip_2.tooltip", ui, null);
}
}
else if (!ui.Visible)
{
builder.Append("!visible");
}
else
{
try
{
builder.Append(ui.ReadText(Encoding.Default, removeColors: true));
string[] ExpNormal = Regex.Split(builder.ToString(), @"\{.*?\}+", RegexOptions.IgnoreCase);
expBuilder.Clear();
expBuilder.Append(ExpNormal[3] + " / " + Regex.Replace(ExpNormal[5], @"\,+", ""));
}
catch (Exception)
{
expBuilder.Clear();
}
}
NormalLevel = expBuilder.ToString();
NormalLevelDecorator.Paint(uiRect.Left + (uiRect.Width * 0.651f), uiRect.Top + (uiRect.Height * 0.470f), uiRect.Width * 0.075f, uiRect.Height * 0.07f, HorizontalAlign.Right);
}
else
{
(bonusRemaining > 0 ? OrangeThisLevelValueDecorator : BlueThisLevelValueDecorator).Paint(uiRect.Left + (uiRect.Width * 0.42f), uiRect.Top + (uiRect.Height * 0.470f), uiRect.Width * 0.075f, uiRect.Height * 0.07f, HorizontalAlign.Right);
(bonusRemaining > 0 ? OrangeNextLevelValueDecorator : BlueNextLevelValueDecorator).Paint(uiRect.Left + (uiRect.Width * 0.505f), uiRect.Top + (uiRect.Height * 0.470f), uiRect.Width * 0.075f, uiRect.Height * 0.07f, HorizontalAlign.Left);
}
if (bonusRemaining > 0)
{
BonusValueDecorator.Paint(uiRect.Left + (uiRect.Width * 0.651f), uiRect.Top + (uiRect.Height * 0.470f), uiRect.Width * 0.075f, uiRect.Height * 0.07f, HorizontalAlign.Right);
}
}
}
}
jarjar helped me with regui earlier so was a chance to test it again. using try/catch because if mouse moved off too fast it throws exceptions.