Merge pull request #227 from Magos/rotationByBuilding

Rotation remembered by building type
This commit is contained in:
tobspr 2020-06-24 18:57:08 +02:00 committed by GitHub
commit 1717c25bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 1 deletions

View File

@ -45,7 +45,13 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
* The current rotation * The current rotation
* @type {number} * @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 * Whether we are currently dragging
@ -114,6 +120,39 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
this.root.camera.upPostHandler.add(this.onMouseUp, this); 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 if the direction lock is currently active
* @returns {boolean} * @returns {boolean}

View File

@ -251,6 +251,7 @@ export const allApplicationSettings = [
new BoolSetting("vignette", categoryGame, (app, value) => {}), new BoolSetting("vignette", categoryGame, (app, value) => {}),
new BoolSetting("compactBuildingInfo", categoryGame, (app, value) => {}), new BoolSetting("compactBuildingInfo", categoryGame, (app, value) => {}),
new BoolSetting("disableCutDeleteWarnings", categoryGame, (app, value) => {}), new BoolSetting("disableCutDeleteWarnings", categoryGame, (app, value) => {}),
new BoolSetting("rotationByBuilding", categoryGame, (app, value) => {}),
]; ];
export function getApplicationSettingById(id) { export function getApplicationSettingById(id) {
@ -277,6 +278,7 @@ class SettingsStorage {
this.vignette = true; this.vignette = true;
this.compactBuildingInfo = false; this.compactBuildingInfo = false;
this.disableCutDeleteWarnings = false; this.disableCutDeleteWarnings = false;
this.rotationByBuilding = true;
this.enableColorBlindHelper = false; this.enableColorBlindHelper = false;
@ -551,6 +553,10 @@ export class ApplicationSettings extends ReadWriteProxy {
data.settings.enableColorBlindHelper = false; data.settings.enableColorBlindHelper = false;
data.version = 17; data.version = 17;
} }
if (data.version < 18) {
data.settings.rotationByBuilding = true;
data.version = 18;
}
return ExplainedResult.good(); return ExplainedResult.good();
} }

View File

@ -721,6 +721,11 @@ settings:
title: Vignette title: Vignette
description: >- description: >-
Enables the vignette which darkens the screen corners and makes text easier to read. 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: compactBuildingInfo:
title: Compact Building Infos title: Compact Building Infos