Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Aug 9, 2024
1 parent bd73a4e commit 0b67a5b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 58 deletions.
1 change: 1 addition & 0 deletions layout/hud/df-jump.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</styles>
<scripts>
<include src="file://{scripts}/common/gamemodes.js" />
<include src="file://{scripts}/util/register-for-gamemodes.js" />
<include src="file://{scripts}/common/buttons.js" />
<include src="file://{scripts}/hud/df-jump.js" />
</scripts>
Expand Down
1 change: 1 addition & 0 deletions layout/hud/ground-boost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</styles>
<scripts>
<include src="file://{scripts}/common/gamemodes.js" />
<include src="file://{scripts}/util/register-for-gamemodes.js" />
<include src="file://{scripts}/hud/ground-boost.js" />
</scripts>

Expand Down
1 change: 1 addition & 0 deletions layout/hud/jump-stats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</styles>
<scripts>
<include src="file://{scripts}/common/gamemodes.js" />
<include src="file://{scripts}/util/register-for-gamemodes.js" />
<include src="file://{scripts}/hud/jump-stats.js" />
</scripts>

Expand Down
1 change: 1 addition & 0 deletions layout/hud/synchronizer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</styles>
<scripts>
<include src="file://{scripts}/common/gamemodes.js" />
<include src="file://{scripts}/util/register-for-gamemodes.js" />
<include src="file://{scripts}/util/math.js" />
<include src="file://{scripts}/util/colors.js" />
<include src="file://{scripts}/hud/synchronizer.js" />
Expand Down
26 changes: 13 additions & 13 deletions scripts/hud/df-jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@ class DFJump {
static totalLabel = $('#JumpTotalLabel');

static onLoad() {
if (GameModeAPI.GetCurrentGameMode() === GameMode.DEFRAG) {
this.updateHandle = $.RegisterEventHandler(
'DFJumpDataUpdate',
this.container,
this.onDFJumpUpdate.bind(this)
);
this.initializeSettings();
this.colorClass = COLOR_CLASS.GROUND;
} else if (this.updateHandle) {
$.UnregisterEventHandler('DFJumpDataUpdate', this.container, this.updateHandle);
this.updateHandle = null;
}
this.initializeSettings();
this.colorClass = COLOR_CLASS.GROUND;
}

static onDFJumpUpdate(releaseDelay, pressDelay, totalDelay) {
Expand Down Expand Up @@ -59,7 +49,17 @@ class DFJump {
}

static {
$.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this));
$.RegisterHUDPanelForGamemode({
gamemodes: [GameMode.DEFRAG],
context: this,
contextPanel: this.container,
onLoad: this.onLoad,
handledEvents: [{
event: 'DFJumpDataUpdate',
contextPanel: this.container,
callback: this.onDFJumpUpdate
}]
})
$.RegisterForUnhandledEvent('DFJumpMaxDelayChanged', this.setMaxDelay.bind(this));
}
}
40 changes: 20 additions & 20 deletions scripts/hud/ground-boost.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,15 @@ class Groundboost {
static container = $('#GroundboostContainer');

static onLoad() {
if (currentMode === GameMode.DEFRAG) {
this.updateHandle = $.RegisterEventHandler(
'HudProcessInput',
$.GetContextPanel(),
this.onUpdate.bind(this)
);
this.onConfigChange();
this.colorClass = ColorClass.SLICK;
this.groundboostMeter.AddClass(this.colorClass);
this.labelClass = LabelClass.FLAT;
this.container.AddClass('groundboost__container--hide');
this.visible = false;
this.missedJumpTimer = 0;
this.peakSpeed = 0;
this.startSpeed = 0;
} else if (this.updateHandle) {
$.UnregisterEventHandler('HudProcessInput', $.GetContextPanel(), this.updateHandle);
this.updateHandle = null;
}
this.onConfigChange();
this.colorClass = ColorClass.SLICK;
this.groundboostMeter.AddClass(this.colorClass);
this.labelClass = LabelClass.FLAT;
this.container.AddClass('groundboost__container--hide');
this.visible = false;
this.missedJumpTimer = 0;
this.peakSpeed = 0;
this.startSpeed = 0;
}

static onUpdate() {
Expand Down Expand Up @@ -179,7 +169,17 @@ class Groundboost {
}

static {
$.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this));
$.RegisterHUDPanelForGamemode({
gamemodes: [GameMode.DEFRAG],
context: this,
contextPanel: GetContextPanel(),
onLoad: this.onLoad,
handledEvents: [{
event: 'HudProcessInput',
contextPanel: GetContextPanel(),
callback: this.onUpdate
}]
})
$.RegisterForUnhandledEvent('OnDefragHUDGroundboostChange', this.onConfigChange.bind(this));
}
}
24 changes: 14 additions & 10 deletions scripts/hud/jump-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,9 @@ class JumpStats {
}

