diff --git a/src/css/ingame_hud/puzzle_editor_settings.scss b/src/css/ingame_hud/puzzle_editor_settings.scss index 70d16123..9d093c42 100644 --- a/src/css/ingame_hud/puzzle_editor_settings.scss +++ b/src/css/ingame_hud/puzzle_editor_settings.scss @@ -57,6 +57,15 @@ } } } + + > .buildingsButton { + display: grid; + align-items: center; + @include S(margin-top, 4px); + > button { + @include SuperSmallText; + } + } } } } diff --git a/src/css/ingame_hud/puzzle_play_settings.scss b/src/css/ingame_hud/puzzle_play_settings.scss index 13e25c61..b53d0829 100644 --- a/src/css/ingame_hud/puzzle_play_settings.scss +++ b/src/css/ingame_hud/puzzle_play_settings.scss @@ -13,7 +13,7 @@ > .section { display: grid; - @include S(grid-gap, 10px); + @include S(grid-gap, 5px); grid-auto-flow: row; > button { diff --git a/src/js/game/hud/parts/puzzle_editor_settings.js b/src/js/game/hud/parts/puzzle_editor_settings.js index cf283a9b..bcd2c85c 100644 --- a/src/js/game/hud/parts/puzzle_editor_settings.js +++ b/src/js/game/hud/parts/puzzle_editor_settings.js @@ -9,6 +9,8 @@ import { makeDiv } from "../../../core/utils"; import { T } from "../../../translations"; import { StaticMapEntityComponent } from "../../components/static_map_entity"; import { BaseHUDPart } from "../base_hud_part"; +import { gMetaBuildingRegistry } from "../../../core/global_registries"; +import { MetaBlockBuilding } from "../../buildings/block"; const logger = createLogger("puzzle-editor"); @@ -43,8 +45,13 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
- +
+ +
+ +
+ ` ); @@ -53,14 +60,35 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart { bind(".zoneHeight .minus", () => this.modifyZone(0, -1)); bind(".zoneHeight .plus", () => this.modifyZone(0, 1)); 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(); } + 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() { // Now, find the center const buildings = this.root.entityMgr.entities.slice(); diff --git a/src/js/game/hud/parts/puzzle_play_settings.js b/src/js/game/hud/parts/puzzle_play_settings.js index 168c3de2..88034f72 100644 --- a/src/js/game/hud/parts/puzzle_play_settings.js +++ b/src/js/game/hud/parts/puzzle_play_settings.js @@ -1,6 +1,9 @@ +import { gMetaBuildingRegistry } from "../../../core/global_registries"; import { createLogger } from "../../../core/logging"; import { makeDiv } from "../../../core/utils"; import { T } from "../../../translations"; +import { MetaBlockBuilding } from "../../buildings/block"; +import { StaticMapEntityComponent } from "../../components/static_map_entity"; import { BaseHUDPart } from "../base_hud_part"; const logger = createLogger("puzzle-play"); @@ -17,19 +20,41 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart { null, ["section"], ` - + + ` ); - bind("button.clear", this.clear); + bind("button.clearItems", this.clearItems); + bind("button.clearBuildings", this.clearBuildings); } } - clear() { + clearItems() { 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() { this.visible = true; } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 80a6deb1..bf5a1890 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -632,6 +632,7 @@ ingame: zoneHeight: Height trimZone: Trim clearItems: Clear Items + clearBuildings: Clear Buildings share: Share report: Report