Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
renderingEngine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
renderingEngine
Commits
f987a9a6
Commit
f987a9a6
authored
Nov 08, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代理
parent
8b44bc20
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
203 additions
and
197 deletions
+203
-197
index.js
dist/index.js
+104
-111
index.js.map
dist/index.js.map
+1
-1
auto-adjust.ts
src/zeroing/decorators/auto-adjust.ts
+86
-65
events.ts
src/zeroing/decorators/events.ts
+3
-3
scripts.ts
src/zeroing/decorators/scripts.ts
+9
-17
No files found.
dist/index.js
View file @
f987a9a6
...
@@ -1686,52 +1686,73 @@
...
@@ -1686,52 +1686,73 @@
return
MouseEvent
;
return
MouseEvent
;
}(
Event
));
}(
Event
));
var
AdjustData
=
(
function
()
{
function
AdjustData
()
{
this
.
percentWidth
=
NaN
;
this
.
percentHeight
=
NaN
;
this
.
left
=
NaN
;
this
.
top
=
NaN
;
this
.
right
=
NaN
;
this
.
bottom
=
NaN
;
this
.
horizonCenter
=
NaN
;
this
.
verticalCenter
=
NaN
;
}
return
AdjustData
;
}());
function
t
(
v
)
{
return
!
isNaN
(
v
)
&&
v
!==
null
&&
v
!==
undefined
;
}
function
applyAutoAdjust
(
ctor
)
{
function
applyAutoAdjust
(
ctor
)
{
ctor
.
prototype
.
applyAutoAdjust
=
function
()
{
ctor
.
prototype
.
applyAutoAdjust
=
function
()
{
var
adjustData
=
new
AdjustData
();
var
adjustProxy
=
this
.
adjustProxy
=
new
AdjustProxy
(
this
);
this
.
__sizeDirty
=
true
;
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
adjustProxy
.
onAddedToStage
,
adjustProxy
);
this
.
adjustData
=
adjustData
;
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
adjustProxy
.
onRemovedFromStage
,
adjustProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
this
.
__onAddedToStageAA
,
this
);
};
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
this
.
__onRemovedFromStageAA
,
this
);
var
temp
=
new
AdjustProxy
(
null
);
};
var
_loop_1
=
function
(
key
)
{
ctor
.
prototype
.
__onAddedToStageAA
=
function
()
{
Object
.
defineProperty
(
ctor
.
prototype
,
key
,
{
this
.
parent
.
addEventListener
(
Event
.
RESIZE
,
this
.
__onResizeAA
,
this
);
get
:
function
()
{
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameAA
,
this
);
return
this
.
adjustProxy
.
data
[
key
];
};
},
ctor
.
prototype
.
__onRemovedFromStageAA
=
function
()
{
set
:
function
(
v
)
{
this
.
parent
.
removeEventListener
(
Event
.
RESIZE
,
this
.
__onResizeAA
);
var
adjustProxy
=
this
.
adjustProxy
;
this
.
removeEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameAA
);
if
(
adjustProxy
.
data
[
key
]
!==
v
)
{
};
adjustProxy
.
data
[
key
]
=
v
;
ctor
.
prototype
.
__onResizeAA
=
function
()
{
adjustProxy
.
makeDirty
();
this
.
__sizeDirty
=
true
;
}
};
},
ctor
.
prototype
.
__onEnterFrameAA
=
function
()
{
enumerable
:
true
,
if
(
this
.
__sizeDirty
)
{
configurable
:
true
this
.
__sizeDirty
=
false
;
});
};
for
(
var
key
in
temp
.
data
)
{
_loop_1
(
key
);
}
}
var
AdjustProxy
=
(
function
()
{
function
AdjustProxy
(
host
)
{
this
.
data
=
{
percentWidth
:
NaN
,
percentHeight
:
NaN
,
left
:
NaN
,
top
:
NaN
,
right
:
NaN
,
bottom
:
NaN
,
horizonCenter
:
NaN
,
verticalCenter
:
NaN
,
};
this
.
_host
=
host
;
this
.
makeDirty
();
}
AdjustProxy
.
prototype
.
makeDirty
=
function
()
{
this
.
_sizeDirty
=
true
;
};
AdjustProxy
.
prototype
.
onAddedToStage
=
function
(
e
)
{
this
.
_host
.
parent
.
addEventListener
(
Event
.
RESIZE
,
this
.
onResize
,
this
);
this
.
_host
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
};
AdjustProxy
.
prototype
.
onRemovedFromStage
=
function
(
e
)
{
this
.
_host
.
parent
.
removeEventListener
(
Event
.
RESIZE
,
this
.
onResize
);
this
.
_host
.
removeEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
);
};
AdjustProxy
.
prototype
.
onResize
=
function
(
e
)
{
this
.
_sizeDirty
=
true
;
};
AdjustProxy
.
prototype
.
onEnterFrame
=
function
(
e
)
{
if
(
this
.
_sizeDirty
)
{
this
.
_sizeDirty
=
false
;
this
.
adjustLayout
();
this
.
adjustLayout
();
}
}
};
};
ctor
.
prototype
.
adjustLayout
=
function
()
{
AdjustProxy
.
prototype
.
adjustLayout
=
function
()
{
var
that
=
this
;
var
that
=
this
.
_host
;
var
_a
=
th
is
.
parent
,
pWidth
=
_a
.
width
,
pHeight
=
_a
.
height
;
var
_a
=
th
at
.
parent
,
pWidth
=
_a
.
width
,
pHeight
=
_a
.
height
;
var
_b
=
this
,
width
=
_b
.
width
,
height
=
_b
.
height
;
var
width
=
that
.
width
,
height
=
that
.
height
;
var
_
c
=
this
.
adjustData
,
percentWidth
=
_c
.
percentWidth
,
percentHeight
=
_c
.
percentHeight
,
left
=
_c
.
left
,
top
=
_c
.
top
,
right
=
_c
.
right
,
bottom
=
_c
.
bottom
,
horizonCenter
=
_c
.
horizonCenter
,
verticalCenter
=
_c
.
verticalCenter
;
var
_
b
=
this
.
data
,
percentWidth
=
_b
.
percentWidth
,
percentHeight
=
_b
.
percentHeight
,
left
=
_b
.
left
,
top
=
_b
.
top
,
right
=
_b
.
right
,
bottom
=
_b
.
bottom
,
horizonCenter
=
_b
.
horizonCenter
,
verticalCenter
=
_b
.
verticalCenter
;
var
applyPercentWidth
=
function
()
{
var
applyPercentWidth
=
function
()
{
if
(
t
(
percentWidth
))
{
if
(
t
(
percentWidth
))
{
that
.
width
=
pWidth
*
percentWidth
/
100
;
that
.
width
=
pWidth
*
percentWidth
/
100
;
...
@@ -1745,18 +1766,18 @@
...
@@ -1745,18 +1766,18 @@
var
pw
=
true
,
ph
=
true
;
var
pw
=
true
,
ph
=
true
;
if
(
t
(
horizonCenter
))
{
if
(
t
(
horizonCenter
))
{
applyPercentWidth
();
applyPercentWidth
();
th
is
.
x
=
(
pWidth
-
this
.
width
)
/
2
+
horizonCenter
;
th
at
.
x
=
(
pWidth
-
that
.
width
)
/
2
+
horizonCenter
;
}
}
else
{
else
{
if
(
t
(
left
))
{
if
(
t
(
left
))
{
th
is
.
x
=
left
;
th
at
.
x
=
left
;
if
(
t
(
right
))
{
if
(
t
(
right
))
{
th
is
.
width
=
pWidth
-
left
-
right
;
th
at
.
width
=
pWidth
-
left
-
right
;
pw
=
false
;
pw
=
false
;
}
}
}
}
else
if
(
t
(
right
))
{
else
if
(
t
(
right
))
{
th
is
.
x
=
pWidth
-
width
-
right
;
th
at
.
x
=
pWidth
-
width
-
right
;
}
}
if
(
pw
)
{
if
(
pw
)
{
applyPercentWidth
();
applyPercentWidth
();
...
@@ -1764,60 +1785,37 @@
...
@@ -1764,60 +1785,37 @@
}
}
if
(
t
(
verticalCenter
))
{
if
(
t
(
verticalCenter
))
{
applyPercentHeight
();
applyPercentHeight
();
th
is
.
y
=
(
pHeight
-
this
.
height
)
/
2
+
verticalCenter
;
th
at
.
y
=
(
pHeight
-
that
.
height
)
/
2
+
verticalCenter
;
}
}
else
{
else
{
if
(
t
(
top
))
{
if
(
t
(
top
))
{
th
is
.
y
=
top
;
th
at
.
y
=
top
;
if
(
t
(
bottom
))
{
if
(
t
(
bottom
))
{
th
is
.
height
=
pHeight
-
top
-
bottom
;
th
at
.
height
=
pHeight
-
top
-
bottom
;
ph
=
false
;
ph
=
false
;
}
}
}
}
else
if
(
t
(
bottom
))
{
else
if
(
t
(
bottom
))
{
th
is
.
y
=
pHeight
-
height
-
bottom
;
th
at
.
y
=
pHeight
-
height
-
bottom
;
}
}
if
(
ph
)
{
if
(
ph
)
{
applyPercentHeight
();
applyPercentHeight
();
}
}
}
}
};
};
var
_loop_1
=
function
(
key
)
{
return
AdjustProxy
;
Object
.
defineProperty
(
ctor
.
prototype
,
key
,
{
}());
get
:
function
()
{
function
t
(
v
)
{
return
this
.
adjustData
[
key
];
return
!
isNaN
(
v
)
&&
v
!==
null
&&
v
!==
undefined
;
},
set
:
function
(
v
)
{
if
(
this
.
adjustData
[
key
]
!==
v
)
{
this
.
adjustData
[
key
]
=
v
;
this
.
__sizeDirty
=
true
;
}
},
enumerable
:
true
,
configurable
:
true
});
};
for
(
var
key
in
new
AdjustData
())
{
_loop_1
(
key
);
}
}
}
var
scriptDefs
=
{};
var
scriptDefs
=
{};
function
applyScript
(
ctor
)
{
function
applyScript
(
ctor
)
{
ctor
.
prototype
.
applyScripts
=
function
()
{
ctor
.
prototype
.
applyScripts
=
function
()
{
this
.
scripts
=
new
ScriptsContainer
(
this
);
var
scriptsProxy
=
this
.
scriptsProxy
=
new
ScriptsProxy
(
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameS
,
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
this
.
__onAddedToStageS
,
this
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
this
.
__onRemovedFromStageS
,
this
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
scriptsProxy
.
onRemovedFromStage
,
scriptsProxy
);
};
ctor
.
prototype
.
__onEnterFrameS
=
function
(
e
)
{
this
.
scripts
.
update
(
e
.
data
);
};
ctor
.
prototype
.
__onAddedToStageS
=
function
(
e
)
{
this
.
scripts
.
awake
();
};
ctor
.
prototype
.
__onRemovedFromStageS
=
function
(
e
)
{
this
.
scripts
.
sleep
();
};
};
}
}
function
registerScriptDef
(
def
)
{
function
registerScriptDef
(
def
)
{
...
@@ -1841,19 +1839,19 @@
...
@@ -1841,19 +1839,19 @@
configurable
:
true
configurable
:
true
});
});
}
}
var
Scripts
Container
=
(
function
()
{
var
Scripts
Proxy
=
(
function
()
{
function
Scripts
Container
(
host
)
{
function
Scripts
Proxy
(
host
)
{
this
.
_scripts
=
[];
this
.
_scripts
=
[];
this
.
_host
=
host
;
this
.
_host
=
host
;
}
}
Object
.
defineProperty
(
Scripts
Container
.
prototype
,
"host"
,
{
Object
.
defineProperty
(
Scripts
Proxy
.
prototype
,
"host"
,
{
get
:
function
()
{
get
:
function
()
{
return
this
.
_host
;
return
this
.
_host
;
},
},
enumerable
:
true
,
enumerable
:
true
,
configurable
:
true
configurable
:
true
});
});
Scripts
Container
.
prototype
.
add
=
function
(
name
,
options
,
disabled
)
{
Scripts
Proxy
.
prototype
.
add
=
function
(
name
,
options
,
disabled
)
{
var
def
=
scriptDefs
[
name
];
var
def
=
scriptDefs
[
name
];
if
(
!
def
)
{
if
(
!
def
)
{
console
.
warn
(
'script def not exists'
);
console
.
warn
(
'script def not exists'
);
...
@@ -1872,7 +1870,7 @@
...
@@ -1872,7 +1870,7 @@
}
}
return
script
;
return
script
;
};
};
Scripts
Container
.
prototype
.
remove
=
function
(
index
)
{
Scripts
Proxy
.
prototype
.
remove
=
function
(
index
)
{
var
script
=
this
.
_scripts
.
splice
(
index
,
1
)[
0
];
var
script
=
this
.
_scripts
.
splice
(
index
,
1
)[
0
];
if
(
script
)
{
if
(
script
)
{
if
(
this
.
_host
&&
this
.
_host
.
stage
)
{
if
(
this
.
_host
&&
this
.
_host
.
stage
)
{
...
@@ -1882,17 +1880,17 @@
...
@@ -1882,17 +1880,17 @@
}
}
return
script
;
return
script
;
};
};
Object
.
defineProperty
(
Scripts
Container
.
prototype
,
"all"
,
{
Object
.
defineProperty
(
Scripts
Proxy
.
prototype
,
"all"
,
{
get
:
function
()
{
get
:
function
()
{
return
this
.
_scripts
;
return
this
.
_scripts
;
},
},
enumerable
:
true
,
enumerable
:
true
,
configurable
:
true
configurable
:
true
});
});
Scripts
Container
.
prototype
.
get
=
function
(
name
)
{
Scripts
Proxy
.
prototype
.
get
=
function
(
name
)
{
return
this
.
_scripts
.
filter
(
function
(
script
)
{
return
script
.
constructor
[
'name'
]
===
name
;
});
return
this
.
_scripts
.
filter
(
function
(
script
)
{
return
script
.
constructor
[
'name'
]
===
name
;
});
};
};
Scripts
Container
.
prototype
.
awak
e
=
function
()
{
Scripts
Proxy
.
prototype
.
onAddedToStag
e
=
function
()
{
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
var
script
=
_a
[
_i
];
var
script
=
_a
[
_i
];
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
...
@@ -1900,7 +1898,7 @@
...
@@ -1900,7 +1898,7 @@
}
}
}
}
};
};
Scripts
Container
.
prototype
.
sleep
=
function
()
{
Scripts
Proxy
.
prototype
.
onRemovedFromStage
=
function
()
{
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
var
script
=
_a
[
_i
];
var
script
=
_a
[
_i
];
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
...
@@ -1908,7 +1906,8 @@
...
@@ -1908,7 +1906,8 @@
}
}
}
}
};
};
ScriptsContainer
.
prototype
.
update
=
function
(
t
)
{
ScriptsProxy
.
prototype
.
onEnterFrame
=
function
(
e
)
{
var
t
=
e
.
data
;
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
for
(
var
_i
=
0
,
_a
=
this
.
_scripts
;
_i
<
_a
.
length
;
_i
++
)
{
var
script
=
_a
[
_i
];
var
script
=
_a
[
_i
];
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
...
@@ -1916,7 +1915,7 @@
...
@@ -1916,7 +1915,7 @@
}
}
}
}
};
};
return
Scripts
Container
;
return
Scripts
Proxy
;
}());
}());
var
_a
;
var
_a
;
...
@@ -1925,25 +1924,25 @@
...
@@ -1925,25 +1924,25 @@
_a
);
_a
);
function
applyEvents
(
ctor
)
{
function
applyEvents
(
ctor
)
{
ctor
.
prototype
.
applyEvents
=
function
()
{
ctor
.
prototype
.
applyEvents
=
function
()
{
var
events
=
this
.
events
=
new
Events
();
var
events
Proxy
=
this
.
eventsProxy
=
new
EventsProxy
();
for
(
var
k
in
eventsConfig
)
{
for
(
var
k
in
eventsConfig
)
{
this
.
addEventListener
(
k
,
events
.
onEvent
,
events
);
this
.
addEventListener
(
k
,
events
Proxy
.
onEvent
,
eventsProxy
);
}
}
};
};
}
}
var
Events
=
(
function
(
_super
)
{
var
Events
Proxy
=
(
function
(
_super
)
{
__extends
(
Events
,
_super
);
__extends
(
Events
Proxy
,
_super
);
function
Events
()
{
function
Events
Proxy
()
{
return
_super
.
call
(
this
)
||
this
;
return
_super
.
call
(
this
)
||
this
;
}
}
Events
.
prototype
.
invoke
=
function
(
name
,
e
)
{
Events
Proxy
.
prototype
.
invoke
=
function
(
name
,
e
)
{
};
};
Events
.
prototype
.
onEvent
=
function
(
e
)
{
Events
Proxy
.
prototype
.
onEvent
=
function
(
e
)
{
console
.
log
(
this
.
instanceId
,
e
.
type
,
e
.
currentTarget
.
name
);
console
.
log
(
this
.
instanceId
,
e
.
type
,
e
.
currentTarget
.
name
);
};
};
Events
.
prototype
.
destroy
=
function
()
{
Events
Proxy
.
prototype
.
destroy
=
function
()
{
};
};
return
Events
;
return
Events
Proxy
;
}(
HashObject
));
}(
HashObject
));
var
Container
=
(
function
(
_super
)
{
var
Container
=
(
function
(
_super
)
{
...
@@ -2189,7 +2188,7 @@
...
@@ -2189,7 +2188,7 @@
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
!
this
.
visible
)
if
(
!
this
.
visible
)
return
null
;
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouse
Enabled
)
if
(
isMouseEvent
&&
!
this
.
mouse
Children
)
return
null
;
return
null
;
var
children
=
this
.
children
;
var
children
=
this
.
children
;
var
length
=
children
.
length
;
var
length
=
children
.
length
;
...
@@ -4112,7 +4111,7 @@
...
@@ -4112,7 +4111,7 @@
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
!
this
.
visible
)
if
(
!
this
.
visible
)
return
null
;
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
)
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
&&
!
this
.
mouseChildren
)
return
null
;
return
null
;
var
hitDisplayObject
;
var
hitDisplayObject
;
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
...
@@ -8523,10 +8522,9 @@
...
@@ -8523,10 +8522,9 @@
};
};
Graphics
.
prototype
.
hitTestPoint
=
function
(
point
,
isMouseEvent
)
{
Graphics
.
prototype
.
hitTestPoint
=
function
(
point
,
isMouseEvent
)
{
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
var
s
=
this
;
if
(
!
this
.
visible
)
if
(
!
s
.
visible
)
return
null
;
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnabled
)
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
&&
!
this
.
mouseChildren
)
return
null
;
return
null
;
var
hitDisplayObject
;
var
hitDisplayObject
;
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
point
,
isMouseEvent
);
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
point
,
isMouseEvent
);
...
@@ -8535,7 +8533,7 @@
...
@@ -8535,7 +8533,7 @@
this
.
updateLocalBoundsSelf
();
this
.
updateLocalBoundsSelf
();
hitDisplayObject
=
this
.
displayObjectHitTestPoint
(
point
,
isMouseEvent
);
hitDisplayObject
=
this
.
displayObjectHitTestPoint
(
point
,
isMouseEvent
);
if
(
hitDisplayObject
)
{
if
(
hitDisplayObject
)
{
if
(
!
s
.
hitTestByPixel
)
if
(
!
thi
s
.
hitTestByPixel
)
return
hitDisplayObject
;
return
hitDisplayObject
;
return
this
.
hitTestPointAccuratly
(
point
);
return
this
.
hitTestPointAccuratly
(
point
);
}
}
...
@@ -9180,10 +9178,6 @@
...
@@ -9180,10 +9178,6 @@
Shape
.
prototype
.
hitTestPoint
=
function
(
globalPoint
,
isMouseEvent
)
{
Shape
.
prototype
.
hitTestPoint
=
function
(
globalPoint
,
isMouseEvent
)
{
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
var
s
=
this
;
var
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnabled
)
return
null
;
var
hitResult
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
var
hitResult
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
if
(
!
hitResult
)
if
(
!
hitResult
)
return
null
;
return
null
;
...
@@ -11181,7 +11175,6 @@
...
@@ -11181,7 +11175,6 @@
return
gameStage
;
return
gameStage
;
}
}
exports
.
AdjustData
=
AdjustData
;
exports
.
BaseTexture
=
BaseTexture
;
exports
.
BaseTexture
=
BaseTexture
;
exports
.
Button
=
Button
;
exports
.
Button
=
Button
;
exports
.
Circle
=
Circle$1
;
exports
.
Circle
=
Circle$1
;
...
...
dist/index.js.map
View file @
f987a9a6
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/zeroing/decorators/auto-adjust.ts
View file @
f987a9a6
...
@@ -6,59 +6,89 @@
...
@@ -6,59 +6,89 @@
import
{
Event
}
from
"../../2d/events"
;
import
{
Event
}
from
"../../2d/events"
;
/**
* 自适应数据
*/
export
class
AdjustData
{
percentWidth
:
number
=
NaN
;
percentHeight
:
number
=
NaN
;
left
:
number
=
NaN
;
top
:
number
=
NaN
;
right
:
number
=
NaN
;
bottom
:
number
=
NaN
;
horizonCenter
:
number
=
NaN
;
verticalCenter
:
number
=
NaN
;
}
function
t
(
v
)
{
return
!
isNaN
(
v
)
&&
v
!==
null
&&
v
!==
undefined
;
}
/**
/**
* 应用自适应
* 应用自适应
* @param ctor
* @param ctor
*/
*/
export
function
applyAutoAdjust
(
ctor
:
Function
)
{
export
function
applyAutoAdjust
(
ctor
:
Function
)
{
ctor
.
prototype
.
applyAutoAdjust
=
function
()
{
ctor
.
prototype
.
applyAutoAdjust
=
function
()
{
let
adjustData
=
new
AdjustData
();
let
adjustProxy
=
this
.
adjustProxy
=
new
AdjustProxy
(
this
);
this
.
__sizeDirty
=
true
;
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
adjustProxy
.
onAddedToStage
,
adjustProxy
);
this
.
adjustData
=
adjustData
;
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
adjustProxy
.
onRemovedFromStage
,
adjustProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
this
.
__onAddedToStageAA
,
this
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
this
.
__onRemovedFromStageAA
,
this
);
};
ctor
.
prototype
.
__onAddedToStageAA
=
function
()
{
this
.
parent
.
addEventListener
(
Event
.
RESIZE
,
this
.
__onResizeAA
,
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameAA
,
this
);
};
};
ctor
.
prototype
.
__onRemovedFromStageAA
=
function
()
{
let
temp
=
new
AdjustProxy
(
null
);
this
.
parent
.
removeEventListener
(
Event
.
RESIZE
,
this
.
__onResizeAA
);
for
(
let
key
in
temp
.
data
)
this
.
removeEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameAA
);
Object
.
defineProperty
(
ctor
.
prototype
,
key
,
{
};
get
:
function
()
{
ctor
.
prototype
.
__onResizeAA
=
function
()
{
return
this
.
adjustProxy
.
data
[
key
];
this
.
__sizeDirty
=
true
;
},
set
:
function
(
v
)
{
const
adjustProxy
:
AdjustProxy
=
this
.
adjustProxy
;
if
(
adjustProxy
.
data
[
key
]
!==
v
)
{
adjustProxy
.
data
[
key
]
=
v
;
adjustProxy
.
makeDirty
();
}
},
enumerable
:
true
,
configurable
:
true
});
}
/**
* 自适应数据
*/
class
AdjustProxy
{
data
=
{
percentWidth
:
NaN
,
percentHeight
:
NaN
,
left
:
NaN
,
top
:
NaN
,
right
:
NaN
,
bottom
:
NaN
,
horizonCenter
:
NaN
,
verticalCenter
:
NaN
,
};
};
ctor
.
prototype
.
__onEnterFrameAA
=
function
()
{
if
(
this
.
__sizeDirty
)
{
private
_host
;
this
.
__sizeDirty
=
false
;
private
_sizeDirty
;
constructor
(
host
)
{
this
.
_host
=
host
;
this
.
makeDirty
();
}
makeDirty
()
{
this
.
_sizeDirty
=
true
;
}
onAddedToStage
(
e
)
{
this
.
_host
.
parent
.
addEventListener
(
Event
.
RESIZE
,
this
.
onResize
,
this
);
this
.
_host
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
onRemovedFromStage
(
e
)
{
this
.
_host
.
parent
.
removeEventListener
(
Event
.
RESIZE
,
this
.
onResize
);
this
.
_host
.
removeEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
);
}
private
onResize
(
e
)
{
this
.
_sizeDirty
=
true
;
}
private
onEnterFrame
(
e
)
{
if
(
this
.
_sizeDirty
)
{
this
.
_sizeDirty
=
false
;
this
.
adjustLayout
();
this
.
adjustLayout
();
}
}
};
}
ctor
.
prototype
.
adjustLayout
=
function
()
{
const
that
=
this
;
adjustLayout
()
{
const
{
width
:
pWidth
,
height
:
pHeight
}
=
this
.
parent
;
const
that
=
this
.
_host
;
const
{
width
,
height
}
=
this
;
const
{
percentWidth
,
percentHeight
,
left
,
top
,
right
,
bottom
,
horizonCenter
,
verticalCenter
}
=
this
.
adjustData
;
const
{
width
:
pWidth
,
height
:
pHeight
}
=
that
.
parent
;
const
{
width
,
height
}
=
that
;
const
{
percentWidth
,
percentHeight
,
left
,
top
,
right
,
bottom
,
horizonCenter
,
verticalCenter
}
=
this
.
data
;
const
applyPercentWidth
=
function
()
{
const
applyPercentWidth
=
function
()
{
if
(
t
(
percentWidth
))
{
if
(
t
(
percentWidth
))
{
...
@@ -74,16 +104,16 @@ export function applyAutoAdjust(ctor: Function) {
...
@@ -74,16 +104,16 @@ export function applyAutoAdjust(ctor: Function) {
let
pw
=
true
,
ph
=
true
;
let
pw
=
true
,
ph
=
true
;
if
(
t
(
horizonCenter
))
{
if
(
t
(
horizonCenter
))
{
applyPercentWidth
();
applyPercentWidth
();
th
is
.
x
=
(
pWidth
-
this
.
width
)
/
2
+
horizonCenter
;
th
at
.
x
=
(
pWidth
-
that
.
width
)
/
2
+
horizonCenter
;
}
else
{
}
else
{
if
(
t
(
left
))
{
if
(
t
(
left
))
{
th
is
.
x
=
left
;
th
at
.
x
=
left
;
if
(
t
(
right
))
{
if
(
t
(
right
))
{
th
is
.
width
=
pWidth
-
left
-
right
;
th
at
.
width
=
pWidth
-
left
-
right
;
pw
=
false
;
pw
=
false
;
}
}
}
else
if
(
t
(
right
))
{
}
else
if
(
t
(
right
))
{
th
is
.
x
=
pWidth
-
width
-
right
;
th
at
.
x
=
pWidth
-
width
-
right
;
}
}
if
(
pw
)
{
if
(
pw
)
{
applyPercentWidth
();
applyPercentWidth
();
...
@@ -92,34 +122,25 @@ export function applyAutoAdjust(ctor: Function) {
...
@@ -92,34 +122,25 @@ export function applyAutoAdjust(ctor: Function) {
if
(
t
(
verticalCenter
))
{
if
(
t
(
verticalCenter
))
{
applyPercentHeight
();
applyPercentHeight
();
th
is
.
y
=
(
pHeight
-
this
.
height
)
/
2
+
verticalCenter
;
th
at
.
y
=
(
pHeight
-
that
.
height
)
/
2
+
verticalCenter
;
}
else
{
}
else
{
if
(
t
(
top
))
{
if
(
t
(
top
))
{
th
is
.
y
=
top
;
th
at
.
y
=
top
;
if
(
t
(
bottom
))
{
if
(
t
(
bottom
))
{
th
is
.
height
=
pHeight
-
top
-
bottom
;
th
at
.
height
=
pHeight
-
top
-
bottom
;
ph
=
false
;
ph
=
false
;
}
}
}
else
if
(
t
(
bottom
))
{
}
else
if
(
t
(
bottom
))
{
th
is
.
y
=
pHeight
-
height
-
bottom
;
th
at
.
y
=
pHeight
-
height
-
bottom
;
}
}
if
(
ph
)
{
if
(
ph
)
{
applyPercentHeight
();
applyPercentHeight
();
}
}
}
}
};
}
for
(
let
key
in
new
AdjustData
())
Object
.
defineProperty
(
ctor
.
prototype
,
key
,
{
}
get
:
function
()
{
return
this
.
adjustData
[
key
];
function
t
(
v
)
{
},
return
!
isNaN
(
v
)
&&
v
!==
null
&&
v
!==
undefined
;
set
:
function
(
v
)
{
if
(
this
.
adjustData
[
key
]
!==
v
)
{
this
.
adjustData
[
key
]
=
v
;
this
.
__sizeDirty
=
true
;
}
},
enumerable
:
true
,
configurable
:
true
});
}
}
src/zeroing/decorators/events.ts
View file @
f987a9a6
...
@@ -21,14 +21,14 @@ const eventsConfig = {
...
@@ -21,14 +21,14 @@ const eventsConfig = {
*/
*/
export
function
applyEvents
(
ctor
:
Function
)
{
export
function
applyEvents
(
ctor
:
Function
)
{
ctor
.
prototype
.
applyEvents
=
function
()
{
ctor
.
prototype
.
applyEvents
=
function
()
{
let
events
=
this
.
events
=
new
Events
();
let
events
Proxy
=
this
.
eventsProxy
=
new
EventsProxy
();
for
(
let
k
in
eventsConfig
){
for
(
let
k
in
eventsConfig
){
this
.
addEventListener
(
k
,
events
.
onEvent
,
events
);
this
.
addEventListener
(
k
,
events
Proxy
.
onEvent
,
eventsProxy
);
}
}
};
};
}
}
class
Events
extends
HashObject
{
class
Events
Proxy
extends
HashObject
{
constructor
(){
constructor
(){
super
();
super
();
}
}
...
...
src/zeroing/decorators/scripts.ts
View file @
f987a9a6
...
@@ -14,20 +14,11 @@ const scriptDefs = {};
...
@@ -14,20 +14,11 @@ const scriptDefs = {};
*/
*/
export
function
applyScript
(
ctor
:
Function
)
{
export
function
applyScript
(
ctor
:
Function
)
{
ctor
.
prototype
.
applyScripts
=
function
()
{
ctor
.
prototype
.
applyScripts
=
function
()
{
this
.
scripts
=
new
ScriptsContainer
(
this
);
let
scriptsProxy
=
this
.
scriptsProxy
=
new
ScriptsProxy
(
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
__onEnterFrameS
,
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
this
.
__onAddedToStageS
,
this
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
this
.
__onRemovedFromStageS
,
this
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
scriptsProxy
.
onRemovedFromStage
,
scriptsProxy
);
};
ctor
.
prototype
.
__onEnterFrameS
=
function
(
e
)
{
this
.
scripts
.
update
(
e
.
data
);
};
ctor
.
prototype
.
__onAddedToStageS
=
function
(
e
)
{
this
.
scripts
.
awake
();
};
ctor
.
prototype
.
__onRemovedFromStageS
=
function
(
e
)
{
this
.
scripts
.
sleep
();
};
};
}
}
...
@@ -79,7 +70,7 @@ export function registerScriptDef(def) {
...
@@ -79,7 +70,7 @@ export function registerScriptDef(def) {
/**
/**
* 脚本容器
* 脚本容器
*/
*/
class
Scripts
Container
{
class
Scripts
Proxy
{
private
_host
:
Container
;
private
_host
:
Container
;
private
_scripts
:
IScript
[]
=
[];
private
_scripts
:
IScript
[]
=
[];
...
@@ -152,7 +143,7 @@ class ScriptsContainer {
...
@@ -152,7 +143,7 @@ class ScriptsContainer {
/**
/**
* 唤醒
* 唤醒
*/
*/
awak
e
()
{
onAddedToStag
e
()
{
for
(
let
script
of
this
.
_scripts
)
{
for
(
let
script
of
this
.
_scripts
)
{
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
script
.
awake
();
script
.
awake
();
...
@@ -163,7 +154,7 @@ class ScriptsContainer {
...
@@ -163,7 +154,7 @@ class ScriptsContainer {
/**
/**
* 睡眠
* 睡眠
*/
*/
sleep
()
{
onRemovedFromStage
()
{
for
(
let
script
of
this
.
_scripts
)
{
for
(
let
script
of
this
.
_scripts
)
{
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
script
.
sleep
();
script
.
sleep
();
...
@@ -174,7 +165,8 @@ class ScriptsContainer {
...
@@ -174,7 +165,8 @@ class ScriptsContainer {
/**
/**
* 更新脚本时钟
* 更新脚本时钟
*/
*/
update
(
t
)
{
onEnterFrame
(
e
)
{
let
t
=
e
.
data
;
for
(
let
script
of
this
.
_scripts
)
{
for
(
let
script
of
this
.
_scripts
)
{
if
(
!
script
.
disabled
)
{
if
(
!
script
.
disabled
)
{
script
.
update
(
t
);
script
.
update
(
t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment