Skip to content

Commit 8a05c48

Browse files
committed
Fix Glyph/Radar tooltip
1 parent cee3911 commit 8a05c48

File tree

3 files changed

+145
-132
lines changed

3 files changed

+145
-132
lines changed

content/panorama/layout/custom_game/custom_ui_manifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/info.xml" />
8989
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/azazel_shop.xml" />
9090
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/music.xml" />
91-
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/custom_glyph_radar.xml" />
9291
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/stat_display.xml" />
9392
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/oaa_game_info.xml" />
9493
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/barebones_notifications.xml" />
@@ -99,6 +98,7 @@
9998
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/bottle_announcement.xml" />
10099
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/surrender.xml" />
101100
<CustomUIElement type="EndScreen" layoutfile="file://{resources}/layout/custom_game/multiteam_end_screen.xml" />
101+
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/custom_glyph_radar.xml" />
102102

103103
<!-- From Overthrow.
104104

content/panorama/scripts/custom_game/custom_glyph_radar.js

+135-129
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,142 @@
11
/* global FindDotaHudElement, GameEvents, $, DOTA_GameState, Game */
22
'use strict';
33
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);
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.GlyphIcon.SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { _this.GlyphTooltip.SetHasClass('Hidden', false); });
69-
this.GlyphIcon.SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { _this.GlyphTooltip.SetHasClass('Hidden', true); });
70-
};
71-
GlyphScanContainer.prototype.CreateRadarTooltip = function () {
72-
var _this = this;
73-
this.RadarTooltip = $.CreatePanel('Panel', $.GetContextPanel(), '');
74-
this.RadarTooltip.BLoadLayoutSnippet('DotaCustomTooltipScan');
75-
this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseover' /* ON_MOUSE_OVER */, function () { _this.RadarTooltip.SetHasClass('Hidden', false); });
76-
this.root.FindChildTraverse('RadarButton').SetPanelEvent('onmouseout' /* ON_MOUSE_OUT */, function () { _this.RadarTooltip.SetHasClass('Hidden', true); });
77-
};
78-
GlyphScanContainer.prototype.SetGlyphIcon = function (isActive) {
79-
if (isActive) {
80-
this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward.png")';
81-
} else {
82-
this.GlyphIcon.style.backgroundImage = 'url("file://{resources}/images/hud/reborn/poop_ward_inactive.png")';
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);
8326
}
84-
};
85-
GlyphScanContainer.prototype.SetRadarIcon = function (isActive) {
86-
if (isActive) {
87-
this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_on_psd.vtex")';
88-
} else {
89-
this.RadarIcon.style.backgroundImage = 'url("s2r://panorama/images/hud/reborn/icon_scan_off_psd.vtex")';
90-
}
91-
};
92-
GlyphScanContainer.prototype.DisableDotaGlyphAndRadar = function () {
93-
// disable default Dota cover because it starts the game with style changed by script that we can't override
94-
var vanilaRadarCD = this.root.FindChildTraverse('CooldownCover');
95-
vanilaRadarCD.visible = false;
96-
vanilaRadarCD.style.opacity = '0';
97-
var vanilaGlyphCD = this.root.FindChildTraverse('GlyphCooldown');
98-
vanilaGlyphCD.visible = false;
99-
vanilaGlyphCD.style.opacity = '0';
100-
};
101-
GlyphScanContainer.prototype.StartPanelCooldown = function (panel, duration, SetIcon) {
102-
$.Msg('StartingCooldown for ' + panel.id);
103-
SetIcon(false);
104-
panel.style.visibility = 'visible';
105-
panel.style.opacity = '1';
106-
panel.style.transitionDuration = duration + 's ';
107-
panel.style.clip = 'radial(50% 50%, 0deg, 0deg)';
108-
// Schedule hiding of the panel
109-
$.Schedule(duration, function () {
110-
$.Msg('FinishCooldown for ' + panel.id);
111-
panel.style.opacity = '0';
112-
panel.style.transitionDuration = 0.1 + 's ';
113-
panel.style.clip = 'radial(50% 50%, 0deg, -359deg)';
114-
SetIcon(true);
115-
});
116-
};
117-
GlyphScanContainer.prototype.StartGlyphCooldown = function (duration) {
118-
var _this = this;
119-
this.GlyphCDRemain = duration;
120-
this.GlyphTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration);
121-
this.StartPanelCooldown(this.GlyphCooldown, duration, function (IsActive) {
122-
_this.SetGlyphIcon(IsActive);
123-
});
124-
};
125-
GlyphScanContainer.prototype.StartRadarCooldown = function (duration) {
126-
var _this = this;
127-
this.RadarCDRemain = duration;
128-
this.RadarTooltip.FindChildTraverse('cooldown_duration').text = this.NumberToTime(duration);
129-
this.StartPanelCooldown(this.RadarCooldown, duration, function (IsActive) {
130-
_this.SetRadarIcon(IsActive);
131-
});
132-
};
133-
return GlyphScanContainer;
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;
134140
}());
135141
var controller = new GlyphScanContainer();
136142
if (!Game.GameStateIsBefore(DOTA_GameState.DOTA_GAMERULES_STATE_GAME_IN_PROGRESS)) {

content/panorama/scripts/custom_game/custom_glyph_radar.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,15 @@ class GlyphScanContainer {
112112
this.GlyphTooltip = $.CreatePanel('Panel', $.GetContextPanel(), '');
113113
this.GlyphTooltip.BLoadLayoutSnippet('DotaCustomTooltipGlyph');
114114

115-
this.GlyphIcon.SetPanelEvent(PanelEvent.ON_MOUSE_OVER , ()=>{ this.GlyphTooltip.SetHasClass('Hidden', false)})
116-
this.GlyphIcon.SetPanelEvent(PanelEvent.ON_MOUSE_OUT , ()=>{ this.GlyphTooltip.SetHasClass('Hidden', true)})
115+
this.root.FindChildTraverse('glyph').SetPanelEvent(PanelEvent.ON_MOUSE_OVER , ()=>{
116+
this.GlyphTooltip.SetHasClass('Hidden', false);
117+
FindDotaHudElement('DOTAHUDGlyphTooltip').visible = false;
118+
})
119+
120+
this.root.FindChildTraverse('glyph').SetPanelEvent(PanelEvent.ON_MOUSE_OUT , ()=>{
121+
this.GlyphTooltip.SetHasClass('Hidden', true);
122+
FindDotaHudElement('DOTAHUDRadarTooltip').visible = false;
123+
})
117124
}
118125

119126
CreateRadarTooltip()

0 commit comments

Comments
 (0)