/** @format */ import {UI} from '../enums/UI' import {BaseUI} from './BaseUI' import {Data, Mgr} from '../GameControl' import {ccUtils} from '../utils/ccUtils' import {observer, render, node, label, editBox, list} from '../mobx/observer' import {msgCmd} from '../proto/msg_cmd' import {EVENT, LANGUAGE_TYPE} from '../enums/Enum' import {HttpUrl} from '../data/HttpUrl' import List from '../uiutils/List' import {IServer} from '../interface/GlobalInterface' import {i18nLabel} from '../uiutils/i18nLabel' const {ccclass, property} = cc._decorator @ccclass @observer export class ServerUI extends BaseUI { @list('allList') allList: List @list('serverList') serverList: List serverArr: IServer[][] = [] curAllIndex: number = 0 onShow(args, fromUI: number) { this.serverArr.length = 0 this.serverArr.push(Data.main.serverList.filter(v => v.create)) this.serverArr.push(...Data.main.serverList.splitArrBySize(10)) this.allList.numItems = this.serverArr.length this.serverList.numItems = this.serverArr[this.curAllIndex].length } onHide(): any { Mgr.event.removeAll(this) } //UI或者其他函数======================================= initAllItem(node, index) { node['index'] = index cc.find('my', node).active = index == 0 cc.find('lb', node).active = index != 0 cc.find('choose', node).active = index == this.curAllIndex let i18n = cc.find('lb', node).getComponent(i18nLabel) i18n.setParamByIndex(`${(index - 1) * 10 + 1}-${index * 10}`, 0) } initServerItem(node, index) { let server: IServer = this.serverArr[this.curAllIndex][index] node['server'] = server ccUtils.setLabel(server.server_name, node, 'serverName') let serverColor = ['#E2E2E2', '#FF6C00', '#66FF00'] ccUtils.setColor(serverColor[server.state], node, 'dl_piont/block5') cc.find('frame', node).active = server.create } //网络事件======================================= //触发事件======================================= onAllItemClick(e) { this.curAllIndex = e.currentTarget['index'] this.allList.numItems = this.serverArr.length this.serverList.numItems = this.serverArr[this.curAllIndex].length } // 点击事件======================================= onServerClick(e) { Mgr.event.trigger(EVENT.chooseServer, e.currentTarget['server']) this.hide() } }