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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     天梯战报
// <br/>Create: 2019-07-24 16:56:10
// --------------------------------------------------------------------
var PathTool = require("pathtool");
var CommonScrollView = require("common_scrollview");
var LadderController = require("ladder_controller");
var LadderGodLogItem = require("ladder_god_log_item");
var LadderMyLogItem = require("ladder_my_log_item");
var RoleController = require("role_controller");
var ChatConst = require("chat_const");
var LadderEvent = require("ladder_event");
 
var Ladder_logWindow = cc.Class({
    extends: BaseView,
    ctor: function () {
        this.prefabPath = PathTool.getPrefabPath("ladder", "ladder_log_window");
        this.viewTag = SCENE_TAG.dialogue;                //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
        this.win_type = WinType.Big;               //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
    },
 
    // 初始化一些配置数据,可以用于声明一些变量之类的
    initConfig: function () {
        this.tab_list = {};
        this.color = new cc.Color(0xf5, 0xe0, 0xb9, 0xff);
        this.color_1 = new cc.Color(245, 224, 185, 255);
        this.color_2 = new cc.Color(105, 55, 5, 255);
        this.ctrl = LadderController.getInstance();
        this.model = this.ctrl.getModel();
    },
 
    // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
    openCallBack: function () {
        this.background = this.seekChild("background");
        this.background.scale = FIT_SCALE;
 
        let container = this.seekChild("container");
        let win_title = this.seekChild("win_title");
        win_title.string = Utils.TI18N("战 报");
 
        this.title_bg = this.seekChild("title_bg");
        let enemy_title = this.seekChild(this.title_bg, "title_bg", cc.Label);
        enemy_title.string = Utils.TI18N("对手");
        let more_title = this.seekChild(this.title_bg, "more_title", cc.Label);
        more_title.string = Utils.TI18N("详细");
 
        this.share_panel = this.seekChild("share_panel");
        this.share_panel.active = false;
        let share_bg = this.seekChild("share_bg");
        this.share_bg = share_bg;
        this.btn_guild = this.seekChild(share_bg, "btn_guild");
        this.btn_world = this.seekChild(share_bg, "btn_world");
        this.btn_cross = this.seekChild(share_bg, "btn_cross");
        let guild_label = this.seekChild(share_bg, "guild_label", cc.Label);
        guild_label.string = Utils.TI18N("公会频道");
        let world_label = this.seekChild(share_bg, "world_label", cc.Label);
        world_label.string = Utils.TI18N("世界频道");
        let cross_label = this.seekChild(share_bg, "cross_label", cc.Label);
        cross_label.string = Utils.TI18N("跨服频道");
 
        let tab_container = this.seekChild(container, "tab_container");
        for (let i = 1; i <= 2; i++) {
            let object = {};
            let tab_btn = this.seekChild(tab_container, "tab_btn_" + i);
            if (tab_btn) {
                let title = tab_btn.getChildByName("title").getComponent(cc.Label);
                if (i == 1) {
                    title.string = Utils.TI18N("我的记录");
                } else if (i == 2) {
                    title.string = Utils.TI18N("大神风采");
                }
                title.node.color = this.color;
                let tips = tab_btn.getChildByName("tips");
                object.tab_btn = tab_btn;
                object.tab_btn_sp = tab_btn.getComponent(cc.Sprite);
                object.label = title;
                object.index = i;
                object.tips = tips;
                this.tab_list[i] = object;
            }
        }
 
        this.close_btn = this.seekChild("close_btn");
        this.confirm_btn = this.seekChild("confirm_btn");
        this.no_log_label = this.seekChild("no_log_label", cc.Label);
        this.no_log_image = this.seekChild("no_log_image");
        this.my_log_panel = this.seekChild("my_log_panel");
        this.god_log_panel = this.seekChild("god_log_panel");
        this.no_log_label.string = Utils.TI18N("暂无战报");
 
        var bgSize = this.my_log_panel.getContentSize();
        var tab_size = cc.size(bgSize.width, bgSize.height - 8);
        var setting = {
            item_class: LadderMyLogItem,      // 单元类
            start_x: 0,                    // 第一个单元的X起点
            space_x: 0,                    // x方向的间隔
            start_y: -5,                    // 第一个单元的Y起点
            space_y: -5,                   // y方向的间隔
            item_width: 612,               // 单元的尺寸width
            item_height: 135,              // 单元的尺寸height
            row: 0,                        // 行数,作用于水平滚动类型
            col: 1,                        // 列数,作用于垂直滚动类型
            need_dynamic: true
        }
        this.my_log_scrollview = new CommonScrollView()
        this.my_log_scrollview.createScroll(this.my_log_panel, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, tab_size, setting, cc.v2(0.5, 0.5))
 
        var bgSize = this.my_log_panel.getContentSize();
        var tab_size = cc.size(bgSize.width, bgSize.height - 8);
        var setting = {
            item_class: LadderGodLogItem,      // 单元类
            start_x: 0,                    // 第一个单元的X起点
            space_x: 0,                    // x方向的间隔
            start_y: -5,                    // 第一个单元的Y起点
            space_y: -5,                   // y方向的间隔
            item_width: 612,               // 单元的尺寸width
            item_height: 153,              // 单元的尺寸height
            row: 0,                        // 行数,作用于水平滚动类型
            col: 1,                        // 列数,作用于垂直滚动类型
            need_dynamic: true
        }
        this.god_log_scrollview = new CommonScrollView()
        this.god_log_scrollview.createScroll(this.my_log_panel, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, tab_size, setting, cc.v2(0.5, 0.5))
 
    },
 
    // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
    registerEvent: function () {
        Utils.onTouchEnd(this.close_btn, function () {
            this.ctrl.openLadderLogWindow(false);
        }.bind(this), 2)
        Utils.onTouchEnd(this.background, function () {
            this.ctrl.openLadderLogWindow(false);
        }.bind(this), 2)
 
        Utils.onTouchEnd(this.share_panel, function () {
            this.share_panel.active = false;
        }.bind(this), 1)
 
        Utils.onTouchEnd(this.btn_world, function () {
            if (this.replay_id != null && this.def_name && this.share_srv_id != null) {
                this.ctrl.requestShareVideo(this.replay_id, this.share_srv_id, ChatConst.Channel.World, this.def_name);
            }
            this.share_panel.active = false;
        }.bind(this), 1)
 
        Utils.onTouchEnd(this.btn_guild, function () {
            let role_vo = RoleController.getInstance().getRoleVo();
            if (role_vo && role_vo.gid != 0 && role_vo.gsrv_id != "") {
                if (this.replay_id != null && this.def_name && this.share_srv_id != null) {
                    this.ctrl.requestShareVideo(this.replay_id, this.share_srv_id, ChatConst.Channel.Gang, this.def_name);
                }
            } else {
                message(Utils.TI18N("暂无公会"));
            }
        }.bind(this), 1)
 
        Utils.onTouchEnd(this.btn_cross, function () {
            if (this.replay_id != null && this.def_name && this.share_srv_id != null) {
                this.ctrl.requestShareVideo(this.replay_id, this.share_srv_id, ChatConst.Channel.Gang, this.def_name);
            }
            this.share_panel.active = false;
        }.bind(this), 1)
 
        for (let k in this.tab_list) {
            let object = this.tab_list[k];
            if (object.tab_btn) {
                object.tab_btn.on(cc.Node.EventType.TOUCH_END, function () {
                    Utils.playButtonSound(1);
                    this.changeSelectedTab(object.index);
                }, this)
            }
        }
 
        this.addGlobalEvent(LadderEvent.UpdateLadderMyLogData, function (data) {
            this.my_log_replay_srv_id = data.replay_srv_id;
            if (data.log_list) {
                this.setMyLogData(data.log_list);
            }
        }, this)
 
        this.addGlobalEvent(LadderEvent.UpdateLadderGodLogData, function (data) {
            this.god_log_replay_srv_id = data.replay_srv_id;
            if (data.log_list) {
                this.setGodLogData(data.log_list);
            }
        }, this)
    },
 
    // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
    openRootWnd: function (index) {
        index = index || 1;
        this.changeSelectedTab(index);
    },
 
    changeSelectedTab: function (index) {
        if (this.tab_object != null && this.tab_object.index == index) return
        if (this.tab_object) {
            // this.tab_object.tab_btn
            this.loadRes(PathTool.getUIIconPath("common", "common_2023"), function (sp) {
                this.tab_object.tab_btn_sp.spriteFrame = sp;
            }.bind(this))
            this.tab_object.label.node.color = this.color_1;
            this.tab_object = null;
        }
 
        this.tab_object = this.tab_list[index];
        if (this.tab_object) {
            this.loadRes(PathTool.getUIIconPath("common", "common_2021"), function (sp) {
                this.tab_object.tab_btn_sp.spriteFrame = sp;
            }.bind(this))
            this.tab_object.label.node.color = this.color_2;
        }
 
        this.__ctor__.title_bg.active = index == 1;
        this.my_log_scrollview.setRootVisible(index == 1);
        this.god_log_scrollview.setRootVisible(index == 2);
 
        if ((index == 1 && this.myLogData && Utils.next(this.myLogData)) != null || (index == 2 && this.godLogData && Utils.next(this.godLogData) != null)) {
            this.no_log_image.active = false;
            this.no_log_label.node.active = false;
        } else {
            this.no_log_image.active = true;
            this.no_log_label.node.active = true;
        }
 
        if (index == 1 && !this.init_my_log) {
            this.ctrl.requestMyLogData();
            this.init_my_log = true;
        } else if (index == 2 && !this.init_god_log) {
            this.ctrl.requestGodLogData();
            this.init_god_log = true;
        }
    },
 
    setMyLogData: function (myLogData) {
        if (this.tab_object == null || this.tab_object.index != 1) return
        this.myLogData = myLogData;
        if (myLogData && Utils.next(myLogData) != null) {
            this.my_log_scrollview.setRootVisible(true);
            this.no_log_image.active = false;
            this.no_log_label.node.active = false;
 
            let extend = {};
            extend.callback = function (world_pos, replay_id, name, srv_id) {
                this.replay_id = replay_id;
                this.def_name = name;
                this.share_srv_id = srv_id;
                let node_pos = this.share_panel.convertToNodeSpaceAR(world_pos);
                if (node_pos) {
                    this.share_bg.setPosition(cc.v2(node_pos.x - 32, node_pos.y + 70));
                    this.share_panel.active = true;
                }
            }.bind(this)
            extend.replay_srv_id = this.my_log_replay_srv_id;
            this.my_log_scrollview.setData(myLogData, null, extend);
        } else {
            this.my_log_scrollview.setRootVisible(false);
            this.no_log_image.active = true;
            this.no_log_label.active = true;
        }
    },
 
    setGodLogData: function (godLogData) {
        if (this.tab_object == null || this.tab_object.index != 2) return
        this.godLogData = godLogData;
        if (godLogData && Utils.next(godLogData) != null) {
            this.god_log_scrollview.setRootVisible(true);
            this.no_log_image.active = false;
            this.no_log_label.active = false;
            this.god_log_scrollview.setData(godLogData, null, this.god_log_replay_srv_id);
        } else {
            this.god_log_scrollview.setRootVisible(false);
            this.no_log_image.active = true;
            this.no_log_label.active = true;
        }
    },
 
 
 
    // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
    closeCallBack: function () {
        this.model.updateLadderRedStatus(LadderConst.RedType.BattleLog, false);
        if (this.my_log_scrollview) {
            this.my_log_scrollview.deleteMe();
            this.my_log_scrollview = null;
        }
        if (this.god_log_scrollview) {
            this.god_log_scrollview.deleteMe();
            this.god_log_scrollview = null;
        }
        this.ctrl.openLadderLogWindow(false);
    },
})