Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-engine
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
劳工
zeroing-engine
Commits
c7394971
Commit
c7394971
authored
Jun 16, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复
parent
efab095d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
371 additions
and
363 deletions
+371
-363
GameStage.ts
src/zeroing/game-warpper/GameStage.ts
+371
-363
No files found.
src/zeroing/game-warpper/GameStage.ts
View file @
c7394971
...
@@ -2,24 +2,24 @@
...
@@ -2,24 +2,24 @@
* Created by rockyl on 2019-11-05.
* Created by rockyl on 2019-11-05.
*/
*/
import
{
Stage
}
from
"../../2d/display/index"
;
import
{
Stage
}
from
"../../2d/display/index"
;
import
{
StackContainer
}
from
"./StackContainer"
;
import
{
StackContainer
}
from
"./StackContainer"
;
import
{
checkAssetGroupLoaded
,
loadAssetsGroup
,
loadAssets
,
loadAssetsGroups
}
from
"./assets-manager"
;
import
{
checkAssetGroupLoaded
,
loadAssetsGroup
,
loadAssets
,
loadAssetsGroups
}
from
"./assets-manager"
;
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
dataCenter
,
DataCenter
}
from
"./data-center"
;
import
{
dataCenter
,
DataCenter
}
from
"./data-center"
;
import
{
setProcessMetaLibs
}
from
"../behavior-runtime/index"
;
import
{
setProcessMetaLibs
}
from
"../behavior-runtime/index"
;
import
{
Tween
}
from
"../../2d/tween/index"
;
import
{
Tween
}
from
"../../2d/tween/index"
;
import
{
Rect
}
from
"./nodes/index"
;
import
{
Rect
}
from
"./nodes/index"
;
import
{
injectEnv
}
from
"./enviroment"
;
import
{
injectEnv
}
from
"./enviroment"
;
import
{
Toast
}
from
"./Toast"
;
import
{
Toast
}
from
"./Toast"
;
import
{
arrayFind
}
from
"../utils/index"
;
import
{
arrayFind
}
from
"../utils/index"
;
import
{
Node
}
from
"./nodes/Node"
;
import
{
Node
}
from
"./nodes/Node"
;
import
{
bind
,
createStore
}
from
"./mvvm/index"
;
import
{
bind
,
createStore
}
from
"./mvvm/index"
;
import
{
registerCustomModules
}
from
"./custom-module"
;
import
{
registerCustomModules
}
from
"./custom-module"
;
import
{
dealPageRemainTime
,
dealPxEnv
}
from
"../px-logics"
;
import
{
dealPageRemainTime
,
dealPxEnv
}
from
"../px-logics"
;
import
Container
from
"../../2d/display/Container"
;
import
Container
from
"../../2d/display/Container"
;
import
{
Event
}
from
"../../2d/events/Event"
;
import
{
Event
}
from
"../../2d/events/Event"
;
import
{
alignMgr
}
from
"../decorators/AlignManager"
;
import
{
alignMgr
}
from
"../decorators/AlignManager"
;
/**
/**
* 游戏舞台
* 游戏舞台
...
@@ -127,7 +127,7 @@ export class GameStage extends Node {
...
@@ -127,7 +127,7 @@ export class GameStage extends Node {
registerCustomModules
(
customs
);
registerCustomModules
(
customs
);
if
(
dataMapping
)
{
if
(
dataMapping
)
{
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
}
}
setProcessMetaLibs
(
processes
,
builtinProcesses
);
setProcessMetaLibs
(
processes
,
builtinProcesses
);
...
@@ -154,7 +154,7 @@ export class GameStage extends Node {
...
@@ -154,7 +154,7 @@ export class GameStage extends Node {
setTimeout
(
async
()
=>
{
setTimeout
(
async
()
=>
{
let
sceneEntry
=
await
this
.
instantiateView
(
entrySceneView
);
let
sceneEntry
=
await
this
.
instantiateView
(
entrySceneView
);
if
(
sceneEntry
)
{
if
(
sceneEntry
)
{
this
.
_sceneContainer
.
push
(
sceneEntry
);
this
.
_sceneContainer
.
push
(
sceneEntry
);
}
}
})
})
...
@@ -166,19 +166,27 @@ export class GameStage extends Node {
...
@@ -166,19 +166,27 @@ export class GameStage extends Node {
async
showInnerLoadingView
()
{
async
showInnerLoadingView
()
{
let
loadingViewName
=
this
.
_config
.
options
.
loadingView
;
let
loadingViewName
=
this
.
_config
.
options
.
loadingView
;
let
loadingView
=
this
.
_loadingView
.
getChildAt
(
0
);
let
loadingView
=
this
.
_loadingView
.
getChildAt
(
0
);
if
(
this
.
_loadingView
.
children
.
length
==
0
&&
loadingViewName
)
{
if
(
this
.
_loadingView
.
children
.
length
==
0
&&
loadingViewName
)
{
loadingView
=
await
this
.
instantiateView
(
loadingViewName
,
true
,
false
);
loadingView
=
await
this
.
instantiateView
(
loadingViewName
,
true
,
false
);
this
.
_loadingView
.
addChild
(
loadingView
);
this
.
_loadingView
.
addChild
(
loadingView
);
}
}
Tween
.
get
(
this
.
_loadingView
,
null
,
null
,
true
)
.
to
({
alpha
:
0
},
200
)
.
call
(()
=>
{
this
.
_loadingView
.
visible
=
true
;
this
.
_loadingView
.
visible
=
true
;
});
}
}
/**
/**
* 隐藏加载视图
* 隐藏加载视图
*/
*/
hideInnerLoadingView
()
{
hideInnerLoadingView
()
{
if
(
this
.
_loadingView
.
visible
)
{
if
(
this
.
_loadingView
.
visible
)
{
Tween
.
get
(
this
.
_loadingView
,
null
,
null
,
true
)
.
to
({
alpha
:
1
},
200
)
.
call
(()
=>
{
this
.
_loadingView
.
visible
=
false
;
this
.
_loadingView
.
visible
=
false
;
});
}
}
}
}
...
@@ -190,40 +198,40 @@ export class GameStage extends Node {
...
@@ -190,40 +198,40 @@ export class GameStage extends Node {
*/
*/
async
instantiateView
(
name
,
cache
=
true
,
showLoadingView
=
true
)
{
async
instantiateView
(
name
,
cache
=
true
,
showLoadingView
=
true
)
{
let
view
;
let
view
;
if
(
cache
)
{
if
(
cache
)
{
view
=
this
.
_viewCache
[
name
];
view
=
this
.
_viewCache
[
name
];
}
}
if
(
!
view
)
{
if
(
!
view
)
{
let
viewConfig
=
this
.
getViewConfigByName
(
name
);
let
viewConfig
=
this
.
getViewConfigByName
(
name
);
if
(
viewConfig
)
{
if
(
viewConfig
)
{
const
{
assets
,
customs
}
=
this
.
_config
;
const
{
assets
,
customs
}
=
this
.
_config
;
if
(
!
Array
.
isArray
(
assets
))
{
if
(
!
Array
.
isArray
(
assets
))
{
let
groups
=
{};
let
groups
=
{};
let
{
depCustoms
}
=
viewConfig
;
let
{
depCustoms
}
=
viewConfig
;
if
(
depCustoms
&&
depCustoms
.
length
>
0
)
{
if
(
depCustoms
&&
depCustoms
.
length
>
0
)
{
for
(
let
custom
of
customs
)
{
for
(
let
custom
of
customs
)
{
if
(
depCustoms
.
indexOf
(
custom
.
id
)
>=
0
&&
custom
.
assets
)
{
if
(
depCustoms
.
indexOf
(
custom
.
id
)
>=
0
&&
custom
.
assets
)
{
if
(
!
checkAssetGroupLoaded
(
custom
.
id
))
{
if
(
!
checkAssetGroupLoaded
(
custom
.
id
))
{
groups
[
custom
.
id
]
=
custom
.
assets
;
groups
[
custom
.
id
]
=
custom
.
assets
;
}
}
}
}
}
}
}
}
if
(
!
checkAssetGroupLoaded
(
viewConfig
.
uuid
))
{
if
(
!
checkAssetGroupLoaded
(
viewConfig
.
uuid
))
{
let
depAssets
=
assets
[
viewConfig
.
uuid
];
let
depAssets
=
assets
[
viewConfig
.
uuid
];
if
(
depAssets
&&
depAssets
.
length
>
0
)
{
if
(
depAssets
&&
depAssets
.
length
>
0
)
{
groups
[
viewConfig
.
uuid
]
=
depAssets
;
groups
[
viewConfig
.
uuid
]
=
depAssets
;
}
}
}
}
if
(
Object
.
keys
(
groups
).
length
>
0
)
{
if
(
Object
.
keys
(
groups
).
length
>
0
)
{
await
loadAssetsGroups
(
groups
,
async
()
=>
{
await
loadAssetsGroups
(
groups
,
async
()
=>
{
if
(
showLoadingView
)
{
if
(
showLoadingView
)
{
await
this
.
showInnerLoadingView
();
await
this
.
showInnerLoadingView
();
}
}
},
async
()
=>
{
},
async
()
=>
{
if
(
showLoadingView
)
{
if
(
showLoadingView
)
{
this
.
hideInnerLoadingView
();
this
.
hideInnerLoadingView
();
}
}
});
});
...
@@ -232,7 +240,7 @@ export class GameStage extends Node {
...
@@ -232,7 +240,7 @@ export class GameStage extends Node {
view
=
instantiate
(
viewConfig
);
view
=
instantiate
(
viewConfig
);
let
store
=
{};
let
store
=
{};
if
(
viewConfig
.
store
)
{
if
(
viewConfig
.
store
)
{
const
{
exp
,
computed
}
=
viewConfig
.
store
;
const
{
exp
,
computed
}
=
viewConfig
.
store
;
store
=
createStore
(
exp
,
computed
);
store
=
createStore
(
exp
,
computed
);
}
}
...
@@ -244,7 +252,7 @@ export class GameStage extends Node {
...
@@ -244,7 +252,7 @@ export class GameStage extends Node {
bind
(
store
,
view
);
bind
(
store
,
view
);
console
.
timeEnd
(
'bind'
);
console
.
timeEnd
(
'bind'
);
if
(
cache
)
{
if
(
cache
)
{
this
.
_viewCache
[
name
]
=
view
;
this
.
_viewCache
[
name
]
=
view
;
}
}
}
else
{
}
else
{
...
@@ -266,11 +274,11 @@ export class GameStage extends Node {
...
@@ -266,11 +274,11 @@ export class GameStage extends Node {
const
{
action
,
view
,
lastView
,
options
,
hasView
}
=
e
.
data
;
const
{
action
,
view
,
lastView
,
options
,
hasView
}
=
e
.
data
;
const
target
=
<
StackContainer
>
e
.
target
;
const
target
=
<
StackContainer
>
e
.
target
;
switch
(
action
)
{
switch
(
action
)
{
case
'push'
:
case
'push'
:
case
'replace'
:
case
'replace'
:
case
'popAll'
:
case
'popAll'
:
if
(
options
&&
options
.
center
)
{
if
(
options
&&
options
.
center
)
{
view
.
x
=
(
target
.
width
-
view
.
width
)
/
2
;
view
.
x
=
(
target
.
width
-
view
.
width
)
/
2
;
view
.
y
=
(
target
.
height
-
view
.
height
)
/
2
;
view
.
y
=
(
target
.
height
-
view
.
height
)
/
2
;
}
}
...
@@ -279,18 +287,18 @@ export class GameStage extends Node {
...
@@ -279,18 +287,18 @@ export class GameStage extends Node {
let
blackLayer
=
this
.
_blackLayer
;
let
blackLayer
=
this
.
_blackLayer
;
let
pParent
=
blackLayer
.
parent
;
let
pParent
=
blackLayer
.
parent
;
if
(
hasView
)
{
if
(
hasView
)
{
target
.
addChildAt
(
blackLayer
,
target
.
childNum
-
1
-
(
view
?
0
:
1
));
target
.
addChildAt
(
blackLayer
,
target
.
childNum
-
1
-
(
view
?
0
:
1
));
let
modalAlpha
=
0.7
;
let
modalAlpha
=
0.7
;
if
(
options
&&
options
.
hasOwnProperty
(
'modalAlpha'
))
{
if
(
options
&&
options
.
hasOwnProperty
(
'modalAlpha'
))
{
modalAlpha
=
options
.
modalAlpha
;
modalAlpha
=
options
.
modalAlpha
;
}
}
if
(
!
pParent
||
blackLayer
[
'tween_count'
]
>
0
)
{
if
(
!
pParent
||
blackLayer
[
'tween_count'
]
>
0
)
{
blackLayer
.
alpha
=
0
;
blackLayer
.
alpha
=
0
;
Tween
.
get
(
blackLayer
,
null
,
null
,
true
)
Tween
.
get
(
blackLayer
,
null
,
null
,
true
)
.
to
({
alpha
:
modalAlpha
},
300
);
.
to
({
alpha
:
modalAlpha
},
300
);
}
}
}
else
if
(
pParent
)
{
}
else
if
(
pParent
)
{
Tween
.
get
(
blackLayer
,
null
,
null
,
true
)
Tween
.
get
(
blackLayer
,
null
,
null
,
true
)
.
to
({
alpha
:
0
},
300
)
.
to
({
alpha
:
0
},
300
)
.
call
(()
=>
{
.
call
(()
=>
{
...
@@ -305,17 +313,17 @@ export class GameStage extends Node {
...
@@ -305,17 +313,17 @@ export class GameStage extends Node {
lazyLoadAllAssets
=
async
()
=>
{
lazyLoadAllAssets
=
async
()
=>
{
let
{
assets
,
customs
}
=
this
.
_config
;
let
{
assets
,
customs
}
=
this
.
_config
;
if
(
!
Array
.
isArray
(
assets
))
{
if
(
!
Array
.
isArray
(
assets
))
{
for
(
let
uuid
in
assets
)
{
for
(
let
uuid
in
assets
)
{
let
group
=
assets
[
uuid
];
let
group
=
assets
[
uuid
];
if
(
group
&&
group
.
length
>
0
)
{
if
(
group
&&
group
.
length
>
0
)
{
await
loadAssetsGroup
(
group
,
uuid
);
await
loadAssetsGroup
(
group
,
uuid
);
}
}
}
}
}
}
for
(
let
custom
of
customs
)
{
for
(
let
custom
of
customs
)
{
let
group
=
custom
.
assets
;
let
group
=
custom
.
assets
;
if
(
group
&&
group
.
length
>
0
)
{
if
(
group
&&
group
.
length
>
0
)
{
await
loadAssetsGroup
(
group
,
custom
.
id
);
await
loadAssetsGroup
(
group
,
custom
.
id
);
}
}
}
}
...
@@ -327,10 +335,10 @@ export class GameStage extends Node {
...
@@ -327,10 +335,10 @@ export class GameStage extends Node {
let
assetsToLoad
=
assets
;
let
assetsToLoad
=
assets
;
let
total
;
let
total
;
if
(
!
Array
.
isArray
(
assets
))
{
//如果是分组后的配置就加载共用分组,否则加载全部
if
(
!
Array
.
isArray
(
assets
))
{
//如果是分组后的配置就加载共用分组,否则加载全部
assetsToLoad
=
assets
[
'common'
];
assetsToLoad
=
assets
[
'common'
];
if
(
assetsToLoad
.
length
>
0
)
{
if
(
assetsToLoad
.
length
>
0
)
{
await
this
.
showInnerLoadingView
();
await
this
.
showInnerLoadingView
();
await
loadAssetsGroups
({
await
loadAssetsGroups
({
preload
:
assetsToLoad
,
preload
:
assetsToLoad
,
...
@@ -367,7 +375,7 @@ export class GameStage extends Node {
...
@@ -367,7 +375,7 @@ export class GameStage extends Node {
loaded
++
;
loaded
++
;
onPreloadAssetsProgress
&&
onPreloadAssetsProgress
(
loaded
,
total
);
onPreloadAssetsProgress
&&
onPreloadAssetsProgress
(
loaded
,
total
);
if
(
loaded
>=
total
)
{
if
(
loaded
>=
total
)
{
onPreloadAssetsComplete
&&
onPreloadAssetsComplete
();
onPreloadAssetsComplete
&&
onPreloadAssetsComplete
();
}
}
}
}
...
...
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