Skip to content

Commit

Permalink
remove mission control buttons when there are no missions
Browse files Browse the repository at this point in the history
  • Loading branch information
BarthPaleologue committed Oct 10, 2024
1 parent 5ee2999 commit 7e65a60
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/ts/ui/currentMissionDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class CurrentMissionDisplay {
private readonly buttonContainer: HTMLElement;

private readonly previousMissionButton: HTMLElement;
private readonly missionCounter: HTMLElement;
private readonly nextMissionButton: HTMLElement;

private activeMission: Mission | null = null;
Expand Down Expand Up @@ -58,6 +59,9 @@ export class CurrentMissionDisplay {
previousSpan.innerText = "Previous";
this.previousMissionButton.appendChild(previousSpan);

this.missionCounter = document.createElement("p");
this.buttonContainer.appendChild(this.missionCounter);

this.nextMissionButton = document.createElement("p");
this.buttonContainer.appendChild(this.nextMissionButton);

Expand Down Expand Up @@ -126,6 +130,18 @@ export class CurrentMissionDisplay {
const nextTaskBlock = descriptionBlocks[1];
const nextTaskText = await this.activeMission.describeNextTask(context);
if (nextTaskText !== nextTaskBlock.innerText) nextTaskBlock.innerText = nextTaskText;

this.buttonContainer.remove();
if (allMissions.length > 1) {
this.rootNode.appendChild(this.buttonContainer);
}

if (this.activeMission !== null) {
const allMissions = this.player.completedMissions.concat(this.player.currentMissions);
const missionIndex = allMissions.indexOf(this.activeMission);

this.missionCounter.innerText = `${missionIndex + 1}/${allMissions.length}`;
}
}

public setNextMission() {
Expand Down Expand Up @@ -173,11 +189,8 @@ export class CurrentMissionDisplay {

this.missionPanel.innerHTML = "";

const allMissions = this.player.completedMissions.concat(this.player.currentMissions);
const missionIndex = allMissions.indexOf(mission);

const missionTitle = document.createElement("h2");
missionTitle.innerText = `${missionIndex + 1}/${allMissions.length} ${mission.getTypeString()}`;
missionTitle.innerText = mission.getTypeString();
this.missionPanel.appendChild(missionTitle);

const missionDescription = document.createElement("p");
Expand All @@ -198,5 +211,7 @@ export class CurrentMissionDisplay {
const defaultPanelP = document.createElement("p");
defaultPanelP.innerText = "You can get missions at space stations.";
this.missionPanel.appendChild(defaultPanelP);

this.buttonContainer.remove();
}
}

0 comments on commit 7e65a60

Please sign in to comment.