Show edit marker dialog instead deleting marker

pull/397/head
isaisstillalive 4 years ago
parent d0d8314d81
commit 8acefda778

@ -169,7 +169,7 @@ export class HUDWaypoints extends BaseHUDPart {
if (this.isWaypointDeletable(waypoint)) {
const deleteButton = makeDiv(element, null, ["deleteButton"]);
this.trackClicks(deleteButton, () => this.deleteWaypoint(waypoint));
this.trackClicks(deleteButton, () => this.requestEditMarker(waypoint));
}
if (!waypoint.label) {
@ -284,6 +284,59 @@ export class HUDWaypoints extends BaseHUDPart {
this.rerenderWaypointList();
}
/**
* Requests to edit a marker.
* @param {Waypoint} waypoint
*/
requestEditMarker(waypoint) {
// Construct dialog with input field
const markerNameInput = new FormElementInput({
id: "markerName",
label: null,
placeholder: "",
defaultValue: waypoint.label,
validator: val =>
val.length > 0 && (val.length < MAX_LABEL_LENGTH || ShapeDefinition.isValidShortKey(val)),
});
const dialog = new DialogWithForm({
app: this.root.app,
title: T.dialogs.editMarker.title,
desc: T.dialogs.editMarker.desc,
formElements: [markerNameInput],
extraButton: "delete:bad",
});
this.root.hud.parts.dialogs.internalShowDialog(dialog);
dialog.buttonSignals.ok.add(() => {
// Actually rename the waypoint
this.renameWaypoint(waypoint, markerNameInput.getValue());
});
dialog.buttonSignals.delete.add(() => {
// Actually delete the waypoint
this.deleteWaypoint(waypoint);
});
}
/**
* Renames a waypoint with the given label
* @param {Waypoint} waypoint
* @param {string} label
*/
renameWaypoint(waypoint, label) {
waypoint.label = label;
this.sort();
// Show notification about renamed
this.root.hud.signals.notification.dispatch(
T.ingame.waypoints.creationSuccessNotification,
enumNotificationType.success
);
// Re-render the list and thus add it
this.rerenderWaypointList();
}
/**
* Called every frame to update stuff
*/
@ -387,7 +440,7 @@ export class HUDWaypoints extends BaseHUDPart {
} else if (button === enumMouseButton.right) {
if (this.isWaypointDeletable(waypoint)) {
this.root.soundProxy.playUiClick();
this.deleteWaypoint(waypoint);
this.requestEditMarker(waypoint);
} else {
this.root.soundProxy.playUiError();
}

@ -284,6 +284,10 @@ dialogs:
title: New Marker
desc: Give it a meaningful name, you can also include a <strong>short key</strong> of a shape (Which you can generate <a href="https://viewer.shapez.io" target="_blank">here</a>)
editMarker:
title: Edit Marker
desc: Give it a new meaningful name, you can also include a <strong>short key</strong> of a shape (Which you can generate <a href="https://viewer.shapez.io" target="_blank">here</a>)
markerDemoLimit:
desc: You can only create two custom markers in the demo. Get the standalone for unlimited markers!

@ -255,6 +255,10 @@ dialogs:
title: マーカーを設置
desc: わかりやすい名前をつけてください。形を表す<strong>短いキー</strong>を含めることもできます。(<a href="https://viewer.shapez.io" target="_blank">ここ</a>から生成できます)
editMarker:
title: マーカーを編集
desc: わかりやすい名前をつけてください。形を表す<strong>短いキー</strong>を含めることもできます。(<a href="https://viewer.shapez.io" target="_blank">ここ</a>から生成できます)
markerDemoLimit:
desc: デモ版ではマーカー設置は2つまでに制限されています。スタンドアローン版は無制限です

Loading…
Cancel
Save