Merge pull request #372 from isaisstillalive/patch-1

Fixed an issue that caused an error when pressing the tab key
pull/380/head
tobspr 4 years ago committed by GitHub
commit 503f9a7fe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -103,15 +103,25 @@ export class HUDBaseToolbar extends BaseHUDPart {
* Cycles through all buildings * Cycles through all buildings
*/ */
cycleBuildings() { cycleBuildings() {
const visible = this.visibilityCondition();
if (!visible) {
return;
}
let newBuildingFound = false;
let newIndex = this.lastSelectedIndex; let newIndex = this.lastSelectedIndex;
for (let i = 0; i < this.supportedBuildings.length; ++i, ++newIndex) { for (let i = 0; i < this.supportedBuildings.length; ++i, ++newIndex) {
newIndex %= this.supportedBuildings.length; newIndex %= this.supportedBuildings.length;
const metaBuilding = gMetaBuildingRegistry.findByClass(this.supportedBuildings[newIndex]); const metaBuilding = gMetaBuildingRegistry.findByClass(this.supportedBuildings[newIndex]);
const handle = this.buildingHandles[metaBuilding.id]; const handle = this.buildingHandles[metaBuilding.id];
if (!handle.selected && handle.unlocked) { if (!handle.selected && handle.unlocked) {
newBuildingFound = true;
break; break;
} }
} }
if (!newBuildingFound) {
return;
}
const metaBuildingClass = this.supportedBuildings[newIndex]; const metaBuildingClass = this.supportedBuildings[newIndex];
const metaBuilding = gMetaBuildingRegistry.findByClass(metaBuildingClass); const metaBuilding = gMetaBuildingRegistry.findByClass(metaBuildingClass);
this.selectBuildingForPlacement(metaBuilding); this.selectBuildingForPlacement(metaBuilding);

Loading…
Cancel
Save