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
"use strict";
cc._RF.push(module, '9630a1/70NFzr+0WgbTuTUI', 'ladder_role_info_window');
// Scripts/mod/ladder/view/ladder_role_info_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-07-24 16:56:21
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var LadderController = require("ladder_controller");
 
var PlayerHead = require("playerhead");
 
var HeroController = require("hero_controller");
 
var PartnerConst = require("partner_const");
 
var LadderEvent = require("ladder_event");
 
var HeroVo = require("hero_vo");
 
var Ladder_role_infoWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("ladder", "ladder_role_info");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Big; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.item_list = {};
    this.ctrl = LadderController.getInstance();
    this.model = this.ctrl.getModel();
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    this.main_panel = this.seekChild("main_panel");
    this.close_btn = this.seekChild(this.main_panel, "close_btn");
    this.challenge_btn = this.seekChild(this.main_panel, "challenge_btn");
    var challenge_btn_lb = this.seekChild(this.challenge_btn, "label", cc.Label);
    challenge_btn_lb.string = Utils.TI18N("挑战");
    this.black_btn = this.seekChild(this.main_panel, "black_btn");
    var black_btn_lb = this.seekChild(this.black_btn, "label", cc.Label);
    black_btn_lb.string = Utils.TI18N("防守阵容");
    this.title_container = this.seekChild(this.main_panel, "title_container");
    var title_label = this.seekChild(this.title_container, "title_label", cc.Label);
    title_label.string = Utils.TI18N("挑战对手");
    this.info_con = this.seekChild(this.main_panel, "info_con");
    this.name_lb = this.seekChild(this.info_con, "name", cc.Label);
    var rank_title = this.seekChild(this.info_con, "rank_title", cc.Label);
    rank_title.string = Utils.TI18N("排名");
    this.rank_lb = this.seekChild(this.info_con, "rank", cc.Label);
    this.rank_lb.string = Utils.TI18N("暂无");
    var guild_title = this.seekChild(this.info_con, "guild_title", cc.Label);
    guild_title.string = Utils.TI18N("公会:");
    this.guild_lb = this.seekChild(this.info_con, "guild", cc.Label);
    this.guild_lb.string = Utils.TI18N("暂无");
    this.head = new PlayerHead();
    this.head.show();
    this.head.setPosition(10, -5);
    this.head.setParent(this.head);
    this.main_container = this.seekChild(this.main_panel, "main_container");
    var fight_title = this.seekChild(this.main_container, "fight_title", cc.Label);
    fight_title.string = Utils.TI18N("战斗阵容");
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.background, function () {
      this.ctrl.openLadderRoleInfoWindow(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.close_btn, function () {
      this.ctrl.openLadderRoleInfoWindow(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.black_btn, function () {
      HeroController.getInstance().openFormMainWindow(true, PartnerConst.Fun_Form.Ladder);
    }.bind(this), 1);
    Utils.onTouchEnd(this.challenge_btn, function () {
      if (this.data && this.data.rid && this.data.srv_id) {
        this.ctrl.checkJoinLadderBattle(this.data.rid, this.data.srv_id);
      }
    }.bind(this), 1);
    this.addGlobalEvent(LadderEvent.GetLadderEnemyData, function (data) {
      this.setData(data);
    }.bind(this));
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(data) {
    if (data && data.rid != null && data.srv_id != null) {
      this.ctrl.requestLadderEnemyData(data.rid, data.srv_id);
    }
  },
  setData: function setData(data) {
    this.data = data;
    this.name_lb.string = Utils.transformNameByServ(data.name, data.srv_id);
    this.head.setHeadRes(data.face);
 
    if (data.gname && data.gname != "") {
      this.guild_lb.string = data.gname;
    } //头像框
 
 
    var vo = Config.avatar_data.data_avatar[data.avatar_id || 0];
 
    if (vo) {
      var res_id = vo.res_id || 1;
      var res = PathTool.getUIIconPath("headcircle", "txt_cn_headcircle_" + res_id);
      this.head.setFrameRes(res);
    }
 
    this.head.setLev(data.lev);
    this.rank_lb.string = cc.js.formatStr(Utils.TI18N("%s名"), data.rank || 0);
    this.head.setSex(data.sex, cc.v2(70, 4));
    this.createPartnerList(data.p_list);
  },
  createPartnerList: function createPartnerList(list) {
    var temp = [];
 
    for (var k in list) {
      var v = list[k];
      var vo = new HeroVo();
      var hero_data = Utils.deepCopy(v);
      hero_data.use_skin = hero_data.quality;
      hero_data.partner_id = v.id;
      vo.updateHeroVo(hero_data);
      temp.push(vo);
    }
 
    var p_list_size = temp.length;
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    if (this.head) {
      this.head.deleteMe();
      this.head = null;
    }
 
    this.ctrl.openLadderRoleInfoWindow(false);
  }
});
 
cc._RF.pop();