|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, instantiate, Node, Prefab, Vec3 } from 'cc';
|
|
|
+import { _decorator, Component, EditBox, instantiate, Node, Prefab, Vec3 } from 'cc';
|
|
|
import { config } from '../../config';
|
|
|
import { edit_event_view_select_btn } from './edit_event_view_select_btn';
|
|
|
import { Attributes } from '../Attributes';
|
|
@@ -7,6 +7,7 @@ import { event_item_view } from './event_item_view';
|
|
|
import { control } from '../control';
|
|
|
import { main } from '../../main';
|
|
|
import { ClientEvent } from '../../clientEvent';
|
|
|
+import { tools } from '../../tools';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('edit_event_view')
|
|
@@ -16,7 +17,21 @@ export class edit_event_view extends Component {
|
|
|
@property(Node) content:Node = null;
|
|
|
@property(Node) type_content:Node = null;
|
|
|
@property(Node) type_btn:Node = null;
|
|
|
+ @property(Node) search_node:Node = null;
|
|
|
+ @property(Node) search_editbox:Node = null;
|
|
|
+ @property(Node) search_btn_search:Node = null;
|
|
|
private m_cur_select_type:number = -1;
|
|
|
+ private m_search_item_list:event_item[] = []
|
|
|
+ protected start(): void {
|
|
|
+ this.search_btn_search.on(Node.EventType.TOUCH_END, ()=> {
|
|
|
+ let id_string = tools.trimLeftAndRightblank(this.search_editbox.getComponent(EditBox).string)
|
|
|
+ this.search_editbox.getComponent(EditBox).string = id_string
|
|
|
+ if(id_string.length<0) {
|
|
|
+ return tools.showToast('请输入id')
|
|
|
+ }
|
|
|
+ this.searchAction(id_string)
|
|
|
+ },this)
|
|
|
+ }
|
|
|
public show(){
|
|
|
this.btn_close.on(Node.EventType.TOUCH_END,()=>{
|
|
|
this.node.removeFromParent()
|
|
@@ -27,6 +42,12 @@ export class edit_event_view extends Component {
|
|
|
btn.getComponent(edit_event_view_select_btn).initView(-1,"全部",this.onTypeItemClick.bind(this))
|
|
|
btn.getComponent(edit_event_view_select_btn).selectStatus()
|
|
|
btn.parent = this.type_content
|
|
|
+
|
|
|
+ let btn_search = instantiate(this.type_btn)
|
|
|
+ btn_search.getComponent(edit_event_view_select_btn).initView(-2,"搜索",this.onTypeItemClick.bind(this))
|
|
|
+ btn_search.getComponent(edit_event_view_select_btn).unselectStatus()
|
|
|
+ btn_search.parent = this.type_content
|
|
|
+
|
|
|
config.event_type_map.forEach((v,k)=>{
|
|
|
let item = instantiate(this.type_btn)
|
|
|
item.parent = this.type_content
|
|
@@ -54,7 +75,16 @@ export class edit_event_view extends Component {
|
|
|
|
|
|
updateView(){
|
|
|
this.content.removeAllChildren()
|
|
|
- let list = this.getEventListByType()
|
|
|
+
|
|
|
+ let list;
|
|
|
+ if(this.m_cur_select_type == -2) {
|
|
|
+ this.search_node.active = true
|
|
|
+ list = this.m_search_item_list
|
|
|
+ } else {
|
|
|
+ this.search_node.active = false
|
|
|
+ list = this.getEventListByType()
|
|
|
+ }
|
|
|
+
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
const element = list[index];
|
|
|
let item = instantiate(this.event_item_prefab)
|
|
@@ -62,6 +92,7 @@ export class edit_event_view extends Component {
|
|
|
item.getComponent(event_item_view).initView(element.type,element,this.onDeleteItem.bind(this))
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public onDeleteItem(item:event_item){
|
|
|
let task_data = main.Singleton.edit_scene_view.getTaskData()
|
|
|
if(task_data!=null){
|
|
@@ -92,6 +123,42 @@ export class edit_event_view extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ searchAction(idString:string) {
|
|
|
+ // console.log('idString=',idString)
|
|
|
+ this.m_search_item_list.splice(0, this.m_search_item_list.length)
|
|
|
+ this.searchData(parseInt(idString))
|
|
|
+ this.searchCreateItem()
|
|
|
+ }
|
|
|
+
|
|
|
+ private searchData(id:number) {
|
|
|
+ let list = Attributes.Singleton.getEventList()
|
|
|
+ for(let i=0; i<list.length; i++) {
|
|
|
+ const element = list[i]
|
|
|
+ if(element.event_id == id) {
|
|
|
+ // console.log('触发下个事件的id=',element.success.trigger_event_id)
|
|
|
+ this.m_search_item_list.push(element)
|
|
|
+ let trigger_event_id = element.success.trigger_event_id
|
|
|
+ if(trigger_event_id != -1) {
|
|
|
+ this.searchData(trigger_event_id)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.m_search_item_list.length == 0) {
|
|
|
+ tools.showToast('搜索的id不存在')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private searchCreateItem() {
|
|
|
+ this.content.removeAllChildren()
|
|
|
+ for (let index = 0; index < this.m_search_item_list.length; index++) {
|
|
|
+ const element = this.m_search_item_list[index];
|
|
|
+ let item = instantiate(this.event_item_prefab)
|
|
|
+ item.parent = this.content;
|
|
|
+ item.getComponent(event_item_view).initView(element.type,element,this.onDeleteItem.bind(this))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|