This commit is contained in:
tobspr 2020-06-24 18:57:46 +02:00
commit 1fade52c20
3 changed files with 51 additions and 1 deletions

View File

@ -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.<string,number>}
*/
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}

View File

@ -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();
}

View File

@ -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