mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Adds tracking for rotation per building type.
Adds a setting to go back to one global base rotation.
This commit is contained in:
parent
4f747a1fc5
commit
c7f8b50d13
@ -82,9 +82,9 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
|||||||
this.buildingInfoElements.tutorialImage.setAttribute(
|
this.buildingInfoElements.tutorialImage.setAttribute(
|
||||||
"data-icon",
|
"data-icon",
|
||||||
"building_tutorials/" +
|
"building_tutorials/" +
|
||||||
metaBuilding.getId() +
|
metaBuilding.getId() +
|
||||||
(variant === defaultBuildingVariant ? "" : "-" + variant) +
|
(variant === defaultBuildingVariant ? "" : "-" + variant) +
|
||||||
".png"
|
".png"
|
||||||
);
|
);
|
||||||
|
|
||||||
removeAllChildren(this.buildingInfoElements.additionalInfo);
|
removeAllChildren(this.buildingInfoElements.additionalInfo);
|
||||||
@ -122,10 +122,10 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
|||||||
T.ingame.buildingPlacement.cycleBuildingVariants.replace(
|
T.ingame.buildingPlacement.cycleBuildingVariants.replace(
|
||||||
"<key>",
|
"<key>",
|
||||||
"<code class='keybinding'>" +
|
"<code class='keybinding'>" +
|
||||||
this.root.keyMapper
|
this.root.keyMapper
|
||||||
.getBinding(KEYMAPPINGS.placement.cycleBuildingVariants)
|
.getBinding(KEYMAPPINGS.placement.cycleBuildingVariants)
|
||||||
.getKeyCodeString() +
|
.getKeyCodeString() +
|
||||||
"</code>"
|
"</code>"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
|||||||
} = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile(
|
} = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile(
|
||||||
this.root,
|
this.root,
|
||||||
mouseTile,
|
mouseTile,
|
||||||
this.currentBaseRotation,
|
this.getBaseRotation(),
|
||||||
this.currentVariant.get()
|
this.currentVariant.get()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { Math_abs, Math_degrees, Math_round } from "../../../core/builtins";
|
import { Math_abs, Math_degrees, Math_round } from "../../../core/builtins";
|
||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
@ -45,7 +46,34 @@ 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.preferredRotations = {};
|
||||||
|
|
||||||
|
this.getBaseRotation = function () {
|
||||||
|
const rotationByBuilding = this.root.app.settings.getAllSettings().rotationByBuilding;
|
||||||
|
if (!rotationByBuilding) {
|
||||||
|
return this.currentBaseRotationGeneral;
|
||||||
|
}
|
||||||
|
const id = this.currentMetaBuilding.get().getId();
|
||||||
|
return this.preferredRotations[id] || this.currentBaseRotationGeneral;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBaseRotation = function (rotation) {
|
||||||
|
const rotationByBuilding = this.root.app.settings.getAllSettings().rotationByBuilding;
|
||||||
|
if (!rotationByBuilding) {
|
||||||
|
this.currentBaseRotationGeneral = rotation;
|
||||||
|
} else {
|
||||||
|
const id = this.currentMetaBuilding.get().getId();
|
||||||
|
this.preferredRotations[id] = rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether we are currently dragging
|
* Whether we are currently dragging
|
||||||
@ -200,12 +228,12 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
const selectedBuilding = this.currentMetaBuilding.get();
|
const selectedBuilding = this.currentMetaBuilding.get();
|
||||||
if (selectedBuilding) {
|
if (selectedBuilding) {
|
||||||
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) {
|
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) {
|
||||||
this.currentBaseRotation = (this.currentBaseRotation + 270) % 360;
|
this.setBaseRotation((this.getBaseRotation() + 270) % 360);
|
||||||
} else {
|
} else {
|
||||||
this.currentBaseRotation = (this.currentBaseRotation + 90) % 360;
|
this.setBaseRotation((this.getBaseRotation() + 90) % 360);
|
||||||
}
|
}
|
||||||
const staticComp = this.fakeEntity.components.StaticMapEntity;
|
const staticComp = this.fakeEntity.components.StaticMapEntity;
|
||||||
staticComp.rotation = this.currentBaseRotation;
|
staticComp.rotation = this.getBaseRotation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -377,7 +405,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
const { rotation, rotationVariant } = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile(
|
const { rotation, rotationVariant } = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile(
|
||||||
this.root,
|
this.root,
|
||||||
tile,
|
tile,
|
||||||
this.currentBaseRotation,
|
this.getBaseRotation(),
|
||||||
this.currentVariant.get()
|
this.currentVariant.get()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -385,7 +413,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
origin: tile,
|
origin: tile,
|
||||||
rotation,
|
rotation,
|
||||||
rotationVariant,
|
rotationVariant,
|
||||||
originalRotation: this.currentBaseRotation,
|
originalRotation: this.getBaseRotation(),
|
||||||
building: this.currentMetaBuilding.get(),
|
building: this.currentMetaBuilding.get(),
|
||||||
variant: this.currentVariant.get(),
|
variant: this.currentVariant.get(),
|
||||||
});
|
});
|
||||||
@ -401,7 +429,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation
|
KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation
|
||||||
).pressed
|
).pressed
|
||||||
) {
|
) {
|
||||||
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
this.setBaseRotation((180 + this.getBaseRotation()) % 360);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should stop placement
|
// Check if we should stop placement
|
||||||
@ -451,7 +479,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
for (let i = 0; i < path.length; ++i) {
|
for (let i = 0; i < path.length; ++i) {
|
||||||
const { rotation, tile } = path[i];
|
const { rotation, tile } = path[i];
|
||||||
|
|
||||||
this.currentBaseRotation = rotation;
|
this.setBaseRotation(rotation);
|
||||||
this.tryPlaceCurrentBuildingAt(tile);
|
this.tryPlaceCurrentBuildingAt(tile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -634,11 +662,11 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
) {
|
) {
|
||||||
const delta = newPos.sub(oldPos);
|
const delta = newPos.sub(oldPos);
|
||||||
const angleDeg = Math_degrees(delta.angle());
|
const angleDeg = Math_degrees(delta.angle());
|
||||||
this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360;
|
this.setBaseRotation((Math.round(angleDeg / 90) * 90 + 360) % 360);
|
||||||
|
|
||||||
// Holding alt inverts the placement
|
// Holding alt inverts the placement
|
||||||
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeInverse).pressed) {
|
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeInverse).pressed) {
|
||||||
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
this.setBaseRotation((180 + this.getBaseRotation()) % 360);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,9 +248,10 @@ export const allApplicationSettings = [
|
|||||||
|
|
||||||
new BoolSetting("alwaysMultiplace", categoryGame, (app, value) => {}),
|
new BoolSetting("alwaysMultiplace", categoryGame, (app, value) => {}),
|
||||||
new BoolSetting("enableTunnelSmartplace", categoryGame, (app, value) => {}),
|
new BoolSetting("enableTunnelSmartplace", categoryGame, (app, value) => {}),
|
||||||
new BoolSetting("vignette", categoryGame, (app, value) => {}),
|
new BoolSetting("vignette", categoryGame, (app, value) => {}),<<<<<<< HEAD
|
||||||
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,8 @@ 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;
|
||||||
|
|
||||||
@ -527,6 +530,7 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.version < 13) {
|
if (data.version < 13) {
|
||||||
|
<<<<<<< HEAD
|
||||||
data.settings.compactBuildingInfo = false;
|
data.settings.compactBuildingInfo = false;
|
||||||
data.version = 13;
|
data.version = 13;
|
||||||
}
|
}
|
||||||
@ -550,6 +554,11 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
if (data.version < 17) {
|
if (data.version < 17) {
|
||||||
data.settings.enableColorBlindHelper = false;
|
data.settings.enableColorBlindHelper = false;
|
||||||
data.version = 17;
|
data.version = 17;
|
||||||
|
=======
|
||||||
|
data.settings.rotationByBuilding = true;
|
||||||
|
data.version = 13;
|
||||||
|
|
||||||
|
>>>>>>> 655c356... Adds tracking for rotation per building type.
|
||||||
}
|
}
|
||||||
|
|
||||||
return ExplainedResult.good();
|
return ExplainedResult.good();
|
||||||
|
Loading…
Reference in New Issue
Block a user