123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import { _decorator, Component, EditBox, instantiate, Node, Prefab } from 'cc';
- import { config } from '../../config';
- import { add_event_item } from './add_event_item';
- import { tools } from '../../tools';
- const { ccclass, property } = _decorator;
- @ccclass('add_event')
- export class add_event extends Component {
- @property(Node) content:Node = null;
- @property(Node) btn_close:Node = null;
- @property(Prefab) item_prefab:Prefab = null;
- @property(Node) btn_add:Node = null;
- @property(Node) btn_cancel:Node = null;
- @property(EditBox) edit:EditBox = null;
- @property(Node) input_event_name:Node = null;
- private call_back = null;
- private select_type:number = 0;
- public show(call){
- this.call_back = call;
- this.input_event_name.active = false;
- config.event_type_map.forEach((v,k)=>{
- let item = instantiate(this.item_prefab)
- item.parent = this.content;
- item.getComponent(add_event_item).initView(k,this.onItemClick.bind(this))
- })
- this.btn_close.on(Node.EventType.TOUCH_END,()=>{
- this.close()
- })
- this.btn_add.on(Node.EventType.TOUCH_END,()=>{
- if(this.edit.string.length>0){
- if(this.call_back!=null){
- this.call_back(this.select_type,this.edit.string)
- }
- this.close()
- }else{
- tools.showToast("请输入事件名字")
- }
-
- })
- this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
- this.input_event_name.active = false;
- })
- }
- onItemClick(type:number){
- this.select_type = type;
- this.input_event_name.active = true;
- }
- close(){
- this.node.destroy()
- }
- }
|