Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SharpDX;
- using SharpDX.Direct2D1;
- using SharpDX.DirectWrite;
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public static class DAV_ExtendFunc {
- public static IController Hud { get; private set; }
- public static int arcIncrement { get; set; } = 6;
- private static double toRad { get; set; } = Math.PI / 180d;
- // ITexture variable
- public static ITexture[] ElementIcon { get; private set; }
- public static ITexture[] ElementIconBar { get; private set; }
- // Initial Setting
- public static void Init(IController hud) {
- Hud = hud;
- ElementIcon = new ITexture[7] {
- Hud.Texture.GetTexture(928374825), // Physical
- Hud.Texture.GetTexture(4122635698), // Fire
- Hud.Texture.GetTexture(569405584), // Lightning
- Hud.Texture.GetTexture(1541236666), // Cold
- Hud.Texture.GetTexture(3513867492), // Poison
- Hud.Texture.GetTexture(3405442230), // Arcane
- Hud.Texture.GetTexture(2639019912), // Holy
- };
- ElementIconBar = new ITexture[7] {
- Hud.Texture.GetTexture(683458403), // Physical Barb
- Hud.Texture.GetTexture(3778595852), // Fire DH
- Hud.Texture.GetTexture(3627085962), // Lightning Monk
- Hud.Texture.GetTexture(1676312247), // Cold Necro
- Hud.Texture.GetTexture(710378302), // Poison WD
- Hud.Texture.GetTexture(126669904), // Arcane Wiz
- Hud.Texture.GetTexture(3778674082), // Holy Sader
- };
- }
- // ITexture Extends
- public static void DrawMiniMap(this ITexture iconTexture, float x, float y, float w, float h, float opacityMultiplier = 1f) {
- Hud.Render.GetMinimapCoordinates(x, y, out var mapX, out var mapY);
- iconTexture.Draw(mapX - w / 2f, mapY - h / 2f, w, h, opacityMultiplier);
- }
- public static void DrawElement(this ITextureController IconController, float x, float y, float w, float h, int eleType, bool isCOErank = false) {
- if (isCOErank) { // 1 ~ 7
- switch (eleType) {
- case 1 : ElementIcon[5].Draw(x, y, w, h); return;
- case 2 : ElementIcon[3].Draw(x, y, w, h); return;
- case 3 : ElementIcon[1].Draw(x, y, w, h); return;
- case 4 : ElementIcon[6].Draw(x, y, w, h); return;
- case 5 : ElementIcon[2].Draw(x, y, w, h); return;
- case 6 : ElementIcon[0].Draw(x, y, w, h); return;
- case 7 : ElementIcon[4].Draw(x, y, w, h); return;
- }
- }
- // 0 ~ 6
- ElementIcon[eleType].Draw(x, y, w, h);
- }
- public static void DrawElementBar(this ITextureController IconController, float x, float y, float w, float h, int eleType, bool isCOErank = false) {
- if (isCOErank) { // 1 ~ 7
- switch (eleType) {
- case 1 : ElementIconBar[5].Draw(x, y, w, h); return;
- case 2 : ElementIconBar[3].Draw(x, y, w, h); return;
- case 3 : ElementIconBar[1].Draw(x, y, w, h); return;
- case 4 : ElementIconBar[6].Draw(x, y, w, h); return;
- case 5 : ElementIconBar[2].Draw(x, y, w, h); return;
- case 6 : ElementIconBar[0].Draw(x, y, w, h); return;
- case 7 : ElementIconBar[4].Draw(x, y, w, h); return;
- }
- }
- // 0 ~ 6
- ElementIconBar[eleType].Draw(x, y, w, h);
- }
- // IFont Extends
- public static void DrawIconText(this IFont textFonnt, string text, float x, float y, float w, float h, int position, int correctionX = 2, int correctionY = 2) {
- var textLayout = textFonnt.GetTextLayout(text);
- var xref = 0f;
- var yref = 0f;
- switch (position % 3) {
- case 0 : xref = x + correctionX; break;
- case 1 : xref = x + (w - textLayout.Metrics.Width) / 2f; break;
- case 2 :
- default: xref = x + w - textLayout.Metrics.Width - correctionX; break;
- }
- switch (position / 3) {
- case 0 : yref = y + correctionY; break;
- case 1 : yref = y + (h - textLayout.Metrics.Height) / 2f; break;
- case 2 :
- default: yref = y + h - textLayout.Metrics.Height - correctionY; break;
- }
- textFonnt.DrawText(textLayout, xref, yref);
- }
- // IBrush Extends
- public static void SetArcIncrement(int arcDiff) { arcIncrement = arcDiff; }
- public static void DrawWorldLineFromMe(this IBrush cBrush, IWorldCoordinate worldCoord, float strokeWidthCorrection = 0) {
- cBrush?.DrawLineWorld(Hud.Game.Me.FloorCoordinate, worldCoord, strokeWidthCorrection);
- }
- public static void DrawWorldArc(this IBrush cBrush, IWorldCoordinate worldCoord, float radius, int Angle_Start, int Angle_End, float ArcCorrection = 1f) {
- if (cBrush == null || Angle_Start >= Angle_End) return;
- if (!worldCoord.IsOnScreen()) return;
- var AdjustArc = (int)Math.Ceiling(arcIncrement * ArcCorrection * (Angle_End - Angle_Start)) / arcIncrement + Angle_Start;
- using (var pg = Hud.Render.CreateGeometry()) {
- using (var gs = pg.Open()) {
- var mx = radius * (float)Math.Cos(Angle_Start * toRad);
- var my = radius * (float)Math.Sin(Angle_Start * toRad);
- var screenCoord = worldCoord.Offset(mx, my, 0).ToScreenCoordinate(true);
- var vector = new Vector2(screenCoord.X, screenCoord.Y);
- gs.BeginFigure(vector, FigureBegin.Filled); // FigureBegin.Filled , FigureBegin.Hollow
- for (var angle = Angle_Start + arcIncrement; angle <= AdjustArc; angle += arcIncrement) {
- mx = radius * (float)Math.Cos(angle * toRad);
- my = radius * (float)Math.Sin(angle * toRad);
- screenCoord = worldCoord.Offset(mx, my, 0).ToScreenCoordinate(true);
- vector = new Vector2(screenCoord.X, screenCoord.Y);
- gs.AddLine(vector);
- }
- gs.EndFigure(FigureEnd.Open);
- gs.Close();
- }
- cBrush.DrawGeometry(pg);
- }
- }
- public static void DrawClockRectangle(this IBrush timeBrush, float x, float y, float w, float h, double timeTotal, double timeLeft) {
- if (timeBrush == null || timeLeft <= 0) return;
- if (timeTotal <= timeLeft) {
- timeBrush.DrawRectangle(x, y, w, h);
- return;
- }
- var endAngle = (int)Math.Ceiling(360d * timeLeft / timeTotal) - 90;
- var rotAngle = (w == h) ? 45 : (int)(Math.Atan2(w, h) / toRad);
- var mx = (float)Math.Cos(endAngle * toRad) * w;
- var my = (float)Math.Sin(endAngle * toRad) * h;
- using (var pg = Hud.Render.CreateGeometry()) {
- using (var gs = pg.Open()) {
- var vector = new Vector2(x + 0.5f * w, y + 0.5f * h); gs.BeginFigure(vector, FigureBegin.Filled);
- vector = new Vector2(x + 0.5f * w, y); gs.AddLine(vector);
- if (endAngle <= -rotAngle) {
- vector = new Vector2(x + 0.5f * w * (1 + mx / my), y); gs.AddLine(vector);
- }
- else if (endAngle <= rotAngle) {
- vector = new Vector2(x, y); gs.AddLine(vector);
- vector = new Vector2(x, y + 0.5f * h * (1 + my / mx)); gs.AddLine(vector);
- }
- else if (endAngle <= 180 - rotAngle) {
- vector = new Vector2(x, y); gs.AddLine(vector);
- vector = new Vector2(x, y + h); gs.AddLine(vector);
- vector = new Vector2(x + 0.5f * w * (1 - mx / my), y + h); gs.AddLine(vector);
- }
- else if (endAngle <= 180 + rotAngle) {
- vector = new Vector2(x, y); gs.AddLine(vector);
- vector = new Vector2(x, y + h); gs.AddLine(vector);
- vector = new Vector2(x + w, y + h); gs.AddLine(vector);
- vector = new Vector2(x + w, y + 0.5f * h * (1 - my / mx)); gs.AddLine(vector);
- }
- else {
- vector = new Vector2(x, y); gs.AddLine(vector);
- vector = new Vector2(x, y + h); gs.AddLine(vector);
- vector = new Vector2(x + w, y + h); gs.AddLine(vector);
- vector = new Vector2(x + w, y); gs.AddLine(vector);
- vector = new Vector2(x + 0.5f * w * (1 + mx / my), y); gs.AddLine(vector);
- }
- gs.EndFigure(FigureEnd.Closed);
- gs.Close();
- }
- timeBrush.DrawGeometry(pg);
- }
- }
- }
- public class DAV_Extend_FuncPlugin : BasePlugin {
- public DAV_Extend_FuncPlugin() {
- Enabled = true;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- DAV_ExtendFunc.Init(hud);
- Enabled = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement