48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { WALLET_HIDE_ACCOUNT_LIST, WALLET_HIDE_MODAL } from "../common/WalletEvent";
|
|
import { IAccount } from "../data/DataModel";
|
|
import WalletBase from "./WallerBase";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class AccountList extends WalletBase {
|
|
|
|
@property(cc.Node)
|
|
contentNode: cc.Node = null
|
|
|
|
@property(cc.Prefab)
|
|
accountPreb: cc.Prefab = null
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
|
|
start () {
|
|
super.start()
|
|
this.wallet.uiHandlers.on(WALLET_HIDE_ACCOUNT_LIST, this.closeMe.bind(this))
|
|
}
|
|
onEnable() {
|
|
this.showAllAccount()
|
|
}
|
|
|
|
// update (dt) {}
|
|
|
|
showAllAccount() {
|
|
this.contentNode.removeAllChildren()
|
|
let accounts = this.wallet.accounts
|
|
for (let i = 0, l = accounts.length; i < l; i ++) {
|
|
this.showOneAccount(accounts[i])
|
|
}
|
|
}
|
|
|
|
showOneAccount(account: IAccount) {
|
|
let node = cc.instantiate(this.accountPreb)
|
|
node.getComponent('OneAccount').init(account)
|
|
this.contentNode.addChild(node)
|
|
}
|
|
|
|
closeMe() {
|
|
this.wallet.uiHandlers.emit(WALLET_HIDE_MODAL)
|
|
}
|
|
}
|