Refactor App.tsx to use completeCreation function
This commit is contained in:
@@ -1386,6 +1386,11 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
setStatusMessage(status);
|
setStatusMessage(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const completeCreation = (status: string) => {
|
||||||
|
store.setToolMode("select");
|
||||||
|
setStatusMessage(status);
|
||||||
|
};
|
||||||
|
|
||||||
const beginBoxCreation = () => {
|
const beginBoxCreation = () => {
|
||||||
beginCreation(
|
beginCreation(
|
||||||
{
|
{
|
||||||
@@ -1550,7 +1555,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createCreateBoxBrushCommand(center === undefined ? {} : { center })
|
createCreateBoxBrushCommand(center === undefined ? {} : { center })
|
||||||
);
|
);
|
||||||
setStatusMessage(
|
completeCreation(
|
||||||
center === undefined
|
center === undefined
|
||||||
? `Created a box brush snapped to the ${DEFAULT_GRID_SIZE}m grid.`
|
? `Created a box brush snapped to the ${DEFAULT_GRID_SIZE}m grid.`
|
||||||
: `Created a box brush at snapped center ${formatVec3(center)}.`
|
: `Created a box brush at snapped center ${formatVec3(center)}.`
|
||||||
@@ -1580,7 +1585,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: `Place ${asset.sourceName}`
|
label: `Place ${asset.sourceName}`
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage(`Placed ${asset.sourceName}.`);
|
completeCreation(`Placed ${asset.sourceName}.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1596,7 +1601,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place point light"
|
label: "Place point light"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Point Light.");
|
completeCreation("Placed Point Light.");
|
||||||
return;
|
return;
|
||||||
case "spotLight":
|
case "spotLight":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
@@ -1607,7 +1612,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place spot light"
|
label: "Place spot light"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Spot Light.");
|
completeCreation("Placed Spot Light.");
|
||||||
return;
|
return;
|
||||||
case "playerStart":
|
case "playerStart":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
@@ -1618,7 +1623,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place player start"
|
label: "Place player start"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Player Start.");
|
completeCreation("Placed Player Start.");
|
||||||
return;
|
return;
|
||||||
case "soundEmitter": {
|
case "soundEmitter": {
|
||||||
const placedAudioAssetId = creationPreview.target.audioAssetId ?? audioAssetList[0]?.id ?? null;
|
const placedAudioAssetId = creationPreview.target.audioAssetId ?? audioAssetList[0]?.id ?? null;
|
||||||
@@ -1632,7 +1637,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place sound emitter"
|
label: "Place sound emitter"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage(
|
completeCreation(
|
||||||
placedAudioAssetId === null
|
placedAudioAssetId === null
|
||||||
? "Placed Sound Emitter."
|
? "Placed Sound Emitter."
|
||||||
: `Placed Sound Emitter using ${editorState.document.assets[placedAudioAssetId]?.sourceName ?? "the authored audio asset"}.`
|
: `Placed Sound Emitter using ${editorState.document.assets[placedAudioAssetId]?.sourceName ?? "the authored audio asset"}.`
|
||||||
@@ -1648,7 +1653,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place trigger volume"
|
label: "Place trigger volume"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Trigger Volume.");
|
completeCreation("Placed Trigger Volume.");
|
||||||
return;
|
return;
|
||||||
case "teleportTarget":
|
case "teleportTarget":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
@@ -1659,7 +1664,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place teleport target"
|
label: "Place teleport target"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Teleport Target.");
|
completeCreation("Placed Teleport Target.");
|
||||||
return;
|
return;
|
||||||
case "interactable":
|
case "interactable":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
@@ -1670,7 +1675,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
label: "Place interactable"
|
label: "Place interactable"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setStatusMessage("Placed Interactable.");
|
completeCreation("Placed Interactable.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user