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
"use strict";
cc._RF.push(module, 'd59a7ARrMBLYIRoM1CUo+hi', 'endless_awards_item_panel');
// Scripts/mod/endless_trail/view/endless_awards_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-07 11:00:13
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Endless_awards_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("endlesstrail", "endlesstrail_awards_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.item_list = [];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.rank_img = this.root_wnd.getChildByName("rank_img").getComponent(cc.Sprite);
    this.rank_label = this.root_wnd.getChildByName("rank_label").getComponent(cc.Label);
    this.item_container = this.root_wnd.getChildByName("item_container");
    this.total_width = this.item_container.getContentSize().width;
 
    if (this.data) {
      this.updateInfo();
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  setData: function setData(data) {
    this.data = data;
    this.updateInfo();
  },
  updateInfo: function updateInfo() {
    if (!this.root_wnd) return;
 
    if (this.data != null) {
      if (this.data.index != null) {
        if (this.data.index <= 3) {
          this.rank_label.node.active = false;
 
          if (this.data.rank == 0) {
            this.rank_img.node.active = false;
          } else {
            var res_id = PathTool.getCommonIcomPath(cc.js.formatStr("common_200%s", this.data.index));
 
            if (this.rank_res_id != res_id) {
              this.rank_res_id = res_id;
              this.loadRes(res_id, function (resObject) {
                this.rank_img.spriteFrame = resObject;
              }.bind(this));
            }
 
            this.rank_img.node.active = true;
          }
        } else {
          this.rank_img.node.active = false;
          this.rank_label.node.active = true;
          this.rank_label.string = cc.js.formatStr("%s~%s", this.data.min, this.data.max);
        }
      }
 
      var item_config = null;
      var index = 1;
      var item = null;
      var scale = 0.8;
      var off = 10;
      var _x = 0;
      var _y = 0;
      var sum = this.data.items.length;
 
      for (var i = sum - 1; i >= 0; i--) {
        var v = this.data.items[i];
        item_config = Utils.getItemConfig(v[0]);
 
        if (item_config) {
          if (this.item_list[index] == null) {
            var item = ItemsPool.getInstance().getItem("backpack_item");
            item.setParent(this.item_container);
            item.initConfig(false, scale, false, true);
 
            var _x = this.total_width - ((index - 1) * (120 * scale + off) + 120 * 0.5 * scale);
 
            item.setPosition(_x, _y);
            item.show();
            this.item_list[index] = item;
          }
 
          item = this.item_list[index];
          item.setData({
            bid: v[0],
            num: v[1]
          });
          index = index + 1;
        }
      }
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    for (var i in this.item_list) {
      this.item_list[i].deleteMe();
      this.item_list[i] = null;
    }
 
    this.item_list = null; // this.removeAllChildren();
    // this.removeFromParent();
  }
});
 
cc._RF.pop();