"use strict"; cc._RF.push(module, '330e6EmCjtEHLCS3tUP9kUg', 'cmp.guild.setting.wnd'); // Scripts/mod/guild/base/cmps/cmp.guild.setting.wnd.js "use strict"; /****************************************************************** * * 联盟设置 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var GuildConst = require("guild_const"); var GuildController = require("guild_controller"); var STEP_LEVEL = 1; var STEP_BP = 10000; var MAX_LEVEL = 200; // 审核类型 var GCVT = GuildConst.ApplyJoinType; cc.Class({ "extends": BridgeWindow, properties: { nodCond: { "default": null, type: cc.Node }, nodVerify: { "default": null, type: cc.Node } }, // 显示 onEnable: function onEnable() { this.ctrl = GuildController.getInstance(); this.model = this.ctrl.getModel(); var 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 setVerify(_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); var block = this.verify == GCVT.Auto; this.nodVerify.opacity = block ? 180 : 255; nx.gui.setActive(this.nodVerify, "block", block); }, // 切换申请开关 onTogVerify: function onTogVerify(_key) { var type = parseInt(_key) || GCVT.Auto; this.setVerify(type); }, // 设置等级 setLevel: function setLevel(_lv) { this.level = _lv; var txt = this.level <= 1 ? nx.text.getKey("GuildNoLimit") : this.level; nx.gui.setString(this.nodVerify, "level/edt", txt); }, // 增减等级 onTogLevel: function onTogLevel(_key) { var inc = _key == "+"; var 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 onLevelEditEnd(_editor) { var lev = parseInt(_editor.string); if (!nx.dt.numGood(lev)) { lev = 1; } lev = cc.math.clamp(lev, 1, MAX_LEVEL); this.setLevel(lev); }, // 设置战力 setBP: function setBP(_bp) { this.bp = _bp; var txt = this.bp <= 1 ? nx.text.getKey("GuildNoLimit") : this.bp; nx.gui.setString(this.nodVerify, "bp/edt", txt); }, // 增加战力 onTogBP: function onTogBP(_key) { var inc = _key == "+"; var bp = this.bp + (inc ? STEP_BP : -STEP_BP); if (bp < 1) { bp = 1; } this.setBP(bp); }, // 战力编辑 onBPEditEnd: function onBPEditEnd(_editor) { var bp = parseInt(_editor.string); if (!nx.dt.numGood(bp)) { bp = 1; } bp = Math.max(1, bp); this.setBP(bp); }, // 点击修改 onTouchModify: function onTouchModify() { var _this = this; this.ctrl.reqModifyApplySetting(this.verify, this.level, this.bp, function (_ret, _data) { if (!_ret) { nx.tbox(_data); return; } _this.close(); }); } }); cc._RF.pop();