UIDialog.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { GameMng } from "../GameMng";
  2. import { UIButton } from "../gcommon/UIButton";
  3. import GBaseUI from "../gcommon/GBaseUI";
  4. import { UIManager } from "../gcommon/UIManager";
  5. import { _decorator,Node, Label } from "cc";
  6. const {ccclass, property} = _decorator;
  7. @ccclass
  8. export default class UIDialog extends GBaseUI {
  9. @property(Label)
  10. lab_des: Node = null;
  11. @property(Node)
  12. btn_queding: Node = null;
  13. @property(Node)
  14. btn_quxiao: Node = null;
  15. static dialog_des:string = null;
  16. static isShowCancel:boolean = true;
  17. static Show(sureCb:any,cancelCb:any,str:any,parent?:Node,isShowCancel?:boolean){
  18. UIDialog.dialog_des = str;
  19. UIDialog.isShowCancel = isShowCancel;
  20. UIDialog.DialogCancelCall = cancelCb
  21. UIDialog.DialogSureCall = sureCb
  22. UIManager.AddPrefab(GameMng.Instance.uiDialog,parent);
  23. }
  24. start () {
  25. this.btn_quxiao.active = UIDialog.isShowCancel;
  26. UIButton.BindClick(this.btn_queding,()=>{
  27. this.closeUI();
  28. UIDialog.DialogSureCall()
  29. },this);
  30. UIButton.BindClick(this.btn_quxiao,()=>{
  31. this.closeUI();
  32. UIDialog.DialogCancelCall()
  33. },this);
  34. }
  35. update(dt){
  36. if(UIDialog.dialog_des!=null){
  37. this.lab_des.getComponent(Label).string = UIDialog.dialog_des.toString()
  38. UIDialog.dialog_des = null;
  39. }
  40. }
  41. static DialogSureCall(){
  42. }
  43. static DialogCancelCall(){
  44. }
  45. }