12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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';
- import PlayerData from '../../game/PlayerData';
- import { ch } from 'db://assets/ch/ch';
- import { UIWaiting } from 'db://assets/module_basic/ui_waiting/UIWaiting';
- import { Hall } from 'db://assets/Scripts/Hall';
- const { ccclass, property } = _decorator;
- type page = 1 | 2;//1总榜2好友榜
- let type: page = 1;
- @ccclass('UI_Rank')
- export class UI_Rank extends ui_base {
- private _owner: { head: string, nickName: string, score: number, userId: number, [key: string]: any };
- private _data: { head: string, nickName: string, score: number, userId: number, [key: string]: any }[];
- constructor() {
- super(ModuleDef.GAME, 'ui/UI_Rank/Rank', GameUILayers.HUD, Layout_Rank);
- }
- protected async onCreated() {
- const layout = this.getLayout<Layout_Rank>();
- 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_Rank>();
- await gui.show(UIWaiting);
- if (type == 1) {
- layout.list1.node.active =true;
- layout.list1.numItems = 0;
- const d = await Hall.getInstance().player.get_rank_floor();
- this._data = d.list;
- this._owner = d.owner;
- let index = d.index;
- layout.list1.numItems=this._data.length;
- if(!this._owner){
- this._owner = { head: Hall.getInstance().player.avatarUrl,nickName:Hall.getInstance().player.nickName, score: 0, userId:0,province:Hall.getInstance().player.user_info.province };
- // layout.own_item.showInfo(index, type, this._ower, true);
- }
- gui.close(UIWaiting);
- }
- if(type == 2){
- layout.list2.node.active = true;
- }
- }
- }
|