Skip to content

Commit

Permalink
Merge pull request #47 from jmerle/team-selector-swap
Browse files Browse the repository at this point in the history
Add Swap Teams button to client runner
  • Loading branch information
gaurav-arya authored Jan 10, 2022
2 parents cbcbd13 + 26ff06c commit fd0c79c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions client/visualizer/src/sidebar/matchrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default class MatchRunner {
// Match information
private teamA: HTMLSelectElement;
private teamB: HTMLSelectElement;
private swapTeamsButton: HTMLButtonElement;
private profilerEnabled: HTMLInputElement;
private selectAllMaps: HTMLButtonElement;
private deselectAllMaps: HTMLButtonElement;
Expand Down Expand Up @@ -119,6 +120,8 @@ export default class MatchRunner {
this.runMatchWithoutViewing = document.createElement("button");
this.killProcs = document.createElement("button");

this.swapTeamsButton = document.createElement("button");

this.profilerEnabled = document.createElement("input");
this.profilerEnabled.type = 'checkbox';
this.profilerEnabled.id = 'profiler-enabled';
Expand All @@ -142,6 +145,14 @@ export default class MatchRunner {
divB.appendChild(document.createElement("br"));
div.appendChild(divB);

// Swap teams button
this.swapTeamsButton.type = "button";
this.swapTeamsButton.appendChild(document.createTextNode("Swap Teams"));
this.swapTeamsButton.className = "custom-button";
this.swapTeamsButton.onclick = this.swapTeams;
div.appendChild(this.swapTeamsButton);
div.appendChild(document.createElement("br"));

// Profiler enabled checkbox
const divProfiler = document.createElement("p");
divProfiler.appendChild(this.profilerEnabled);
Expand Down Expand Up @@ -286,6 +297,16 @@ export default class MatchRunner {
}
}

private swapTeams = () => {
if (this.teamA.options.length === 0 || this.teamB.options.length === 0) {
return;
}

const teamAIndex = this.teamA.selectedIndex;
this.teamA.selectedIndex = this.teamB.selectedIndex;
this.teamB.selectedIndex = teamAIndex;
}

/**
* If the scaffold can run a match, add the functionality to the run button
*/
Expand Down

0 comments on commit fd0c79c

Please sign in to comment.