59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
|
|
import { respath } from "../constants/respath";
|
||
|
|
import { UIManager } from "../models/UIManager";
|
||
|
|
|
||
|
|
const { regClass, property } = Laya;
|
||
|
|
|
||
|
|
|
||
|
|
export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
|
||
|
|
Laya.loader.load(respath.common_tips_ui_res).then((go)=>{
|
||
|
|
var prefab = go.create()
|
||
|
|
var obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips)
|
||
|
|
obj.showCommonTips(title, content, showToggle, func)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
@regClass()
|
||
|
|
export class CommonTips extends Laya.Script {
|
||
|
|
declare owner : Laya.Box;
|
||
|
|
|
||
|
|
@property(Laya.Label)
|
||
|
|
public label_title: Laya.Label
|
||
|
|
@property(Laya.Label)
|
||
|
|
public label_content: Laya.Label
|
||
|
|
|
||
|
|
@property(Laya.Box)
|
||
|
|
public btn_ok: Laya.Box
|
||
|
|
@property(Laya.Box)
|
||
|
|
public btn_cancel: Laya.Box
|
||
|
|
|
||
|
|
@property(Laya.Box)
|
||
|
|
public toggle: Laya.Box
|
||
|
|
@property(Laya.Image)
|
||
|
|
public check: Laya.Image
|
||
|
|
private isChecked = false
|
||
|
|
|
||
|
|
public showCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
|
||
|
|
this.label_title.text = title
|
||
|
|
this.label_content.text = content
|
||
|
|
this.toggle.visible = showToggle
|
||
|
|
this.check.visible = false
|
||
|
|
this.toggle.on(Laya.Event.CLICK, this, ()=>{
|
||
|
|
this.isChecked = !this.isChecked
|
||
|
|
this.check.visible = this.isChecked
|
||
|
|
})
|
||
|
|
|
||
|
|
this.btn_ok.on(Laya.Event.CLICK, this, ()=>{
|
||
|
|
if (func) {
|
||
|
|
func(true, this.isChecked)
|
||
|
|
}
|
||
|
|
this.owner.destroy()
|
||
|
|
})
|
||
|
|
this.btn_cancel.on(Laya.Event.CLICK, this, ()=>{
|
||
|
|
if (func) {
|
||
|
|
func(false, this.isChecked)
|
||
|
|
}
|
||
|
|
this.owner.destroy()
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|