parent
abd26182f5
commit
d39ae528f0
@ -0,0 +1,28 @@
|
||||
#ingame_HUD_DemoTimer {
|
||||
position: absolute;
|
||||
@include S(top, 10px);
|
||||
left: 50%;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
transform: translateX(-50%);
|
||||
color: rgb(248, 40, 106);
|
||||
|
||||
.timer {
|
||||
@include Heading;
|
||||
@include S(font-size, 40px);
|
||||
}
|
||||
|
||||
&.expired .timer {
|
||||
@include InlineAnimation(1s ease-in-out infinite) {
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
@include SuperSmallText;
|
||||
@include S(margin-top, 10px);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
import { makeDiv } from "../../../core/utils";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
export class HUDDemoTimer extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
this.mainElement = makeDiv(parent, "ingame_HUD_DemoTimer", [], "");
|
||||
|
||||
this.timerElement = makeDiv(this.mainElement, null, ["timer"], "12:00");
|
||||
this.descElement = makeDiv(this.mainElement, null, ["description"], "Until end of demo");
|
||||
|
||||
this.currentValue = "";
|
||||
}
|
||||
|
||||
get totalTime() {
|
||||
return this.root.app.gameAnalytics.abtVariant === "1" ? 15 : 30;
|
||||
}
|
||||
|
||||
initialize() {}
|
||||
|
||||
update() {
|
||||
const time = Math.max(0, this.totalTime * 60 - this.root.time.now());
|
||||
|
||||
let minutes = Math.floor(time / 60);
|
||||
let seconds = Math.floor(time % 60);
|
||||
let displayString = String(minutes).padStart(2, "0") + ":" + String(seconds).padStart(2, "0");
|
||||
|
||||
if (displayString !== this.currentValue) {
|
||||
this.currentValue = displayString;
|
||||
this.timerElement.innerText = displayString;
|
||||
if (time === 0) {
|
||||
this.mainElement.classList.add("expired");
|
||||
}
|
||||
}
|
||||
|
||||
if (time === 0) {
|
||||
const advantages = this.root.hud.parts.standaloneAdvantages;
|
||||
if (advantages && !advantages.visible) {
|
||||
advantages.show(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue