-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJAXHudView.js
More file actions
184 lines (164 loc) · 4.48 KB
/
Copy pathJAXHudView.js
File metadata and controls
184 lines (164 loc) · 4.48 KB
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
import {JAXEnv,$JXV,$V} from "./JAXEnv.js";
import {JAXHudObj} from "./JAXHudObj.js";
import {jaxHudState} from "./JAXHudState.js";
var JAXHudView,__Proto;
JAXHudView=function(jaxEnv)
{
var statesInView=[];
var viewOnline=1;
var ownerView=null;
var allowValNotify=true;
var self=this;
var updateStates;
if(!jaxEnv){
return;
}
JAXHudObj.call(this,jaxEnv);
self.isJAXHudView=true;
//***********************************************************************
//属性/数据链接相关
//***********************************************************************
{
//-------------------------------------------------------------------
//当前View是否允许valNotify
Object.defineProperty(this,"allowValNotify",{
get:function(){
var view,ownerView;
if(!allowValNotify)
return false;
ownerView=this.ownerView;
return ownerView?ownerView.allowValNotify:true;
},
set:function(v){
v=v?true:false;
if(v!==allowValNotify){
allowValNotify=v;
if(v && self.stateObj){
self.stateObj.update();
}
}
}
});
//-------------------------------------------------------------------
//增加View绑定的HudState
this.addHudState=function(state){
statesInView.push(state);
};
//-------------------------------------------------------------------
//更新当前View下面的全部链接
this.updateStates=updateStates=function(){
var state;
for(state of statesInView){
state.updateState();
}
};
}
};
__Proto=JAXHudView.prototype=new JAXHudObj();
//***************************************************************************
//属性列表/注册创建函数:
//***************************************************************************
{
//CSS属性列表
JAXHudView.jaxPptSet=new Set(Array.from(JAXHudObj.jaxPptSet).concat([
'allowValNotify'
]));
//---------------------------------------------------------------------------
//注册基础Hud类
JAXHudObj.regHudByType('view', function (env) {
return new JAXHudView(env);
});
}
//***************************************************************************
//可继承的成员函数:
//***************************************************************************
{
//---------------------------------------------------------------
//ApplyCSS的最后,创建WebObj:
__Proto.preApplyCSS = function (cssObj) {
var div, father, self,stateObj;
let jaxEnv=this.jaxEnv;
let owner,ownerState;
father = this.father;
owner = this.owner;
this.removeAllChildren();
if (!this.webObj) {
div = this.webObj = document.createElement('div');
div.style.position = cssObj.position||"absolute";
father = this.father;
if (father && father.webObj) {
father.webObj.appendChild(div);
}
div.jaxObj = this;
}
if (cssObj.faces) {
cssObj.jaxObjHash = 1;
}
if(cssObj.jaxId){
this["#self"]=this;
//添加这个Hud
jaxEnv.addHashObj("#"+cssObj.jaxId, this);
}
this.jaxEnv.pushHudView(this);
//确定StateObj:
stateObj=cssObj.hudState;
if(stateObj){
ownerState=father?father.stateObj:(owner?owner.stateObj:null);
if(!stateObj.isJAXHudState) {
stateObj = jaxHudState(this.jaxEnv, stateObj);
}
this.jaxEnv.pushHudState(stateObj);
this.stateObj=stateObj;
this.stateObj_=stateObj;
stateObj.setupState(this,ownerState,this.hudView);
if(cssObj.jaxId){
//添加这个State对象
jaxEnv.addHashObj("%"+cssObj.jaxId, stateObj);
}
}else{
this.stateObj=this.jaxEnv.getCurHudState();
}
};
//---------------------------------------------------------------
//ApplyCSS把pptList赋值后
__Proto.finApplyCSS = function (cssObj) {
var self = this;
if (this.webObj) {
this.webObj.id = this.id;
}
this.items2Add_ = cssObj.items;
};
//---------------------------------------------------------------
//ApplyCSS的最后,设置WebObj属性:
__Proto.postApplyCSS = function (cssObj) {
let list;
list = this.items2Add_;
if (Array.isArray(list)) {
this._applyItems(list);
}
this.items2Add_ = null;
{
let hudPose, aniPose;
hudPose = this.hudPose;
aniPose = this.aniPose;
aniPose.x = 0;
aniPose.y = 0;
aniPose.alpha = hudPose.alpha;
aniPose.scale = hudPose.scale;
aniPose.rot = hudPose.rot;
}
if(cssObj.face){
this.showFace(cssObj.face);
}
this._syncWebObj();
let stateObj=this.stateObj_;
if(stateObj){
this.jaxEnv.popHudState(stateObj);
}
// if(cssObj.jaxObjHash){
// this.jaxEnv.popObjHasher(this);
// }
this.jaxEnv.popHudView(this);
};
}
export {JAXHudView};