mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Fixed Lint Issues
This commit is contained in:
parent
16545bfefa
commit
e9206c1057
@ -31,6 +31,6 @@ export class ConstantSignalComponent extends Component {
|
|||||||
constructor({ signal = null }) {
|
constructor({ signal = null }) {
|
||||||
super();
|
super();
|
||||||
this.signal = signal;
|
this.signal = signal;
|
||||||
this.clicked = false;
|
this.clicked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ import { HUDSandboxController } from "./parts/sandbox_controller";
|
|||||||
import { HUDWiresToolbar } from "./parts/wires_toolbar";
|
import { HUDWiresToolbar } from "./parts/wires_toolbar";
|
||||||
import { HUDWireInfo } from "./parts/wire_info";
|
import { HUDWireInfo } from "./parts/wire_info";
|
||||||
import { HUDLeverToggle } from "./parts/lever_toggle";
|
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 { HUDLayerPreview } from "./parts/layer_preview";
|
||||||
import { HUDMinerHighlight } from "./parts/miner_highlight";
|
import { HUDMinerHighlight } from "./parts/miner_highlight";
|
||||||
import { HUDBetaOverlay } from "./parts/beta_overlay";
|
import { HUDBetaOverlay } from "./parts/beta_overlay";
|
||||||
@ -73,7 +73,7 @@ export class GameHUD {
|
|||||||
waypoints: new HUDWaypoints(this.root),
|
waypoints: new HUDWaypoints(this.root),
|
||||||
wireInfo: new HUDWireInfo(this.root),
|
wireInfo: new HUDWireInfo(this.root),
|
||||||
leverToggle: new HUDLeverToggle(this.root),
|
leverToggle: new HUDLeverToggle(this.root),
|
||||||
editConstantSignal: new HUDEditConstantSignal(this.root),
|
editConstantSignal: new HUDEditConstantSignal(this.root),
|
||||||
|
|
||||||
// Must always exist
|
// Must always exist
|
||||||
pinnedShapes: new HUDPinnedShapes(this.root),
|
pinnedShapes: new HUDPinnedShapes(this.root),
|
||||||
|
@ -27,75 +27,77 @@ export class ConstantSignalSystem extends GameSystemWithFilter {
|
|||||||
const entity = this.allEntities[i];
|
const entity = this.allEntities[i];
|
||||||
const pinsComp = entity.components.WiredPins;
|
const pinsComp = entity.components.WiredPins;
|
||||||
const signalComp = entity.components.ConstantSignal;
|
const signalComp = entity.components.ConstantSignal;
|
||||||
if (signalComp.clicked == true) {
|
if (signalComp.clicked == true) {
|
||||||
signalComp.clicked = false;
|
signalComp.clicked = false;
|
||||||
if (!entity.components.ConstantSignal) {
|
if (!entity.components.ConstantSignal) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, query, but also save the uid because it could get stale
|
// Ok, query, but also save the uid because it could get stale
|
||||||
const uid = entity.uid;
|
const uid = entity.uid;
|
||||||
|
|
||||||
const signalValueInput = new FormElementInput({
|
const signalValueInput = new FormElementInput({
|
||||||
id: "signalValue",
|
id: "signalValue",
|
||||||
label: fillInLinkIntoTranslation(T.dialogs.editSignal.descShortKey, THIRDPARTY_URLS.shapeViewer),
|
label: fillInLinkIntoTranslation(
|
||||||
placeholder: "",
|
T.dialogs.editSignal.descShortKey,
|
||||||
defaultValue: signalComp.signal ? signalComp.signal.getAsCopyableKey() : "",
|
THIRDPARTY_URLS.shapeViewer
|
||||||
validator: val => this.parseSignalCode(val),
|
),
|
||||||
});
|
placeholder: "",
|
||||||
|
defaultValue: signalComp.signal ? signalComp.signal.getAsCopyableKey() : "",
|
||||||
|
validator: val => this.parseSignalCode(val),
|
||||||
|
});
|
||||||
|
|
||||||
const itemInput = new FormElementItemChooser({
|
const itemInput = new FormElementItemChooser({
|
||||||
id: "signalItem",
|
id: "signalItem",
|
||||||
label: null,
|
label: null,
|
||||||
items: [
|
items: [
|
||||||
BOOL_FALSE_SINGLETON,
|
BOOL_FALSE_SINGLETON,
|
||||||
BOOL_TRUE_SINGLETON,
|
BOOL_TRUE_SINGLETON,
|
||||||
...Object.values(COLOR_ITEM_SINGLETONS),
|
...Object.values(COLOR_ITEM_SINGLETONS),
|
||||||
this.root.shapeDefinitionMgr.getShapeItemFromShortKey(blueprintShape),
|
this.root.shapeDefinitionMgr.getShapeItemFromShortKey(blueprintShape),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const dialog = new DialogWithForm({
|
const dialog = new DialogWithForm({
|
||||||
app: this.root.app,
|
app: this.root.app,
|
||||||
title: T.dialogs.editSignal.title,
|
title: T.dialogs.editSignal.title,
|
||||||
desc: T.dialogs.editSignal.descItems,
|
desc: T.dialogs.editSignal.descItems,
|
||||||
formElements: [itemInput, signalValueInput],
|
formElements: [itemInput, signalValueInput],
|
||||||
buttons: ["cancel:bad:escape", "ok:good:enter"],
|
buttons: ["cancel:bad:escape", "ok:good:enter"],
|
||||||
closeButton: false,
|
closeButton: false,
|
||||||
});
|
});
|
||||||
this.root.hud.parts.dialogs.internalShowDialog(dialog);
|
this.root.hud.parts.dialogs.internalShowDialog(dialog);
|
||||||
|
|
||||||
// When confirmed, set the signal
|
// When confirmed, set the signal
|
||||||
const closeHandler = () => {
|
const closeHandler = () => {
|
||||||
if (!this.root || !this.root.entityMgr) {
|
if (!this.root || !this.root.entityMgr) {
|
||||||
// Game got stopped
|
// Game got stopped
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entityRef = this.root.entityMgr.findByUid(uid, false);
|
const entityRef = this.root.entityMgr.findByUid(uid, false);
|
||||||
if (!entityRef) {
|
if (!entityRef) {
|
||||||
// outdated
|
// outdated
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const constantComp = entityRef.components.ConstantSignal;
|
const constantComp = entityRef.components.ConstantSignal;
|
||||||
if (!constantComp) {
|
if (!constantComp) {
|
||||||
// no longer interesting
|
// no longer interesting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemInput.chosenItem) {
|
if (itemInput.chosenItem) {
|
||||||
console.log(itemInput.chosenItem);
|
console.log(itemInput.chosenItem);
|
||||||
constantComp.signal = itemInput.chosenItem;
|
constantComp.signal = itemInput.chosenItem;
|
||||||
} else {
|
} else {
|
||||||
constantComp.signal = this.parseSignalCode(signalValueInput.getValue());
|
constantComp.signal = this.parseSignalCode(signalValueInput.getValue());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog.buttonSignals.ok.add(closeHandler);
|
dialog.buttonSignals.ok.add(closeHandler);
|
||||||
dialog.valueChosen.add(closeHandler);
|
dialog.valueChosen.add(closeHandler);
|
||||||
|
}
|
||||||
}
|
|
||||||
pinsComp.slots[0].value = signalComp.signal;
|
pinsComp.slots[0].value = signalComp.signal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user