add thanks

This commit is contained in:
Vick Scarlet
2021-11-28 13:17:41 +08:00
parent e1e2ab4701
commit 0e272ffd99
12 changed files with 388 additions and 116 deletions

View File

@@ -2,5 +2,58 @@ export default class Thanks extends ThanksUI {
constructor() {
super();
this.btnBack.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MAIN));
this.listSupports.renderHandler = Laya.Handler.create(this, this.renderSupport, null, false);
this.panelTopSupports.vScrollBar.elasticDistance = 150;
this.listSupports.scrollBar.elasticDistance = 150;
this.btnAFD.on(Laya.Event.CLICK, this, goto, ['sponsor_afd']);
this.btnDDF.on(Laya.Event.CLICK, this, goto, ['sponsor_ddf']);
}
static #createComponent = plugin.extractComponents(Thanks.uiView, ['boxTopSupport']);
#createTopSupportItem() {
const item = Thanks.#createComponent('boxTopSupport');
item.name = item.getChildByName('name');
item.comment = item.getChildByName('comment');
$_.deepMapSet(item, $ui.common.topSupportItem);
return item;
}
#topSupports;
init() {
const supports = [];
this.#topSupports = [];
core.specialThanks
.sort(()=>0.5-Math.random())
.forEach(({group, name, comment, color})=>
group == 2
? supports.push({name, color})
: this.renderTopSupport(name, comment, color)
);
this.listSupports.array = supports;
}
renderTopSupport(name, comment, color) {
const item = this.#createTopSupportItem();
item.name.text = name;
item.comment.text = comment;
item.name.color = color || '#000000';
this.vboxTopSupports.addChild(item);
this.#topSupports.push(item);
this.#topSupports.forEach((item, index) => item.y = index);
}
renderSupport(label) {
const {name, color} = label.dataSource;
label.text = name;
label.color = color || $ui.common.defaultFontColor;
}
close() {
this.#topSupports.forEach(item => {
item.removeSelf();
item.destroy();
});
this.#topSupports = null;
}
}