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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
"use strict";
cc._RF.push(module, 'c647bBeNapBd5w/+6QcPHj2', 'backpack_tips');
// Scripts/mod/tips/view/backpack_tips.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      普通物品的tips,区分背包中和其他
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var TipsConst = require("tips_const");
 
var GoodsVo = require("goods_vo");
 
var BackPackConst = require("backpack_const");
 
var StringUtil = require("string_util");
 
var BackpackController = require("backpack_controller");
 
var BackPackTips = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("tips", "backpack_tips");
    this.viewTag = SCENE_TAG.dialogue;
    this.win_type = WinType.Tips;
  },
  initConfig: function initConfig() {
    this.tips_controller = require("tips_controller").getInstance();
    this.btn_list = {};
  },
  openCallBack: function openCallBack() {
    this.background = this.seekChild("background");
    this.container = this.seekChild("container");
    this.container_init_height = this.container.height;
    this.close_btn = this.seekChild("close_btn");
    this.base_panel = this.seekChild(this.container, "base_panel");
    this.goods_item = ItemsPool.getInstance().getItem("backpack_item");
    this.goods_item.setParent(this.base_panel);
    this.goods_item.initConfig(false, 1, false, false);
    this.goods_item.setPosition(-134, -68);
    this.goods_item.show();
    this.name = this.seekChild(this.base_panel, "name");
    this.equip_type = this.seekChild(this.base_panel, "equip_type", cc.Label);
    this.extend_desc = this.seekChild(this.base_panel, "extend_desc", cc.RichText);
    this.usedesc_panel = this.seekChild(this.container, "usedesc_panel");
    this.use_desc = this.seekChild(this.usedesc_panel, "desc", cc.Label);
    this.usedesc_panel_height = this.usedesc_panel.height;
    this.desc_panel = this.seekChild(this.container, "desc_panel");
    this.desc_panel_height = this.desc_panel.height;
    this.scroll_view = this.seekChild(this.desc_panel, "content");
    this.desc_label = this.seekChild(this.scroll_view, "desc_label");
    this.tab_panel = this.seekChild(this.container, "tab_panel");
    this.tab_panel_height = this.tab_panel.height;
 
    for (var index = 0; index < 3; index++) {
      var btn = this.seekChild(this.tab_panel, "tab_btn_" + (index + 1));
 
      if (btn) {
        var object = {};
        object.btn = btn;
        object.label = btn.getChildByName("Label").getComponent(cc.Label);
        this.btn_list[index + 1] = object;
      }
    }
  },
  registerEvent: function registerEvent() {
    this.background.on(cc.Node.EventType.TOUCH_END, function (event) {
      this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
    }.bind(this));
    this.close_btn.on(cc.Node.EventType.TOUCH_END, function (event) {
      this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
    }.bind(this));
  },
  openRootWnd: function openRootWnd(object) {
    object = object || {};
    var data = object.data;
    var is_show_btn = object.show;
    this.is_special_source = object.is_special_source;
    this.item_config = null;
 
    if (typeof data == "number") {
      this.item_config = Utils.getItemConfig(data);
    } else if (data instanceof GoodsVo) {
      this.item_config = data.config;
    } else {
      this.item_config = data;
    }
 
    if (this.item_config == null) {
      this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
      return;
    }
 
    this.data = data;
    this.goods_item.setData(this.item_config);
    this.resetLayout(is_show_btn);
  },
  // 重设布局
  resetLayout: function resetLayout(is_show_btn) {
    is_show_btn = is_show_btn || false;
    var target_height = this.container_init_height; // 是否显示按钮
 
    if (!is_show_btn) {
      this.tab_panel.active = false;
      target_height -= this.tab_panel_height;
    } // 是否显示描述
 
 
    var show_use_desc = true;
 
    if (this.item_config.use_desc == null || this.item_config.use_desc == "") {
      show_use_desc = false;
      this.usedesc_panel.active = false;
      target_height -= this.usedesc_panel_height;
    } // 只需要改变一下尺寸就好了
 
 
    if (this.container_init_height != target_height) {
      this.container.height = target_height;
 
      if (show_use_desc) {
        this.usedesc_panel.y = this.base_panel.y - this.base_panel.height;
        this.desc_panel.y = this.usedesc_panel.y - this.usedesc_panel.height;
      } else {
        this.desc_panel.y = this.base_panel.y - this.base_panel.height;
      }
    }
 
    if (is_show_btn) {
      this.updateBtnList();
    }
 
    this.setBaseInfo();
  },
  // 设置按钮
  updateBtnList: function updateBtnList() {
    if (this.item_config == null) return;
    var type = this.item_config.type || 0;
 
    for (var key in this.btn_list) {
      var object = this.btn_list[key];
 
      if (object.btn) {
        object.btn.active = false;
      }
    }
 
    var btn_list = [];
 
    if (this.is_special_source) {
      // 强制显示某一些按钮
      if (this.is_special_source == 1) {
        // 强制只显示来源
        btn_list.push(BackPackConst.tips_btn_type.source);
      } else if (this.is_special_source == 2) {
        // 强制显示神装图鉴
        btn_list.push(BackPackConst.tips_btn_type.heaven_book);
      }
    } else {
      btn_list = this.item_config.tips_btn || [];
    } // var btn_list = this.item_config.tips_btn || []
 
 
    var btn_sum = btn_list.length;
 
    if (btn_sum == 1) {
      var object_1 = this.btn_list[1];
      var object_3 = this.btn_list[3];
      object_1.btn.x = object_3.btn.x;
    } else if (btn_sum == 2) {
      var object_1 = this.btn_list[1];
      var object_2 = this.btn_list[2];
      object_1.btn.x = -110;
      object_2.btn.x = 110;
    }
 
    for (var index = 0; index < btn_list.length; index++) {
      if (index > 2) return;
      var object = this.btn_list[index + 1];
 
      if (object && object.btn) {
        var element = btn_list[index];
        var title = BackPackConst.tips_btn_title[element] || "";
        object.btn.active = true;
        object.label.string = Utils.TI18N(title);
        object.btn.on(cc.Node.EventType.TOUCH_END, function (element, event) {
          this.gotoSources(element);
        }.bind(this, element));
      }
    }
  },
  // 跳转对应标签
  gotoSources: function gotoSources(index) {
    if (!this.item_config) return;
    this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
 
    if (index == BackPackConst.tips_btn_type.source) {
      //来源
      if (this.item_config.source.length > 0) {
        BackpackController.getInstance().openTipsSource(true, this.data);
      } else {
        message(Utils.TI18N("暂时没有来源"));
      }
    } else if (index == BackPackConst.tips_btn_type.sell) {
      //金币市场道具出售
      if (this.data.quantity <= 1) {// MarketController:getInstance():sender23502( this.data.id,this.data.quantity )
      } else {
        if (!this.sell_vo) return;
        BackpackController.getInstance().openBatchUseItemView(true, this.data, BackPackConst.ItemConsumeType.sell, {
          type: 1,
          value_list: this.sell_vo
        });
      }
    } else if (index == BackPackConst.tips_btn_type.goods_use) {
      //普通物品使用
      var use_type = this.item_config.use_type || 1;
 
      if (this.data && this.data.id && use_type == BackPackConst.item_use_type.BATCH_USE) {
        var quantity = this.data.quantity || 0;
 
        if (this.item_config.type == BackPackConst.item_type.FREE_GIFT) {
          BackpackController.getInstance().openGiftSelectPanel(this.data);
        } else if (quantity == 1) {
          BackpackController.getInstance().sender10515(this.data.id || 0, quantity);
        } else {
          BackpackController.getInstance().openBatchUseItemView(true, this.data);
        }
      }
    } else if (index == BackPackConst.tips_btn_type.boss_source) {//跳转世界boss界面
    } else if (index == BackPackConst.tips_btn_type.drama_new_source) {
      //跳转剧情副本最新的关卡页面
      var MainuiController = require("mainui_controller");
 
      var MainuiConst = require("mainui_const");
 
      MainuiController.getInstance().changeMainUIStatus(MainuiConst.btn_index.drama_scene);
    } else if (index == BackPackConst.tips_btn_type.drama_source) {
      //跳转剧情副本界面
      var MainuiController = require("mainui_controller");
 
      var MainuiConst = require("mainui_const");
 
      MainuiController.getInstance().changeMainUIStatus(MainuiConst.btn_index.drama_scene);
    } else if (index == BackPackConst.tips_btn_type.hero_source) {
      //跳转英雄信息界面
      var MainuiController = require("mainui_controller");
 
      var MainuiConst = require("mainui_const");
 
      MainuiController.getInstance().changeMainUIStatus(MainuiConst.btn_index.partner);
    } else if (index == BackPackConst.tips_btn_type.skill_source) {
      //跳转英雄技能界面
      var HeroController = require("hero_controller");
 
      HeroController.getInstance().openHeroBagWindow(true);
    } else if (index == BackPackConst.tips_btn_type.form_source) {
      //跳转编队阵法界面
      var MainuiController = require("mainui_controller");
 
      var MainuiConst = require("mainui_const");
 
      MainuiController.getInstance().changeMainUIStatus(MainuiConst.btn_index.partner);
    } else if (index == BackPackConst.tips_btn_type.call_source) {
      //跳转召唤界面
      var PartnersummonController = require("partnersummon_controller");
 
      PartnersummonController.getInstance().openPartnerSummonWindow(true);
    } else if (index == BackPackConst.tips_btn_type.artifact_source) {} else if (index == BackPackConst.tips_btn_type.seerpalace_summon) {
      //先知召唤
      var SeerpalaceController = require("seerpalace_controller");
 
      var SeerpalaceConst = require("seerpalace_const");
 
      SeerpalaceController.getInstance().openSeerpalaceMainWindow(true, SeerpalaceConst.Tab_Index.Summon);
    } else if (index == BackPackConst.tips_btn_type.seerpalace_change) {
      //先知转换
      var SeerpalaceController = require("seerpalace_controller");
 
      var SeerpalaceConst = require("seerpalace_const");
 
      SeerpalaceController.getInstance().openSeerpalaceMainWindow(true, SeerpalaceConst.Tab_Index.Change);
    } else if (index == BackPackConst.tips_btn_type.hecheng2) {//神器合成,统一一个合成窗口了
      // var config = this.data.config;
      // if(config && config.effect && config.effect[1] && config.effect[1].effect_type == 24){
      //     var item_id = config.effect[1].val || 0;
      //     BackpackController.getInstance().openBackPackComposeWindow(true, {bid=item_id});
      // }
    } else if (index == BackPackConst.tips_btn_type.fenjie) {
      //英雄碎片分解
      var list = [];
      list.push({
        id: this.data.id,
        bid: this.data.base_id,
        num: this.data.quantity
      });
      BackpackController.getInstance().openBatchUseItemView(true, this.data, BackPackConst.ItemConsumeType.resolve);
    } else if (index == BackPackConst.tips_btn_type.redbag) {
      //公会红包
      var RoleController = require("role_controller");
 
      var role_vo = RoleController.getInstance().getRoleVo();
 
      if (role_vo && role_vo.gid != 0 && role_vo.gsrid != "") {
        var id = 1; //默认这个跳转1
 
        if (this.data && this.data.config && this.data.config.client_effect && Utils.next(this.data.config.client_effect || {}) != null && this.data.config.client_effect[0]) {
          id = this.data.config.client_effect[0];
        }
 
        var RedbagController = require("redbag_controller");
 
        RedbagController.getInstance().openMainView(true, id);
      } else {
        message(Utils.TI18N("未加入公会不能发红包哦!"));
      }
    } else if (index == BackPackConst.tips_btn_type.head) {
      //个人设置头像
      var RoleController = require("role_controller");
 
      RoleController.getInstance().openRoleDecorateView(true, 2);
    } else if (index == BackPackConst.tips_btn_type.chenghao) {
      //个人设置称号
      var RoleController = require("role_controller");
 
      RoleController.getInstance().openRoleDecorateView(true, 4);
    } else if (index == BackPackConst.tips_btn_type.partner_character) {
      //跳转个人形形象设置
      var config = this.data.config;
 
      if (config) {
        var setting = {};
        setting.id = this.data.config.id;
 
        var RoleController = require("role_controller");
 
        RoleController.getInstance().openRoleDecorateView(true, 3, setting);
      }
    } else if (index == BackPackConst.tips_btn_type.arena_source) {
      //跳转竞技场
      var ArenaController = require("arena_controller");
 
      ArenaController.getInstance().requestOpenArenaLoopMathWindow(true);
    } else if (index == BackPackConst.tips_btn_type.stone_upgrade) {//跳转宝石升级界面
    } else if (index == BackPackConst.tips_btn_type.upgrade_star) {//伙伴直升卡,升星
    } else if (index == BackPackConst.tips_btn_type.low_treasure) {
      //跳转幸运探宝
      var ActionController = require("action_controller");
 
      ActionController.getInstance().openLuckyTreasureWin(true);
    } else if (index == BackPackConst.tips_btn_type.high_treasure) {
      //跳转高级探宝
      var ActionController = require("action_controller");
 
      ActionController.getInstance().openLuckyTreasureWin(true, 2);
    } else if (index == BackPackConst.tips_btn_type.halidom) {//跳转圣物
      // var open_cfg = Config.HalidomData.data_const["halidom_open_lev"]
      // var role_vo = RoleController:getInstance():getRoleVo()
      // if open_cfg and role_vo and role_vo.lev >= open_cfg.val then
      //     MainuiController:getInstance():changeMainUIStatus(MainuiConst.btn_index.partner, HeroConst.BagTab.eHalidom)
      // elseif open_cfg then
      //     message(open_cfg.desc)
      // end
    } else if (index == BackPackConst.tips_btn_type.item_sell) {
      //道具出售 --目前是符石
      BackpackController.getInstance().openItemSellPanel(true, this.data, BackPackConst.Bag_Code.BACKPACK);
    } // this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
 
  },
  // 设置基础数据
  setBaseInfo: function setBaseInfo() {
    if (this.item_config == null) return;
    this.extend_desc.string = "";
    var hex = BackPackConst.quality_color(this.item_config.quality);
    var color = this.name.color;
    color.fromHEX(hex);
    this.name.color = color;
    this.name.getComponent(cc.Label).string = this.item_config.name;
    this.equip_type.string = Utils.TI18N("类型:") + this.item_config.type_desc;
    this.use_desc.string = this.item_config.use_desc || "";
 
    if (this.item_config.desc) {
      this.desc_label.getComponent(cc.RichText).string = "<color=#a1978b>" + StringUtil.parse(this.item_config.desc) + "</c>";
    } else {
      this.desc_label.getComponent(cc.RichText).string = "";
    }
 
    this.scroll_view.height = this.desc_label.height;
  },
  closeCallBack: function closeCallBack() {
    if (this.goods_item) {
      this.goods_item.deleteMe();
    }
 
    this.goods_item = null;
    this.tips_controller.closeTIpsByType(TipsConst.type.GOODS);
  }
});
 
cc._RF.pop();