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
"use strict";
cc._RF.push(module, '69da9MgwjJKVIdtg8p32uz5', 'endless_friend_help_item_2_panel');
// Scripts/mod/endless_trail/view/endless_friend_help_item_2_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-05 21:07:24
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var PartnerConst = require("partner_const");
 
var Endless_friend_help_item_2Panel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("endlesstrail", "endlesstrail_friend_help_item_2");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.item_list = {};
    this.is_init = false;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    var container = this.root_wnd.getChildByName("container");
    this.career_name = container.getChildByName("career_name").getComponent(cc.Label);
    this.career_icon = container.getChildByName("career_icon").getComponent(cc.Sprite);
    this.power_panel = container.getChildByName("power_panel");
    this.role_power = this.power_panel.getChildByName("role_power").getComponent(cc.Label);
    this.role_name = container.getChildByName("role_name").getComponent(cc.Label);
    this.help_button = container.getChildByName("help_button");
    this.help_label = this.help_button.getChildByName("help_label").getComponent(cc.Label);
    ;
    this.help_label.string = Utils.TI18N("选择");
    this.hero_node = container.getChildByName("hero_node");
    this.hero_icon = ItemsPool.getInstance().getItem("hero_exhibition_item");
    ;
    this.hero_icon.setRootScale(0.8);
    this.hero_icon.setRootPosition(0, 0);
    this.hero_icon.setParent(this.hero_node);
    this.hero_icon.show();
 
    if (this.data) {
      this.updateInfo();
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.help_button, function () {
      if (this.click_fun) {
        if (this.data.select == true) {
          this.click_fun(this, this.data, this.index, false);
        } else {
          this.click_fun(this, this.data, this.index, true);
        }
      }
    }.bind(this), 1);
  },
  setData: function setData(data) {
    this.data = data;
    this.updateInfo();
  },
  updateInfo: function updateInfo() {
    if (!this.root_wnd) return;
 
    if (this.data) {
      this.type = this.data.type;
      this.info_data = this.data.info_data;
      this.index = this.data._index;
      this.role_name.string = this.info_data.name;
      this.role_power.string = this.info_data.power;
      this.hero_icon.setData(this.info_data);
      var res = PathTool.getCommonIcomPath(cc.js.formatStr("common_%s", 90045 + this.info_data.type));
      this.loadRes(res, function (resObject) {
        this.career_icon.spriteFrame = resObject;
      }.bind(this));
      var str = PartnerConst.Hero_Type[this.info_data.type] || "";
      this.career_name.string = "[" + str + "]";
    }
  },
  addCallBack: function addCallBack(click_fun) {
    this.click_fun = click_fun;
  },
  updateBtnStatus: function updateBtnStatus(status) {
    this.select_status = status;
 
    if (status == true) {// -- this.help_label:setString(TI18N("取消选择"))    
    } else {// -- this.help_label:setString(TI18N("选择"))
      }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.hero_icon) {
      this.hero_icon.deleteMe();
      this.hero_icon = null;
    } // self:removeAllChildren()
    // self:removeFromParent()
 
  }
});
 
cc._RF.pop();