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
"use strict";
cc._RF.push(module, '7a7c5TpThNGGa9p08TFtMLb', 'guild_list_panel');
// Scripts/mod/guild/view/guild_list_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: @syg.com(必填, 创建模块的人员)
// @description:
//      公会列表面板
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var GuildConst = require("guild_const");
 
var CommonScrollView = require("common_scrollview");
 
var GuildRequestItem = require("guild_request_item");
 
var GuildController = require("guild_controller");
 
var GuildEvent = require("guild_event");
 
var GuildListPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("guild", "guild_list_panel");
    this.ctrl = GuildController.getInstance();
  },
  initPanel: function initPanel() {
    this.empty_tips = this.seekChild("empty_tips");
    this.desc = this.seekChild("desc", cc.Label);
    this.desc.string = Utils.TI18N("暂无任何公会信息");
    this.scroll_container = this.seekChild("background");
    this.checkbox = this.seekChild("checkbox", cc.Toggle);
    this.checkbox.isChecked = false;
 
    if (this.scroll_view == null) {
      var list_size = this.scroll_container.getContentSize();
      var setting = {
        item_class: GuildRequestItem,
        // 单元类
        start_x: 2.5,
        // 第一个单元的X起点
        space_x: 0,
        // x方向的间隔
        start_y: 2,
        // 第一个单元的Y起点
        space_y: 0,
        // y方向的间隔
        item_width: 616,
        // 单元的尺寸width
        item_height: 134,
        // 单元的尺寸height
        row: 0,
        // 行数,作用于水平滚动类型
        col: 1,
        // 列数,作用于垂直滚动类型
        need_dynamic: true
      };
      this.scroll_view = new CommonScrollView();
      this.scroll_view.createScroll(this.scroll_container, cc.v2(0, list_size.height * 0.5 - 5), ScrollViewDir.vertical, ScrollViewStartPos.top, list_size, setting, cc.v2(0.5, 0.5));
    }
  },
  registerEvent: function registerEvent() {
    this.addGlobalEvent(GuildEvent.UpdateGuildList, function (type, list) {
      if (type != GuildConst.list_type.total) return;
      this.all_list = list || [];
      this.filterNotFullList();
    }.bind(this));
    this.checkbox.node.on("toggle", function () {
      this.filterNotFullList();
    }, this);
    this.ctrl.requestGuildList();
  },
  openRootWnd: function openRootWnd() {},
  onShow: function onShow() {},
  addToParent: function addToParent(status) {
    if (this.root_wnd != null) this.setVisible(status); // this.root_wnd.active = status;
 
    if (status == true) {
      if (this.scroll_view == null) {// this.ctrl.requestGuildList();
      }
    }
  },
  filterNotFullList: function filterNotFullList() {
    if (!this.all_list) return;
    var status = this.checkbox.isChecked;
    var list;
 
    if (status) {
      if (this.filter_list == null) {
        this.filter_list = [];
 
        for (var i in this.all_list) {
          var data = this.all_list[i];
          if (data.members_num < data.members_max) this.filter_list.push(data);
        }
      }
 
      list = this.filter_list;
    } else {
      list = this.all_list;
    }
 
    this.updateGuildList(list);
  },
  updateGuildList: function updateGuildList(list) {
    if (list == null || Utils.next(list) == null) {
      this.empty_tips.active = true;
    } else {
      this.empty_tips.active = false;
 
      if (this.scroll_view == null) {
        var list_size = this.scroll_container.getContentSize();
        var setting = {
          item_class: GuildRequestItem,
          // 单元类
          start_x: 2.5,
          // 第一个单元的X起点
          space_x: 0,
          // x方向的间隔
          start_y: 2,
          // 第一个单元的Y起点
          space_y: 0,
          // y方向的间隔
          item_width: 616,
          // 单元的尺寸width
          item_height: 134,
          // 单元的尺寸height
          row: 0,
          // 行数,作用于水平滚动类型
          col: 1,
          // 列数,作用于垂直滚动类型
          need_dynamic: true
        };
        this.scroll_view = new CommonScrollView();
        this.scroll_view.createScroll(this.scroll_container, cc.v2(0, list_size.height * 0.5 - 5), ScrollViewDir.vertical, ScrollViewStartPos.top, list_size, setting, cc.v2(0.5, 0.5));
      }
 
      this.scroll_view.setData(list);
    }
  },
  onDelete: function onDelete() {
    if (this.scroll_view) this.scroll_view.deleteMe();
    this.scroll_view = null;
  }
});
module.exports = GuildListPanel;
 
cc._RF.pop();