Add preview controls

This commit is contained in:
Misode
2020-11-30 02:35:38 +01:00
parent f08fedc206
commit 2688f4bc85
8 changed files with 49 additions and 24 deletions

View File

@@ -1,5 +1,8 @@
import { DataModel, Path, ModelPath } from "@mcschema/core"
import { App } from "../App"
import { Octicon } from "../components/Octicon"
import { Property } from "../state/Property"
import { View } from "../views/View"
import { NormalNoise } from './NormalNoise'
import { Preview } from './Preview'
@@ -31,6 +34,22 @@ export class BiomeNoisePreview extends Preview {
&& path.push('type').get() === 'minecraft:multi_noise'
}
menu(view: View, redraw: () => void) {
return `
<div class="btn" data-id="${view.onClick(() => {
this.viewScale -= 0.5
redraw()
})}">
${Octicon.plus}
</div>
<div class="btn" data-id="${view.onClick(() => {
this.viewScale += 0.5
redraw()
})}">
${Octicon.dash}
</div>`
}
draw(model: DataModel, img: ImageData) {
this.noise = BiomeNoisePreview.noiseMaps.map((id, i) => {
const config = this.state[`${id}_noise`]

View File

@@ -1,4 +1,5 @@
import { DataModel, ModelPath } from "@mcschema/core"
import { View } from "../views/View"
export abstract class Preview {
state: any
@@ -8,6 +9,10 @@ export abstract class Preview {
return JSON.stringify(this.state) !== JSON.stringify(path.get())
}
menu(view: View, redraw: () => void): string {
return ''
}
abstract getName(): string
abstract active(path: ModelPath): boolean
abstract draw(model: DataModel, img: ImageData): void