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
"use strict";
cc._RF.push(module, '85c9aLJKUlEXaIzFYQUR/yQ', 'form_hallows_select_window');
// Scripts/mod/hero/form/form_hallows_select_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-01-28 11:21:08
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var FormHallowsSelectwindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("hero", "form_hallows_select_panel");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Full; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = arguments[0];
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    var HallowsController = require("hallows_controller");
 
    this.hallows_model = HallowsController.getInstance().getModel();
  },
  openCallBack: function openCallBack() {
    this.background_nd = this.seekChild("background");
    this.items_container = this.seekChild("items_container");
    this.background_nd.scale = FIT_SCALE;
    this.background_nd.on(cc.Node.EventType.TOUCH_END, this.onClickCloseBtn, this);
    this.initListView();
  },
  registerEvent: function registerEvent() {},
  closeCallBack: function closeCallBack() {},
  openRootWnd: function openRootWnd(params) {
    this.hallows_id = params.hallows_id;
    this.select_cb = params.callback;
    this.updateWidgets();
  },
  testFunction: function testFunction() {
    return this.testData;
  },
  initListView: function initListView() {
    var CommonScrollView = require("common_scrollview");
 
    var FormHallowSelectItem = require("form_hallows_select_item");
 
    var scroll_view_size = cc.size(this.items_container.width, this.items_container.height);
    var setting = {
      item_class: FormHallowSelectItem,
      // 单元类
      start_x: 0,
      // 第一个单元的X起点
      space_x: 4,
      // x方向的间隔
      start_y: 0,
      // 第一个单元的Y起点
      space_y: 0,
      // y方向的间隔
      item_width: 630,
      // 单元的尺寸width
      item_height: 150,
      // 单元的尺寸height
      col: 1,
      // 列数,作用于垂直滚动类型
      once_num: 5,
      need_dynamic: true
    };
    this.item_scrollview = new CommonScrollView();
    this.item_scrollview.createScroll(this.items_container, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, scroll_view_size, setting, cc.v2(0.5, 0.5));
  },
  onClickCloseBtn: function onClickCloseBtn() {
    this.ctrl.openFormHallowsSelectPanel(false);
  },
  updateWidgets: function updateWidgets() {
    var hallows_list = [];
    var config_list = Config.hallows_data.data_base;
 
    for (var hallow_i in config_list) {
      var hallow_data = {};
      var hallow_cfg = config_list[hallow_i];
      var hallow_vo = this.hallows_model.getHallowsById(hallow_cfg.id);
 
      if (hallow_vo) {
        if (this.hallows_id == hallow_vo.id) {
          hallow_vo.is_equip = true;
        } else {
          hallow_vo.is_equip = false;
        }
      }
 
      hallow_data.hallow_cfg = hallow_cfg;
      hallow_data.hallow_vo = hallow_vo;
      hallows_list.push(hallow_data);
    }
 
    this.item_scrollview.setData(hallows_list, this.onClickHeroExhibiton.bind(this), {
      can_click: true
    });
  },
  onClickHeroExhibiton: function onClickHeroExhibiton(hallow_vo) {
    if (this.select_cb) this.select_cb(hallow_vo);
    this.ctrl.openFormHallowsSelectPanel(false);
  }
});
 
cc._RF.pop();