Skip to content

Commit ca4cb47

Browse files
carlosrpgchrisinajar
authored andcommitted
Hold alt for score limit and time until duel/capture points (#2337)
* Add Alt Dashboard * semistandard fixes * Add initial cap point timer
1 parent 04fce18 commit ca4cb47

File tree

7 files changed

+138
-5
lines changed

7 files changed

+138
-5
lines changed

content/panorama/layout/custom_game/timer.xml

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<include src="file://{resources}/styles/custom_game/timer.css" />
88
</styles>
99
<scripts>
10+
<include src="file://{resources}/scripts/custom_game/util.js" />
1011
<include src="file://{resources}/scripts/custom_game/timer.js" />
1112
</scripts>
1213
<Panel class="CustomTimer">
@@ -18,6 +19,14 @@
1819
<DOTAHeroImage id="NightstalkerNight" class="TimeOfDayIcon" heroname="npc_dota_hero_night_stalker" heroimagestyle="icon"/>
1920
<Label id="GameTime" text="{s:time_of_day}" hittest="false"/>
2021
</Panel>
22+
<Panel id="ExtraInfo">
23+
<Label id="TimeToNextCapture" text="#NextCaptureLabel" hittest="false"/>
24+
<Label id="TimeToNextDuel" text="#NextDuelLabel" hittest="false"/>
25+
<Label id="KillLimit" text="#ScoreLimit" hittest="false"/>
26+
<Label id="TimeToNextCaptureValue" hittest="false"/>
27+
<Label id="KillLimitValue" hittest="false"/>
28+
<Label id="TimeToNextDuelValue" text="{s:time_of_day}" hittest="false"/>
29+
</Panel>
2130
</Panel>
2231
</Panel>
2332
</root>

content/panorama/scripts/custom_game/timer.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
/* global CustomNetTables $ */
1+
/* global CustomNetTables $ FindDotaHudElement */
2+
var topBar = FindDotaHudElement('topbar');
3+
var extraInfo = FindDotaHudElement('ExtraInfo');
4+
var killLimit = FindDotaHudElement('KillLimitValue');
5+
var nextDuel = FindDotaHudElement('TimeToNextDuelValue');
6+
var nextCapture = FindDotaHudElement('TimeToNextCaptureValue');
7+
8+
if (extraInfo.GetParent().id !== 'topbar') {
9+
extraInfo.SetParent(topBar);
10+
extraInfo = null;
11+
killLimit = null;
12+
nextDuel = null;
13+
nextCapture = null;
14+
}
215

316
(function () {
417
CustomNetTables.SubscribeNetTableListener('timer', UpdateClock);
@@ -9,8 +22,21 @@ function UpdateClock (table, name, data) {
922
if (!data || data.time === undefined) {
1023
return;
1124
}
12-
$('#TimeHider').style.visibility = 'visible';
25+
if (killLimit === null) {
26+
killLimit = FindDotaHudElement('KillLimitValue');
27+
}
28+
if (nextDuel === null) {
29+
nextDuel = FindDotaHudElement('TimeToNextDuelValue');
30+
}
31+
if (nextCapture === null) {
32+
nextCapture = FindDotaHudElement('TimeToNextCaptureValue');
33+
}
1334

35+
killLimit.text = data.killLimit;
36+
nextDuel.text = formatTime(data.timeToNextDuel);
37+
nextCapture.text = formatTime(data.timeToNextCapture);
38+
39+
$('#TimeHider').style.visibility = 'visible';
1440
$('#GameTime').text = formatTime(data.time);
1541
var dayTime = $('#DayTime');
1642
var nightTime = $('#NightTime');

content/panorama/styles/custom_game/timer.css

+60-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.CustomTimer {
22
width: 100%;
3-
height: 60px;
3+
height: 160px;
44
vertical-align: top;
55
}
66

@@ -20,3 +20,62 @@
2020
.HIDE_TOP_TIMEOFDAY #TimeOfDay, .HIDE_TOP_TIMEOFDAY #TimeOfDayBG {
2121
visibility: visible;
2222
}
23+
24+
#ExtraInfo{
25+
width: 160px;
26+
height: 0px;
27+
horizontal-align: center;
28+
vertical-align: top;
29+
margin-top: 40px;
30+
background-image: url("s2r://panorama/images/hud/reborn/bg_timer_psd.vtex");
31+
background-size: 100% 100%;
32+
transition-property: height;
33+
transition-duration: 0.20s;
34+
transition-timing-function: ease-in-out;
35+
}
36+
37+
.AltPressed #ExtraInfo
38+
{
39+
height: 76px;
40+
}
41+
42+
#ExtraInfo Label
43+
{
44+
font-size: 16px;
45+
vertical-align: top;
46+
horizontal-align: left;
47+
font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU;
48+
}
49+
50+
#TimeToNextCapture {
51+
margin-top: 5px;
52+
margin-left: 15px;
53+
}
54+
55+
#TimeToNextDuel {
56+
margin-top: 25px;
57+
margin-left: 25px;
58+
}
59+
60+
#KillLimit {
61+
margin-top: 45px;
62+
margin-left: 32px;
63+
}
64+
65+
#TimeToNextCaptureValue {
66+
margin-top: 5px;
67+
margin-left: 120px;
68+
color: red;
69+
}
70+
71+
#TimeToNextDuelValue {
72+
margin-top: 25px;
73+
margin-left: 110px;
74+
color: red;
75+
}
76+
77+
#KillLimitValue {
78+
margin-top: 45px;
79+
margin-left: 109px;
80+
color: red;
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//=============================================================================
2+
// OAA Dashboard
3+
//=============================================================================
4+
"NextCaptureLabel" "Next Capture in:"
5+
"NextDuelLabel" "Next Duel in:"
6+
"ScoreLimit" "Score Limit"

