Skip to content

Commit

Permalink
feat: Remove some outdated events/apis
Browse files Browse the repository at this point in the history
- Remove MomentumSpectatorTargetChanged in favor of generic
ObserverTargetChanged
- Remove currentRunData and currentRunStats from HudComparisons (replaced
by MomentumTimer::GetObservedTimerStatus() and GetObservedTimerRunSplits())
- Remove OnMomentumZoneChange (replaced by new timer events)
- Remove OnChargeToggled and add enabled value to OnChargeUpdate
  • Loading branch information
jason-e committed Sep 17, 2024
1 parent 3028525 commit 9df16ef
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 44 deletions.
2 changes: 2 additions & 0 deletions scripts/hud/comparisons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class HudComparisonsHandler {
}

updateComparisons() {
/* TODO
const currentData = $.GetContextPanel<HudComparisons>().currentRunData;
const currentStats = $.GetContextPanel<HudComparisons>().currentRunStats;
const comparisonRun = RunComparisonsAPI.GetLoadedComparison();
Expand Down Expand Up @@ -139,5 +140,6 @@ class HudComparisonsHandler {
isFirst: true
}
);
*/
}
}
2 changes: 1 addition & 1 deletion scripts/hud/spec-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HudSpecInfoHandler implements OnPanelLoad {
maxNames = GameInterfaceAPI.GetSettingInt('mom_hud_specinfo_names_count');

constructor() {
$.RegisterForUnhandledEvent('MomentumSpectatorTargetChanged', () => this.onSpectatorChanged());
$.RegisterForUnhandledEvent('ObserverTargetChanged', () => this.onSpectatorChanged());

Check failure on line 15 in scripts/hud/spec-info.ts

View workflow job for this annotation

GitHub Actions / build

No overload matches this call.
$.RegisterForUnhandledEvent('MomentumSpectatorUpdate', () => this.onSpectatorChanged());
$.RegisterForUnhandledEvent('MomentumSpecListMaxNamesUpdate', (val) => {
this.maxNames = val;
Expand Down
8 changes: 5 additions & 3 deletions scripts/hud/spectate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class HudSpectateHandler {
toggleReplayControls: $('#ToggleReplayControls')
};

/* TODO
constructor() {
$.RegisterForUnhandledEvent('MomentumSpectatorTargetChanged', (type: RunEntityType) =>
this.onSpectatorChanged(type)
);
$.RegisterForUnhandledEvent('MomentumSpectatorTargetChanged', (type: RunEntityType) =>
this.onSpectatorChanged(type)
);
}
onSpectatorChanged(type: RunEntityType) {
Expand All @@ -32,4 +33,5 @@ class HudSpectateHandler {
this.panels.indicatorWatchingReplay.visible = isReplay;
}
}
*/
}
5 changes: 2 additions & 3 deletions scripts/hud/speedometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ class SpeedometerHandler {
$.RegisterEventHandler('OnSpeedometerUpdate', this.container, (deltaTime: float) =>
this.onSpeedometerUpdate(deltaTime)
);
$.RegisterForUnhandledEvent('OnMomentumZoneChange', (enter, linear, curZone, curTrack, timerState) =>
this.onZoneChange(enter, linear, curZone, curTrack, timerState)
);

// color profiles load before speedo settings, so listening to just the speedo settings load event should be enough
$.RegisterForUnhandledEvent('OnSpeedometerSettingsLoaded', (succ: boolean) => this.onSettingsUpdate(succ));
Expand Down Expand Up @@ -142,6 +139,7 @@ class SpeedometerHandler {
this.updateSpeedometersOfType(SpeedometerType.OVERALL_VELOCITY, velocity);
}

/* TODO: replace with updates based on new timer events
onZoneChange(enter: boolean, linear: boolean, curZone: int32, _curTrack: int32, timerState: TimerState_OLD) {
const startZone = curZone === 1;
if (enter && startZone) {
Expand Down Expand Up @@ -176,6 +174,7 @@ class SpeedometerHandler {
this.updateZoneSpeedometers(actualSpeedAbs, actualSpeedHoriz, false);
}
}
*/

resetSpeedometerFadeouts() {
for (const [type, speedometers] of this.speedometers) {
Expand Down
15 changes: 5 additions & 10 deletions scripts/hud/sticky-charge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ class StickyChargeHandler {
};

constructor() {
$.RegisterEventHandler('OnChargeUpdate', this.panels.container, (speed, percentage) =>
this.onChargeUpdate(speed, percentage)
$.RegisterEventHandler('OnChargeUpdate', this.panels.container, (enabled, speed, percentage) =>
this.onChargeUpdate(enabled, speed, percentage)
);
$.RegisterEventHandler('OnChargeToggled', this.panels.container, (enabled) => this.onChargeToggled(enabled));
}

onChargeUpdate(speed: float, percentage: float) {
onChargeUpdate(enabled: boolean, speed: float, percentage: float) {
this.panels.chargeMeter.enabled = enabled;

const chargeUnit = this.panels.cp.stickyChargeUnitType;

let speedText;
Expand All @@ -40,10 +41,4 @@ class StickyChargeHandler {
this.panels.chargeSpeed.text = speedText;
this.panels.chargeMeter.value = percentage;
}

onChargeToggled(enabled: boolean) {
if (this.panels.chargeMeter.enabled !== enabled) {
this.panels.chargeMeter.enabled = enabled;
}
}
}
7 changes: 2 additions & 5 deletions scripts/hud/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class HudTimerHandler {
constructor() {
$.RegisterEventHandler('HudProcessInput', this.panels.cp, () => this.onUpdate());
$.RegisterForUnhandledEvent('OnMomentumTimerStateChange', (arg1, arg2) => this.onTimerEvent(arg1, arg2));
$.RegisterForUnhandledEvent(
'OnMomentumZoneChange',
(entering, isLinear, currentZone, currentTrack, timerState) =>
this.onZoneChange(entering, isLinear, currentZone, currentTrack, timerState)
);
$.RegisterForUnhandledEvent('OnSaveStateUpdate', (count, current, usingMenu) =>
this.onSaveStateChange(count, current, usingMenu)
);
Expand Down Expand Up @@ -86,6 +81,7 @@ class HudTimerHandler {
this.panels.cp.SetDialogVariableFloat('runtime', MomentumTimerAPI.GetObservedTimerStatus().runTime);
}

/* TODO: replace with updates based on new timer events
onZoneChange(enter: any, linear: any, curZone: any, _curTrack: any, timerState: any) {
if (timerState === TimerState_OLD.NOT_RUNNING && enter && curZone === 1) {
// timer state is not reset on map finished until entering the start zone again (on reset)
Expand Down Expand Up @@ -121,6 +117,7 @@ class HudTimerHandler {
this.prevZone = curZone;
}
*/

forceHideComparison() {
this.panels.comparison.RemoveClass(FADEOUT_START_CLASS);
Expand Down
18 changes: 1 addition & 17 deletions scripts/types-mom/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ interface GlobalEventNameMap {
*/
Toast_Clear: (location?: import('util/toast-manager').ToastLocation) => void;

MomentumSpectatorTargetChanged: (type: import('common/timer').RunEntityType) => void;

MomentumSpectatorModeChanged: (mode: SpectateMode) => void;

MomentumSpecListMaxNamesUpdate: (maxNames: uint32) => void;
Expand All @@ -236,25 +234,11 @@ interface GlobalEventNameMap {
/** Called whgen lobby-wide spectator state changes */
MomentumSpectatorUpdate: () => void;

/**
* TODO: changing with new zones/timer
* @deprecated
*/
OnMomentumZoneChange: (
entering: boolean,
isLinear: boolean,
currentZone: int32,
currentTrack: int32,
timerState: import('common/timer').TimerState_OLD
) => void;

OnMomentumReplayStarted: () => void;

OnMomentumReplayStopped: () => void;

OnChargeUpdate: (speedInUps: float, percentageCharge: float) => void;

OnChargeToggled: (enabled: boolean) => void;
OnChargeUpdate: (chargeEnabled: boolean, speedInUps: float, percentageCharge: float) => void;

OnStickyPanelStateChanged: (
panel: Panel,
Expand Down
6 changes: 1 addition & 5 deletions scripts/types-mom/panels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ interface RangeColorDisplay extends AbstractPanel<'RangeColorDisplay'> {
SetColorNoEvent(color: color): void;
}

/** Only doing loose type since liable to change in near future. */
interface HudComparisons extends AbstractHudPanel<'HudComparisons'> {
readonly currentRunData: any;
readonly currentRunStats: any;
}
interface HudComparisons extends AbstractHudPanel<'HudComparisons'> {}

interface MomHudTabMenu extends AbstractHudPanel<'MomHudTabMenu'> {
forceCloseTabMenu(): void;
Expand Down

0 comments on commit 9df16ef

Please sign in to comment.