-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerTemplate.py.bak
364 lines (284 loc) · 12.3 KB
/
LayerTemplate.py.bak
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/usr/bin/env python
# -*- coding: : utf-8 -*-
##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
import builtins as builtin
except ImportError:
import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from LayerTemplateBase import LayerTemplateBase
##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1466600727.944
__CHEETAH_genTimestamp__ = 'Wed Jun 22 21:05:27 2016'
__CHEETAH_src__ = 'LayerTemplate.tmpl'
__CHEETAH_srcLastModified__ = 'Wed Jun 22 21:05:25 2016'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
raise AssertionError(
'This template was compiled with Cheetah version'
' %s. Templates compiled before version %s must be recompiled.'%(
__CHEETAH_version__, RequiredCheetahVersion))
##################################################
## CLASSES
class LayerTemplate(Template):
##################################################
## CHEETAH GENERATED METHODS
def __init__(self, *args, **KWs):
super(LayerTemplate, self).__init__(*args, **KWs)
if not self._CHEETAH__instanceInitialized:
cheetahKWArgs = {}
allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
for k,v in KWs.items():
if k in allowedKWs: cheetahKWArgs[k] = v
self._initCheetahInstance(**cheetahKWArgs)
def respond(self, trans=None):
## CHEETAH: main method generated for this template
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
trans = self.transaction # is None unless self.awake() was called
if not trans:
trans = DummyTransaction()
_dummyTrans = True
else: _dummyTrans = False
write = trans.response().write
SL = self._CHEETAH__searchList
_filter = self._CHEETAH__currentFilter
########################################
## START - generated method body
# 首字母大写
self._CHEETAH__globalSetVars["g_fullLayerName"] = '%s.%sLayer' % (VFFSL(SL,"namespace",True), VFFSL(SL,"name",True))
self._CHEETAH__globalSetVars["g_guiFileName"] = 'res/UI/%s/Layer%s.json' % (VFFSL(SL,"namespace",True), VFFSL(SL,"name",True))
# 首字母大写
self._CHEETAH__globalSetVars["g_modelName"] = 'model.%sModel' % VFFSL(SL,"model",True)
# 首字母大写
self._CHEETAH__globalSetVars["g_globalEventName"] = 'common.NotifyType.%s_EVENT' % VFFSL(SL,"name",True)
# 首字母大写
self._CHEETAH__globalSetVars["g_globalEventFuncName"] = '__on%sEvent' % VFFSL(SL,"name",True)
self._CHEETAH__globalSetVars["g_mediatorName"] = '%sLayerMediator' % VFFSL(SL,"name",True)
self._CHEETAH__globalSetVars["g_fullMediatorName"] = '%s.$sLayerMediator' % (VFFSL(SL,"namespace",True), VFFSL(SL,"name",True))
write(u'''//
// ''')
_v = VFFSL(SL,"comment",True) # u'$comment' on line 11, col 4
if _v is not None: write(_filter(_v, rawExpr=u'$comment')) # from line 11, col 4.
write(u'''
//
/**
* \u521d\u59cb\u5316\u3001\u6e05\u7406\uff0c\u4e0d\u8d1f\u8d23\u5176\u4ed6\u903b\u8f91
*
*/
''')
_v = VFFSL(SL,"g_fullLayerName",True) # u'$g_fullLayerName' on line 19, col 1
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullLayerName')) # from line 19, col 1.
write(u'''\t\t\t\t\t\t\\= game.IView.extend({
\tUI_MAIN\t\t: ''')
_v = VFFSL(SL,"g_guiFileName",True) # u'$g_guiFileName' on line 21, col 13
if _v is not None: write(_filter(_v, rawExpr=u'$g_guiFileName')) # from line 21, col 13.
write(u''',
\t__data\t\t: null,
\t__root\t\t: null,
\tctor:function(){
\t\tthis._super();
//cc.log(''')
_v = VFFSL(SL,"g_fullLayerName",True) # u'$g_fullLayerName' on line 30, col 18
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullLayerName')) # from line 30, col 18.
write(u"""\\.DEBUG.format('ctor'));
\t\tthis.__data\t\t= game.Facade.getModelData(""")
_v = VFFSL(SL,"g_modelName",True) # u'$g_modelName' on line 32, col 43
if _v is not None: write(_filter(_v, rawExpr=u'$g_modelName')) # from line 32, col 43.
write(u''');
\t\tthis.__root\t\t= ccs.load(this.UI_MAIN).node;
\t\tthis.addChild(this.__root);
var comp = null;
''')
if VFFSL(SL,"btn_back",True) == True: # generated from line 39, col 1
write(u""" comp = this.__root.getChildByName('btn_back');
if(comp){
comp.addTouchEventListener(this.__onTouchEvent, this);
}
""")
write(u'''
''')
if VFFSL(SL,"btn_close",True) == True: # generated from line 46, col 1
write(u""" comp = this.__root.getChildByName('btn_close');
if(comp){
comp.addTouchEventListener(this.__onTouchEvent, this);
}
""")
write(u'''
\t\tthis.__update();
\t\treturn true;
\t},
destroy:function(){
},
__update:function(){
\t},
__onTouchEvent:function(sender, type){
\tswitch(type){
case ccui.Widget.TOUCH_ENDED:
switch(sender.name){
''')
if VFFSL(SL,"btn_back",True) == True: # generated from line 73, col 1
write(u""" case 'btn_back':
this.send(""")
_v = VFFSL(SL,"g_globalEventName",True) # u'$g_globalEventName' on line 75, col 27
if _v is not None: write(_filter(_v, rawExpr=u'$g_globalEventName')) # from line 75, col 27.
write(u''', {
key : sender.name
});
break;
''')
write(u'''
''')
if VFFSL(SL,"btn_close",True) == True: # generated from line 81, col 1
write(u""" case 'btn_close':
this.send(""")
_v = VFFSL(SL,"g_globalEventName",True) # u'$g_globalEventName' on line 83, col 27
if _v is not None: write(_filter(_v, rawExpr=u'$g_globalEventName')) # from line 83, col 27.
write(u''', {
key : sender.name
});
break;
''')
write(u'''
default:
''')
if VFFSL(SL,"global_event",True) == True: # generated from line 90, col 1
write(u''' this.send(''')
_v = VFFSL(SL,"g_globalEventName",True) # u'$g_globalEventName' on line 91, col 27
if _v is not None: write(_filter(_v, rawExpr=u'$g_globalEventName')) # from line 91, col 27.
write(u''', {
key : sender.name
});
''')
write(u''' break;
}
break;
}
},
});
/********************************************************************/
/** static **/
/********************************************************************/
''')
_v = VFFSL(SL,"g_fullLayerName",True) # u'$g_fullLayerName' on line 107, col 1
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullLayerName')) # from line 107, col 1.
write(u"""\\.DEBUG\t\t\t\t\t\t\t= '""")
# $g_fullLayerName\.{0}: ';
write(u'''
''')
if VFFSL(SL,"mediator",True) == True: # generated from line 109, col 1
write(u'''/********************************************************************/
/** mediator **/
/********************************************************************/
''')
_v = VFFSL(SL,"g_fullMediatorName",True) # u'$g_fullMediatorName' on line 114, col 1
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullMediatorName')) # from line 114, col 1.
write(u'''\t\t\t\t\t\t\t\\= game.LayerMediator.extend({
\tctor:function(view){
\t\tthis._super(view, true);
//cc.log(''')
_v = VFFSL(SL,"g_fullMediatorName",True) # u'$g_fullMediatorName' on line 120, col 18
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullMediatorName')) # from line 120, col 18.
write(u"""\\.DEBUG.format('ctor'));
\t},
\tinit:function (){
\t\ttools.UIUtils.AutoClearManager.getInstance().addSubscribe('""")
_v = VFFSL(SL,"g_mediatorName",True) # u'$g_mediatorName' on line 125, col 62
if _v is not None: write(_filter(_v, rawExpr=u'$g_mediatorName')) # from line 125, col 62.
write(u"""',
\t\t\tg_fullMediatorName, this.""")
_v = VFFSL(SL,"g_globalEventFuncName",True) # u'$g_globalEventFuncName' on line 126, col 29
if _v is not None: write(_filter(_v, rawExpr=u'$g_globalEventFuncName')) # from line 126, col 29.
write(u""", this);
\t},
\tshow:function(parent){
\t\tthis._super(parent);
\t\tparent.addChild(this.currLayer);
\t},
\tfreshen:function(){
\t},
\tdestroy:function(){
\t\ttools.UIUtils.AutoClearManager.getInstance().removeAll('""")
_v = VFFSL(SL,"g_mediatorName",True) # u'$g_mediatorName' on line 142, col 59
if _v is not None: write(_filter(_v, rawExpr=u'$g_mediatorName')) # from line 142, col 59.
write(u"""');
\t},
""")
_v = VFFSL(SL,"g_globalEventFuncName",True) # u'$g_globalEventFuncName' on line 146, col 5
if _v is not None: write(_filter(_v, rawExpr=u'$g_globalEventFuncName')) # from line 146, col 5.
write(u''':function(obj, unusedTarget){
switch(obj.key){
''')
if VFFSL(SL,"btn_back",True) == True: # generated from line 148, col 1
write(u""" case 'btn_back':
this.popLayer(this);
break;
""")
write(u'''
''')
if VFFSL(SL,"btn_close",True) == True: # generated from line 154, col 1
write(u""" case 'btn_close':
this.popLayer(this, true);
break;
""")
write(u'''
default:
break;
}
},
});
/********************************************************************/
/** static **/
/********************************************************************/
''')
_v = VFFSL(SL,"g_fullMediatorName",True) # u'$g_fullMediatorName' on line 171, col 1
if _v is not None: write(_filter(_v, rawExpr=u'$g_fullMediatorName')) # from line 171, col 1.
write(u"""\\.DEBUG\t\t\t\t\t\t\t= '""")
# $g_fullMediatorName\.{0}: ';
write(u'''
''')
########################################
## END - generated method body
return _dummyTrans and trans.response().getvalue() or ""
##################################################
## CHEETAH GENERATED ATTRIBUTES
_CHEETAH__instanceInitialized = False
_CHEETAH_version = __CHEETAH_version__
_CHEETAH_versionTuple = __CHEETAH_versionTuple__
_CHEETAH_genTime = __CHEETAH_genTime__
_CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
_CHEETAH_src = __CHEETAH_src__
_CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
_mainCheetahMethod_for_LayerTemplate= 'respond'
## END CLASS DEFINITION
if not hasattr(LayerTemplate, '_initCheetahAttributes'):
templateAPIClass = getattr(LayerTemplate, '_CHEETAH_templateClass', Template)
templateAPIClass._addCheetahPlumbingCodeToClass(LayerTemplate)
# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/
##################################################
## if run from command line:
if __name__ == '__main__':
from Cheetah.TemplateCmdLineIface import CmdLineIface
CmdLineIface(templateObj=LayerTemplate()).run()