//********************* // create by 流云 // time: Mon Apr 20 2026 // desc: //********************* import { _decorator, Component, Node, find, Color, instantiate, Label, EditBox, RichText } from 'cc'; import { Auto_PopGM } from './Auto_PopGM'; import { TableNames } from '../../game/ConfigTableData'; const { ccclass, property } = _decorator; @ccclass('UIPopGM') export class UIPopGM extends Auto_PopGM { @property({ type: Color }) colors: Color[] = []; curentwpArr: number[] = []; curentskillArr: number[] = []; notwpArr = []; onLoad(): void { super.onLoad(); } onEnable(): void { super.onEnable(); } onDisable(): void { super.onDisable(); } onInit(): void { this.typeNum = this.prema; this.curentwpArr = gg.game.playerWeaponIdArray; this.curentskillArr = gg.game.playerSkillIdArray; if (this.typeNum == 1) { this.click_btnWpSet(); } else { this.click_btnSkill(); } } typeNum: number = 0; click_btnClose(): void { this.close(); } click_btnClaer(): void { if (this.ui_wpSelect.active) { gg.game.playerWeaponIdArray = []; gg.game.playerSkillIdArray = []; this.curentwpArr = []; this.curentskillArr = []; this.updateWp(); } } click_btnSave(): void { if (this.ui_setWp.active) { for (let i = 0; i < this.ui_wpSetList.children.length; i++) { let n = this.ui_wpSetList.children[i]; if (!n.active) continue; let id = Number(n.name); let level = Number(n.getChildByName('EditBox').getComponent(EditBox).string); gg.data.project.unlockWeapon(id); gg.data.project.setWeaponLevel(id, level); } } else if (this.ui_wpSelect.active) { gg.game.playerSkillIdArray = this.curentskillArr; gg.game.playerWeaponIdArray = this.curentwpArr; } } click_btnSkill(): void { this.ui_setWp.active = false; this.ui_wpSelect.active = true; this.updateWp(); } click_btnWpSet(): void { this.ui_setWp.active = true; this.ui_wpSelect.active = false; this.updateSetLevel(); } updateWp() { let allList = gg.data.project.getWeaponDataList(); //所有武器 allList = allList.filter(item => !this.notwpArr.includes(item.weaponid)); this.ui_wpList.children.map(x => x.active = false); for (let i = 0; i < allList.length; i++) { let w1 = allList[i]; let n: Node = null; if (i < this.ui_wpList.children.length) { n = this.ui_wpList.children[i]; } else { n = instantiate(this.ui_wpList.children[0]); this.ui_wpList.addChild(n); } n.active = true; let bg = n.getChildByName('bg'); let lbName = n.getChildByName('lbName'); let select = n.getChildByName('select'); select.active = this.curentwpArr.includes(w1.weaponid); lbName.getComponent(Label).string = w1.name; bg.color = this.colors[w1.quality - 1]; n.targetOff(Node.EventType.TOUCH_END); n.on(Node.EventType.TOUCH_END, this.onClickWp.bind(this, n, w1), this); } //已选武器 let selectedList = allList.filter(item => this.curentwpArr.includes(item.weaponid)); //所有技能 let allSkillList = gg.data.table.getTableList(TableNames.Skill); //已选武器的所有技能 let selectedSkillList = allSkillList.filter(item => selectedList.some(w => w.weaponid == item.weapon)); this.ui_waSelectSkillList.children.map(x => x.active = false); for (let i = 0; i < selectedSkillList.length; i++) { const s2 = selectedSkillList[i]; const w2 = gg.data.project.getWeaponData(s2.weapon); let n: Node = null; if (i < this.ui_waSelectSkillList.children.length) { n = this.ui_waSelectSkillList.children[i]; } else { n = instantiate(this.ui_waSelectSkillList.children[0]); this.ui_waSelectSkillList.addChild(n); } n.active = true; let bg = n.getChildByName('bg'); let lbName = n.getChildByName('lbName'); let lbDesc = n.getChildByName('lbDesc'); let select = n.getChildByName('select'); lbName.getComponent(Label).string = gg.lang.get(w2.name); lbDesc.getComponent(RichText).string = gg.lang.get(s2.desc); select.active = this.curentskillArr.includes(s2.id); bg.color = this.colors[s2.quality - 1]; n.targetOff(Node.EventType.TOUCH_END); n.on(Node.EventType.TOUCH_END, this.onClickWpSelect.bind(this, n, s2), this); } } updateSetLevel() { let allList = gg.data.project.getWeaponDataList(); //所有武器 allList = allList.filter(item => !this.notwpArr.includes(item.weaponid)); this.ui_wpSetList.children.map(x => x.active = false); for (let i = 0; i < allList.length; i++) { let w1 = allList[i]; let n: Node = null; if (i < this.ui_wpSetList.children.length) { n = this.ui_wpSetList.children[i]; } else { n = instantiate(this.ui_wpSetList.children[0]); this.ui_wpSetList.addChild(n); } n.active = true; n.name = w1.weaponid.toString(); let bg = n.getChildByName('bg'); let lbName = n.getChildByName('lbName'); let ed = n.getChildByName('EditBox').getComponent(EditBox); lbName.getComponent(Label).string = w1.name; bg.color = this.colors[w1.quality - 1]; ed.string = gg.data.project.getWeaponLevel(w1.weaponid).toString(); } } onClickWp(n: Node, data: ITableWeapon2) { if (!this.curentwpArr.includes(data.weaponid)) { this.curentwpArr.push(data.weaponid); } else { this.curentwpArr.splice(this.curentwpArr.indexOf(data.weaponid), 1); } this.updateWp(); } onClickWpSelect(n: Node, data: ITableSkill) { if (this.curentskillArr.includes(data.id)) { this.curentskillArr.splice(this.curentskillArr.indexOf(data.id), 1); n.getChildByName('select').active = false; } else { this.curentskillArr.push(data.id); n.getChildByName('select').active = true; } } }