|
@@ -1,6 +1,6 @@
|
|
|
-import { _decorator, Button, Component, EditBox, instantiate, Node, ScrollView, UITransform, Vec2, Vec3 } from 'cc';
|
|
|
+import { _decorator, Button, Component, EditBox, instantiate, Label, Node, ScrollView, UITransform, Vec2, Vec3 } from 'cc';
|
|
|
import { LayerMgr } from '../../script/Manager/LayerMgr';
|
|
|
-import { allMapList, getAllMapKeys, MapData, SuperFind, UserMap } from '../../script/Manager/LocalDataMgr';
|
|
|
+import { allMapList, getAllMapKeys, getOneTypeImgKeyList, imgTypeList, MapData, MapItemData, SuperFind, UserMap } from '../../script/Manager/LocalDataMgr';
|
|
|
import { MapItem } from './MapItem';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
@@ -18,22 +18,28 @@ export class SelectMapPanel extends Component {
|
|
|
editBox:EditBox = null;
|
|
|
@property(Button)
|
|
|
btnTurn:Button = null;
|
|
|
-
|
|
|
+ @property(Button)
|
|
|
+ btnAll:Button = null;
|
|
|
+ @property(Node)
|
|
|
+ btnsMoreContent:Node = null;
|
|
|
+ @property(Node)
|
|
|
+ selectTypeBtns:Node = null
|
|
|
_mapData:MapData = null
|
|
|
- _allMapList:{ [key: number]: string };
|
|
|
+ _allMapList:{ [key: number]: MapItemData };
|
|
|
_items: Node[] = [];
|
|
|
_hasCreatedItems:boolean = false;
|
|
|
protected start(): void {
|
|
|
this.btnClose.node.on(Node.EventType.TOUCH_END,this.onBtnCloseClick,this)
|
|
|
this.btnTurn.node.on(Node.EventType.TOUCH_END,this.scrollToItem,this)
|
|
|
+ this.btnAll.node.on(Node.EventType.TOUCH_END,this.onBtnAllClick,this)
|
|
|
}
|
|
|
|
|
|
- init() {
|
|
|
+ init(mapList:number[] = null) {
|
|
|
if(this._hasCreatedItems) return;
|
|
|
this._hasCreatedItems = true;
|
|
|
this._allMapList = allMapList
|
|
|
this._mapData = UserMap.getMapData()
|
|
|
- let allMapKeys = getAllMapKeys()
|
|
|
+ let allMapKeys = mapList? mapList : getAllMapKeys()
|
|
|
let count = allMapKeys.length;
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
this.createItem(allMapKeys[i]);
|
|
@@ -56,8 +62,9 @@ export class SelectMapPanel extends Component {
|
|
|
|
|
|
judgeSelect(key)
|
|
|
{
|
|
|
- let selMaps = this._mapData.selectedMaps
|
|
|
+ let selMaps = UserMap.getMapData().selectedMaps
|
|
|
let index = selMaps.indexOf(key)
|
|
|
+ console.log("key",key,"存在",index !== -1)
|
|
|
return index !== -1
|
|
|
}
|
|
|
|
|
@@ -116,6 +123,56 @@ export class SelectMapPanel extends Component {
|
|
|
// 滚动到该偏移量
|
|
|
this.scrollView.scrollToOffset(new Vec2(0, offset), 0.5);
|
|
|
}
|
|
|
+
|
|
|
+ reset(type:string)
|
|
|
+ {
|
|
|
+ this.clearItems()
|
|
|
+ let mapList = getOneTypeImgKeyList(type)
|
|
|
+ this.init(mapList)
|
|
|
+ }
|
|
|
+
|
|
|
+ clearItems()
|
|
|
+ {
|
|
|
+ this._items.forEach((item)=>{
|
|
|
+ item.destroy()
|
|
|
+ })
|
|
|
+ this._items = []
|
|
|
+ this._hasCreatedItems = false
|
|
|
+ }
|
|
|
+
|
|
|
+ onBtnAllClick()
|
|
|
+ {
|
|
|
+ this.selectTypeBtns.active = true
|
|
|
+ this.appearMoreBtns()
|
|
|
+ }
|
|
|
+
|
|
|
+ typeBtns:Node[] = []
|
|
|
+ appearMoreBtns()
|
|
|
+ {
|
|
|
+ if(this.typeBtns.length > 0)
|
|
|
+ {
|
|
|
+ this.selectTypeBtns.active = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let count = imgTypeList.length
|
|
|
+ for(let i = 0; i < count; i++){
|
|
|
+ let itemNode = instantiate(this.btnAll.node);
|
|
|
+ itemNode.parent = this.btnsMoreContent;
|
|
|
+ itemNode.setPosition(0,0,0)
|
|
|
+ itemNode.getComponentInChildren(Label).string = imgTypeList[i]
|
|
|
+ this.typeBtns.push(itemNode)
|
|
|
+ }
|
|
|
+ this.typeBtns.forEach((item)=>{
|
|
|
+ item.on(Node.EventType.TOUCH_END,this.onBtnTypeClick,this)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ onBtnTypeClick(event: Event) {
|
|
|
+ let item = event.target as unknown as Node
|
|
|
+ let type = item.getComponentInChildren(Label).string
|
|
|
+ this.reset(type)
|
|
|
+ this.selectTypeBtns.active = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|