Skip to content

Commit

Permalink
fix: Don't do cgaz updates on modes that aren't defrag
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-e committed Oct 15, 2023
1 parent 748cf08 commit 233da25
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions scripts/hud/cgaz.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,24 @@ class Cgaz {
static snapAccel = 0;
static bShouldUpdateStyles = false;

static updateHandle = null;

static onLoad() {
if (GameModeAPI.GetCurrentGameMode() !== GameMode.DEFRAG) return;

this.onAccelConfigChange();
this.onSnapConfigChange();
this.onPrimeConfigChange();
this.onProjectionChange();
this.onHudFovChange();
this.onSnapConfigChange();
this.onWindicatorConfigChange();
this.onCompassConfigChange();
if (GameModeAPI.GetCurrentGameMode() === GameMode.DEFRAG) {
this.updateHandle = $.RegisterEventHandler('ChaosHudProcessInput', $.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('ChaosHudProcessInput', $.GetContextPanel(), this.updateHandle);
this.updateHandle = null;
}
}

static onProjectionChange() {
Expand Down Expand Up @@ -1333,8 +1340,6 @@ class Cgaz {
}

static {
$.RegisterEventHandler('ChaosHudProcessInput', $.GetContextPanel(), this.onUpdate.bind(this));

$.RegisterForUnhandledEvent('ChaosLevelInitPostEntity', this.onLoad.bind(this));
$.RegisterForUnhandledEvent('OnDefragHUDProjectionChange', this.onProjectionChange.bind(this));
$.RegisterForUnhandledEvent('OnDefragHUDFOVChange', this.onHudFovChange.bind(this));
Expand Down

0 comments on commit 233da25

Please sign in to comment.