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
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      日常主界面的成就标签页
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
 
var PathTool = require("pathtool");
var TaskController = require("task_controller");
var TaskItem = require("task_item");
var TaskEvent = require("task_event");
var CommonScrollView = require("common_scrollview");
 
var FeatPanel = cc.Class({
    extends: BasePanel,
    ctor: function () {
        this.prefabPath = PathTool.getPrefabPath("task", "feat_panel");
 
        this.ctrl = TaskController.getInstance();
        this.model = this.ctrl.getModel();
        this.status = null;
    },
 
 
    initPanel: function () {
 
        this.quest_container = this.root_wnd.getChildByName("quest_container");
        var size = this.quest_container.getContentSize();
        var scroll_view_size = cc.size(size.width, size.height-20)
        var setting = {
            item_class: TaskItem,      // 单元类
            start_x: 6,                    // 第一个单元的X起点
            space_x: 0,                    // x方向的间隔
            start_y: 0,                    // 第一个单元的Y起点
            space_y: 2,                   // y方向的间隔
            item_width: 610,               // 单元的尺寸width
            item_height: 148,              // 单元的尺寸height
            row: 0,                        // 行数,作用于水平滚动类型
            col: 1,                        // 列数,作用于垂直滚动类型
            need_dynamic: true
        }
        this.item_scrollview = new CommonScrollView()
        this.item_scrollview.createScroll(this.quest_container, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, scroll_view_size, setting, cc.v2(0.5, 0.5))
 
        this.addToParent(this.status);
    },
 
    addToParent: function (status) {
        // this.handleDynamicEvent(status);
        this.status = status;
        if (this.root_wnd == null)
            return
        this.setVisible(status);
        if (status == true)
            this.updateFeatList(true);
    },
 
    registerEvent: function () {
        this.addGlobalEvent(TaskEvent.UpdateFeatList, function () {
            this.updateFeatList();
        }.bind(this))
    },
 
    updateFeatList: function () {
        var list = this.model.getFeatList();
        this.item_scrollview.setData(list);
    },
 
    onDelete: function () {
        if (this.item_scrollview) {
            this.item_scrollview.deleteMe();
            this.item_scrollview = null;
        }
    }
 
});
 
module.exports = FeatPanel;