Skip to content

Commit

Permalink
feat(momentum): Display sync track button on official map leaderboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Panzerhandschuh committed Jan 24, 2025
1 parent 6acb512 commit bd8380c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/pages/leaderboards/leaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class LeaderboardsHandler {

this.panels.tracksDropdown.RemoveAllOptions();
this.panels.tracksDropdown.visible = false;

this.panels.endOfRunButton.visible = false;
this.panels.syncTrackButton.visible = false;
}

onTimesUpdated(count: number) {
Expand Down Expand Up @@ -201,18 +204,13 @@ class LeaderboardsHandler {
* Hide the button to go to the end of run page.
*/
onMapLoad(isOfficial: boolean) {
this.panels.endOfRunButton.visible = false;
this.panels.syncTrackButton.visible = false;

if (isOfficial) {
return; // Load official leaderboard tracks instead
}

// Try to load tracks from local zones
const mapZoneData = MomentumTimerAPI.GetActiveZoneDefs();
if (mapZoneData) {
this.panels.syncTrackButton.visible = true;

// Main track
{
const trackStr = $.Localize('#Leaderboards_Tracks_Main');
Expand Down Expand Up @@ -299,6 +297,11 @@ class LeaderboardsHandler {
return;
}

// Allow player to sync their current track to the value selected in the dropdown
if (this.panels.cp.id === 'TabMenuLeaderboards') {
this.panels.syncTrackButton.visible = true;
}

this.panels.tracksDropdown.visible = true;
this.panels.tracksDropdown.SetSelectedIndex(0);
this.panels.tracksDropdown.SetPanelEvent('onuserinputsubmit', () => {
Expand Down

0 comments on commit bd8380c

Please sign in to comment.