diff --git a/src/js/game/hud/parts/building_placer_logic.js b/src/js/game/hud/parts/building_placer_logic.js index 6aee65b6..9bf031c0 100644 --- a/src/js/game/hud/parts/building_placer_logic.js +++ b/src/js/game/hud/parts/building_placer_logic.js @@ -45,7 +45,13 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { * The current rotation * @type {number} */ - this.currentBaseRotation = 0; + this.currentBaseRotationGeneral = 0; + + /** + * The current rotation preference for each building. + * @type{Object.} + */ + this.preferredBaseRotations = {}; /** * Whether we are currently dragging @@ -114,6 +120,39 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { this.root.camera.upPostHandler.add(this.onMouseUp, this); } + /** + * Returns the current base rotation for the current meta-building. + * @returns {number} + */ + get currentBaseRotation() { + if (!this.root.app.settings.getAllSettings().rotationByBuilding) { + return this.currentBaseRotationGeneral; + } + const metaBuilding = this.currentMetaBuilding.get(); + if (metaBuilding && this.preferredBaseRotations.hasOwnProperty(metaBuilding.getId())) { + return this.preferredBaseRotations[metaBuilding.getId()]; + } else { + return this.currentBaseRotationGeneral; + } + } + + /** + * Sets the base rotation for the current meta-building. + * @param {number} rotation The new rotation/angle. + */ + set currentBaseRotation(rotation) { + if (!this.root.app.settings.getAllSettings().rotationByBuilding) { + this.currentBaseRotationGeneral = rotation; + } else { + const metaBuilding = this.currentMetaBuilding.get(); + if (metaBuilding) { + this.preferredBaseRotations[metaBuilding.getId()] = rotation; + } else { + this.currentBaseRotationGeneral = rotation; + } + } + } + /** * Returns if the direction lock is currently active * @returns {boolean} diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 16ec4cbd..8fd80df0 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -251,6 +251,7 @@ export const allApplicationSettings = [ new BoolSetting("vignette", categoryGame, (app, value) => {}), new BoolSetting("compactBuildingInfo", categoryGame, (app, value) => {}), new BoolSetting("disableCutDeleteWarnings", categoryGame, (app, value) => {}), + new BoolSetting("rotationByBuilding", categoryGame, (app, value) => {}), ]; export function getApplicationSettingById(id) { @@ -277,6 +278,7 @@ class SettingsStorage { this.vignette = true; this.compactBuildingInfo = false; this.disableCutDeleteWarnings = false; + this.rotationByBuilding = true; this.enableColorBlindHelper = false; @@ -551,6 +553,10 @@ export class ApplicationSettings extends ReadWriteProxy { data.settings.enableColorBlindHelper = false; data.version = 17; } + if (data.version < 18) { + data.settings.rotationByBuilding = true; + data.version = 18; + } return ExplainedResult.good(); } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index d349bbe3..8581bb2c 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -721,6 +721,11 @@ settings: title: Vignette description: >- Enables the vignette which darkens the screen corners and makes text easier to read. + + rotationByBuilding: + title: Rotation by building type + description: >- + Each building type remembers the rotation you last set it to individually. This may be more comfortable if you frequently switch between placing different building types. compactBuildingInfo: title: Compact Building Infos