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
"use strict";
cc._RF.push(module, '29198iYUfhPR6/98M4YkzvQ', 'item_exhibition_list_panel');
// Scripts/mod/mainui/view/item_exhibition_list_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-01 16:07:58
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var MainUIConst = require("mainui_const");
 
var ItemExhibitionListPanel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {},
  // 设置父节点
  setParent: function setParent(parent) {
    this.parent = parent;
    this.createItemName();
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  show: function show(data) {
    if (data) {
      this.data = data;
      var show_type = data.show_type || MainUIConst.item_exhibition_type.item_type;
 
      if (show_type == MainUIConst.item_exhibition_type.item_type) {
        this.showItemUI(data);
      } else if (show_type == MainUIConst.item_exhibition_type.partner_type) {
        this.showPartnerUI(data);
      } else {
        console.log(Utils.TI18N("ItemExhibitionList类型出错:%s"), show_type.toString());
      }
    }
  },
  //创建道具名文本
  createItemName: function createItemName() {
    if (this.parent) {
      this.item_name_label = Utils.createLabel(24, new cc.Color(0xff, 0xe8, 0xff, 0xff), null, 0, 0, "", this.parent, null, cc.v2(0.5, 0.5));
    }
  },
  // 显示物品的
  showItemUI: function showItemUI(data) {
    var item_bid = data.bid || data.base_id;
    if (data == null || item_bid == null) return;
    var item_config = Utils.getItemConfig(item_bid) || {};
    if (item_config == null) return;
 
    if (this.item == null) {
      this.item = Utils.createClass("backpack_item");
 
      var BackpackController = require("backpack_controller");
 
      var BackPackConst = require("backpack_const");
 
      var item_vo = BackpackController.getInstance().getModel().getBackPackItemById(data.id);
 
      if (item_config.type == BackPackConst.item_type.ARTIFACTCHIPS && item_vo) {
        this.item.initConfig(true); //获取符文特殊处理,点击显示符文详细信息
 
        this.item.addCallBack(function () {
          var HeroController = require("hero_controller");
 
          var PartnerConst = require("partner_const");
 
          HeroController.getInstance().openArtifactTipsWindow(true, item_vo, PartnerConst.ArtifactTips.normal);
        }.bind(this));
      } else {
        this.item.initConfig(true, 1, false, true);
      }
 
      this.item.setParent(this.parent);
      this.item.show();
    }
 
    this.item.setData({
      bid: data.bid,
      num: data.num
    });
    var quality = null;
    var name = null;
    quality = item_config.quality;
    name = item_config.name;
 
    if (quality != null && name != null && this.item_name_label) {
      var BackPackConst = require("backpack_const");
 
      var hex = BackPackConst.quality_color(quality);
      var color = this.item_name_label.node.color;
      color.fromHEX(hex);
      this.item_name_label.node.color = color;
      this.item_name_label.string = name;
      this.item_name_label.node.active = true;
    }
  },
  // 显示伙伴的
  showPartnerUI: function showPartnerUI(data) {
    if (!data.bid) return;
    var config = Config.partner_data.data_partner_base[data.bid];
    if (!config) return;
    var quality = null;
 
    if (this.item == null) {
      this.item = ItemsPool.getInstance().getItem("hero_exhibition_item");
      this.item.addCallBack(function () {
        var HeroController = require("hero_controller");
 
        HeroController.getInstance().openHeroTipsPanelByBid(data.bid);
      });
      this.item.setParent(this.parent);
      this.item.show();
      this.item.setData(data);
    }
 
    var quality = data.star || config.init_star;
    quality = quality - 1;
 
    if (quality > 5) {
      quality = 5;
    }
 
    if (this.item_name_label) {
      var BackPackConst = require("backpack_const");
 
      var hex = BackPackConst.quality_color(quality);
      var color = this.item_name_label.node.color;
      color.fromHEX(hex);
      this.item_name_label.node.color = color;
      this.item_name_label.string = config.name;
      this.item_name_label.node.active = true;
    }
  },
  // 设置不可见
  hide: function hide() {},
  // 设置点击回调
  addCallBack: function addCallBack(callback) {},
  // 设置位置
  setPosition: function setPosition(x, y) {
    if (this.item) this.item.setPosition(x, y);
 
    if (this.item_name_label) {
      this.item_name_label.node.setPosition(x, y - 80);
    }
  },
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  deleteMe: function deleteMe() {
    if (this.item) {
      this.item.deleteMe();
    }
 
    if (this.item_name_label) {
      this.item_name_label.node.destroy();
    }
 
    this.item = null;
  }
});
 
cc._RF.pop();