// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import * as cc from "cc";
import cp_palette from "./cp_palette";

const { ccclass, property } = cc._decorator;

@ccclass('control')
export class control extends cc.Component {

    @property(cp_palette)
    cp_palette: cp_palette = null;

    @property(cc.Slider)
    slider: cc.Slider = null;

    onLoad() {
        this.cp_palette.hide();
        this.slider.progress = this.cp_palette.density / 64;
    }

    on_change_slider(slider: cc.Slider): void {
        this.cp_palette.density = Math.floor(slider.progress * 15) * 4 + 4;
        this.cp_palette.update_all();
    }

}
