mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-12 17:51:50 +00:00
added lock option
This commit is contained in:
parent
708c7d22fe
commit
a3b51cf7f0
@ -67,6 +67,14 @@
|
|||||||
opacity: 0.15;
|
opacity: 0.15;
|
||||||
background-image: none !important;
|
background-image: none !important;
|
||||||
|
|
||||||
|
&.editor {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(22, 30, 68, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: " ";
|
content: " ";
|
||||||
|
|
||||||
@ -108,6 +116,32 @@
|
|||||||
color: #111;
|
color: #111;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.puzzle-lock {
|
||||||
|
& {
|
||||||
|
/* @load-async */
|
||||||
|
background: uiResource("locked_building.png") center center / #{D(15px)} #{D(15px)}
|
||||||
|
no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-auto-flow: column;
|
||||||
|
@include S(margin-bottom, 58px);
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
transition: all 0.12s ease-in-out;
|
||||||
|
transition-property: opacity, transform;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
pointer-events: all;
|
||||||
|
|
||||||
|
@include S(width, 15px);
|
||||||
|
@include S(height, 15px);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||||
import { makeDiv, safeModulo } from "../../../core/utils";
|
import { makeDiv, safeModulo } from "../../../core/utils";
|
||||||
|
import { MetaBeltBuilding } from "../../buildings/belt";
|
||||||
|
import { MetaBlockBuilding } from "../../buildings/block";
|
||||||
|
import { MetaConstantProducerBuilding } from "../../buildings/constant_producer";
|
||||||
|
import { MetaGoalAcceptorBuilding } from "../../buildings/goal_acceptor";
|
||||||
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { MetaBuilding } from "../../meta_building";
|
import { MetaBuilding } from "../../meta_building";
|
||||||
@ -108,19 +112,21 @@ export class HUDBaseToolbar extends BaseHUDPart {
|
|||||||
);
|
);
|
||||||
itemContainer.setAttribute("data-icon", "building_icons/" + metaBuilding.getId() + ".png");
|
itemContainer.setAttribute("data-icon", "building_icons/" + metaBuilding.getId() + ".png");
|
||||||
itemContainer.setAttribute("data-id", metaBuilding.getId());
|
itemContainer.setAttribute("data-id", metaBuilding.getId());
|
||||||
binding.add(() => this.togglePuzzleLock(metaBuilding));
|
binding.add(() => this.selectBuildingForPlacement(metaBuilding));
|
||||||
|
|
||||||
this.trackClicks(itemContainer, () => this.selectBuildingForPlacement(metaBuilding), {
|
this.trackClicks(itemContainer, () => this.selectBuildingForPlacement(metaBuilding), {
|
||||||
clickSound: null,
|
clickSound: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
//new stuff
|
//new stuff
|
||||||
const puzzleLock = makeDiv(itemContainer, null, ["puzzle-lock"]);
|
if (this.root.gameMode.getIsEditor() && !this.inRequiredBuildings(metaBuilding)) {
|
||||||
puzzleLock.setAttribute("data-icon", "unlocked_building.png");
|
const puzzleLock = makeDiv(itemContainer, null, ["puzzle-lock"]);
|
||||||
|
|
||||||
this.trackClicks(puzzleLock, () => this.togglePuzzleLock(metaBuilding), {
|
itemContainer.classList.toggle("editor", true);
|
||||||
clickSound: null,
|
this.trackClicks(puzzleLock, () => this.toggleBuildingLock(metaBuilding), {
|
||||||
});
|
clickSound: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.buildingHandles[metaBuilding.id] = {
|
this.buildingHandles[metaBuilding.id] = {
|
||||||
metaBuilding: metaBuilding,
|
metaBuilding: metaBuilding,
|
||||||
@ -246,6 +252,14 @@ export class HUDBaseToolbar extends BaseHUDPart {
|
|||||||
return STOP_PROPAGATION;
|
return STOP_PROPAGATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handle = this.buildingHandles[metaBuilding.getId()];
|
||||||
|
if (handle.puzzleLocked) {
|
||||||
|
handle.puzzleLocked = false;
|
||||||
|
handle.element.classList.toggle("unlocked", false);
|
||||||
|
this.root.soundProxy.playUiClick();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Allow clicking an item again to deselect it
|
// Allow clicking an item again to deselect it
|
||||||
for (const buildingId in this.buildingHandles) {
|
for (const buildingId in this.buildingHandles) {
|
||||||
const handle = this.buildingHandles[buildingId];
|
const handle = this.buildingHandles[buildingId];
|
||||||
@ -263,17 +277,22 @@ export class HUDBaseToolbar extends BaseHUDPart {
|
|||||||
/**
|
/**
|
||||||
* @param {MetaBuilding} metaBuilding
|
* @param {MetaBuilding} metaBuilding
|
||||||
*/
|
*/
|
||||||
togglePuzzleLock(metaBuilding) {
|
toggleBuildingLock(metaBuilding) {
|
||||||
if (!this.visibilityCondition()) {
|
if (!this.visibilityCondition()) {
|
||||||
// Not active
|
// Not active
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metaBuilding.getIsUnlocked(this.root)) {
|
if (this.inRequiredBuildings(metaBuilding) || !metaBuilding.getIsUnlocked(this.root)) {
|
||||||
this.root.soundProxy.playUiError();
|
this.root.soundProxy.playUiError();
|
||||||
return STOP_PROPAGATION;
|
return STOP_PROPAGATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handle = this.buildingHandles[metaBuilding.getId()];
|
||||||
|
handle.puzzleLocked = !handle.puzzleLocked;
|
||||||
|
handle.element.classList.toggle("unlocked", !handle.puzzleLocked);
|
||||||
|
this.root.soundProxy.playUiClick();
|
||||||
|
|
||||||
const entityManager = this.root.entityMgr;
|
const entityManager = this.root.entityMgr;
|
||||||
for (const entity of entityManager.getAllWithComponent(StaticMapEntityComponent)) {
|
for (const entity of entityManager.getAllWithComponent(StaticMapEntityComponent)) {
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
@ -288,11 +307,18 @@ export class HUDBaseToolbar extends BaseHUDPart {
|
|||||||
if (currentMetaBuilding.get() == metaBuilding) {
|
if (currentMetaBuilding.get() == metaBuilding) {
|
||||||
currentMetaBuilding.set(null);
|
currentMetaBuilding.set(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handle = this.buildingHandles[metaBuilding.getId()];
|
/**
|
||||||
handle.puzzleLocked = !handle.puzzleLocked;
|
* @param {MetaBuilding} metaBuilding
|
||||||
handle.element.classList.toggle("unlocked", handle.puzzleLocked);
|
*/
|
||||||
|
inRequiredBuildings(metaBuilding) {
|
||||||
this.root.soundProxy.playUiClick();
|
const requiredBuildings = [
|
||||||
|
gMetaBuildingRegistry.findByClass(MetaConstantProducerBuilding),
|
||||||
|
gMetaBuildingRegistry.findByClass(MetaGoalAcceptorBuilding),
|
||||||
|
gMetaBuildingRegistry.findByClass(MetaBlockBuilding),
|
||||||
|
gMetaBuildingRegistry.findByClass(MetaBeltBuilding),
|
||||||
|
];
|
||||||
|
return requiredBuildings.includes(metaBuilding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ export class ClientAPI {
|
|||||||
if (G_IS_DEV) {
|
if (G_IS_DEV) {
|
||||||
return "http://localhost:15001";
|
return "http://localhost:15001";
|
||||||
}
|
}
|
||||||
return "https://api-staging.shapez.io";
|
|
||||||
if (window.location.host === "beta.shapez.io") {
|
if (window.location.host === "beta.shapez.io") {
|
||||||
return "https://api-staging.shapez.io";
|
return "https://api-staging.shapez.io";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user