static onLoad() {
if (currentMode === GameMode.BHOP) {
this.updateHandle = $.RegisterEventHandler('OnJumpStarted', this.container, this.onJump.bind(this));
this.onConfigChange();
this.initializeStats();
this.setText();
} else if (this.updateHandle) {
$.UnregisterEventHandler('OnJumpStarted', this.container, this.updateHandle);
this.updateHandle = null;
}
this.onConfigChange();
this.initializeStats();
this.setText();
}

static initializeStats() {
Expand Down Expand Up @@ -136,7 +130,17 @@ class JumpStats {
}

static {
$.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this));
$.RegisterHUDPanelForGamemode({
gamemodes: [GameMode.BHOP],
context: this,
contextPanel: this.container,
onLoad: this.onLoad,
handledEvents: [{
event: 'OnJumpStarted',
contextPanel: this.container,
callback: this.onJump
}]
})
$.RegisterForUnhandledEvent('OnJumpStatsCFGChange', this.onConfigChange.bind(this));
}
}
32 changes: 17 additions & 15 deletions scripts/hud/synchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,8 @@ class Synchronizer {
static altColor = 'rgba(0, 0, 0, 0.0)';

static onLoad() {
const currentMode = GameModeAPI.GetCurrentGameMode();
if (currentMode === GameMode.BHOP || currentMode === GameMode.SURF) {
this.updateHandle = $.RegisterEventHandler(
'HudProcessInput',
$.GetContextPanel(),
this.onUpdate.bind(this)
);
this.initializeSettings();
if (this.statMode) this.onJump(); // show stats if enabled
} else if (this.updateHandle) {
$.UnregisterEventHandler('HudProcessInput', $.GetContextPanel(), this.updateHandle);
this.updateHandle = null;
}
this.initializeSettings();
if (this.statMode) this.onJump(); // show stats if enabled
}

static onUpdate() {
Expand Down Expand Up @@ -266,6 +255,21 @@ class Synchronizer {
}

static {
$.RegisterHUDPanelForGamemode({
gamemodes: [GameMode.BHOP, GameMode.SURF],
context: this,
contextPanel: $.GetContextPanel(),
onLoad: this.onLoad,
handledEvents: [{
event: 'HudProcessInput',
contextPanel: $.GetContextPanel(),
callback: this.onUpdate
}],
unhandledEvents: [{
event: 'OnJumpStarted',
callback: this.onJump
}]
});
$.RegisterForUnhandledEvent('OnSynchroModeChanged', this.setDisplayMode.bind(this));
$.RegisterForUnhandledEvent('OnSynchroColorModeChanged', this.setColorMode.bind(this));
$.RegisterForUnhandledEvent('OnSynchroDynamicModeChanged', this.setDynamicMode.bind(this));
Expand All @@ -274,7 +278,5 @@ class Synchronizer {
$.RegisterForUnhandledEvent('OnSynchroMinSpeedChanged', this.setMinSpeed.bind(this));
$.RegisterForUnhandledEvent('OnSynchroStatModeChanged', this.setStatMode.bind(this));
$.RegisterForUnhandledEvent('OnSynchroStatColorModeChanged', this.setStatColorMode.bind(this));
$.RegisterForUnhandledEvent('OnJumpStarted', this.onJump.bind(this));
$.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this));
}
}

0 comments on commit 0b67a5b

Please sign in to comment.