2025-05-28 18:47:51 +08:00
|
|
|
import { respath } from "../constants/respath"
|
2025-06-05 17:00:48 +08:00
|
|
|
import { ResourceManager } from "../models/ResourceManager"
|
2025-05-28 18:47:51 +08:00
|
|
|
import { UIManager } from "../models/UIManager"
|
2025-06-06 16:05:54 +08:00
|
|
|
import { Utility_EaseOut, Utility_EaseOut_2 } from "../utils/utility"
|
|
|
|
|
|
2025-05-26 19:57:17 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
const { regClass, property } = Laya
|
2025-05-26 19:57:17 +08:00
|
|
|
|
|
|
|
|
export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
|
2025-06-05 17:00:48 +08:00
|
|
|
ResourceManager.getInstance().loadPrefab(respath.common_tips_ui_res, (go: any)=> {
|
2025-05-28 18:47:51 +08:00
|
|
|
const prefab = go.create()
|
|
|
|
|
const obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips)
|
|
|
|
|
obj.showCommonTips(title, content, showToggle, func)
|
|
|
|
|
})
|
2025-05-26 19:57:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@regClass()
|
|
|
|
|
export class CommonTips extends Laya.Script {
|
2025-05-28 18:47:51 +08:00
|
|
|
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
|
|
|
|
|
|
2025-06-06 16:05:54 +08:00
|
|
|
private mask: Laya.Image
|
|
|
|
|
private center: Laya.Box
|
|
|
|
|
|
|
|
|
|
onAwake(): void {
|
|
|
|
|
this.mask = this.owner.getChildByName("Image") as Laya.Image
|
|
|
|
|
this.mask.alpha = 0
|
|
|
|
|
Laya.Tween.to(this.mask, {alpha: 0.6}, 400, Utility_EaseOut)
|
|
|
|
|
|
|
|
|
|
this.center = this.owner.getChildByName("center") as Laya.Box
|
|
|
|
|
this.center.scaleX = 0.8
|
|
|
|
|
this.center.scaleY = 0.8
|
|
|
|
|
Laya.Tween.to(this.center, {scaleX: 1, scaleY: 1}, 400, Utility_EaseOut)
|
|
|
|
|
this.center.alpha = 0
|
|
|
|
|
Laya.Tween.to(this.center, {alpha: 1}, 400, Utility_EaseOut)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
destroyUI(): void {
|
|
|
|
|
Laya.Tween.to(this.mask, {alpha: 0}, 400, Utility_EaseOut_2)
|
|
|
|
|
Laya.Tween.to(this.center, {scaleX: 0.8, scaleY: 0.8}, 400, Utility_EaseOut_2)
|
|
|
|
|
Laya.Tween.to(this.center, {alpha: 0}, 400, Utility_EaseOut_2, Laya.Handler.create(this, () => {
|
|
|
|
|
this.owner.destroy()
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
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)
|
|
|
|
|
}
|
2025-06-06 16:05:54 +08:00
|
|
|
this.destroyUI()
|
2025-05-28 18:47:51 +08:00
|
|
|
})
|
|
|
|
|
this.btn_cancel.on(Laya.Event.CLICK, this, () => {
|
|
|
|
|
if (func) {
|
|
|
|
|
func(false, this.isChecked)
|
|
|
|
|
}
|
2025-06-06 16:05:54 +08:00
|
|
|
this.destroyUI()
|
|
|
|
|
})
|
|
|
|
|
this.mask.on(Laya.Event.CLICK, this, () => {
|
|
|
|
|
this.destroyUI()
|
2025-05-28 18:47:51 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|