game/scripts/vscripts/components/capturepoints/capturepoints.lua

+12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function CapturePoints:Init ()
5555

5656
self.currentCapture = nil
5757

58+
CapturePoints.nextCaptureTime = HudTimer:GetGameTime() + INITIAL_CAPTURE_POINT_DELAY
5859
Timers:CreateTimer(INITIAL_CAPTURE_POINT_DELAY - 60, function ()
5960
self:ScheduleCapture()
6061
end)
@@ -113,12 +114,20 @@ function CapturePoints:MinimapPing()
113114
end
114115
end
115116

117+
function CapturePoints:GetCaptureTime()
118+
if CapturePoints.nextCaptureTime == nil or CapturePoints.nextCaptureTime < 0 then return 0 end
119+
return CapturePoints.nextCaptureTime
120+
end
121+
116122
function CapturePoints:ScheduleCapture()
117123
if self.scheduleCaptureTimer then
118124
Timers:RemoveTimer(self.scheduleCaptureTimer)
119125
self.scheduleCaptureTimer = nil
120126
end
121127
PrepareCapture.broadcast(true)
128+
129+
CapturePoints.nextCaptureTime = HudTimer:GetGameTime() + CAPTURE_INTERVAL + CAPTURE_FIRST_WARN
130+
122131
self.scheduleCaptureTimer = Timers:CreateTimer(CAPTURE_INTERVAL, function ()
123132
self:ScheduleCapture()
124133
end)
@@ -151,6 +160,8 @@ function CapturePoints:ScheduleCapture()
151160
end
152161

153162
function CapturePoints:StartCapture(color)
163+
CapturePoints.nextCaptureTime = HudTimer:GetGameTime() + CAPTURE_FIRST_WARN
164+
154165
self.currentCapture = {
155166
y = 1
156167
}
@@ -169,6 +180,7 @@ function CapturePoints:StartCapture(color)
169180

170181
Timers:CreateTimer(CAPTURE_FIRST_WARN, function ()
171182
self:ActuallyStartCapture()
183+
CapturePoints.nextCaptureTime = HudTimer:GetGameTime() + CAPTURE_INTERVAL + CAPTURE_FIRST_WARN
172184
end)
173185
end
174186

game/scripts/vscripts/components/duels/duels.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function Duels:Init ()
9999
self:CountPlayerDeath(player)
100100
end
101101
end)
102-
102+
Duels.nextDuelTime = HudTimer:GetGameTime() + INITIAL_DUEL_DELAY + DUEL_START_WARN_TIME
103103
Timers:CreateTimer(INITIAL_DUEL_DELAY, function ()
104104
self:StartDuel({
105105
players = 0,
@@ -496,6 +496,15 @@ function Duels:TimeoutDuel ()
496496
})
497497
end
498498

499+
function Duels:SetNextDuelTime()
500+
Duels.nextDuelTime = HudTimer:GetGameTime() + DUEL_INTERVAL + DUEL_START_WARN_TIME
501+
end
502+
503+
function Duels:GetNextDuelTime()
504+
if Duels:IsActive() then return HudTimer:GetGameTime() end
505+
return Duels.nextDuelTime
506+
end
507+
499508
function Duels:EndDuel ()
500509
if self.currentDuel == nil then
501510
DebugPrint ('There is no duel running')
@@ -508,6 +517,7 @@ function Duels:EndDuel ()
508517
Music:PlayBackground(1, 7)
509518

510519
local nextDuelIn = DUEL_INTERVAL
520+
Duels:SetNextDuelTime()
511521

512522
if self.startDuelTimer then
513523
Timers:RemoveTimer(self.startDuelTimer)

game/scripts/vscripts/components/statprovider/timer.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ function HudTimer:Init()
44
self.isPaused = false
55
self.gameTime = 0
66
Timers:CreateTimer(function()
7+
local timeToNextDuel = Duels:GetNextDuelTime()
8+
if timeToNextDuel == nil then timeToNextDuel = 0 else timeToNextDuel = timeToNextDuel - self.gameTime end
9+
if timeToNextDuel < 0 then timeToNextDuel = 0 end
10+
11+
local timeToNextCapture = CapturePoints:GetCaptureTime()
12+
if timeToNextCapture == nil then timeToNextCapture = 0 else timeToNextCapture = timeToNextCapture - self.gameTime end
13+
if timeToNextCapture < 0 then timeToNextCapture = 0 end
14+
715
CustomNetTables:SetTableValue( 'timer', 'data', {
816
time = self.gameTime,
917
isDay = GameRules:IsDaytime(),
10-
isNightstalker = GameRules:IsNightstalkerNight()
18+
isNightstalker = GameRules:IsNightstalkerNight(),
19+
killLimit = PointsManager:GetLimit(),
20+
timeToNextDuel = timeToNextDuel,
21+
timeToNextCapture = timeToNextCapture
1122
})
1223

1324
if not self.isPaused then

0 commit comments

Comments
 (0)