mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-06 17:44:33 +00:00
Added a button to clear all non fixed buildings in both modes (#1229)
* added the new splitter * Update base-en.yaml * added clear buildings button to both game modes * Minor cleanups and added translation for new button
This commit is contained in:
parent
6efbdc6ad1
commit
1c23549b39
@ -57,6 +57,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
> .buildingsButton {
|
||||||
|
display: grid;
|
||||||
|
align-items: center;
|
||||||
|
@include S(margin-top, 4px);
|
||||||
|
> button {
|
||||||
|
@include SuperSmallText;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
> .section {
|
> .section {
|
||||||
display: grid;
|
display: grid;
|
||||||
@include S(grid-gap, 10px);
|
@include S(grid-gap, 5px);
|
||||||
grid-auto-flow: row;
|
grid-auto-flow: row;
|
||||||
|
|
||||||
> button {
|
> button {
|
||||||
|
@ -9,6 +9,8 @@ import { makeDiv } from "../../../core/utils";
|
|||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
|
import { MetaBlockBuilding } from "../../buildings/block";
|
||||||
|
|
||||||
const logger = createLogger("puzzle-editor");
|
const logger = createLogger("puzzle-editor");
|
||||||
|
|
||||||
@ -43,8 +45,13 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
|
|
||||||
<div class="buttonBar">
|
<div class="buttonBar">
|
||||||
<button class="styledButton trim">${T.ingame.puzzleEditorSettings.trimZone}</button>
|
<button class="styledButton trim">${T.ingame.puzzleEditorSettings.trimZone}</button>
|
||||||
<button class="styledButton clear">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
<button class="styledButton clearItems">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="buildingsButton">
|
||||||
|
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.clearBuildings}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -53,14 +60,35 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
bind(".zoneHeight .minus", () => this.modifyZone(0, -1));
|
bind(".zoneHeight .minus", () => this.modifyZone(0, -1));
|
||||||
bind(".zoneHeight .plus", () => this.modifyZone(0, 1));
|
bind(".zoneHeight .plus", () => this.modifyZone(0, 1));
|
||||||
bind("button.trim", this.trim);
|
bind("button.trim", this.trim);
|
||||||
bind("button.clear", this.clear);
|
bind("button.clearItems", this.clearItems);
|
||||||
|
bind("button.clearBuildings", this.clearBuildings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clearItems() {
|
||||||
this.root.logic.clearAllBeltsAndItems();
|
this.root.logic.clearAllBeltsAndItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearBuildings() {
|
||||||
|
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||||
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
|
const signalComp = entity.components.ConstantSignal;
|
||||||
|
const goalComp = entity.components.GoalAcceptor;
|
||||||
|
|
||||||
|
if (
|
||||||
|
signalComp ||
|
||||||
|
goalComp ||
|
||||||
|
staticComp.getMetaBuilding().id === gMetaBuildingRegistry.findByClass(MetaBlockBuilding).id
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.root.map.removeStaticEntity(entity);
|
||||||
|
this.root.entityMgr.destroyEntity(entity);
|
||||||
|
}
|
||||||
|
this.root.entityMgr.processDestroyList();
|
||||||
|
}
|
||||||
|
|
||||||
trim() {
|
trim() {
|
||||||
// Now, find the center
|
// Now, find the center
|
||||||
const buildings = this.root.entityMgr.entities.slice();
|
const buildings = this.root.entityMgr.entities.slice();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
import { createLogger } from "../../../core/logging";
|
import { createLogger } from "../../../core/logging";
|
||||||
import { makeDiv } from "../../../core/utils";
|
import { makeDiv } from "../../../core/utils";
|
||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
|
import { MetaBlockBuilding } from "../../buildings/block";
|
||||||
|
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
|
||||||
const logger = createLogger("puzzle-play");
|
const logger = createLogger("puzzle-play");
|
||||||
@ -17,19 +20,41 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart {
|
|||||||
null,
|
null,
|
||||||
["section"],
|
["section"],
|
||||||
`
|
`
|
||||||
<button class="styledButton clear">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
<button class="styledButton clearItems">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
||||||
|
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.clearBuildings}</button>
|
||||||
|
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
bind("button.clear", this.clear);
|
bind("button.clearItems", this.clearItems);
|
||||||
|
bind("button.clearBuildings", this.clearBuildings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clearItems() {
|
||||||
this.root.logic.clearAllBeltsAndItems();
|
this.root.logic.clearAllBeltsAndItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearBuildings() {
|
||||||
|
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||||
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
|
const signalComp = entity.components.ConstantSignal;
|
||||||
|
const goalComp = entity.components.GoalAcceptor;
|
||||||
|
|
||||||
|
if (
|
||||||
|
signalComp ||
|
||||||
|
goalComp ||
|
||||||
|
staticComp.getMetaBuilding().id === gMetaBuildingRegistry.findByClass(MetaBlockBuilding).id
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.root.map.removeStaticEntity(entity);
|
||||||
|
this.root.entityMgr.destroyEntity(entity);
|
||||||
|
}
|
||||||
|
this.root.entityMgr.processDestroyList();
|
||||||
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
}
|
}
|
||||||
|
@ -632,6 +632,7 @@ ingame:
|
|||||||
zoneHeight: Height
|
zoneHeight: Height
|
||||||
trimZone: Trim
|
trimZone: Trim
|
||||||
clearItems: Clear Items
|
clearItems: Clear Items
|
||||||
|
clearBuildings: Clear Buildings
|
||||||
share: Share
|
share: Share
|
||||||
report: Report
|
report: Report
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user