994 lines
26 KiB
JavaScript
994 lines
26 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '1617ajp791AzZalaKPDAhY/', 'cmp.personal.avatar.wnd');
|
|
// Scripts/mod/personal/cmps/cmp.personal.avatar.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 技能预览界面
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var RoleController = require("role_controller");
|
|
var BackpackController = require("backpack_controller");
|
|
var TimeTool = require("timetool");
|
|
var FxTogs = require("nx.fx.togs");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
var MenuTags = {
|
|
Avatar: 0,
|
|
HeadFrame: 1,
|
|
Bubble: 2,
|
|
Badge: 3
|
|
};
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
togMenu: {
|
|
"default": null,
|
|
type: FxTogs
|
|
},
|
|
nodPages: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodPreview: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
lstAvatars: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
lstFrames: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
lstBubbles: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
lstBadges: {
|
|
"default": null,
|
|
type: FxSVC
|
|
}
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
// 初始化预览
|
|
this.initPreview();
|
|
|
|
// Tog监听
|
|
this.togMenu.posTog = this.onTogMenu.bind(this);
|
|
if (_params.fromOther) {
|
|
this.togMenu.togTo(_params.fromOther);
|
|
this.onTogMenu(_params.fromOther);
|
|
return;
|
|
}
|
|
this.togMenu.togTo(0);
|
|
this.onTogMenu(0);
|
|
},
|
|
// 载入
|
|
onLoad: function onLoad() {
|
|
// 监听绑定
|
|
this.role = RoleController.getInstance().getRoleVo();
|
|
// this.roleHandler = this.role.bind( EventId.UPDATE_ROLE_ATTRIBUTE, this.onRoleAttrUpdate, this );
|
|
// this.bindGEvent( RoleEvent.GetFaceList, this.rebuildFrameList.bind( this ) );
|
|
},
|
|
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 监听绑定解除
|
|
if (this.roleHandler) {
|
|
this.role.unbind(this.roleHandler);
|
|
this.roleHandler = null;
|
|
}
|
|
},
|
|
// 重载:关闭前
|
|
onPreClosed: function onPreClosed() {
|
|
// 列表清理
|
|
this.lstAvatars.rebuild([]);
|
|
this.lstFrames.rebuild([]);
|
|
this.lstBubbles.rebuild([]);
|
|
this.lstBadges.rebuild([]);
|
|
},
|
|
// 等级切换
|
|
onTogMenu: function onTogMenu(_index) {
|
|
switch (_index) {
|
|
case MenuTags.HeadFrame:
|
|
{
|
|
this.showFramePage();
|
|
}
|
|
break;
|
|
case MenuTags.Bubble:
|
|
{
|
|
this.showBubblePage();
|
|
}
|
|
break;
|
|
case MenuTags.Badge:
|
|
{
|
|
this.showBadgePage();
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
this.showAvatarPage();
|
|
}
|
|
break;
|
|
}
|
|
},
|
|
// 角色属性改变
|
|
onRoleAttrUpdate: function onRoleAttrUpdate(_key, _val) {
|
|
|
|
// // 头像更新
|
|
// if( _key == "face_id" || _key == "face_list" ) {
|
|
// this.rebuildAvatarList();
|
|
// return;
|
|
// }
|
|
|
|
// // 头像框更新
|
|
// if( _key == "avatar_base_id" ) {
|
|
// this.rebuildFrameList();
|
|
// return;
|
|
// }
|
|
},
|
|
// ========================================================================
|
|
// 头像选择相关
|
|
// ========================================================================
|
|
|
|
// 显示头像页
|
|
showAvatarPage: function showAvatarPage() {
|
|
var _this = this;
|
|
nx.gui.setActive(this.nodPages, "avatars", true);
|
|
nx.gui.setActive(this.nodPages, "frames", false);
|
|
nx.gui.setActive(this.nodPages, "chat", false);
|
|
nx.gui.setActive(this.nodPages, "badges", false);
|
|
|
|
// 不需要重建
|
|
if (nx.dt.arrNEmpty(this.avatars)) {
|
|
var index = this.idxAvatar >= 0 ? this.idxAvatar : 0;
|
|
this.onAvatarFocusChanged({
|
|
index: index,
|
|
mdata: this.avatars[index]
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 重建
|
|
RoleController.getInstance().send10325(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
|
|
// 列表重置
|
|
_this.rebuildAvatarList(_data.face_list);
|
|
});
|
|
},
|
|
// 列表重置
|
|
rebuildAvatarList: function rebuildAvatarList(_list) {
|
|
var haves = {};
|
|
for (var i in _list) {
|
|
var tmp = _list[i];
|
|
if (tmp && nx.dt.numPositive(tmp.face_id, false)) {
|
|
haves[tmp.face_id] = {
|
|
id: tmp.face_id,
|
|
have: true
|
|
};
|
|
}
|
|
}
|
|
this.avatars = [];
|
|
|
|
// 数组化
|
|
var libs = game.configs.looks_data.data_head_data;
|
|
for (var id in libs) {
|
|
var _tmp = libs[id];
|
|
var info = {
|
|
id: _tmp.id,
|
|
name: _tmp.name,
|
|
icon: 0,
|
|
date: 0,
|
|
type: MenuTags.Avatar,
|
|
lock: !haves[id],
|
|
lock_tip: _tmp.tips,
|
|
unlock_tip: _tmp.unlock_tips
|
|
};
|
|
var cfg = gitemdata(id);
|
|
info.icon = cfg ? cfg.icon : 0;
|
|
this.avatars.push(info);
|
|
}
|
|
|
|
// 排序
|
|
var curId = this.role.face_id;
|
|
this.avatars.sort(function (_a, _b) {
|
|
if (_a.lock != _b.lock) {
|
|
return _a.lock ? 1 : -1;
|
|
}
|
|
if (_a.id == curId) {
|
|
return -1;
|
|
}
|
|
if (_b.id == curId) {
|
|
return 1;
|
|
}
|
|
return _a.id - _b.id;
|
|
});
|
|
|
|
// 列表重建
|
|
this.lstAvatars.rebuild(this.avatars);
|
|
|
|
// 选中当前使用
|
|
this.idxAvatar = -1;
|
|
for (var _i = 0; _i < this.avatars.length; ++_i) {
|
|
var _tmp2 = this.avatars[_i];
|
|
if (_tmp2 && _tmp2.id == curId) {
|
|
this.idxAvatar = _i;
|
|
var chds = this.lstAvatars.bindSCV.content.children;
|
|
var node = chds[_i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(true);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 默认选中
|
|
var index = this.idxAvatar >= 0 ? this.idxAvatar : 0;
|
|
this.onAvatarFocusChanged({
|
|
index: index,
|
|
mdata: this.avatars[index]
|
|
});
|
|
},
|
|
// 选中切换
|
|
onAvatarFocusChanged: function onAvatarFocusChanged(_item) {
|
|
// 空
|
|
if (!_item || !_item.mdata) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.lstAvatars.cleanFocus();
|
|
this.lstAvatars.addFocus(_item.index);
|
|
|
|
// 预览设置
|
|
this.setPreview(_item.mdata.icon);
|
|
this.setCurrent(_item.mdata);
|
|
},
|
|
// 更变头像
|
|
onTouchChangeAvatar: function onTouchChangeAvatar() {
|
|
var _this2 = this;
|
|
var id = this.current.id;
|
|
RoleController.getInstance().send10327(id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this2.lstAvatars.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(node.svItem.mdata.id == id);
|
|
}
|
|
}
|
|
nx.gui.setLocked(_this2.nodPreview, "ops/confirm", true);
|
|
});
|
|
},
|
|
// ========================================================================
|
|
// 头像框选择相关
|
|
// ========================================================================
|
|
|
|
// 显示头像框页
|
|
showFramePage: function showFramePage() {
|
|
var _this3 = this;
|
|
nx.gui.setActive(this.nodPages, "avatars", false);
|
|
nx.gui.setActive(this.nodPages, "frames", true);
|
|
nx.gui.setActive(this.nodPages, "chat", false);
|
|
nx.gui.setActive(this.nodPages, "badges", false);
|
|
nx.gui.setActive(this.nodPages, "frames/use", false);
|
|
nx.gui.setActive(this.nodPages, "frames/active", false);
|
|
RoleController.getInstance().send21500(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
|
|
// 列表重置
|
|
_this3.rebuildFrameList(_data.avatar_frame);
|
|
});
|
|
},
|
|
// 列表重置
|
|
rebuildFrameList: function rebuildFrameList(_list) {
|
|
var BC = BackpackController.getInstance();
|
|
var BM = BC.getModel();
|
|
var have = _list ? _list : [];
|
|
var cur = this.role.avatar_base_id;
|
|
var libs = game.configs.avatar_data.data_avatar;
|
|
var records = {};
|
|
for (var k in have) {
|
|
var tmp = have[k];
|
|
if (tmp && nx.dt.numPositive(tmp.base_id, false)) {
|
|
records[tmp.base_id] = tmp;
|
|
}
|
|
}
|
|
this.frames = [];
|
|
for (var _k in libs) {
|
|
var _tmp3 = libs[_k];
|
|
if (!_tmp3 || _tmp3.is_show != 1) {
|
|
continue;
|
|
}
|
|
|
|
// 当前选中
|
|
var id = _tmp3.base_id;
|
|
var item = {
|
|
id: id,
|
|
name: _tmp3.name,
|
|
icon: _tmp3.item_icon_id,
|
|
date: 0,
|
|
type: MenuTags.HeadFrame,
|
|
lock: true,
|
|
attrs: _tmp3.attr || [],
|
|
lock_tip: _tmp3.lock_tip || "Locked",
|
|
unlock_tip: _tmp3.desc,
|
|
canActive: false
|
|
};
|
|
if (records[id]) {
|
|
item.lock = false;
|
|
if (nx.dt.numPositive(records[id].expire_time, false)) {
|
|
item.date = records[id].expire_time;
|
|
}
|
|
} else if (_tmp3.loss && _tmp3.loss[0]) {
|
|
var num = BM.getBackPackItemNumByBid(_tmp3.loss[0][0]);
|
|
if (num >= _tmp3.loss[0][1]) {
|
|
item.canActive = true;
|
|
item.lock = false;
|
|
}
|
|
}
|
|
this.frames.push(item);
|
|
}
|
|
|
|
// 排序
|
|
this.frames.sort(function (_a, _b) {
|
|
if (_a.lock != _b.lock) {
|
|
return _a.lock ? 1 : -1;
|
|
}
|
|
if (_a.canActive != _b.canActive) {
|
|
return _a.canActive ? -1 : 1;
|
|
}
|
|
return _a.id - _b.id;
|
|
});
|
|
|
|
// 列表重建
|
|
this.lstFrames.rebuild(this.frames);
|
|
|
|
// 使用中
|
|
this.idxFrame = -1;
|
|
for (var i = 0; i < this.frames.length; ++i) {
|
|
var _tmp4 = this.frames[i];
|
|
if (_tmp4 && _tmp4.id == cur) {
|
|
this.idxFrame = i;
|
|
var chds = this.lstFrames.bindSCV.content.children;
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(true);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 默认选中
|
|
var index = this.idxFrame >= 0 ? this.idxFrame : 0;
|
|
this.onFrameFocusChanged({
|
|
index: index,
|
|
mdata: this.frames[index]
|
|
});
|
|
},
|
|
// 选中切换
|
|
onFrameFocusChanged: function onFrameFocusChanged(_item) {
|
|
// 空
|
|
if (!_item || !_item.mdata) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.lstFrames.cleanFocus();
|
|
this.lstFrames.addFocus(_item.index);
|
|
|
|
// 预览设置
|
|
this.setPreview(-1, _item.mdata.id);
|
|
this.setCurrent(_item.mdata);
|
|
},
|
|
// 更变头像框
|
|
onTouchChangeFrame: function onTouchChangeFrame() {
|
|
var _this4 = this;
|
|
var id = this.current.id;
|
|
RoleController.getInstance().send21501(id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this4.lstFrames.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(node.svItem.mdata.id == id);
|
|
}
|
|
}
|
|
nx.gui.setLocked(_this4.nodPreview, "ops/confirm", true);
|
|
});
|
|
},
|
|
// ========================================================================
|
|
// 聊天泡泡选择相关
|
|
// ========================================================================
|
|
|
|
// 显示聊天泡泡页
|
|
showBubblePage: function showBubblePage() {
|
|
var _this5 = this;
|
|
nx.gui.setActive(this.nodPages, "avatars", false);
|
|
nx.gui.setActive(this.nodPages, "frames", false);
|
|
nx.gui.setActive(this.nodPages, "chat", true);
|
|
nx.gui.setActive(this.nodPages, "badges", false);
|
|
nx.gui.setActive(this.nodPages, "frames/use", false);
|
|
nx.gui.setActive(this.nodPages, "frames/active", false);
|
|
RoleController.getInstance().sender12700(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
|
|
// 列表重置
|
|
_this5.rebuildBubbleList(_data.say_frame);
|
|
});
|
|
},
|
|
// 列表重置
|
|
rebuildBubbleList: function rebuildBubbleList(_list) {
|
|
var BC = BackpackController.getInstance();
|
|
var BM = BC.getModel();
|
|
var have = _list ? _list : [];
|
|
var cur = this.role.bubble_bid;
|
|
var libs = game.configs.say_data.data_say_frame;
|
|
var records = {};
|
|
for (var k in have) {
|
|
var tmp = have[k];
|
|
if (tmp && nx.dt.numPositive(tmp.base_id, false)) {
|
|
records[tmp.base_id] = tmp;
|
|
}
|
|
}
|
|
this.bubbles = [];
|
|
for (var key in libs) {
|
|
var _tmp5 = libs[key];
|
|
if (!_tmp5) {
|
|
continue;
|
|
}
|
|
|
|
// 当前选中
|
|
var id = _tmp5.base_id;
|
|
var item = {
|
|
id: id,
|
|
name: _tmp5.name,
|
|
icon: id,
|
|
date: 0,
|
|
type: MenuTags.Bubble,
|
|
lock: true,
|
|
lock_tip: _tmp5.lock_tip || "Locked",
|
|
unlock_tip: _tmp5.desc,
|
|
canActive: false
|
|
};
|
|
if (records[id]) {
|
|
item.lock = false;
|
|
if (nx.dt.numPositive(records[id].expire_time, false)) {
|
|
item.date = records[id].expire_time;
|
|
}
|
|
} else if (_tmp5.loss && _tmp5.loss[0]) {
|
|
var num = BM.getBackPackItemNumByBid(_tmp5.loss[0][0]);
|
|
if (num >= _tmp5.loss[0][1]) {
|
|
item.canActive = true;
|
|
item.lock = false;
|
|
}
|
|
}
|
|
this.bubbles.push(item);
|
|
}
|
|
|
|
// 排序
|
|
this.bubbles.sort(function (_a, _b) {
|
|
if (_a.lock != _b.lock) {
|
|
return _a.lock ? 1 : -1;
|
|
}
|
|
if (_a.canActive != _b.canActive) {
|
|
return _a.canActive ? -1 : 1;
|
|
}
|
|
return _a.id - _b.id;
|
|
});
|
|
|
|
// 列表重建
|
|
this.lstBubbles.rebuild(this.bubbles);
|
|
|
|
// 使用中
|
|
this.idxBubble = -1;
|
|
for (var i = 0; i < this.bubbles.length; ++i) {
|
|
var _tmp6 = this.bubbles[i];
|
|
if (_tmp6 && _tmp6.id == cur) {
|
|
this.idxBubble = i;
|
|
var chds = this.lstBubbles.bindSCV.content.children;
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(true);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 默认选中
|
|
var index = this.idxBubble >= 0 ? this.idxBubble : 0;
|
|
this.onBubbleFocusChanged({
|
|
index: index,
|
|
mdata: this.bubbles[index]
|
|
});
|
|
},
|
|
// 选中切换
|
|
onBubbleFocusChanged: function onBubbleFocusChanged(_item) {
|
|
// 空
|
|
if (!_item || !_item.mdata) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.lstBubbles.cleanFocus();
|
|
this.lstBubbles.addFocus(_item.index);
|
|
|
|
// 预览设置
|
|
this.setPreview(-1, -1, _item.mdata.id);
|
|
this.setCurrent(_item.mdata);
|
|
},
|
|
// 更变聊天泡泡
|
|
onTouchChangeBubble: function onTouchChangeBubble() {
|
|
var _this6 = this;
|
|
var id = this.current.id;
|
|
RoleController.getInstance().sender12701(id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this6.lstBubbles.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(node.svItem.mdata.id == id);
|
|
}
|
|
}
|
|
nx.gui.setLocked(_this6.nodPreview, "ops/confirm", true);
|
|
});
|
|
},
|
|
// ========================================================================
|
|
// 徽章选择相关
|
|
// ========================================================================
|
|
|
|
// 显示徽章页
|
|
showBadgePage: function showBadgePage() {
|
|
var _this7 = this;
|
|
nx.gui.setActive(this.nodPages, "avatars", false);
|
|
nx.gui.setActive(this.nodPages, "frames", false);
|
|
nx.gui.setActive(this.nodPages, "chat", false);
|
|
nx.gui.setActive(this.nodPages, "badges", true);
|
|
|
|
// 不需要重建
|
|
if (nx.dt.arrNEmpty(this.badges)) {
|
|
var index = this.idxBadge >= 0 ? this.idxBadge : 0;
|
|
this.onBadgeFocusChanged({
|
|
index: index,
|
|
mdata: this.badges[index]
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 重建
|
|
RoleController.getInstance().send23300(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
|
|
// 列表重置
|
|
_this7.rebuildBadgeList(_data.honor);
|
|
});
|
|
},
|
|
// 列表重置
|
|
rebuildBadgeList: function rebuildBadgeList(_list) {
|
|
var BC = BackpackController.getInstance();
|
|
var BM = BC.getModel();
|
|
var haves = {};
|
|
for (var i in _list) {
|
|
var tmp = _list[i];
|
|
if (tmp && nx.dt.numPositive(tmp.base_id, false)) {
|
|
haves[tmp.base_id] = tmp;
|
|
}
|
|
}
|
|
this.badges = [];
|
|
|
|
// 数组化
|
|
var libs = game.configs.honor_data.data_title;
|
|
for (var id in libs) {
|
|
var _tmp7 = libs[id];
|
|
var info = {
|
|
id: _tmp7.base_id,
|
|
name: _tmp7.name,
|
|
icon: _tmp7.res_id,
|
|
sicon: _tmp7.item_icon_id,
|
|
date: 0,
|
|
type: MenuTags.Badge,
|
|
lock: !haves[id],
|
|
lock_tip: _tmp7.desc,
|
|
unlock_tip: _tmp7.desc,
|
|
attrs: _tmp7.attr,
|
|
canActive: false
|
|
};
|
|
if (haves[id]) {
|
|
info.date = haves[id].expire_time;
|
|
} else if (_tmp7.loss && _tmp7.loss[0]) {
|
|
var num = BM.getBackPackItemNumByBid(_tmp7.loss[0][0]);
|
|
if (num >= _tmp7.loss[0][1]) {
|
|
info.canActive = true;
|
|
info.lock = false;
|
|
}
|
|
}
|
|
this.badges.push(info);
|
|
}
|
|
|
|
// 排序
|
|
var curId = this.role.title_id;
|
|
this.badges.sort(function (_a, _b) {
|
|
if (_a.lock != _b.lock) {
|
|
return _a.lock ? 1 : -1;
|
|
}
|
|
if (_a.id == curId) {
|
|
return -1;
|
|
}
|
|
if (_b.id == curId) {
|
|
return 1;
|
|
}
|
|
return _a.id - _b.id;
|
|
});
|
|
|
|
// 列表重建
|
|
this.lstBadges.rebuild(this.badges);
|
|
|
|
// 选中当前使用
|
|
this.idxBadge = -1;
|
|
for (var _i2 = 0; _i2 < this.badges.length; ++_i2) {
|
|
var _tmp8 = this.badges[_i2];
|
|
if (_tmp8 && _tmp8.id == curId) {
|
|
this.idxBadge = _i2;
|
|
var chds = this.lstBadges.bindSCV.content.children;
|
|
var node = chds[_i2];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(true);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 默认选中
|
|
var index = this.idxBadge >= 0 ? this.idxBadge : 0;
|
|
this.onBadgeFocusChanged({
|
|
index: index,
|
|
mdata: this.badges[index]
|
|
});
|
|
},
|
|
// 选中切换
|
|
onBadgeFocusChanged: function onBadgeFocusChanged(_item) {
|
|
// 空
|
|
if (!_item || !_item.mdata) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.lstBadges.cleanFocus();
|
|
this.lstBadges.addFocus(_item.index);
|
|
|
|
// 预览设置
|
|
this.setPreview(-1, -1, -1, _item.mdata.icon);
|
|
this.setCurrent(_item.mdata);
|
|
},
|
|
// 更变徽章
|
|
onTouchChangeBadge: function onTouchChangeBadge() {
|
|
var _this8 = this;
|
|
var id = this.current.id;
|
|
RoleController.getInstance().send23301(id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this8.lstBadges.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem) {
|
|
node.svItem.setUsed(node.svItem.mdata.id == id);
|
|
}
|
|
}
|
|
nx.gui.setLocked(_this8.nodPreview, "ops/confirm", true);
|
|
});
|
|
},
|
|
// ========================================================================
|
|
// 预览相关
|
|
// ========================================================================
|
|
|
|
// 初始化预览
|
|
initPreview: function initPreview() {
|
|
var faceId = this.role.face_id;
|
|
var frameId = this.role.avatar_base_id;
|
|
var bubbleId = this.role.bubble_bid;
|
|
var badgeId = this.role.title_id;
|
|
this.setPreview(faceId, frameId, bubbleId, badgeId);
|
|
},
|
|
// 设置预览
|
|
setPreview: function setPreview(_avatar, _frame, _bubble, _badge) {
|
|
// 头像
|
|
if (nx.dt.numPositive(_avatar, false)) {
|
|
nx.bridge.setAvatarByFaceId(this.nodPreview, "avatar/head", _avatar);
|
|
}
|
|
|
|
// 头像框
|
|
if (nx.dt.numPositive(_frame, false)) {
|
|
nx.bridge.setAvatarFrame(this.nodPreview, "avatar/frame", _frame);
|
|
}
|
|
|
|
// 聊天框
|
|
if (nx.dt.numPositive(_bubble, false)) {
|
|
nx.bridge.setChatBubble(this.nodPreview, "chat", _bubble);
|
|
}
|
|
|
|
// 徽章
|
|
if (nx.dt.numGood(_badge)) {
|
|
if (_badge <= 0) {
|
|
nx.gui.setSpriteFrame(this.nodPreview, "badge", null);
|
|
} else {
|
|
var path = cc.path.join("resDB/honors", _badge);
|
|
nx.gui.setSpriteFrame(this.nodPreview, "badge", path);
|
|
}
|
|
}
|
|
},
|
|
// 设置当前操作项
|
|
setCurrent: function setCurrent(_item) {
|
|
this.current = _item ? _item : null;
|
|
|
|
// 置空
|
|
if (nx.dt.objEmpty(_item)) {
|
|
nx.gui.setActive(this.nodPreview, "info", false);
|
|
nx.gui.setActive(this.nodPreview, "ops", false);
|
|
return;
|
|
}
|
|
|
|
// 标题
|
|
// let txt = _item.lock ? "UnlockCondition" : "BaseInfo";
|
|
var txt = _item.name || "BaseInfo";
|
|
var info = nx.gui.setActive(this.nodPreview, "info", true);
|
|
|
|
// 描述
|
|
var desc = _item.lock ? _item.lock_tip : _item.unlock_tip;
|
|
var ops = nx.gui.setActive(this.nodPreview, "ops", true);
|
|
|
|
// 聊天框直设
|
|
// if( _item.type == MenuTags.Bubble ) {
|
|
// txt = _item.name;
|
|
// desc = _item.unlock_tip;
|
|
// }
|
|
|
|
nx.gui.setString(info, "head/txt", nx.text.getKey(txt));
|
|
nx.gui.setString(info, "desc", nx.text.getKey(desc));
|
|
|
|
// 加成
|
|
if (nx.dt.arrEmpty(_item.attrs)) {
|
|
nx.gui.setString(info, "attr", nx.text.getKey("NoPropBonus"));
|
|
} else {
|
|
// 属性加成(显示两个)
|
|
var _txt = "";
|
|
for (var i = 0; i < _item.attrs.length; ++i) {
|
|
var attr = _item.attrs[i];
|
|
if (nx.dt.arrEmpty(attr)) {
|
|
break;
|
|
}
|
|
var prop = nx.bridge.attrs.fmtAttribute(attr[0], attr[1]);
|
|
_txt += nx.text.format("PropValue", prop.name, prop.val);
|
|
if (i < _item.attrs.length - 1) {
|
|
_txt += "\t\t";
|
|
}
|
|
}
|
|
nx.gui.setString(info, "attr", _txt);
|
|
}
|
|
|
|
// 有效期
|
|
var time = "";
|
|
if (!_item.lock) {
|
|
time = nx.text.getKey("Permanent");
|
|
if (_item.date > 0) {
|
|
var tm = TimeTool.getYMD(_item.date);
|
|
time = nx.text.format("ExpireDate", tm);
|
|
}
|
|
}
|
|
nx.gui.setString(this.nodPreview, "date", time);
|
|
|
|
// 操作
|
|
switch (_item.type) {
|
|
// 头像
|
|
case MenuTags.Avatar:
|
|
{
|
|
var curId = this.role.face_id;
|
|
nx.gui.setActive(ops, "active", false);
|
|
nx.gui.setActive(ops, "confirm", true);
|
|
nx.gui.setLocked(ops, "confirm", _item.lock || _item.id == curId);
|
|
}
|
|
break;
|
|
|
|
// 头像框
|
|
case MenuTags.HeadFrame:
|
|
{
|
|
if (_item.canActive) {
|
|
nx.gui.setActive(ops, "active", true);
|
|
nx.gui.setActive(ops, "confirm", false);
|
|
} else {
|
|
var _curId = this.role.avatar_base_id;
|
|
nx.gui.setActive(ops, "active", false);
|
|
nx.gui.setActive(ops, "confirm", true);
|
|
nx.gui.setLocked(ops, "confirm", _item.lock || _item.id == _curId);
|
|
}
|
|
}
|
|
break;
|
|
|
|
// 聊天框
|
|
case MenuTags.Bubble:
|
|
{
|
|
if (_item.canActive) {
|
|
nx.gui.setActive(ops, "active", true);
|
|
nx.gui.setActive(ops, "confirm", false);
|
|
} else {
|
|
var _curId2 = this.role.bubble_bid;
|
|
nx.gui.setActive(ops, "active", false);
|
|
nx.gui.setActive(ops, "confirm", true);
|
|
nx.gui.setLocked(ops, "confirm", _item.lock || _item.id == _curId2);
|
|
}
|
|
}
|
|
break;
|
|
|
|
// 徽章框
|
|
case MenuTags.Badge:
|
|
{
|
|
if (_item.canActive) {
|
|
nx.gui.setActive(ops, "active", true);
|
|
nx.gui.setActive(ops, "confirm", false);
|
|
} else {
|
|
var _curId3 = this.role.title_id;
|
|
nx.gui.setActive(ops, "active", false);
|
|
nx.gui.setActive(ops, "confirm", true);
|
|
nx.gui.setLocked(ops, "confirm", _item.lock || _item.id == _curId3);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
},
|
|
// 点击激活
|
|
onTouchActive: function onTouchActive() {
|
|
var _this9 = this;
|
|
if (!this.current) {
|
|
return;
|
|
}
|
|
|
|
// 头像框激活
|
|
if (this.current.type == MenuTags.HeadFrame) {
|
|
var id = this.current.id;
|
|
RoleController.getInstance().send21503(id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this9.lstAvatars.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem && node.svItem.mdata.id == id) {
|
|
node.svItem.setActive(false);
|
|
break;
|
|
}
|
|
}
|
|
_this9.current.canActive = false;
|
|
_this9.current.lock = false;
|
|
var arr = _data.avatar_frame || [];
|
|
for (var _i3 = 0; _i3 < arr.length; ++_i3) {
|
|
if (arr[_i3].base_id == _this9.current.id) {
|
|
_this9.current.date = arr[_i3].expire_time;
|
|
break;
|
|
}
|
|
}
|
|
_this9.setCurrent(_this9.current);
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 聊天泡泡激活
|
|
if (this.current.type == MenuTags.Bubble) {
|
|
var _id = this.current.id;
|
|
RoleController.getInstance().sender12703(_id, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this9.lstBubbles.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem && node.svItem.mdata.id == _id) {
|
|
node.svItem.setActive(false);
|
|
break;
|
|
}
|
|
}
|
|
_this9.current.canActive = false;
|
|
_this9.current.lock = false;
|
|
// let arr = _data.avatar_frame || [];
|
|
// for( let i = 0; i < arr.length; ++i ) {
|
|
// if( arr[ i ].base_id == this.current.id ) {
|
|
// this.current.date = arr[ i ].expire_time;
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
_this9.setCurrent(_this9.current);
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 徽章泡泡激活
|
|
if (this.current.type == MenuTags.Badge) {
|
|
var _id2 = this.current.id;
|
|
RoleController.getInstance().send23303(_id2, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
var chds = _this9.lstBadges.bindSCV.content.children;
|
|
for (var i in chds) {
|
|
var node = chds[i];
|
|
if (node && node.svItem && node.svItem.mdata.id == _id2) {
|
|
node.svItem.setActive(false);
|
|
break;
|
|
}
|
|
}
|
|
_this9.current.canActive = false;
|
|
_this9.current.lock = false;
|
|
_this9.setCurrent(_this9.current);
|
|
});
|
|
return;
|
|
}
|
|
},
|
|
// 点击使用
|
|
onTouchUse: function onTouchUse() {
|
|
if (!this.current) {
|
|
return;
|
|
}
|
|
|
|
// 区别处理
|
|
switch (this.current.type) {
|
|
case MenuTags.Avatar:
|
|
{
|
|
this.onTouchChangeAvatar();
|
|
}
|
|
break;
|
|
case MenuTags.HeadFrame:
|
|
{
|
|
this.onTouchChangeFrame();
|
|
}
|
|
break;
|
|
case MenuTags.Bubble:
|
|
{
|
|
this.onTouchChangeBubble();
|
|
}
|
|
break;
|
|
case MenuTags.Badge:
|
|
{
|
|
this.onTouchChangeBadge();
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |