Add trash button to delete sheet
This commit is contained in:
		
							
								
								
									
										22
									
								
								editmode.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								editmode.ts
									
									
									
									
									
								
							| @@ -6,8 +6,8 @@ import { COLOR } from "./colors.ts"; | |||||||
| import { mouseClick, mousePos } from "./mouse.ts"; | import { mouseClick, mousePos } from "./mouse.ts"; | ||||||
| import { drawIcon } from "./builtins.ts"; | import { drawIcon } from "./builtins.ts"; | ||||||
| import { inRect } from "./util.ts"; | import { inRect } from "./util.ts"; | ||||||
| import { sheetsIcon } from "./icons.ts"; | import { sheetsIcon, trashIcon } from "./icons.ts"; | ||||||
| import { SheetType } from "./sheet.ts"; | import { SheetType, setSheet } from "./sheet.ts"; | ||||||
| import { nonetab } from "./nonetab.ts"; | import { nonetab } from "./nonetab.ts"; | ||||||
|  |  | ||||||
| type TabName = SheetType; // "code" | "sprite" | "map" | "sfx" | "music" | "sheet"; | type TabName = SheetType; // "code" | "sprite" | "map" | "sfx" | "music" | "sheet"; | ||||||
| @@ -29,9 +29,27 @@ const makeTabButton = (tabname: TabName | "sheet", x: number, y: number, icon: A | |||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const makeTrashButton = (x: number, y: number, icon: Array<number>) => { | ||||||
|  | 	buttons.push({ | ||||||
|  | 		update() { | ||||||
|  | 			if (mouseClick()) { | ||||||
|  | 				const {x: mouseX, y: mouseY} = mousePos(); | ||||||
|  | 				if (inRect(mouseX, mouseY, x, y, 8, 8)) { | ||||||
|  | 					setSheet(page.activeSheet, "none", null); | ||||||
|  | 					page.tab = "sheet"; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}, | ||||||
|  | 		draw() { | ||||||
|  | 			drawIcon(x, y, icon, COLOR.BLACK); | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  | } | ||||||
|  |  | ||||||
| // makeTabButton("code", 88, 0, codeIcon); | // makeTabButton("code", 88, 0, codeIcon); | ||||||
| // makeTabButton("sprite", 88+8, 0, spriteIcon); | // makeTabButton("sprite", 88+8, 0, spriteIcon); | ||||||
| makeTabButton("sheet", 120, 0, sheetsIcon); | makeTabButton("sheet", 120, 0, sheetsIcon); | ||||||
|  | makeTrashButton(0, 0, trashIcon); | ||||||
|  |  | ||||||
| const update = () => { | const update = () => { | ||||||
| 	buttons.forEach(button => button.update()); | 	buttons.forEach(button => button.update()); | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								icons.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								icons.ts
									
									
									
									
									
								
							| @@ -30,3 +30,14 @@ export const sheetsIcon = [ | |||||||
| 	0, 1, 1, 0, 0, 1, 1, 0, | 	0, 1, 1, 0, 0, 1, 1, 0, | ||||||
| 	0, 0, 0, 0, 0, 0, 0, 0, | 	0, 0, 0, 0, 0, 0, 0, 0, | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
|  | export const trashIcon = [ | ||||||
|  | 	0, 0, 0, 0, 0, 0, 0, 0, | ||||||
|  | 	0, 0, 0, 1, 1, 0, 0, 0, | ||||||
|  | 	0, 1, 1, 1, 1, 1, 1, 0, | ||||||
|  | 	0, 0, 0, 0, 0, 0, 0, 0, | ||||||
|  | 	0, 0, 1, 1, 1, 1, 0, 0, | ||||||
|  | 	0, 0, 1, 1, 1, 1, 0, 0, | ||||||
|  | 	0, 0, 1, 1, 1, 1, 0, 0, | ||||||
|  | 	0, 0, 0, 0, 0, 0, 0, 0, | ||||||
|  | ]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 dylan
					dylan