1
0
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:
Git-Nivrak 2020-10-01 08:10:01 +03:00
parent 16545bfefa
commit e9206c1057
3 changed files with 65 additions and 63 deletions

View File

@ -31,6 +31,6 @@ export class ConstantSignalComponent extends Component {
constructor({ signal = null }) {
super();
this.signal = signal;
this.clicked = false;
this.clicked = false;
}
}

View File

@ -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),

View File

@ -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;
}
}