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
"use strict";
cc._RF.push(module, '30b0bjFY85GjrR9Du6UKr6X', 'common_explain_window');
// Scripts/common/common_explain_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      通用的规则说明面板,只需要传固定格式的就行了
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var CommonExplainWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("common", "common_explain_view");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Mini; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = arguments[0];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.max_height = 0;
    this.cache_list = [];
    this.title_str = Utils.TI18N("规则");
    this.color_1 = new cc.Color(0x68, 0x45, 0x2a, 0xff);
  },
  openCallBack: function openCallBack() {
    this.background = this.root_wnd.getChildByName("background");
    this.background.scale = FIT_SCALE;
    this.container = this.root_wnd.getChildByName("container");
    this.close_btn = this.container.getChildByName("close_btn");
    this.scroll_view = this.container.getChildByName("scroll_view");
    this.scroll_content = this.scroll_view.getChildByName("content");
    this.scroll_view_compend = this.scroll_view.getComponent(cc.ScrollView);
    this.scroll_width = this.scroll_view.getContentSize().width;
    this.scroll_height = this.scroll_view.getContentSize().height;
    this.win_title = this.container.getChildByName("win_title").getComponent(cc.Label);
    this.win_title.string = this.title_str;
  },
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.background, function () {
      this.ctrl.openCommonExplainView(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.close_btn, function () {
      this.ctrl.openCommonExplainView(false);
    }.bind(this), 2);
  },
  openRootWnd: function openRootWnd(tmpInfo) {
    if (tmpInfo && tmpInfo.length >= 2) {
      this.title_str = tmpInfo[1];
      this.setDataList(tmpInfo[0]);
    }
  },
  setDataList: function setDataList(list) {
    this.render_list = list;
 
    for (var i in this.render_list) {
      gcore.Timer.set(function (v) {
        this.createList(v);
      }.bind(this, this.render_list[i]), i / 60, 1, "render_list" + i);
    }
  },
  createList: function createList(data) {
    var info = this.createTitleContent(data);
    this.scroll_content.addChild(info.container);
    this.cache_list.push(info.container);
    this.max_height = this.max_height + info.height + 30;
    var max_height = Math.max(this.max_height, this.scroll_height);
    this.scroll_content.setContentSize(cc.size(this.scroll_width, max_height));
    var off_y = 0;
 
    for (var i in this.cache_list) {
      this.cache_list[i].setPosition(8, max_height - off_y);
      off_y = off_y + this.cache_list[i].getContentSize().height + 30;
    }
 
    this.scroll_view_compend.scrollToTop(0);
  },
  createTitleContent: function createTitleContent(data) {
    if (data == null) return;
    var container = new cc.Node();
    container.setAnchorPoint(cc.v2(0, 1));
    var _height = 0;
 
    if (data.title == " " || data.title == "") {
      var content = Utils.createRichLabel(24, this.color_1, cc.v2(0, 1), cc.v2(0, 0), 30, 605);
      content.horizontalAlign = cc.macro.TextAlignment.LEFT;
      content.string = Utils.splitDataStr(data.desc);
      container.addChild(content.node);
 
      var _width = this.scroll_width - 8;
 
      _height = content.node.getContentSize().height;
      container.node.setContentSize(cc.size(_width, _height));
      content.node.y = _height - 8;
    } else {
      //  重新矫正一下位置坐标
      var title_bg = Utils.createImage(container, null, 0, 0, cc.v2(0, 1), true, 0, true);
      title_bg.type = cc.Sprite.Type.SLICED;
      title_bg.sizeMode = cc.Sprite.SizeMode.CUSTOM;
      title_bg.node.setContentSize(cc.size(617, 44));
      var title = Utils.createLabel(26, this.color_1, null, 5, -title_bg.node.height * 0.5, data.title, title_bg.node, 0, cc.v2(0, 0.5));
      this.loadRes(PathTool.getCommonIcomPath("common_90025"), function (resObject) {
        title_bg.spriteFrame = resObject;
      }.bind(this));
      var content = Utils.createRichLabel(24, this.color_1, cc.v2(0, 1), cc.v2(0, 0), 30, 605);
      content.horizontalAlign = cc.macro.TextAlignment.LEFT;
      content.string = Utils.splitDataStr(data.desc);
      container.addChild(content.node);
 
      var _width = this.scroll_width - 8;
 
      _height = title_bg.node.height + content.node.height;
      container.setContentSize(cc.size(_width, _height));
      title_bg.node.y = 0;
      content.node.y = title_bg.node.y - title_bg.node.height - 8;
    }
 
    return {
      container: container,
      height: _height
    };
  },
  closeCallBack: function closeCallBack() {
    if (this.render_list) {
      for (var i in this.render_list) {
        gcore.Timer.del("render_list" + i);
      }
    }
 
    this.cache_list = null;
    this.title_str = null;
    this.max_height = null;
    this.ctrl.openCommonExplainView(false);
  }
});
module.exports = CommonExplainWindow;
 
cc._RF.pop();