Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_FriendList : BasePlugin, IInGameTopPainter {
- public int MaxLength { get; set; }
- public IFont TextFont { get; set; }
- public IBrush DefaultBrush { get; set; }
- public Dictionary<string, string> MyFriendList { get; set; } = new Dictionary<string, string> ();
- public Dictionary<string, IBrush> HighLightBrushs { get; set; } = new Dictionary<string, IBrush>();
- private IUiElement FdListSlot { get; set; }
- private IUiElement FdListContainer1 { get; set; }
- private IUiElement FdListContainer2 { get; set; }
- private string UiPathFriend { get; set; } = "Root.NormalLayer.BattleNetFriendsList_main.LayoutRoot.OverlayContainer.FriendsListContent.SocialListContainer.SocialList.FriendsListContainer.FriendsList._content._stackpanel._item";
- public DAV_FriendList() {
- Enabled = true;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- MaxLength = 20;
- MyFriendList.Add("Friend1", "My_Team");
- MyFriendList.Add("Friend2", "My_CLAN");
- TextFont = Hud.Render.CreateFont("Arial", 8, 255, 225, 255, 102, true, false, true);
- DefaultBrush = Hud.Render.CreateBrush(255, 255, 255, 51, 4f);
- HighLightBrushs.Add("My_Team", Hud.Render.CreateBrush(255, 255, 128, 51, 4f));
- // SharpDX.Direct2D1.DashStyle : Dash, DashDot, DashDotDot, Dot, Solid
- FdListSlot = Hud.Render.GetUiElement("Root.NormalLayer.BattleNetFriendsList_main.LayoutRoot.OverlayContainer.FriendsListContent");
- FdListContainer1 = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetFriendsList_main.LayoutRoot.OverlayContainer.FriendsListContent.SocialListContainer", FdListSlot, null);
- FdListContainer2 = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetFriendsList_main.LayoutRoot.OverlayContainer.FriendsListContent.SocialListContainer.SocialList", FdListSlot, null);
- }
- public void PaintTopInGame(ClipState clipState) {
- if (clipState != ClipState.AfterClip) return;
- if (!FdListSlot.Visible) return;
- for (var i = 0; i < MaxLength; i++) {
- var Slot = Hud.Render.RegisterUiElement(UiPathFriend + i.ToString() + ".Name", FdListSlot, null);
- if (Slot == null || !Slot.Visible) continue;
- if (Slot.Rectangle.Bottom < FdListContainer1.Rectangle.Y || Slot.Rectangle.Y > FdListContainer1.Rectangle.Bottom) continue;
- var fdName = Slot.ReadText(System.Text.Encoding.UTF8, true);
- if (string.IsNullOrEmpty(fdName)) continue;
- if (MyFriendList.TryGetValue(NameTrim(fdName), out var profileN)) {
- var usedBrush = HighLightBrushs.ContainsKey(profileN) ? HighLightBrushs[profileN] : DefaultBrush;
- usedBrush.DrawRectangle(FdListContainer2.Rectangle.X, Slot.Rectangle.Y, FdListContainer2.Rectangle.Width, 2 * Slot.Rectangle.Height);
- var textLayout = TextFont.GetTextLayout(profileN);
- TextFont.DrawText(textLayout, FdListContainer2.Rectangle.Right - textLayout.Metrics.Width - 2.2f * Slot.Rectangle.Height, Slot.Rectangle.Y + 2);
- }
- }
- }
- public string NameTrim(string input) {
- var result = Regex.Replace(input, @"\<(.*)\> ", "");
- return Regex.Replace(result, @"\ {(.*)}", "");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement