Skip to content

Commit

Permalink
fix: only process cgaz in defrag
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Aug 20, 2024
1 parent 3ec00d1 commit a8a4ca7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions layout/hud/cgaz.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/cgaz.js" />
Expand Down
42 changes: 22 additions & 20 deletions scripts/hud/cgaz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit a8a4ca7

Please sign in to comment.