mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
refactor: add affixes to variable names in selection context
This commit is contained in:
parent
634b6c24cb
commit
df016ddf74
6 changed files with 28 additions and 24 deletions
|
|
@ -31,12 +31,7 @@ PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
|
|||
|
||||
function Canvas() {
|
||||
const { stageSize, canvasSize, blocks, coords, scale, version, setStageSize, setBlocks, setCoords, setScale } = useContext(CanvasContext);
|
||||
const {
|
||||
coords: selectionCoords,
|
||||
layerBlocks: selectionLayerBlocks,
|
||||
setCoords: setSelectionCoords,
|
||||
setLayerBlocks: setSelectionLayerBlocks,
|
||||
} = useContext(SelectionContext);
|
||||
const { selectionCoords, selectionLayerBlocks, setSelectionCoords, setSelectionLayerBlocks } = useContext(SelectionContext);
|
||||
const { settings } = useContext(SettingsContext);
|
||||
const { missingTexture } = useContext(TexturesContext);
|
||||
const { isDark } = useContext(ThemeContext);
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ import { Button } from "@/components/ui/button";
|
|||
|
||||
function SelectionBar() {
|
||||
const { blocks, setBlocks } = useContext(CanvasContext);
|
||||
const { layerBlocks, setLayerBlocks } = useContext(SelectionContext);
|
||||
const { selectionLayerBlocks, setSelectionLayerBlocks } = useContext(SelectionContext);
|
||||
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setIsVisible(layerBlocks.length !== 0);
|
||||
}, [layerBlocks]);
|
||||
setIsVisible(selectionLayerBlocks.length !== 0);
|
||||
}, [selectionLayerBlocks]);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -25,11 +25,11 @@ function SelectionBar() {
|
|||
`}
|
||||
>
|
||||
{/* todo: place back blocks removed */}
|
||||
<Button variant="ghost" className="w-8 h-8" onClick={() => setLayerBlocks([])}>
|
||||
<Button variant="ghost" className="w-8 h-8" onClick={() => setSelectionLayerBlocks([])}>
|
||||
<XIcon />
|
||||
</Button>
|
||||
<span className="mx-2 text-[0.85rem]">Confirm selection?</span>
|
||||
<Button variant="ghost" className="w-8 h-8" onClick={() => selection.confirm(blocks, layerBlocks, setBlocks, setLayerBlocks)}>
|
||||
<Button variant="ghost" className="w-8 h-8" onClick={() => selection.confirm(blocks, selectionLayerBlocks, setBlocks, setSelectionLayerBlocks)}>
|
||||
<CheckIcon />
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarShor
|
|||
|
||||
function EditMenu() {
|
||||
const { blocks, setBlocks } = useContext(CanvasContext);
|
||||
const { coords: selectionCoords, setCoords: setSelectionCoords, setLayerBlocks: setSelectionLayerBlocks } = useContext(SelectionContext);
|
||||
const { selectionCoords, setSelectionCoords, setSelectionLayerBlocks } = useContext(SelectionContext);
|
||||
const { setTool } = useContext(ToolContext);
|
||||
|
||||
const cut = () => {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import * as selection from "@/utils/selection";
|
|||
|
||||
function SelectMenu() {
|
||||
const { canvasSize } = useContext(CanvasContext);
|
||||
const { coords: selectionCoords, setCoords: setSelectionCoords } = useContext(SelectionContext);
|
||||
const { selectionCoords, setSelectionCoords } = useContext(SelectionContext);
|
||||
|
||||
// Add every block within the canvas size to the temporary array
|
||||
const selectAll = () => {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import * as selection from "@/utils/selection";
|
|||
|
||||
function Replace() {
|
||||
const { version, setBlocks } = useContext(CanvasContext);
|
||||
const { coords: selectionCoords } = useContext(SelectionContext);
|
||||
const { selectionCoords } = useContext(SelectionContext);
|
||||
const { selectedBlock, tool, setTool } = useContext(ToolContext);
|
||||
const { missingTexture } = useContext(TexturesContext);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue