From d13c2f4137d9bc8b1c0d150378640a8b22e05a85 Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Thu, 8 Aug 2024 11:41:52 -0400 Subject: [PATCH 1/5] fix: only process df jump in defrag --- layout/hud/df-jump.xml | 2 ++ scripts/hud/df-jump.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/layout/hud/df-jump.xml b/layout/hud/df-jump.xml index 2dad75de..e355ee5c 100644 --- a/layout/hud/df-jump.xml +++ b/layout/hud/df-jump.xml @@ -3,6 +3,8 @@ + + diff --git a/scripts/hud/df-jump.js b/scripts/hud/df-jump.js index aabb2419..f318ca87 100644 --- a/scripts/hud/df-jump.js +++ b/scripts/hud/df-jump.js @@ -49,9 +49,20 @@ class DFJump { } static { - $.RegisterEventHandler('DFJumpDataUpdate', this.container, this.onDFJumpUpdate.bind(this)); + RegisterHUDPanelForGamemode({ + gamemodes: [GameMode.DEFRAG], + context: this, + contextPanel: this.container, + onLoad: this.onLoad, + handledEvents: [ + { + event: 'DFJumpDataUpdate', + contextPanel: this.container, + callback: this.onDFJumpUpdate + } + ] + }); - $.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this)); $.RegisterForUnhandledEvent('DFJumpMaxDelayChanged', this.setMaxDelay.bind(this)); } } From 3404012fb8e97b554b1820c2dc773f0512348c50 Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Thu, 8 Aug 2024 11:42:24 -0400 Subject: [PATCH 2/5] fix: only process groundboost in defrag --- layout/hud/ground-boost.xml | 2 ++ scripts/hud/ground-boost.js | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/layout/hud/ground-boost.xml b/layout/hud/ground-boost.xml index ebde70f2..06b722bb 100644 --- a/layout/hud/ground-boost.xml +++ b/layout/hud/ground-boost.xml @@ -3,6 +3,8 @@ + + diff --git a/scripts/hud/ground-boost.js b/scripts/hud/ground-boost.js index fd79dc51..0b5b93b0 100644 --- a/scripts/hud/ground-boost.js +++ b/scripts/hud/ground-boost.js @@ -32,12 +32,9 @@ class Groundboost { static onLoad() { 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; @@ -172,8 +169,20 @@ class Groundboost { } static { - $.RegisterEventHandler('HudProcessInput', $.GetContextPanel(), this.onUpdate.bind(this)); - $.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)); } } From 819133e45eba9c5d0da778d7f4302b08454f6032 Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Thu, 8 Aug 2024 11:43:11 -0400 Subject: [PATCH 3/5] fix: only process synchronizer in bhop or surf --- layout/hud/synchronizer.xml | 1 + scripts/hud/synchronizer.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/layout/hud/synchronizer.xml b/layout/hud/synchronizer.xml index 25bdb2d2..5f169eeb 100644 --- a/layout/hud/synchronizer.xml +++ b/layout/hud/synchronizer.xml @@ -4,6 +4,7 @@ + diff --git a/scripts/hud/synchronizer.js b/scripts/hud/synchronizer.js index ed1b53dc..22f700d7 100644 --- a/scripts/hud/synchronizer.js +++ b/scripts/hud/synchronizer.js @@ -33,7 +33,6 @@ class Synchronizer { static onLoad() { this.initializeSettings(); - if (this.statMode) this.onJump(); // show stats if enabled } @@ -256,7 +255,25 @@ class Synchronizer { } static { - $.RegisterEventHandler('HudProcessInput', $.GetContextPanel(), this.onUpdate.bind(this)); + 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)); @@ -266,7 +283,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)); } } From 3ec00d1643986dd56707e28aa54ea777c5271ccf Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Thu, 8 Aug 2024 11:43:21 -0400 Subject: [PATCH 4/5] fix: only process jump stats in bhop --- layout/hud/jump-stats.xml | 2 ++ scripts/hud/jump-stats.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/layout/hud/jump-stats.xml b/layout/hud/jump-stats.xml index 6b53bfeb..d6e7402f 100644 --- a/layout/hud/jump-stats.xml +++ b/layout/hud/jump-stats.xml @@ -3,6 +3,8 @@ + + diff --git a/scripts/hud/jump-stats.js b/scripts/hud/jump-stats.js index 3d9a18ac..21477a09 100644 --- a/scripts/hud/jump-stats.js +++ b/scripts/hud/jump-stats.js @@ -130,9 +130,20 @@ class JumpStats { } static { - $.RegisterEventHandler('OnJumpStarted', this.container, this.onJump.bind(this)); + RegisterHUDPanelForGamemode({ + gamemodes: [GameMode.BHOP], + context: this, + contextPanel: this.container, + onLoad: this.onLoad, + handledEvents: [ + { + event: 'OnJumpStarted', + contextPanel: this.container, + callback: this.onJump + } + ] + }); - $.RegisterForUnhandledEvent('LevelInitPostEntity', this.onLoad.bind(this)); $.RegisterForUnhandledEvent('OnJumpStatsCFGChange', this.onConfigChange.bind(this)); } } From a8a4ca706bc85451c5464a03e4227f84cfa40e02 Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Mon, 19 Aug 2024 22:51:54 -0400 Subject: [PATCH 5/5] fix: only process cgaz in defrag --- layout/hud/cgaz.xml | 1 + scripts/hud/cgaz.js | 42 ++++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/layout/hud/cgaz.xml b/layout/hud/cgaz.xml index 435de46a..6a710567 100644 --- a/layout/hud/cgaz.xml +++ b/layout/hud/cgaz.xml @@ -4,6 +4,7 @@ + diff --git a/scripts/hud/cgaz.js b/scripts/hud/cgaz.js index b2fa552e..668e0bb2 100644 --- a/scripts/hud/cgaz.js +++ b/scripts/hud/cgaz.js @@ -124,25 +124,14 @@ class Cgaz { static updateHandle = null; static onLoad() { - if (GameModeAPI.GetCurrentGameMode() === GameMode.DEFRAG) { - this.updateHandle = $.RegisterEventHandler( - 'HudProcessInput', - $.GetContextPanel(), - this.onUpdate.bind(this) - ); - - this.onAccelConfigChange(); - this.onSnapConfigChange(); - this.onPrimeConfigChange(); - this.onProjectionChange(); - this.onHudFovChange(); - this.onSnapConfigChange(); - this.onWindicatorConfigChange(); - this.onCompassConfigChange(); - } else if (this.updateHandle) { - $.UnregisterEventHandler('HudProcessInput', $.GetContextPanel(), this.updateHandle); - this.updateHandle = null; - } + this.onAccelConfigChange(); + this.onSnapConfigChange(); + this.onPrimeConfigChange(); + this.onProjectionChange(); + this.onHudFovChange(); + this.onSnapConfigChange(); + this.onWindicatorConfigChange(); + this.onCompassConfigChange(); } static onProjectionChange() { @@ -1267,7 +1256,20 @@ class Cgaz { } 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('OnDefragHUDProjectionChange', this.onProjectionChange.bind(this)); $.RegisterForUnhandledEvent('OnDefragHUDFOVChange', this.onHudFovChange.bind(this)); $.RegisterForUnhandledEvent('OnDefragHUDAccelChange', this.onAccelConfigChange.bind(this));