|
1 | 1 | /* global FindDotaHudElement, GameEvents, $, DOTA_GameState, Game */
|
2 | 2 | 'use strict';
|
3 | 3 | var GlyphScanContainer = /** @class */ (function () {
|
4 |
| - // constructor |
5 |
| - function GlyphScanContainer () { |
6 |
| - var _this = this; |
7 |
| - this.root = FindDotaHudElement('GlyphScanContainer'); |
8 |
| - $.GetContextPanel().RemoveAndDeleteChildren(); |
9 |
| - var panel = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
10 |
| - panel.BLoadLayoutSnippet('CustomGlyphRadarContainerSnippet'); |
11 |
| - this.RadarCooldown = $('#OAARadarCooldown'); |
12 |
| - this.GlyphCooldown = $('#OAAGlyphCooldown'); |
13 |
| - this.RadarIcon = this.root.FindChildTraverse('RadarIcon'); |
14 |
| - this.GlyphIcon = this.root.FindChildTraverse('GlyphButton'); |
15 |
| - this.GlyphCooldown.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
16 |
| - this.RadarCooldown.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
17 |
| - this.CreateTooltips(); |
18 |
| - this.StartGlyphCooldown(0.1); |
19 |
| - this.StartRadarCooldown(0.1); |
20 |
| - $.Schedule(0.2, function () { |
21 |
| - _this.SetRadarIcon(false); |
22 |
| - _this.SetGlyphIcon(true); |
23 |
| - }); |
24 |
| - // First Cooldown |
25 |
| - this.GlyphTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(120); |
| 4 | + // constructor |
| 5 | + function GlyphScanContainer () { |
| 6 | + var _this = this; |
| 7 | + this.root = FindDotaHudElement('GlyphScanContainer'); |
| 8 | + $.GetContextPanel().RemoveAndDeleteChildren(); |
| 9 | + var panel = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
| 10 | + panel.BLoadLayoutSnippet('CustomGlyphRadarContainerSnippet'); |
| 11 | + this.RadarCooldown = $('#OAARadarCooldown'); |
| 12 | + this.GlyphCooldown = $('#OAAGlyphCooldown'); |
| 13 | + this.RadarIcon = this.root.FindChildTraverse('RadarIcon'); |
| 14 | + this.GlyphIcon = this.root.FindChildTraverse('GlyphButton'); |
| 15 | + this.GlyphCooldown.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
| 16 | + this.RadarCooldown.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
| 17 | + this.CreateTooltips(); |
| 18 | + this.StartGlyphCooldown(0.1); |
| 19 | + this.StartRadarCooldown(0.1); |
| 20 | + $.Schedule(0.2, function () { |
| 21 | + _this.SetRadarIcon(false); |
| 22 | + _this.SetGlyphIcon(true); |
| 23 | + }); |
| 24 | + // First Cooldown |
| 25 | + this.GlyphTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(120); |
| 26 | + } |
| 27 | + GlyphScanContainer.prototype.Initialize = function () { |
| 28 | + var _this = this; |
| 29 | + this.DisableDotaGlyphAndRadar(); |
| 30 | + this.UpdateCooldowns(); |
| 31 | + this.StartRadarCooldown(210); |
| 32 | + GameEvents.Subscribe('glyph_scan_cooldown', function (args) { |
| 33 | + _this.StartRadarCooldown(args.maxCooldown); |
| 34 | + }); |
| 35 | + GameEvents.Subscribe('glyph_ward_cooldown', function (args) { |
| 36 | + _this.StartGlyphCooldown(args.maxCooldown); |
| 37 | + }); |
| 38 | + }; |
| 39 | + GlyphScanContainer.prototype.CreateTooltips = function () { |
| 40 | + this.CreateGlyphTooltip(); |
| 41 | + this.CreateRadarTooltip(); |
| 42 | + }; |
| 43 | + GlyphScanContainer.prototype.UpdateCooldowns = function () { |
| 44 | + var _this = this; |
| 45 | + $.Schedule(1, function () { |
| 46 | + if (_this.GlyphCDRemain > 0) { |
| 47 | + _this.GlyphCDRemain--; |
| 48 | + } |
| 49 | + if (_this.RadarCDRemain > 0) { |
| 50 | + _this.RadarCDRemain--; |
| 51 | + } |
| 52 | + _this.GlyphTooltip.SetHasClass('IsCooldownReady', _this.GlyphCDRemain <= 0); |
| 53 | + _this.RadarTooltip.SetHasClass('IsCooldownReady', _this.RadarCDRemain <= 0); |
| 54 | + _this.GlyphTooltip.FindChildTraverse('cooldown_timer_label').SetDialogVariable('cooldown_time', _this.NumberToTime(_this.GlyphCDRemain)); |
| 55 | + _this.RadarTooltip.FindChildTraverse('cooldown_timer_label').SetDialogVariable('cooldown_time', _this.NumberToTime(_this.RadarCDRemain)); |
| 56 | + _this.UpdateCooldowns(); |
| 57 | + }); |
| 58 | + }; |
| 59 | + GlyphScanContainer.prototype.NumberToTime = function (seconds) { |
| 60 | + var date = new Date(0); |
| 61 | + date.setSeconds(seconds); |
| 62 | + return date.toUTCString().substr(21, 4); |
| 63 | + }; |
| 64 | + GlyphScanContainer.prototype.CreateGlyphTooltip = function () { |
| 65 | + var _this = this; |
| 66 | + this.GlyphTooltip = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
| 67 | + this.GlyphTooltip.BLoadLayoutSnippet('DotaCustomTooltipGlyph'); |
| 68 | + this.root.FindChildTraverse('glyph').SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { |
| 69 | + _this.GlyphTooltip.SetHasClass('Hidden', false); |
| 70 | + FindDotaHudElement('DOTAHUDGlyphTooltip').visible = false; |
| 71 | + }); |
| 72 | + this.root.FindChildTraverse('glyph').SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { |
| 73 | + _this.GlyphTooltip.SetHasClass('Hidden', true); |
| 74 | + FindDotaHudElement('DOTAHUDRadarTooltip').visible = false; |
| 75 | + }); |
| 76 | + }; |
| 77 | + GlyphScanContainer.prototype.CreateRadarTooltip = function () { |
| 78 | + var _this = this; |
| 79 | + this.RadarTooltip = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
| 80 | + this.RadarTooltip.BLoadLayoutSnippet('DotaCustomTooltipScan'); |
| 81 | + this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { _this.RadarTooltip.SetHasClass('Hidden', false); }); |
| 82 | + this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { _this.RadarTooltip.SetHasClass('Hidden', true); }); |
| 83 | + }; |
| 84 | + GlyphScanContainer.prototype.SetGlyphIcon = function (isActive) { |
| 85 | + if (isActive) { |
| 86 | + this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward.png")'; |
| 87 | + } else { |
| 88 | + this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward_inactive.png")'; |
26 | 89 | }
|
27 |
| - GlyphScanContainer.prototype.Initialize = function () { |
28 |
| - var _this = this; |
29 |
| - this.DisableDotaGlyphAndRadar(); |
30 |
| - this.UpdateCooldowns(); |
31 |
| - this.StartRadarCooldown(210); |
32 |
| - GameEvents.Subscribe('glyph_scan_cooldown', function (args) { |
33 |
| - _this.StartRadarCooldown(args.maxCooldown); |
34 |
| - }); |
35 |
| - GameEvents.Subscribe('glyph_ward_cooldown', function (args) { |
36 |
| - _this.StartGlyphCooldown(args.maxCooldown); |
37 |
| - }); |
38 |
| - }; |
39 |
| - GlyphScanContainer.prototype.CreateTooltips = function () { |
40 |
| - this.CreateGlyphTooltip(); |
41 |
| - this.CreateRadarTooltip(); |
42 |
| - }; |
43 |
| - GlyphScanContainer.prototype.UpdateCooldowns = function () { |
44 |
| - var _this = this; |
45 |
| - $.Schedule(1, function () { |
46 |
| - if (_this.GlyphCDRemain > 0) { |
47 |
| - _this.GlyphCDRemain--; |
48 |
| - } |
49 |
| - if (_this.RadarCDRemain > 0) { |
50 |
| - _this.RadarCDRemain--; |
51 |
| - } |
52 |
| - _this.GlyphTooltip.SetHasClass('IsCooldownReady', _this.GlyphCDRemain <= 0); |
53 |
| - _this.RadarTooltip.SetHasClass('IsCooldownReady', _this.RadarCDRemain <= 0); |
54 |
| - _this.GlyphTooltip.FindChildTraverse('cooldown_timer_label').SetDialogVariable('cooldown_time', _this.NumberToTime(_this.GlyphCDRemain)); |
55 |
| - _this.RadarTooltip.FindChildTraverse('cooldown_timer_label').SetDialogVariable('cooldown_time', _this.NumberToTime(_this.RadarCDRemain)); |
56 |
| - _this.UpdateCooldowns(); |
57 |
| - }); |
58 |
| - }; |
59 |
| - GlyphScanContainer.prototype.NumberToTime = function (seconds) { |
60 |
| - var date = new Date(0); |
61 |
| - date.setSeconds(seconds); |
62 |
| - return date.toUTCString().substr(21, 4); |
63 |
| - }; |
64 |
| - GlyphScanContainer.prototype.CreateGlyphTooltip = function () { |
65 |
| - var _this = this; |
66 |
| - this.GlyphTooltip = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
67 |
| - this.GlyphTooltip.BLoadLayoutSnippet('DotaCustomTooltipGlyph'); |
68 |
| - this.root.FindChildTraverse('glyph').SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { |
69 |
| - _this.GlyphTooltip.SetHasClass('Hidden', false); |
70 |
| - FindDotaHudElement('DOTAHUDGlyphTooltip').visible = false; |
71 |
| - }); |
72 |
| - this.root.FindChildTraverse('glyph').SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { |
73 |
| - _this.GlyphTooltip.SetHasClass('Hidden', true); |
74 |
| - FindDotaHudElement('DOTAHUDRadarTooltip').visible = false; |
75 |
| - }); |
76 |
| - }; |
77 |
| - GlyphScanContainer.prototype.CreateRadarTooltip = function () { |
78 |
| - var _this = this; |
79 |
| - this.RadarTooltip = $.CreatePanel('Panel', $.GetContextPanel(), ''); |
80 |
| - this.RadarTooltip.BLoadLayoutSnippet('DotaCustomTooltipScan'); |
81 |
| - this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { _this.RadarTooltip.SetHasClass('Hidden', false); }); |
82 |
| - this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { _this.RadarTooltip.SetHasClass('Hidden', true); }); |
83 |
| - }; |
84 |
| - GlyphScanContainer.prototype.SetGlyphIcon = function (isActive) { |
85 |
| - if (isActive) { |
86 |
| - this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward.png")'; |
87 |
| - } else { |
88 |
| - this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward_inactive.png")'; |
89 |
| - } |
90 |
| - }; |
91 |
| - GlyphScanContainer.prototype.SetRadarIcon = function (isActive) { |
92 |
| - if (isActive) { |
93 |
| - this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_on_psd.vtex")'; |
94 |
| - } else { |
95 |
| - this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_off_psd.vtex")'; |
96 |
| - } |
97 |
| - }; |
98 |
| - GlyphScanContainer.prototype.DisableDotaGlyphAndRadar = function () { |
99 |
| - // disable default Dota cover because it starts the game with style changed by script that we can't override |
100 |
| - var vanilaRadarCD = this.root.FindChildTraverse('CooldownCover'); |
101 |
| - vanilaRadarCD.visible = false; |
102 |
| - vanilaRadarCD.style.opacity = '0'; |
103 |
| - var vanilaGlyphCD = this.root.FindChildTraverse('GlyphCooldown'); |
104 |
| - vanilaGlyphCD.visible = false; |
105 |
| - vanilaGlyphCD.style.opacity = '0'; |
106 |
| - }; |
107 |
| - GlyphScanContainer.prototype.StartPanelCooldown = function (panel, duration, SetIcon) { |
108 |
| - $.Msg('StartingCooldown for ' + panel.id); |
109 |
| - SetIcon(false); |
110 |
| - panel.style.visibility = 'visible'; |
111 |
| - panel.style.opacity = '1'; |
112 |
| - panel.style.transitionDuration = duration + 's '; |
113 |
| - panel.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
114 |
| - // Schedule hiding of the panel |
115 |
| - $.Schedule(duration, function () { |
116 |
| - $.Msg('FinishCooldown for ' + panel.id); |
117 |
| - panel.style.opacity = '0'; |
118 |
| - panel.style.transitionDuration = 0.1 + 's '; |
119 |
| - panel.style.clip = 'radial(50% 50%, 0deg, -359deg)'; |
120 |
| - SetIcon(true); |
121 |
| - }); |
122 |
| - }; |
123 |
| - GlyphScanContainer.prototype.StartGlyphCooldown = function (duration) { |
124 |
| - var _this = this; |
125 |
| - this.GlyphCDRemain = duration; |
126 |
| - this.GlyphTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration); |
127 |
| - this.StartPanelCooldown(this.GlyphCooldown, duration, function (IsActive) { |
128 |
| - _this.SetGlyphIcon(IsActive); |
129 |
| - }); |
130 |
| - }; |
131 |
| - GlyphScanContainer.prototype.StartRadarCooldown = function (duration) { |
132 |
| - var _this = this; |
133 |
| - this.RadarCDRemain = duration; |
134 |
| - this.RadarTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration); |
135 |
| - this.StartPanelCooldown(this.RadarCooldown, duration, function (IsActive) { |
136 |
| - _this.SetRadarIcon(IsActive); |
137 |
| - }); |
138 |
| - }; |
139 |
| - return GlyphScanContainer; |
| 90 | + }; |
| 91 | + GlyphScanContainer.prototype.SetRadarIcon = function (isActive) { |
| 92 | + if (isActive) { |
| 93 | + this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_on_psd.vtex")'; |
| 94 | + } else { |
| 95 | + this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_off_psd.vtex")'; |
| 96 | + } |
| 97 | + }; |
| 98 | + GlyphScanContainer.prototype.DisableDotaGlyphAndRadar = function () { |
| 99 | + // disable default Dota cover because it starts the game with style changed by script that we can't override |
| 100 | + var vanilaRadarCD = this.root.FindChildTraverse('CooldownCover'); |
| 101 | + vanilaRadarCD.visible = false; |
| 102 | + vanilaRadarCD.style.opacity = '0'; |
| 103 | + var vanilaGlyphCD = this.root.FindChildTraverse('GlyphCooldown'); |
| 104 | + vanilaGlyphCD.visible = false; |
| 105 | + vanilaGlyphCD.style.opacity = '0'; |
| 106 | + }; |
| 107 | + GlyphScanContainer.prototype.StartPanelCooldown = function (panel, duration, SetIcon) { |
| 108 | + $.Msg('StartingCooldown for ' + panel.id); |
| 109 | + SetIcon(false); |
| 110 | + panel.style.visibility = 'visible'; |
| 111 | + panel.style.opacity = '1'; |
| 112 | + panel.style.transitionDuration = duration + 's '; |
| 113 | + panel.style.clip = 'radial(50% 50%, 0deg, 0deg)'; |
| 114 | + // Schedule hiding of the panel |
| 115 | + $.Schedule(duration, function () { |
| 116 | + $.Msg('FinishCooldown for ' + panel.id); |
| 117 | + panel.style.opacity = '0'; |
| 118 | + panel.style.transitionDuration = 0.1 + 's '; |
| 119 | + panel.style.clip = 'radial(50% 50%, 0deg, -359deg)'; |
| 120 | + SetIcon(true); |
| 121 | + }); |
| 122 | + }; |
| 123 | + GlyphScanContainer.prototype.StartGlyphCooldown = function (duration) { |
| 124 | + var _this = this; |
| 125 | + this.GlyphCDRemain = duration; |
| 126 | + this.GlyphTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration); |
| 127 | + this.StartPanelCooldown(this.GlyphCooldown, duration, function (IsActive) { |
| 128 | + _this.SetGlyphIcon(IsActive); |
| 129 | + }); |
| 130 | + }; |
| 131 | + GlyphScanContainer.prototype.StartRadarCooldown = function (duration) { |
| 132 | + var _this = this; |
| 133 | + this.RadarCDRemain = duration; |
| 134 | + this.RadarTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration); |
| 135 | + this.StartPanelCooldown(this.RadarCooldown, duration, function (IsActive) { |
| 136 | + _this.SetRadarIcon(IsActive); |
| 137 | + }); |
| 138 | + }; |
| 139 | + return GlyphScanContainer; |
140 | 140 | }());
|
141 | 141 | var controller = new GlyphScanContainer();
|
142 | 142 | if (!Game.GameStateIsBefore(DOTA_GameState.DOTA_GAMERULES_STATE_GAME_IN_PROGRESS)) {
|
|
0 commit comments