mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Fix keys being stuck, show savegame levels in main menu
This commit is contained in:
@@ -59,6 +59,7 @@ export class GameHUD {
|
||||
|
||||
vignetteOverlay: new HUDVignetteOverlay(this.root),
|
||||
|
||||
// Must always exist
|
||||
pinnedShapes: new HUDPinnedShapes(this.root),
|
||||
|
||||
notifications: new HUDNotifications(this.root),
|
||||
|
||||
@@ -59,7 +59,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
const tile = worldPos.toTileSpace();
|
||||
if (blueprint.tryPlace(this.root, tile)) {
|
||||
// This actually feels weird
|
||||
// if (!this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).currentlyDown) {
|
||||
// if (!this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).isCurrentlyPressed()) {
|
||||
// this.currentBlueprint.set(null);
|
||||
// }
|
||||
}
|
||||
@@ -84,7 +84,11 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
|
||||
rotateBlueprint() {
|
||||
if (this.currentBlueprint.get()) {
|
||||
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).currentlyDown) {
|
||||
if (
|
||||
this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placement.rotateInverseModifier)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
this.currentBlueprint.get().rotateCcw();
|
||||
} else {
|
||||
this.currentBlueprint.get().rotateCw();
|
||||
|
||||
@@ -161,9 +161,9 @@ export class HUDBuildingPlacer extends BaseHUDPart {
|
||||
if (
|
||||
metaBuilding &&
|
||||
metaBuilding.getRotateAutomaticallyWhilePlacing(this.currentVariant.get()) &&
|
||||
!this.root.keyMapper.getBinding(
|
||||
KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation
|
||||
).currentlyDown
|
||||
!this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
const delta = newPos.sub(oldPos);
|
||||
const angleDeg = Math_degrees(delta.angle());
|
||||
@@ -171,8 +171,9 @@ export class HUDBuildingPlacer extends BaseHUDPart {
|
||||
|
||||
// Holding alt inverts the placement
|
||||
if (
|
||||
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeInverse)
|
||||
.currentlyDown
|
||||
this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placementModifiers.placeInverse)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
||||
}
|
||||
@@ -394,7 +395,11 @@ export class HUDBuildingPlacer extends BaseHUDPart {
|
||||
tryRotate() {
|
||||
const selectedBuilding = this.currentMetaBuilding.get();
|
||||
if (selectedBuilding) {
|
||||
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).currentlyDown) {
|
||||
if (
|
||||
this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placement.rotateInverseModifier)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
this.currentBaseRotation = (this.currentBaseRotation + 270) % 360;
|
||||
} else {
|
||||
this.currentBaseRotation = (this.currentBaseRotation + 90) % 360;
|
||||
@@ -479,16 +484,18 @@ export class HUDBuildingPlacer extends BaseHUDPart {
|
||||
|
||||
if (
|
||||
metaBuilding.getFlipOrientationAfterPlacement() &&
|
||||
!this.root.keyMapper.getBinding(
|
||||
KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation
|
||||
).currentlyDown
|
||||
!this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
||||
}
|
||||
|
||||
if (
|
||||
!metaBuilding.getStayInPlacementMode() &&
|
||||
!this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).currentlyDown &&
|
||||
!this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple)
|
||||
.isCurrentlyPressed() &&
|
||||
!this.root.app.settings.getAllSettings().alwaysMultiplace
|
||||
) {
|
||||
// Stop placement
|
||||
|
||||
@@ -12,6 +12,7 @@ import { enumMouseButton } from "../../camera";
|
||||
import { T } from "../../../translations";
|
||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||
import { THEME } from "../../theme";
|
||||
import { enumHubGoalRewards } from "../../tutorial_goals";
|
||||
|
||||
const logger = createLogger("hud/mass_selector");
|
||||
|
||||
@@ -30,9 +31,9 @@ export class HUDMassSelector extends BaseHUDPart {
|
||||
"ingame_HUD_MassSelector",
|
||||
[],
|
||||
T.ingame.massSelect.infoText
|
||||
.replace("<keyDelete>", removalKeybinding)
|
||||
.replace("<keyCopy>", copyKeybinding)
|
||||
.replace("<keyCancel>", abortKeybinding)
|
||||
.replace("<keyDelete>", `<code class='keybinding'>${removalKeybinding}</code>`)
|
||||
.replace("<keyCopy>", `<code class='keybinding'>${copyKeybinding}</code>`)
|
||||
.replace("<keyCancel>", `<code class='keybinding'>${abortKeybinding}</code>`)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,6 +108,13 @@ export class HUDMassSelector extends BaseHUDPart {
|
||||
|
||||
startCopy() {
|
||||
if (this.selectedUids.size > 0) {
|
||||
if (!this.root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_blueprints)) {
|
||||
this.root.hud.parts.dialogs.showInfo(
|
||||
T.dialogs.blueprintsNotUnlocked.title,
|
||||
T.dialogs.blueprintsNotUnlocked.desc
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.root.hud.signals.buildingsSelectedForCopy.dispatch(Array.from(this.selectedUids));
|
||||
this.selectedUids = new Set();
|
||||
this.root.soundProxy.playUiClick();
|
||||
@@ -121,7 +129,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
||||
* @param {enumMouseButton} mouseButton
|
||||
*/
|
||||
onMouseDown(pos, mouseButton) {
|
||||
if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectStart).currentlyDown) {
|
||||
if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectStart).isCurrentlyPressed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,7 +137,11 @@ export class HUDMassSelector extends BaseHUDPart {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiple).currentlyDown) {
|
||||
if (
|
||||
!this.root.keyMapper
|
||||
.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiple)
|
||||
.isCurrentlyPressed()
|
||||
) {
|
||||
// Start new selection
|
||||
this.selectedUids = new Set();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,19 @@ export class HUDPinnedShapes extends BaseHUDPart {
|
||||
this.element = makeDiv(parent, "ingame_HUD_PinnedShapes", []);
|
||||
}
|
||||
|
||||
serialize() {
|
||||
return {
|
||||
shapes: this.pinnedShapes,
|
||||
};
|
||||
}
|
||||
|
||||
deserialize(data) {
|
||||
if (!data || !data.shapes || !Array.isArray(data.shapes)) {
|
||||
return "Invalid pinned shapes data";
|
||||
}
|
||||
this.pinnedShapes = data.shapes;
|
||||
}
|
||||
|
||||
initialize() {
|
||||
/** @type {Array<{ key: string, goal: number }>} */
|
||||
this.pinnedShapes = [];
|
||||
|
||||
@@ -89,9 +89,10 @@ export class HUDUnlockNotification extends BaseHUDPart {
|
||||
clearTimeout(this.buttonShowTimeout);
|
||||
}
|
||||
|
||||
this.element.querySelector("button.close").classList.remove("unlocked");
|
||||
this.buttonShowTimeout = setTimeout(
|
||||
() => this.element.querySelector("button.close").classList.add("unlocked"),
|
||||
G_IS_DEV ? 1000 : 10000
|
||||
10000
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user