/****************************************************************** * * 联盟设置 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const GuildConst = require( "guild_const" ); const GuildController = require( "guild_controller" ); const STEP_LEVEL = 1; const STEP_BP = 10000; const MAX_LEVEL = 200; // 审核类型 const GCVT = GuildConst.ApplyJoinType; cc.Class( { extends: BridgeWindow, properties: { nodCond: { default: null, type: cc.Node }, nodVerify: { default: null, type: cc.Node }, }, // 显示 onEnable: function() { this.ctrl = GuildController.getInstance(); this.model = this.ctrl.getModel(); let info = this.model.getMyGuildInfo(); this.setVerify( info.apply_type || GCVT.Auto ); this.setLevel( info.apply_lev || 1 ); this.setBP( info.apply_power || 1 ); }, // 设置申请开关 setVerify: function( _type ) { this.verify = _type; nx.gui.setActive( this.nodCond, "tog0/ico/off", _type != GCVT.Auto ) nx.gui.setActive( this.nodCond, "tog0/ico/on", _type == GCVT.Auto ) nx.gui.setActive( this.nodCond, "tog1/ico/off", _type != GCVT.Manual ) nx.gui.setActive( this.nodCond, "tog1/ico/on", _type == GCVT.Manual ) let block = ( this.verify == GCVT.Auto ); this.nodVerify.opacity = block ? 180 : 255; nx.gui.setActive( this.nodVerify, "block", block ); }, // 切换申请开关 onTogVerify: function( _key ) { let type = parseInt( _key ) || GCVT.Auto; this.setVerify( type ); }, // 设置等级 setLevel: function( _lv ) { this.level = _lv; let txt = ( this.level <= 1 ) ? nx.text.getKey( "GuildNoLimit" ) : this.level; nx.gui.setString( this.nodVerify, "level/edt", txt ); }, // 增减等级 onTogLevel: function( _key ) { let inc = ( _key == "+" ); let lev = this.level + ( inc ? STEP_LEVEL : -STEP_LEVEL ); if( lev < 1 ) { lev = 1; } if( lev > MAX_LEVEL ) { lev = MAX_LEVEL; } this.setLevel( lev ); }, // 等级编辑 onLevelEditEnd: function( _editor ) { let lev = parseInt( _editor.string ); if( !nx.dt.numGood( lev ) ) { lev = 1; } lev = cc.math.clamp( lev, 1, MAX_LEVEL ); this.setLevel( lev ); }, // 设置战力 setBP: function( _bp ) { this.bp = _bp; let txt = ( this.bp <= 1 ) ? nx.text.getKey( "GuildNoLimit" ) : this.bp; nx.gui.setString( this.nodVerify, "bp/edt", txt ); }, // 增加战力 onTogBP: function( _key ) { let inc = ( _key == "+" ); let bp = this.bp + ( inc ? STEP_BP : -STEP_BP ); if( bp < 1 ) { bp = 1; } this.setBP( bp ); }, // 战力编辑 onBPEditEnd: function( _editor ) { let bp = parseInt( _editor.string ); if( !nx.dt.numGood( bp ) ) { bp = 1; } bp = Math.max( 1, bp ); this.setBP( bp ); }, // 点击修改 onTouchModify: function() { this.ctrl.reqModifyApplySetting( this.verify, this.level, this.bp, ( _ret, _data ) => { if( !_ret ) { nx.tbox( _data ); return; } this.close(); } ); }, } );