-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerTemplate.tmpl
173 lines (125 loc) · 3.86 KB
/
LayerTemplate.tmpl
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
#encoding: utf-8
#from LayerTemplateBase import LayerTemplateBase
#extends LayerTemplateBase
#set global $g_fullLayerName = '%s.%sLayer' % ($namespace, $name) ## 首字母大写
#set global $g_guiFileName = 'res/UI/%s/Layer%s.json' % ($namespace, $name)
#set global $g_modelName = 'model.%sModel' % $model ## 首字母大写
#set global $g_globalEventName = 'common.NotifyType.%s_EVENT' % $name ## 首字母大写
#set global $g_globalEventFuncName = '__on%sEvent' % $name ## 首字母大写
#set global $g_mediatorName = '%sLayerMediator' % $name
#set global $g_fullMediatorName = '%s.%sLayerMediator' % ($namespace, $name)
//
// $comment
//
/**
* 初始化、清理,不负责其他逻辑
*
*/
$g_fullLayerName \= game.IView.extend({
UI_MAIN : $g_guiFileName,
__data : null,
__root : null,
ctor:function(){
this._super();
//cc.log($g_fullLayerName\.DEBUG.format('ctor'));
this.__data = game.Facade.getModelData($g_modelName);
this.__root = ccs.load(this.UI_MAIN).node;
this.addChild(this.__root);
var comp = null;
#if $btn_back == True:
comp = this.__root.getChildByName('btn_back');
if(comp){
comp.addTouchEventListener(this.__onTouchEvent, this);
}
#end if
#if $btn_close == True:
comp = this.__root.getChildByName('btn_close');
if(comp){
comp.addTouchEventListener(this.__onTouchEvent, this);
}
#end if
this.__update();
return true;
},
destroy:function(){
},
__update:function(){
},
__onTouchEvent:function(sender, type){
switch(type){
case ccui.Widget.TOUCH_ENDED:
switch(sender.name){
#if $btn_back == True:
case 'btn_back':
this.send($g_globalEventName, {
key : sender.name
});
break;
#end if
#if $btn_close == True:
case 'btn_close':
this.send($g_globalEventName, {
key : sender.name
});
break;
#end if
default:
#if $global_event == True:
this.send($g_globalEventName, {
key : sender.name
});
#end if
break;
}
break;
}
},
});
/********************************************************************/
/** static **/
/********************************************************************/
$g_fullLayerName\.DEBUG = '## $g_fullLayerName\.{0}: ';
#if $mediator == True:
/********************************************************************/
/** mediator **/
/********************************************************************/
$g_fullMediatorName \= game.LayerMediator.extend({
ctor:function(view){
this._super(view, true);
//cc.log($g_fullMediatorName\.DEBUG.format('ctor'));
},
init:function (){
tools.UIUtils.AutoClearManager.getInstance().addSubscribe('$g_mediatorName',
g_fullMediatorName, this.$g_globalEventFuncName, this);
},
show:function(parent){
this._super(parent);
parent.addChild(this.currLayer);
},
freshen:function(){
},
destroy:function(){
tools.UIUtils.AutoClearManager.getInstance().removeAll('$g_mediatorName');
},
$g_globalEventFuncName:function(obj, unusedTarget){
switch(obj.key){
#if $btn_back == True:
case 'btn_back':
this.popLayer(this);
break;
#end if
#if $btn_close == True:
case 'btn_close':
this.popLayer(this, true);
break;
#end if
default:
break;
}
},
});
/********************************************************************/
/** static **/
/********************************************************************/
$g_fullMediatorName\.DEBUG = '## $g_fullMediatorName\.{0}: ';
#end if