import { _decorator, Component, Node, Toggle } from 'cc'; import { GameUILayers, gui } from 'db://assets/core/ui/ui'; import ui_base from 'db://assets/core/ui/ui_base'; import { ModuleDef } from 'db://assets/Scripts/ModuleDef'; import { Layout_Rank } from './Layout_Rank'; import { ani_ui } from '../UI_Main/UI_Main'; const { ccclass, property } = _decorator; type page = 1 | 2;//1总榜2好友榜 let type: page = 1; @ccclass('UI_Rank') export class UI_Rank extends ui_base { constructor() { super(ModuleDef.GAME, 'ui/UI_Rank/Rank', GameUILayers.HUD,Layout_Rank); } protected async onCreated() { const layout = this.getLayout(); ani_ui(layout.Close_Btn.node.parent); this.onButtonEvent(layout.Close_Btn, async (button: any) => { //关闭设置界面 gui.close(UI_Rank); }, this); layout.onList1 = (item: Node, index: number) => { // item.getComponent(ui_skin_item).showInfo(index + 1, this._data1[index]); } layout.onList2 = (item: Node, index: number) => { // item.getComponent(ui_skin_block).showInfo(index + 1, this._data2[index]); } layout.list1.numItems = type == 1 ? 10 : 0; layout.list2.numItems = type == 2 ? 10 : 0; layout.Rank_Toggle_1.isChecked = type == 1; layout.Rank_Toggle_2.isChecked = type == 2; this.show(); this.onToggleEvent(layout.Rank_Toggle_1, (tg: Toggle, i: page) => { if (tg.isChecked) this.show(i) }, this, 1); this.onToggleEvent(layout.Rank_Toggle_2, (tg: Toggle, i: page) => { if (tg.isChecked) this.show(i) }, this, 2); } private async show(t?: null | page) { if (t != null) { if (t == type) return; type = t; // button_sound(); } const layout = this.getLayout(); layout.list1.numItems = type == 1 ? 10: 0; layout.list2.numItems = type == 2 ? 10: 0; layout.list1.node.active = type == 1; layout.list2.node.active = type == 2; } }