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
"use strict";
cc._RF.push(module, '7e353/c4UtDaKl95vKK/Jf8', 'guild_member_window');
// Scripts/mod/guild/view/guild_member_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      公会成员窗体
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var GuildController = require("guild_controller");
 
var GuildConst = require("guild_const");
 
var CommonScrollView = require("common_scrollview");
 
var RoleController = require("role_controller");
 
var GuildMemberItem = require("guild_member_item");
 
var GuildEvent = require("guild_event");
 
var RoleEvent = require("role_event");
 
var GuildMemberWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("guild", "guild_member_window");
    this.win_type = WinType.Mini;
    this.viewTag = SCENE_TAG.dialogue;
    this.ctrl = GuildController.getInstance();
    this.model = this.ctrl.getModel();
    this.my_guild_info = this.model.getMyGuildInfo();
    this.role_vo = RoleController.getInstance().getRoleVo();
  },
  openCallBack: function openCallBack() {
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    this.main_panel = this.seekChild("main_panel");
    this.scroll_container = this.seekChild("scroll_container");
    this.desc = this.seekChild(this.main_panel, "desc", cc.Label);
    this.close_btn = this.seekChild("close_btn");
    this.exit_btn = this.seekChild(this.main_panel, "exit_btn");
    this.exit_btn_label = this.seekChild(this.exit_btn, "label", cc.Label);
    this.explain_btn = this.seekChild(this.main_panel, "explain_btn");
    this.extend_container = this.seekChild(this.main_panel, "extend_container");
  },
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.background, function () {
      this.ctrl.openGuildMemberWindow(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.close_btn, function () {
      this.ctrl.openGuildMemberWindow(false);
    }.bind(this), 2);
    this.exit_btn.on(cc.Node.EventType.TOUCH_END, function () {
      this.ctrl.requestExitGuild();
    }, this);
    this.explain_btn.on(cc.Node.EventType.TOUCH_END, function (event) {
      var pos = event.touch.getLocation();
      var config = Config.guild_data.data_const.game_rule;
      if (config) require("tips_controller").getInstance().showCommonTips(StringUtil.parse(config.desc), pos, null, null, 500);
    }, this);
    this.addGlobalEvent(GuildEvent.UpdateMyInfoEvent, function (key, value) {
      if (key == "members_num" || key == "members_max") this.updateMemberNum();
    }, this);
    this.addGlobalEvent(GuildEvent.UpdateMyMemberListEvent, function (type) {
      if (type == 0) return;
      this.updateMemberList(type);
    }, this);
    this.addGlobalEvent(GuildEvent.UpdateAssistantNumEvent, function () {
      if (this.role_vo != null && this.role_vo.position != GuildConst.post_type.member) this.updateMemberNum();
    }, this);
 
    if (this.role_vo != null) {
      if (this.role_assets_event == null) {
        this.role_assets_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) {
          if (key == "gid") {
            if (value == 0) this.ctrl.openGuildMemberWindow(false);
          } else if (key == "position") this.updateExitStatus();
        }, this);
      }
    }
  },
  openRootWnd: function openRootWnd() {
    this.ctrl.requestGuildMemberList();
    this.updateMemberNum();
    this.updateExitStatus();
  },
  updateExitStatus: function updateExitStatus() {
    if (this.role_vo == null) return;
    if (this.role_vo.position == GuildConst.post_type.leader) this.exit_btn_label.string = Utils.TI18N("解散公会");else this.exit_btn_label.string = Utils.TI18N("退出公会");
    this.extend_container.active = this.role_vo.position != GuildConst.post_type.member;
  },
  //只有会长或者副会长才做这个处理
  updateMemberNum: function updateMemberNum() {
    if (this.my_guild_info != null && this.role_vo != null) {
      if (this.role_vo.position == GuildConst.post_type.member) this.desc.string = cc.js.formatStr("人数:%s/%s", this.my_guild_info.members_num, this.my_guild_info.members_max);else {
        var config = Config.guild_data.data_post[Utils.getNorKey(GuildConst.post_type.assistant, this.my_guild_info.lev)];
 
        if (config != null) {
          var num = this.model.getAssistantSum();
          this.desc.string = cc.js.formatStr("%s%s/%s   %s%s/%s", Utils.TI18N("人数:"), this.my_guild_info.members_num, this.my_guild_info.members_max, Utils.TI18N("副会长:"), num, config.num);
        }
      }
    }
  },
  //打开窗体或者收到增删成员的时候才会更新
  updateMemberList: function updateMemberList(type) {
    var list = this.model.getGuildMemberList();
 
    if (list != null && Utils.next(list) != null) {
      if (this.scroll_view == null) {
        var size = this.scroll_container.getContentSize();
        var list_size = cc.size(size.width, size.height - 10);
        var setting = {
          item_class: GuildMemberItem,
          // 单元类
          start_x: 4,
          // 第一个单元的X起点
          space_x: 0,
          // x方向的间隔
          start_y: 0,
          // 第一个单元的Y起点
          space_y: 0,
          // y方向的间隔
          item_width: 600,
          // 单元的尺寸width
          item_height: 135,
          // 单元的尺寸height
          row: 0,
          // 行数,作用于水平滚动类型
          col: 1,
          // 列数,作用于垂直滚动类型
          need_dynamic: true
        };
        this.scroll_view = new CommonScrollView();
        this.scroll_view.createScroll(this.scroll_container, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, list_size, setting, cc.v2(0.5, 0.5));
      } // if (type == 1) {
 
 
      list.sort(Utils.tableLowerSorter(["_index"]));
      if (this.scroll_view) this.scroll_view.setData(list); // } else {
      //     var sort_func = Utils.tableLowerSorter(["_index"]);
      //     this.scroll_view.resetAddPosition(list, sort_func);
      // }
    }
  },
  closeCallBack: function closeCallBack() {
    this.ctrl.openGuildMemberWindow(false);
 
    if (this.role_vo != null) {
      if (this.role_assets_event != null) {
        this.role_vo.unbind(this.role_assets_event);
        this.role_assets_event = null;
      }
    }
 
    if (this.scroll_view) {
      this.scroll_view.deleteMe();
      this.scroll_view = null;
    }
  }
});
module.exports = GuildMemberWindow;
 
cc._RF.pop();