Code:
using System;
using System.Linq;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.Prrovoss
{
public class PopupNotifications : BasePlugin, IInGameWorldPainter
{
public enum EnumPopupDecoratorToUse {Default, Ancient, Primal };
public TopLabelWithTitleDecorator PrimalPopupDecorator { get; set; }
public TopLabelWithTitleDecorator AcientPopupDecorator { get; set; }
public TopLabelWithTitleDecorator DefaultPopupDecorator { get; set; }
public float RatioX { get; set; }
public float RatioY { get; set; }
public float RatioW { get; set; }
public float RatioH { get; set; }
public float VerticalGap { get; set; }
public class Popup : IQueueItem
{
public string Text { get; set; }
public string Title { get; set; }
public string Hint { get; set; }
public DateTime QueuedOn { get; private set; }
public TimeSpan LifeTime { get; private set; }
public EnumPopupDecoratorToUse PopUpDecoratorTouse { get; private set; }
public Popup(string text, string title, TimeSpan lifetime, string hint, EnumPopupDecoratorToUse popupDecoratorToUse = EnumPopupDecoratorToUse.Default)
{
this.Text = text;
this.Title = title;
this.LifeTime = lifetime;
this.Hint = hint;
this.QueuedOn = DateTime.Now;
this.PopUpDecoratorTouse = popupDecoratorToUse;
}
}
public void Show(string text, string title, int duration, string hint = null, EnumPopupDecoratorToUse popupDecoratorToUse = EnumPopupDecoratorToUse.Default)
{
Hud.Queue.AddItem(new Popup(text, title, new TimeSpan(0, 0, 0, 0, duration), hint, popupDecoratorToUse));
}
public PopupNotifications()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
PrimalPopupDecorator = new TopLabelWithTitleDecorator(Hud)
{
BorderBrush = Hud.Render.CreateBrush(255, 255, 0, 0, -1),
BackgroundBrush = Hud.Render.CreateBrush(200, 0, 0, 0, 0),
TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, false),
TitleFont = Hud.Render.CreateFont("tahoma", 6, 255, 180, 147, 109, true, false, false),
};
AcientPopupDecorator = new TopLabelWithTitleDecorator(Hud)
{
BorderBrush = Hud.Render.CreateBrush(255, 255, 165, 0, -1),
BackgroundBrush = Hud.Render.CreateBrush(200, 0, 0, 0, 0),
TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, false),
TitleFont = Hud.Render.CreateFont("tahoma", 6, 255, 180, 147, 109, true, false, false),
};
DefaultPopupDecorator = new TopLabelWithTitleDecorator(Hud)
{
BorderBrush = Hud.Render.CreateBrush(255, 180, 147, 109, -1),
BackgroundBrush = Hud.Render.CreateBrush(200, 0, 0, 0, 0),
TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, false),
TitleFont = Hud.Render.CreateFont("tahoma", 6, 255, 180, 147, 109, true, false, false),
};
RatioX = 0.6f;
RatioY = 0.75f;
RatioW = 0.18f;
RatioH = 0.05f;
VerticalGap = 1.20f;
}
public void PaintWorld(WorldLayer layer)
{
var w = Hud.Window.Size.Height * RatioW;
var h = Hud.Window.Size.Height * RatioH;
var x = Hud.Window.Size.Width * RatioX;
var y = Hud.Window.Size.Height * RatioY;
foreach (Popup p in Hud.Queue.GetItems<Popup>().Take(13))
{
switch (p.PopUpDecoratorTouse)
{
case EnumPopupDecoratorToUse.Ancient:
AcientPopupDecorator.Paint(x, y, w, h, p.Text, p.Title, p.Hint);
break;
case EnumPopupDecoratorToUse.Primal:
PrimalPopupDecorator.Paint(x, y, w, h, p.Text, p.Title, p.Hint);
break;
case EnumPopupDecoratorToUse.Default:
default:
DefaultPopupDecorator.Paint(x, y, w, h, p.Text, p.Title, p.Hint);
break;
}
y -= h * VerticalGap;
}
}
}
}
-------------------------------
Code:
using System.Collections.Generic;
using System.Linq;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.Prrovoss.Popups
{
public class MonsterAppearedPopup : BasePlugin, IInGameWorldPainter
{
public class MyMonster
{
public List<double> MaxHitpoints { get; set; }
public uint Sno { get; set; }
public string Name { get; set; }
public string Hint { get; set; }
public string Title { get; set; }
public int Duration { get; set; }
public TopLabelWithTitleDecorator Decorator { get; set; }
public MyMonster(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
{
MaxHitpoints = new List<double>();
this.Sno = sno;
this.Hint = hint;
this.Name = name;
this.Title = title;
this.Duration = duration;
this.Decorator = decorator;
}
}
public List<MyMonster> MonstersToWatch { get; set; }
public override void Load(IController hud)
{
base.Load(hud);
MonstersToWatch = new List<MyMonster>();
}
public void Add(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
{
MonstersToWatch.Add(new MyMonster(sno, name, hint, title, duration, decorator));
}
public void PaintWorld(WorldLayer layer)
{
foreach (MyMonster monster in MonstersToWatch)
{ var candidates = Hud.Game.Monsters.Where(m => m.SnoActor.Sno == monster.Sno && !monster.MaxHitpoints.Contains(m.MaxHealth));
if (candidates.Count() != 0)
{
foreach (IMonster candidate in candidates)
{
Hud.RunOnPlugin<PopupNotifications>(plugin =>
{
plugin.Show(monster.Name, monster.Title, monster.Duration, monster.Hint);
});
monster.MaxHitpoints.Add(candidate.MaxHealth);
}
}
}
}
public MonsterAppearedPopup()
{
Enabled = true;
}
}
}
+