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
"use strict";
cc._RF.push(module, '79413u5nOZDEYbX0m2T0Fhf', 'guild_search_panel');
// Scripts/mod/guild/view/guild_search_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 GuildSearchPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("guild", "guild_search_panel");
    this.panel_index = 1; //1:为搜索界面 2:为列表界面 3:为没有查找到界面
 
    this.ctrl = GuildController.getInstance();
  },
  initPanel: function initPanel() {
    this.background = this.seekChild("background");
    this.background_width = this.background.getContentSize().width;
    this.search_container = this.seekChild("search_container");
    this.search_btn = this.seekChild(this.search_container, "search_btn");
    this.guild_value = this.seekChild(this.search_container, "guild_value", cc.EditBox);
    this.list_container = this.seekChild("list_container");
    this.return_btn = this.seekChild(this.list_container, "return_btn");
    this.notice_container = this.seekChild("notice_container");
    this.notice_btn = this.seekChild(this.notice_container, "notice_btn");
  },
  registerEvent: function registerEvent() {
    this.search_btn.on(cc.Node.EventType.TOUCH_END, function () {
      var guild_name = this.guild_value.string;
      if (guild_name == "") message(Utils.TI18N("公会名字不得为空"));else this.ctrl.requestGuildList(null, null, null, guild_name);
    }, this);
    this.return_btn.on(cc.Node.EventType.TOUCH_END, function () {
      this.changeViewStatus(1);
    }, this);
    this.notice_btn.on(cc.Node.EventType.TOUCH_END, function () {
      this.changeViewStatus(1);
    }, this);
    this.addGlobalEvent(GuildEvent.UpdateGuildList, function (type, list) {
      if (type != GuildConst.list_type.search) return;
      this.updateGuildList(list);
    }.bind(this));
  },
  openRootWnd: function openRootWnd() {},
  onShow: function onShow() {
    var pos = this.root_wnd.getPosition();
    this.setPosition(pos.x, pos.y);
  },
  addToParent: function addToParent(status) {
    if (this.root_wnd != null) this.setVisible(status); // this.root_wnd.active = status;
  },
  changeViewStatus: function changeViewStatus(index) {
    if (this.panel_index == index) return;
    this.panel_index = index;
    this.search_container.active = this.panel_index == 1;
    this.list_container.active = this.panel_index == 2;
    this.notice_container.active = this.panel_index == 3;
    if (this.panel_index == 1) this.background.setContentSize(this.background_width, 780);else this.background.setContentSize(this.background_width, 702);
  },
  //外部判断是不是在公会查找到的列表界面
  checkIsInListStatus: function checkIsInListStatus() {
    return this.panel_index == 2;
  },
  changeToSearchListStatus: function changeToSearchListStatus() {
    this.changeViewStatus(1);
  },
  updateGuildList: function updateGuildList(list) {
    if (list == null || Utils.next(list) == null) {
      this.changeViewStatus(3);
    } else {
      if (this.scroll_view == null) {
        var list_size = this.list_container.getContentSize();
        var setting = {
          item_class: GuildRequestItem,
          // 单元类
          start_x: 3,
          // 第一个单元的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.list_container, cc.v2(0, -list_size.height * 0.5 - 3), ScrollViewDir.vertical, ScrollViewStartPos.top, list_size, setting, cc.v2(0.5, 0.5));
      }
 
      this.scroll_view.setData(list);
      this.changeViewStatus(2);
    }
  },
  onDelete: function onDelete() {
    if (this.scroll_view) this.scroll_view.deleteMe();
    this.scroll_view = null;
  }
});
module.exports = GuildSearchPanel;
 
cc._RF.pop();