109 lines
2.5 KiB
JavaScript
109 lines
2.5 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const PrayMod = require( "pray.mod" );
|
||
|
|
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
nodChoice: { default: null, type: cc.Node },
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function(){
|
||
|
|
|
||
|
|
let pray = PrayMod.getInstance();
|
||
|
|
let choice = pray.getChoices();
|
||
|
|
|
||
|
|
let chd = this.nodChoice.children;
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
let desc = choice[i];
|
||
|
|
if( !desc ){
|
||
|
|
nx.gui.setActive( nod, "", false );
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
let cmp = nod.getComponent( cc.Toggle );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.isChecked = false;
|
||
|
|
}
|
||
|
|
nx.gui.setString( nod, "desc", nx.text.getKey( desc ) );
|
||
|
|
nx.gui.setActive( nod, "", true );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function( _params ) {
|
||
|
|
|
||
|
|
let pray = PrayMod.getInstance();
|
||
|
|
let options = pray.getOptions();
|
||
|
|
if( options ){
|
||
|
|
for (let i = 0; i < options.length; i++) {
|
||
|
|
let op = options[i];
|
||
|
|
if( op.flag == 1 ){
|
||
|
|
let nod = this.nodChoice.children[i];
|
||
|
|
let cmp = nod.getComponent( cc.Toggle );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.isChecked = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// // 重建
|
||
|
|
// this.rebuild();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:关闭前
|
||
|
|
onPreClosed: function() {
|
||
|
|
|
||
|
|
// this.svcList.rebuild( [] );
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
//
|
||
|
|
onTouchConfirm: function(){
|
||
|
|
|
||
|
|
let option = [];
|
||
|
|
let chd = this.nodChoice.children;
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
let cmp = nod.getComponent( cc.Toggle );
|
||
|
|
if( cmp ){
|
||
|
|
if( cmp.isChecked ){
|
||
|
|
option.push( {
|
||
|
|
flag: 1
|
||
|
|
} );
|
||
|
|
}else{
|
||
|
|
option.push( {
|
||
|
|
flag: 0
|
||
|
|
} );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let pray = PrayMod.getInstance();
|
||
|
|
pray.sender25234( option );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//
|
||
|
|
onTouchCancle: function(){
|
||
|
|
|
||
|
|
let chd = this.nodChoice.children;
|
||
|
|
chd.forEach( nod => {
|
||
|
|
let cmp = nod.getComponent( cc.Toggle );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.isChecked = false;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
});
|