fix: make clear blocks dialog not change coords and scale
This commit is contained in:
parent
efe2d00339
commit
1ab5955ada
2 changed files with 2 additions and 10 deletions
|
|
@ -6,18 +6,10 @@ import { DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTit
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
function ClearBlocks({ close }: DialogProps) {
|
function ClearBlocks({ close }: DialogProps) {
|
||||||
const { stageSize, setBlocks, setCoords, setScale } = useContext(CanvasContext);
|
const { setBlocks } = useContext(CanvasContext);
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
const newScale = 8;
|
|
||||||
const blockCenter = (1 + 1 * 16) / 2;
|
|
||||||
|
|
||||||
setBlocks([{ name: "bedrock", x: 0, y: 0 }]);
|
setBlocks([{ name: "bedrock", x: 0, y: 0 }]);
|
||||||
setCoords({
|
|
||||||
x: stageSize.width / 2 - blockCenter * newScale,
|
|
||||||
y: stageSize.height / 2 - blockCenter * newScale,
|
|
||||||
});
|
|
||||||
setScale(newScale);
|
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ function FileMenu() {
|
||||||
<MenubarSeparator />
|
<MenubarSeparator />
|
||||||
|
|
||||||
<MenubarItem onClick={() => openDialog("SetVersion")}>Set Version</MenubarItem>
|
<MenubarItem onClick={() => openDialog("SetVersion")}>Set Version</MenubarItem>
|
||||||
<MenubarItem onClick={() => openDialog("ClearBlocks")}>Clear All Blocks</MenubarItem>
|
<MenubarItem onClick={() => openDialog("ClearBlocks")}>Clear Blocks</MenubarItem>
|
||||||
</MenubarContent>
|
</MenubarContent>
|
||||||
</MenubarMenu>
|
</MenubarMenu>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue