Allow cycling backwards, closes #790
This commit is contained in:
parent
f5032a02ce
commit
ca1af5a505
|
@ -5,6 +5,7 @@ export const CHANGELOG = [
|
||||||
entries: [
|
entries: [
|
||||||
"Added the ability to edit constant signals by left clicking them",
|
"Added the ability to edit constant signals by left clicking them",
|
||||||
"You can now add markers in the wire layer (partially by daanbreur)",
|
"You can now add markers in the wire layer (partially by daanbreur)",
|
||||||
|
"Allow to cycle backwards in the toolbar with SHIFT + Tab (idea by emeraldblock)",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
import { Signal, STOP_PROPAGATION } from "../../../core/signal";
|
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||||
import { makeDiv } from "../../../core/utils";
|
import { makeDiv, safeModulo } from "../../../core/utils";
|
||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { MetaBuilding } from "../../meta_building";
|
import { MetaBuilding } from "../../meta_building";
|
||||||
import { GameRoot } from "../../root";
|
import { GameRoot } from "../../root";
|
||||||
|
@ -161,8 +161,12 @@ export class HUDBaseToolbar extends BaseHUDPart {
|
||||||
|
|
||||||
let newBuildingFound = false;
|
let newBuildingFound = false;
|
||||||
let newIndex = this.lastSelectedIndex;
|
let newIndex = this.lastSelectedIndex;
|
||||||
for (let i = 0; i < this.primaryBuildings.length; ++i, ++newIndex) {
|
const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed
|
||||||
newIndex %= this.primaryBuildings.length;
|
? -1
|
||||||
|
: 1;
|
||||||
|
|
||||||
|
for (let i = 0; i <= this.primaryBuildings.length; ++i) {
|
||||||
|
newIndex = safeModulo(newIndex + direction, this.primaryBuildings.length);
|
||||||
const metaBuilding = gMetaBuildingRegistry.findByClass(this.primaryBuildings[newIndex]);
|
const metaBuilding = gMetaBuildingRegistry.findByClass(this.primaryBuildings[newIndex]);
|
||||||
const handle = this.buildingHandles[metaBuilding.id];
|
const handle = this.buildingHandles[metaBuilding.id];
|
||||||
if (!handle.selected && handle.unlocked) {
|
if (!handle.selected && handle.unlocked) {
|
||||||
|
|
Reference in New Issue