Add undo-redo
This commit is contained in:
18
sheet.ts
18
sheet.ts
@ -1,5 +1,5 @@
|
||||
import { getCart } from "./cart.ts";
|
||||
import { runCode, addToContext } from "./runcode.ts";
|
||||
// import { runCode, addToContext } from "./runcode.ts";
|
||||
|
||||
// "code" | "spritesheet" | "map" | "sfx" | "patterns" | "fonts"
|
||||
export type Sheet = {
|
||||
@ -20,12 +20,20 @@ export const setSheet = (n: number, type: SheetType, value: any) => {
|
||||
return getCart()[n] = {sheet_type: type, value};
|
||||
}
|
||||
|
||||
export const codeSheet = (sheet: number) => {
|
||||
export const getCodeSheet = (sheet: number) => {
|
||||
const {sheet_type, value} = getSheet(sheet);
|
||||
if (sheet_type !== "code") {
|
||||
throw "Trying to run a non-code sheet as code."
|
||||
throw "Trying to use a non-code sheet as code."
|
||||
}
|
||||
return runCode(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
addToContext("code_sheet", codeSheet);
|
||||
export const getSpriteSheet = (sheet: number) => {
|
||||
const {sheet_type, value} = getSheet(sheet);
|
||||
if (sheet_type !== "spritesheet") {
|
||||
throw "Trying to use a non-sprite sheet as a spritesheet."
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// addToContext("code", codeSheet);
|
Reference in New Issue
Block a user