Advertisement
taotse

Untitled

Aug 20th, 2018
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.95 KB | None | 0 0
  1. //plugin modified . Although it keeps the name GLQ, it is not the original, modified enough to adapt it to what I need
  2.  
  3. using System;
  4. using System.Globalization;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using Turbo.Plugins.Default;
  8.  
  9. namespace Turbo.Plugins.glq
  10. {
  11.  
  12. public class GLQ_GreaterRiftPylonMarkerPlugin : BasePlugin, IInGameTopPainter
  13. {
  14. public IBrush ProgressionLineBrush { get; set; }
  15. public Dictionary<string, Tuple<double,string>> ProgressionofShrines { get; set; }
  16. public IFont GreaterRiftFont { get; set; }
  17. public IFont GreaterRiftFont2 { get; set; }
  18.  
  19. public GLQ_GreaterRiftPylonMarkerPlugin()
  20. {
  21. Enabled = true;
  22. }
  23.  
  24. public override void Load(IController hud)
  25. {
  26. base.Load(hud);
  27. GreaterRiftFont = Hud.Render.CreateFont("tahoma", 7, 255, 215, 110, 215, false, false, 160, 0, 0, 0, true);
  28. GreaterRiftFont2 = Hud.Render.CreateFont("tahoma", 7, 255, 250, 150, 250, false, false, 160, 0, 0, 0, true);
  29. ProgressionLineBrush = Hud.Render.CreateBrush(255, 125, 175, 240, 1f);
  30. ProgressionofShrines = new Dictionary<string, Tuple<double,string>>();
  31. }
  32.  
  33. public void PaintTopInGame(ClipState clipState)
  34. {
  35. if (clipState != ClipState.BeforeClip) return;
  36.  
  37. if (Hud.Game.SpecialArea == SpecialArea.GreaterRift)
  38. {
  39. var percent = Hud.Game.RiftPercentage;
  40. if (percent <= 0) {
  41. ProgressionofShrines.Clear();
  42. return;
  43. }
  44. var ui = Hud.Render.GreaterRiftBarUiElement;
  45.  
  46. if (ui.Visible) {
  47. var uiRect = ui.Rectangle;
  48. var shrines = Hud.Game.Shrines;
  49. Tuple<double,string> valuesOut;
  50. var poder = "";
  51. foreach (var actor in shrines) {
  52. switch (actor.SnoActor.Sno) {
  53. case 330695: poder = "Power"; break;
  54. case 330696:
  55. case 398654: poder = "Conduit"; break;
  56. case 330697: poder = "Chann"; break;
  57. case 330698: poder = "Shied"; break;
  58. case 330699: poder = "Speed"; break;
  59. default: poder = actor.SnoActor.Sno.ToString("F0"); break;
  60. }
  61. // Para parchear que Hud.Game.Me.SnoArea.NameLocalized no se actualice inmediatamente al entrar en un mapa. Hay problemas si el pilón está cerca de la puerta
  62. if (ProgressionofShrines.TryGetValue(poder, out valuesOut)) {
  63. if (valuesOut.Item2 != Hud.Game.Me.SnoArea.NameLocalized) {
  64. Tuple<double,string> updateValues = new Tuple<double,string>(valuesOut.Item1, Hud.Game.Me.SnoArea.NameLocalized);
  65. ProgressionofShrines[poder] = updateValues;
  66. }
  67. }
  68. else {
  69. Tuple<double,string> updateValues = new Tuple<double,string>(percent, Hud.Game.Me.SnoArea.NameLocalized);
  70. ProgressionofShrines.Add(poder, updateValues);
  71. }
  72.  
  73.  
  74. }
  75.  
  76. var py = Hud.Window.Size.Height / 30 ; var anterior = 0d; var contador = 0; var text = "";
  77. var ancho = (GreaterRiftFont.GetTextLayout("00,0%")).Metrics.Width ; var alto = (GreaterRiftFont.GetTextLayout("00,0%")).Metrics.Height;
  78. Dictionary<string, Tuple<double,string>>.KeyCollection keyColl = ProgressionofShrines.Keys;
  79.  
  80. foreach (string s in keyColl) {
  81. // Tuple<double,string> valuesOut;
  82. if (ProgressionofShrines.TryGetValue(s, out valuesOut)) {
  83. contador += 1 ;
  84.  
  85. double porcentaje = valuesOut.Item1; //porcentaje al que salio el pilon
  86. string piso = valuesOut.Item2.Replace("Rift ","");; //piso en el que salio el pilon
  87.  
  88. var xPos = (float)( uiRect.Left + uiRect.Width / 100.0f * porcentaje);
  89.  
  90. ProgressionLineBrush.DrawLine(xPos, uiRect.Bottom, xPos, uiRect.Bottom + py, 0);
  91. var PilonApilon = (contador > 1) ? (" [+" + (porcentaje - anterior).ToString("F0") + "%" + "]") : "";
  92. text = porcentaje.ToString("F1") + "%" + "\r\n" + s + "\r\n"+ piso + "\r\n" + PilonApilon ;
  93. anterior = porcentaje;
  94. GreaterRiftFont.DrawText(text, xPos - ancho , uiRect.Bottom + py, true);
  95.  
  96. if ( ( contador != 4) && (contador == ProgressionofShrines.Count) ) {
  97. var DesdePîlon = "(+" + (percent - porcentaje).ToString("F1") + "%" + ")";
  98. GreaterRiftFont2.DrawText(DesdePîlon, uiRect.Left + uiRect.Width /2 - GreaterRiftFont2.GetTextLayout(DesdePîlon).Metrics.Width / 2 , uiRect.Bottom + uiRect.Height * 0.2f, true);
  99. // --- Otra posible colocación del progreso ---
  100. //var progry = ui.Rectangle.Top - ui.Rectangle.Height * 0.7f - alto * 2;
  101. //var progrx = (float)(ui.Rectangle.Left + ui.Rectangle.Width / 100.0f * percent) - ancho / 2;
  102. //GreaterRiftFont.DrawText(DesdePîlon, progrx, progry, true);
  103. }
  104.  
  105. }
  106. }
  107. }
  108. }
  109. }
  110.  
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement