difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
"use strict";
cc._RF.push(module, 'ca381dQ479GKaB8XnUcyuYk', 'rank_main_item');
// Scripts/mod/rank/view/rank_main_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     竖版排行榜排行界面item
// <br/>Create: 2019-03-12 14:47:58
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var RankConstant = require("rank_constant");
 
var PlayerHead = require("playerhead");
 
var Rank_main_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("rank", "rank_main_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.main_panel = this.seekChild("main_panel");
    this.bg_sp = this.seekChild("bg", cc.Sprite);
    this.first_icon_sp = this.seekChild("first_icon", cc.Sprite);
    this.name_lb = this.seekChild("name", cc.Label);
    this.rank_rt = this.seekChild("rank", cc.RichText);
    this.union_icon = this.seekChild("union_icon");
    this.union_icon.active = false;
    this.icon_sp = this.seekChild("icon", cc.Sprite);
    this.icon_sp.node.active = false;
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
      if (!this.data || Utils.next(this.data) == null) {
        message(Utils.TI18N("暂无排名数据"));
        return;
      }
 
      if (this.call_fun) {
        this.call_fun(this, this.data);
      }
    }, this);
  },
  setData: function setData(data) {
    this.data = data;
    if (this.root_wnd) this.onShow();
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow() {
    if (this.data == null) return;
    this.showActionIcon(false);
    var data = this.data;
    this.rank_type = this.data.type;
    var res_id = PathTool.getBigBg("txt_cn_rank_" + this.rank_type, null, "rank");
 
    if (this.item_res_id != res_id) {
      this.item_res_id = res_id;
      this.loadRes(res_id, function (sf_obj) {
        this.bg_sp.spriteFrame = sf_obj;
      }.bind(this));
    }
 
    if (this.data.val1 != 0) {
      this.first_icon_sp.node.active = true;
      var name = this.data.name;
 
      if (name == "") {
        name = Utils.TI18N("暂无排名");
      } else {
        if (this.is_cluster == true) {
          name = Utils.transformNameByServ(this.data.name, this.data.srv_id);
        }
      }
 
      this.name_lb.string = name;
      this.name_lb.node.setPosition(cc.v2(125, 38));
      if (!this.data || Utils.next(this.data) == null) return;
 
      if (this.rank_type != RankConstant.RankType.union) {
        if (!this.player_head) {
          this.player_head = new PlayerHead();
          this.player_head.setParent(this.main_panel);
          this.player_head.show();
          this.player_head.setScale(0.6);
          this.player_head.setPosition(88, 38);
        }
 
        this.player_head.setHeadRes(this.data.face_id);
        var avatar_bid = this.data.avatar_bid;
        this.player_head.setFrameRes(avatar_bid);
 
        if (this.union_icon) {
          this.union_icon.active = false;
        }
 
        this.player_head.setVisible(true);
      } else {
        this.union_icon.active = true;
 
        if (this.player_head) {
          this.player_head.setVisible(false);
        }
      }
 
      this.icon_sp.node.active = false;
      this.rank_rt.node.x = 327;
      var str = "";
 
      if (this.rank_type == RankConstant.RankType.arena) {
        var res = PathTool.getItemRes(8);
        var val = this.data.val1 || 0;
        this.loadRes(res, function (sf_obj) {
          this.icon_sp.spriteFrame = sf_obj;
        }.bind(this));
        this.icon_sp.node.active = true;
        this.icon_sp.node.scale = 0.3;
        this.rank_rt.node.x = 360;
        str = String(val);
      } else if (this.rank_type == RankConstant.RankType.drama) {
        var dungeon_id = this.data.val1 | 0;
        var config = gdata("dungeon_data", "data_drama_dungeon_info", [dungeon_id]);
 
        if (config) {
          str = config.name;
        }
      } else if (this.rank_type == RankConstant.RankType.power || this.rank_type == RankConstant.RankType.action_partner || this.rank_type == RankConstant.RankType.colors_tone) {
        var res = PathTool.getCommonIcomPath("common_90001");
        this.loadRes(res, function (sf_obj) {
          this.icon_sp.spriteFrame = sf_obj;
        }.bind(this));
        this.icon_sp.node.active = true;
        this.icon_sp.node.scale = 0.9;
        this.rank_rt.node.x = 360;
        var val = this.data.val1 || 0;
        str = String(val);
 
        if (this.rank_type == RankConstant.RankType.action_partner) {
          this.showActionIcon(true);
        }
      } else if (this.rank_type == RankConstant.RankType.tower) {
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("通关层数:%s", val);
      } else if (this.rank_type == RankConstant.RankType.union) {
        name = this.data.guild_name || "";
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("总战力:%s", val);
      } else if (this.rank_type == RankConstant.RankType.star_power) {
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("评分:%s", val);
      } else if (this.rank_type == RankConstant.RankType.action_star) {
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("评分:%s", val);
        this.showActionIcon(true);
      } else if (this.rank_type == RankConstant.RankType.action_adventure) {
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("神界探索度:%s", val);
        this.showActionIcon(true);
      } else if (this.rank_type == RankConstant.RankType.hallows_power) {
        var val = this.data.val1 || 0;
        str = cc.js.formatStr("圣器战力:%s", val);
      }
 
      this.name_lb.string = name;
      this.name_lb.node.setPosition(cc.v2(125, 55));
      this.rank_rt.string = str;
    } else {
      this.name_lb.string = Utils.TI18N("虚位以待");
      this.name_lb.node.setPosition(cc.v2(25, 35));
      this.rank_rt.string = "";
      this.first_icon_sp.node.active = false;
 
      if (this.union_icon) {
        this.union_icon.active = false;
      }
 
      if (this.player_head) {
        this.player_head.setVisible(false);
      }
    }
  },
  setExtendData: function setExtendData(is_cluster) {
    this.is_cluster = is_cluster;
  },
  //活动标签
  showActionIcon: function showActionIcon(bool) {
    if (bool == false && !this.action_icon) return;
 
    if (!this.action_icon) {
      this.action_icon = this.seekChild("action_icon");
      this.action_label = this.seekChild("action_label");
    }
 
    this.action_icon.active = bool;
    this.action_label.active = bool;
  },
  clickHandler: function clickHandler() {
    if (this.call_fun) {
      this.call_fun(this.data);
    }
  },
  addCallBack: function addCallBack(call_fun) {
    this.call_fun = call_fun;
  },
  setSelectStatus: function setSelectStatus(bool) {// this.select
  },
  setVisibleStatus: function setVisibleStatus(bool) {
    this.setVisible(bool);
  },
  getRankIndex: function getRankIndex() {
    return this.rank_type || 1;
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.player_head) {
      this.player_head.deleteMe();
      this.player_head = null;
    }
  }
});
 
cc._RF.pop();