Skip to content

Commit

Permalink
feat: added timers for defrag powerups
Browse files Browse the repository at this point in the history
  • Loading branch information
Mac-tf2 committed Apr 15, 2024
1 parent 0cd3d1c commit 672780f
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions images/hud/damageboost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/hud/haste.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions layout/hud/hud.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!-- Anchored to the bottom-left corner of the screen, laid out from top to bottom -->
<Panel id="HudLowerLeft" hittest="false" hittestchildren="true">
<MomHudPowerupTimer />
<HudStaticMenu />
<MomHudChat />
</Panel>
Expand Down
25 changes: 25 additions & 0 deletions layout/hud/powerup-timer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<root>
<styles>
<include src="file://{resources}/styles/main.scss" />
</styles>
<scripts>
<include src="file://{scripts}/common/gamemodes.js" />
<include src="file://{scripts}/util/register-event-for-gamemodes.js" />
<include src="file://{scripts}/hud/powerup-timer.js" />
</scripts>

<MomHudPowerupTimer class="powerup-timer">
<Panel id="HasteTimer" class="powerup-timer__item">
<Image id="HasteIcon" class="powerup-timer__icon powerup-timer__icon--haste" src="file://{images}/hud/haste.svg" textureheight="72"/>
<Label id="HasteLabel" class="powerup-timer__label" text="" />
</Panel>
<Panel id="DamageBoostTimer" class="powerup-timer__item">
<Image id="DamageBoostIcon" class="powerup-timer__icon powerup-timer__icon--damageboost" src="file://{images}/hud/damageboost.svg" textureheight="72"/>
<Label id="DamageBoostLabel" class="powerup-timer__label" text="" />
</Panel>
<Panel id="SlickTimer" class="powerup-timer__item">
<Image id="SlickIcon" class="powerup-timer__icon" src="file://{images}/logo.svg" textureheight="72"/>
<Label id="SlickLabel" class="powerup-timer__label" text="" />
</Panel>
</MomHudPowerupTimer>
</root>
35 changes: 35 additions & 0 deletions scripts/hud/powerup-timer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class PowerupTimer {
static panels = {
panelDamageBoost: $('#DamageBoostTimer'),
labelDamageBoost: $('#DamageBoostLabel'),
panelHaste: $('#HasteTimer'),
labelHaste: $('#HasteLabel'),
panelSlick: $('#SlickTimer'),
labelSlick: $('#SlickLabel')
};

static onUpdate() {
const { damageBoostTime, hasteTime, slickTime } = MomentumMovementAPI.GetLastMoveData();
if (!damageBoostTime) {
this.panels.panelDamageBoost.visible = false;
} else {
this.panels.labelDamageBoost.text = damageBoostTime < 0 ? '∞' : Math.ceil(damageBoostTime / 1000);
this.panels.panelDamageBoost.visible = true;
}
if (!hasteTime) {
this.panels.panelHaste.visible = false;
} else {
this.panels.labelHaste.text = hasteTime < 0 ? '∞' : Math.ceil(hasteTime / 1000);
this.panels.panelHaste.visible = true;
}
if (!slickTime) {
this.panels.panelSlick.visible = false;
} else {
this.panels.labelSlick.text = slickTime < 0 ? '∞' : Math.ceil(slickTime / 1000);
this.panels.panelSlick.visible = true;
}
}
static {
RegisterEventForGamemodes([GameMode.DEFRAG], 'HudProcessInput', $.GetContextPanel(), this.onUpdate.bind(this));
}
}
1 change: 1 addition & 0 deletions scripts/util/panel-registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ UiToolkitAPI.RegisterHUDPanel2d('MomHudDFJump', 'file://{resources}/layout/hud/d
UiToolkitAPI.RegisterHUDPanel2d('MomHudJumpStats', 'file://{resources}/layout/hud/jump-stats.xml');
UiToolkitAPI.RegisterHUDPanel2d('MomHudSpecInfo', 'file://{resources}/layout/hud/spec-info.xml');
UiToolkitAPI.RegisterHUDPanel2d('MomHudSynchronizer', 'file://{resources}/layout/hud/synchronizer.xml');
UiToolkitAPI.RegisterHUDPanel2d('MomHudPowerupTimer', 'file://{resources}/layout/hud/powerup-timer.xml');

UiToolkitAPI.RegisterPanel2d('ToastManager', 'file://{resources}/layout/util/toast-manager.xml');
UiToolkitAPI.RegisterPanel2d('ToastGeneric', 'file://{resources}/layout/modals/toasts/generic.xml');
1 change: 1 addition & 0 deletions styles/hud/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@use 'jump-stats';
@use 'key-press';
@use 'map-info';
@use 'powerup-timer';
@use 'replay-controls';
@use 'show-pos';
@use 'spec-info';
Expand Down
36 changes: 36 additions & 0 deletions styles/hud/powerup-timer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@use '../config' as *;
@use '../abstract/mixin';

.powerup-timer {
margin: 10px;
flow-children: down;
padding-left: 16px;

&__item {
flow-children: right;
}

&__label {
@include mixin.font-styles($use-header: true);
font-size: 64px;
padding-left: 16px;
horizontal-align: left;
vertical-align: center;
text-overflow: ellipsis;
color: $white;
}

&__icon {
vertical-align: center;
height: 50px;
width: 50px;

&--haste {
wash-color: #ec931f;
}

&--damageboost {
wash-color: #1896d3ff;
}
}
}

0 comments on commit 672780f

Please sign in to comment.