show_copy_scene.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, EditBox, Node, Toggle } from 'cc';
  2. import { tools } from '../tools';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('show_copy_scene')
  5. export class show_copy_scene extends Component {
  6. @property(Node) btn_sure:Node = null;
  7. @property(Node) btn_cancel:Node = null;
  8. @property(Node) editBox_scene_name:Node = null;
  9. @property(Toggle) toggle_copy_only_widget:Toggle = null;
  10. private m_sure_callback:Function = null;
  11. private is_copy_only_widget:boolean = false;
  12. start() {
  13. this.btn_sure.on(Node.EventType.TOUCH_END, ()=> {
  14. if(this.m_sure_callback != null) {
  15. let string = tools.trimLeftAndRightblank(this.editBox_scene_name.getComponent(EditBox).string)
  16. this.editBox_scene_name.getComponent(EditBox).string = string
  17. if(string=='') {
  18. return tools.showToast('请输入场景名称')
  19. }
  20. this.m_sure_callback(string,this)
  21. }
  22. },this)
  23. this.btn_cancel.on(Node.EventType.TOUCH_END, ()=> {
  24. this.close()
  25. },this)
  26. this.toggle_copy_only_widget.node.on(Toggle.EventType.CLICK, ()=>{
  27. this.is_copy_only_widget = this.toggle_copy_only_widget.isChecked
  28. })
  29. this.toggle_copy_only_widget.isChecked = this.getIsCopyOnlyWidget()
  30. }
  31. public getIsCopyOnlyWidget():boolean {
  32. return this.is_copy_only_widget
  33. }
  34. initView(scene_name:string, sure_callback:Function) {
  35. this.m_sure_callback = sure_callback
  36. this.editBox_scene_name.getComponent(EditBox).string = scene_name
  37. }
  38. close() {
  39. this.node.removeFromParent()
  40. }
  41. }