diff --git a/src/js/game/components/constant_signal.js b/src/js/game/components/constant_signal.js index addcbc18..b54bb3b4 100644 --- a/src/js/game/components/constant_signal.js +++ b/src/js/game/components/constant_signal.js @@ -31,6 +31,6 @@ export class ConstantSignalComponent extends Component { constructor({ signal = null }) { super(); this.signal = signal; - this.clicked = false; + this.clicked = false; } } diff --git a/src/js/game/hud/hud.js b/src/js/game/hud/hud.js index e3753054..8abaea4e 100644 --- a/src/js/game/hud/hud.js +++ b/src/js/game/hud/hud.js @@ -42,7 +42,7 @@ import { HUDSandboxController } from "./parts/sandbox_controller"; import { HUDWiresToolbar } from "./parts/wires_toolbar"; import { HUDWireInfo } from "./parts/wire_info"; import { HUDLeverToggle } from "./parts/lever_toggle"; -import { HUDEditConstantSignal } from "./parts/edit_constant_signal" +import { HUDEditConstantSignal } from "./parts/edit_constant_signal"; import { HUDLayerPreview } from "./parts/layer_preview"; import { HUDMinerHighlight } from "./parts/miner_highlight"; import { HUDBetaOverlay } from "./parts/beta_overlay"; @@ -73,7 +73,7 @@ export class GameHUD { waypoints: new HUDWaypoints(this.root), wireInfo: new HUDWireInfo(this.root), leverToggle: new HUDLeverToggle(this.root), - editConstantSignal: new HUDEditConstantSignal(this.root), + editConstantSignal: new HUDEditConstantSignal(this.root), // Must always exist pinnedShapes: new HUDPinnedShapes(this.root), diff --git a/src/js/game/systems/constant_signal.js b/src/js/game/systems/constant_signal.js index a893e042..e7715ba4 100644 --- a/src/js/game/systems/constant_signal.js +++ b/src/js/game/systems/constant_signal.js @@ -27,75 +27,77 @@ export class ConstantSignalSystem extends GameSystemWithFilter { const entity = this.allEntities[i]; const pinsComp = entity.components.WiredPins; const signalComp = entity.components.ConstantSignal; - if (signalComp.clicked == true) { - signalComp.clicked = false; - if (!entity.components.ConstantSignal) { - return; - } + if (signalComp.clicked == true) { + signalComp.clicked = false; + if (!entity.components.ConstantSignal) { + return; + } - // Ok, query, but also save the uid because it could get stale - const uid = entity.uid; + // Ok, query, but also save the uid because it could get stale + const uid = entity.uid; - const signalValueInput = new FormElementInput({ - id: "signalValue", - label: fillInLinkIntoTranslation(T.dialogs.editSignal.descShortKey, THIRDPARTY_URLS.shapeViewer), - placeholder: "", - defaultValue: signalComp.signal ? signalComp.signal.getAsCopyableKey() : "", - validator: val => this.parseSignalCode(val), - }); + const signalValueInput = new FormElementInput({ + id: "signalValue", + label: fillInLinkIntoTranslation( + T.dialogs.editSignal.descShortKey, + THIRDPARTY_URLS.shapeViewer + ), + placeholder: "", + defaultValue: signalComp.signal ? signalComp.signal.getAsCopyableKey() : "", + validator: val => this.parseSignalCode(val), + }); - const itemInput = new FormElementItemChooser({ - id: "signalItem", - label: null, - items: [ - BOOL_FALSE_SINGLETON, - BOOL_TRUE_SINGLETON, - ...Object.values(COLOR_ITEM_SINGLETONS), - this.root.shapeDefinitionMgr.getShapeItemFromShortKey(blueprintShape), - ], - }); + const itemInput = new FormElementItemChooser({ + id: "signalItem", + label: null, + items: [ + BOOL_FALSE_SINGLETON, + BOOL_TRUE_SINGLETON, + ...Object.values(COLOR_ITEM_SINGLETONS), + this.root.shapeDefinitionMgr.getShapeItemFromShortKey(blueprintShape), + ], + }); - const dialog = new DialogWithForm({ - app: this.root.app, - title: T.dialogs.editSignal.title, - desc: T.dialogs.editSignal.descItems, - formElements: [itemInput, signalValueInput], - buttons: ["cancel:bad:escape", "ok:good:enter"], - closeButton: false, - }); - this.root.hud.parts.dialogs.internalShowDialog(dialog); + const dialog = new DialogWithForm({ + app: this.root.app, + title: T.dialogs.editSignal.title, + desc: T.dialogs.editSignal.descItems, + formElements: [itemInput, signalValueInput], + buttons: ["cancel:bad:escape", "ok:good:enter"], + closeButton: false, + }); + this.root.hud.parts.dialogs.internalShowDialog(dialog); - // When confirmed, set the signal - const closeHandler = () => { - if (!this.root || !this.root.entityMgr) { - // Game got stopped - return; - } + // When confirmed, set the signal + const closeHandler = () => { + if (!this.root || !this.root.entityMgr) { + // Game got stopped + return; + } - const entityRef = this.root.entityMgr.findByUid(uid, false); - if (!entityRef) { - // outdated - return; - } + const entityRef = this.root.entityMgr.findByUid(uid, false); + if (!entityRef) { + // outdated + return; + } - const constantComp = entityRef.components.ConstantSignal; - if (!constantComp) { - // no longer interesting - return; - } + const constantComp = entityRef.components.ConstantSignal; + if (!constantComp) { + // no longer interesting + return; + } - if (itemInput.chosenItem) { - console.log(itemInput.chosenItem); - constantComp.signal = itemInput.chosenItem; - } else { - constantComp.signal = this.parseSignalCode(signalValueInput.getValue()); - } - }; + if (itemInput.chosenItem) { + console.log(itemInput.chosenItem); + constantComp.signal = itemInput.chosenItem; + } else { + constantComp.signal = this.parseSignalCode(signalValueInput.getValue()); + } + }; - dialog.buttonSignals.ok.add(closeHandler); - dialog.valueChosen.add(closeHandler); - - } + dialog.buttonSignals.ok.add(closeHandler); + dialog.valueChosen.add(closeHandler); + } pinsComp.slots[0].value = signalComp.signal; } }