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
af6a8e74
Commit
af6a8e74
authored
Jan 08, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
8f20e2d8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
134 additions
and
50 deletions
+134
-50
engine.js
debug/engine.js
+66
-24
engine.js.map
debug/engine.js.map
+1
-1
FloatDisplay.ts
src/2d/display/FloatDisplay.ts
+8
-1
TextField.ts
src/2d/text/TextField.ts
+6
-1
Process.ts
src/zeroing/behavior-runtime/Process.ts
+13
-4
GameStage.ts
src/zeroing/game-warpper/GameStage.ts
+2
-3
custom-module.ts
src/zeroing/game-warpper/custom-module.ts
+10
-1
HtmlView.ts
src/zeroing/game-warpper/nodes/HtmlView.ts
+9
-0
Label.ts
src/zeroing/game-warpper/nodes/Label.ts
+7
-5
index.ts
src/zeroing/game-warpper/nodes/index.ts
+1
-0
view-interpreter.ts
src/zeroing/game-warpper/view-interpreter.ts
+11
-10
No files found.
debug/engine.js
View file @
af6a8e74
...
...
@@ -2441,6 +2441,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
Process
=
(
function
()
{
function
Process
(
id
)
{
this
.
id
=
id
;
this
.
_scope
=
{};
}
Object
.
defineProperty
(
Process
.
prototype
,
"processConfig"
,
{
get
:
function
()
{
...
...
@@ -2463,6 +2464,13 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
Process
.
prototype
,
"scope"
,
{
get
:
function
()
{
return
this
.
_scope
;
},
enumerable
:
true
,
configurable
:
true
});
Process
.
prototype
.
init
=
function
(
context
)
{
var
vm
=
context
.
vm
,
parent
=
context
.
parent
,
sequence
=
context
.
sequence
,
id
=
context
.
id
,
target
=
context
.
target
;
this
.
_vm
=
vm
;
...
...
@@ -2553,14 +2561,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
func
=
this
.
_vm
.
getScript
(
metaConfig
.
script
.
replace
(
linkScheme
,
''
));
}
else
{
func
=
new
Function
(
'args'
,
'props'
,
'target'
,
'global'
,
'vm'
,
warpAsyncScript
(
metaConfig
.
script
));
func
=
new
Function
(
'args'
,
'props'
,
'target'
,
'global'
,
'vm'
,
'scope'
,
warpAsyncScript
(
metaConfig
.
script
));
}
if
(
!
func
)
return
[
3
,
2
];
globalContext
=
this
.
_vm
.
globalContext
;
globalContext
.
gameStage
=
engine
.
gameStage
;
globalContext
.
dataCenter
=
engine
.
gameStage
.
dataCenter
;
globalContext
.
env
=
engine
.
env
;
return
[
4
,
func
(
payload
,
this
.
_config
.
props
,
this
.
_target
,
globalContext
,
this
.
_vm
)];
return
[
4
,
func
(
payload
,
this
.
_config
.
props
,
this
.
_target
,
globalContext
,
this
.
_vm
,
this
.
_parent
.
scope
)];
case
1
:
result
=
_a
.
sent
();
if
(
log
)
{
...
...
@@ -2668,6 +2676,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
case
'static'
:
props
[
key
]
=
name
;
break
;
case
'scope'
:
props
[
key
]
=
getDataByPath
(
this
.
_parent
.
scope
,
name
);
break
;
case
'arguments'
:
props
[
key
]
=
args
?
getDataByPath
(
args
,
name
)
:
undefined
;
break
;
...
...
@@ -2920,6 +2931,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Container
.
prototype
.
onChildrenChange
=
function
(
index
)
{
};
Container
.
prototype
.
attachVisibility
=
function
()
{
return
;
this
.
dispatchEvent
(
this
.
worldVisible
?
Event
.
VISIBLE
:
Event
.
HIDDEN
);
for
(
var
i
=
0
,
li
=
this
.
children
.
length
;
i
<
li
;
i
++
)
{
var
child
=
this
.
children
[
i
];
...
...
@@ -3370,6 +3382,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Container
.
prototype
.
containerUpdateTransform
=
Container
.
prototype
.
updateTransform
;
var
container
;
var
el$1
;
var
FloatDisplay
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
FloatDisplay
,
_super
);
function
FloatDisplay
()
{
...
...
@@ -3389,6 +3402,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
container
.
style
.
position
=
"absolute"
;
container
.
style
.
left
=
"0"
;
container
.
style
.
top
=
"0"
;
container
.
style
.
fontSize
=
'30px'
;
container
.
style
.
lineHeight
=
'normal'
;
s
.
stage
.
rootDiv
.
appendChild
(
container
);
}
if
(
s
.
_htmlElement
)
{
...
...
@@ -3423,7 +3438,11 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
s
=
this
;
var
she
;
if
(
typeof
(
htmlElement
)
==
"string"
)
{
she
=
document
.
getElementById
(
htmlElement
);
if
(
!
el$1
)
{
el$1
=
document
.
createElement
(
'div'
);
}
el$1
.
innerHTML
=
htmlElement
;
she
=
el$1
.
children
[
0
];
}
else
if
(
htmlElement
.
_instanceType
==
"Video"
)
{
she
=
htmlElement
.
media
;
...
...
@@ -11255,7 +11274,13 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
ctx
.
fillText
(
line
,
0
,
y
,
maxW
);
}
else
{
var
x
=
0
;
var
lineWidth
=
0
;
for
(
var
_a
=
0
,
line_1
=
line
;
_a
<
line_1
.
length
;
_a
++
)
{
var
char
=
line_1
[
_a
];
var
charWidth
=
measureChar
(
char
);
lineWidth
+=
charWidth
;
}
var
x
=
-
lineWidth
/
2
;
for
(
var
j
=
0
,
lj
=
line
.
length
;
j
<
lj
;
j
++
)
{
var
char
=
line
[
j
];
var
style
=
s
.
getStyle
(
index
);
...
...
@@ -15240,12 +15265,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
set
:
function
(
value
)
{
if
(
this
.
_htmlText
!=
value
)
{
this
.
_htmlText
=
value
;
var
matchResult
=
value
.
match
(
ESCAPE_REG_EXP
);
if
(
matchResult
)
{
this
.
dealEscape
(
value
,
matchResult
,
this
.
onHtmlMutated
);
}
else
{
this
.
text
=
htmlToPureText
(
value
);
if
(
this
.
_htmlText
)
{
var
matchResult
=
value
.
match
(
ESCAPE_REG_EXP
);
if
(
matchResult
)
{
this
.
dealEscape
(
value
,
matchResult
,
this
.
onHtmlMutated
);
}
else
{
this
.
text
=
htmlToPureText
(
value
);
}
}
}
},
...
...
@@ -15611,6 +15638,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
BitmapText
;
}(
Container
));
var
HtmlView
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
HtmlView
,
_super
);
function
HtmlView
()
{
return
_super
!==
null
&&
_super
.
apply
(
this
,
arguments
)
||
this
;
}
return
HtmlView
;
}(
FloatDisplay
));
var
nodeTypeMapping
=
{
node
:
Container
,
rect
:
Rect
,
...
...
@@ -15621,6 +15656,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
scrollView
:
ScrollView
,
scrollList
:
ScrollList
,
bitmapText
:
BitmapText
,
htmlView
:
HtmlView
,
};
function
registerNodeType
(
name
,
def
)
{
nodeTypeMapping
[
name
]
=
def
;
...
...
@@ -15641,24 +15677,24 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
node
.
uuid
=
uuid
;
node
.
__originConfig
=
config
;
injectProperties
(
node
,
properties
);
if
(
scripts
&&
scripts
.
length
>
0
)
{
for
(
var
_i
=
0
,
scripts_1
=
scripts
;
_i
<
scripts_1
.
length
;
_i
++
)
{
var
scriptConfig
=
scripts_1
[
_i
];
instantiateScript
(
node
,
scriptConfig
);
}
}
if
(
events
)
{
node
.
eventsProxy
.
start
(
events
);
}
if
(
children
&&
children
.
length
>
0
)
{
for
(
var
_
a
=
0
,
children_1
=
children
;
_a
<
children_1
.
length
;
_a
++
)
{
var
childConfig
=
children_1
[
_
a
];
for
(
var
_
i
=
0
,
children_1
=
children
;
_i
<
children_1
.
length
;
_i
++
)
{
var
childConfig
=
children_1
[
_
i
];
var
childNode
=
instantiateView
(
childConfig
);
if
(
childNode
)
{
node
.
addChild
(
childNode
);
}
}
}
if
(
scripts
&&
scripts
.
length
>
0
)
{
for
(
var
_a
=
0
,
scripts_1
=
scripts
;
_a
<
scripts_1
.
length
;
_a
++
)
{
var
scriptConfig
=
scripts_1
[
_a
];
instantiateScript
(
node
,
scriptConfig
);
}
}
if
(
events
&&
node
.
eventsProxy
)
{
node
.
eventsProxy
.
start
(
events
);
}
return
node
;
}
...
...
@@ -15868,7 +15904,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
_a
=
this
.
_config
,
_b
=
_a
.
options
,
entrySceneView
=
_b
.
entrySceneView
,
env
=
_b
.
env
,
dataMapping
=
_a
.
dataMapping
,
processes
=
_a
.
processes
,
builtinProcesses
=
_a
.
builtinProcesses
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
Stage
.
addUpdateObj
(
Tween
);
injectEnv
(
env
);
registerCustomModule
Asset
s
(
customs
);
registerCustomModules
(
customs
);
if
(
dataMapping
)
{
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
}
...
...
@@ -15924,10 +15960,11 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}(
Container
));
var
customMap
=
{};
function
registerCustomModule
Asset
s
(
customs
)
{
function
registerCustomModules
(
customs
)
{
for
(
var
_i
=
0
,
customs_1
=
customs
;
_i
<
customs_1
.
length
;
_i
++
)
{
var
custom
=
customs_1
[
_i
];
customMap
[
custom
.
id
].
assets
=
custom
.
assets
;
customMap
[
custom
.
id
].
props
=
custom
.
props
;
}
}
function
registerCustomModule
(
id
,
def
)
{
...
...
@@ -15973,6 +16010,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
config
;
}
}
function
getProps
(
id
)
{
return
customMap
[
id
].
props
;
}
var
howler
=
createCommonjsModule
(
function
(
module
,
exports
)
{
/*!
...
...
@@ -19268,6 +19308,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
HashObject
=
HashObject
;
exports
.
Howl
=
howler_2
;
exports
.
Howler
=
howler_1
;
exports
.
HtmlView
=
HtmlView
;
exports
.
Image
=
Image$1
;
exports
.
InputText
=
InputText
;
exports
.
Label
=
Label
;
...
...
@@ -19318,6 +19359,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
getAssetByUUID
=
getAssetByUUID
;
exports
.
getDataByPath
=
getDataByPath
;
exports
.
getLogSwitch
=
getLogSwitch
;
exports
.
getProps
=
getProps
;
exports
.
getTexture
=
getTexture
;
exports
.
globalEvent
=
globalEvent
;
exports
.
globalLoader
=
globalLoader
;
...
...
@@ -19351,8 +19393,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
queryParams
=
queryParams
;
exports
.
registerCustomCodeModule
=
registerCustomCodeModule
;
exports
.
registerCustomModule
=
registerCustomModule
;
exports
.
registerCustomModuleAssets
=
registerCustomModuleAssets
;
exports
.
registerCustomModuleFromConfig
=
registerCustomModuleFromConfig
;
exports
.
registerCustomModules
=
registerCustomModules
;
exports
.
registerNodeType
=
registerNodeType
;
exports
.
registerScriptDef
=
registerScriptDef
;
exports
.
registerScripts
=
registerScripts
;
...
...
debug/engine.js.map
View file @
af6a8e74
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/2d/display/FloatDisplay.ts
View file @
af6a8e74
...
...
@@ -3,6 +3,7 @@ import {DisplayObject} from "./DisplayObject";
import
{
devicePixelRatio
}
from
"../const"
;
let
container
;
let
el
;
/**
* 此类对于需要在canvas上放置html其他类型元素的时候非常有用<br/>
...
...
@@ -87,6 +88,8 @@ export class FloatDisplay extends DisplayObject {
container
.
style
.
position
=
"absolute"
;
container
.
style
.
left
=
"0"
;
container
.
style
.
top
=
"0"
;
container
.
style
.
fontSize
=
'30px'
;
container
.
style
.
lineHeight
=
'normal'
;
s
.
stage
.
rootDiv
.
appendChild
(
container
);
//, s.stage.rootDiv.childNodes[0]
}
if
(
s
.
_htmlElement
)
{
...
...
@@ -126,7 +129,11 @@ export class FloatDisplay extends DisplayObject {
let
s
=
this
;
let
she
:
any
;
if
(
typeof
(
htmlElement
)
==
"string"
)
{
she
=
document
.
getElementById
(
htmlElement
);
if
(
!
el
)
{
el
=
document
.
createElement
(
'div'
);
}
el
.
innerHTML
=
htmlElement
;
she
=
el
.
children
[
0
];
}
else
if
(
htmlElement
.
_instanceType
==
"Video"
)
{
she
=
htmlElement
.
media
;
}
else
{
...
...
src/2d/text/TextField.ts
View file @
af6a8e74
...
...
@@ -676,7 +676,12 @@ export class TextField extends Sprite {
}
ctx
.
fillText
(
line
,
0
,
y
,
maxW
);
}
else
{
let
x
=
0
;
let
lineWidth
=
0
;
for
(
let
char
of
line
)
{
let
charWidth
=
measureChar
(
char
);
lineWidth
+=
charWidth
;
}
let
x
=
-
lineWidth
/
2
;
for
(
let
j
=
0
,
lj
=
line
.
length
;
j
<
lj
;
j
++
)
{
const
char
=
line
[
j
];
let
style
=
s
.
getStyle
(
index
);
...
...
src/zeroing/behavior-runtime/Process.ts
View file @
af6a8e74
...
...
@@ -20,9 +20,11 @@ export class Process {
private
_meta
;
private
_target
;
private
_originProps
;
private
_scope
:
any
;
constructor
(
id
)
{
this
.
id
=
id
;
this
.
_scope
=
{};
}
get
processConfig
()
{
...
...
@@ -37,6 +39,10 @@ export class Process {
return
this
.
_sequence
;
}
get
scope
()
{
return
this
.
_scope
;
}
init
(
context
)
{
const
{
vm
,
parent
,
sequence
,
id
,
target
}
=
context
;
this
.
_vm
=
vm
;
...
...
@@ -104,19 +110,19 @@ export class Process {
if
(
metaConfig
.
script
.
indexOf
(
linkScheme
)
===
0
)
{
func
=
this
.
_vm
.
getScript
(
metaConfig
.
script
.
replace
(
linkScheme
,
''
));
}
else
{
func
=
new
Function
(
'args'
,
'props'
,
'target'
,
'global'
,
'vm'
,
warpAsyncScript
(
metaConfig
.
script
));
func
=
new
Function
(
'args'
,
'props'
,
'target'
,
'global'
,
'vm'
,
'scope'
,
warpAsyncScript
(
metaConfig
.
script
));
}
if
(
func
)
{
let
globalContext
=
this
.
_vm
.
globalContext
;
globalContext
.
gameStage
=
engine
.
gameStage
;
globalContext
.
dataCenter
=
engine
.
gameStage
.
dataCenter
;
globalContext
.
env
=
engine
.
env
;
result
=
await
func
(
payload
,
this
.
_config
.
props
,
this
.
_target
,
globalContext
,
this
.
_vm
);
if
(
log
){
result
=
await
func
(
payload
,
this
.
_config
.
props
,
this
.
_target
,
globalContext
,
this
.
_vm
,
this
.
_parent
.
scope
);
if
(
log
)
{
console
.
log
(
`[
${
this
.
_vm
.
id
}
:
${
this
.
id
}
] output: <
${
result
.
type
}
>`
,
result
.
payload
);
}
}
else
{
if
(
log
){
if
(
log
)
{
console
.
log
(
'script lose'
);
}
}
...
...
@@ -214,6 +220,9 @@ export class Process {
case
'static'
:
props
[
key
]
=
name
;
break
;
case
'scope'
:
props
[
key
]
=
getDataByPath
(
this
.
_parent
.
scope
,
name
);
break
;
case
'arguments'
:
props
[
key
]
=
args
?
getDataByPath
(
args
,
name
)
:
undefined
;
break
;
...
...
src/zeroing/game-warpper/GameStage.ts
View file @
af6a8e74
...
...
@@ -13,8 +13,7 @@ import {Rect} from "./nodes";
import
{
injectEnv
}
from
"./enviroment"
;
import
{
Toast
}
from
"./Toast"
;
import
{
arrayFind
}
from
"../utils"
;
import
{
registerCustomModuleAssets
,
registerScripts
}
from
".."
;
import
{
registerCustomModuleFromConfig
}
from
"./custom-module"
;
import
{
registerCustomModules
,
registerScripts
}
from
".."
;
/**
* 游戏舞台
...
...
@@ -150,7 +149,7 @@ export class GameStage extends Container {
//registerScripts(scripts);
//registerCustomModuleFromConfig(customs);
registerCustomModule
Asset
s
(
customs
);
registerCustomModules
(
customs
);
if
(
dataMapping
){
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
...
...
src/zeroing/game-warpper/custom-module.ts
View file @
af6a8e74
...
...
@@ -11,9 +11,10 @@ const customMap = {};
* 注册自定义模块素材映射
* @param customs
*/
export
function
registerCustomModule
Asset
s
(
customs
)
{
export
function
registerCustomModules
(
customs
)
{
for
(
let
custom
of
customs
)
{
customMap
[
custom
.
id
].
assets
=
custom
.
assets
;
customMap
[
custom
.
id
].
props
=
custom
.
props
;
}
}
...
...
@@ -87,3 +88,11 @@ export function resolveCustomAsset(id, uuid) {
return
config
;
}
}
/**
* 获取配置参数
* @param id
*/
export
function
getProps
(
id
)
{
return
customMap
[
id
].
props
;
}
src/zeroing/game-warpper/nodes/HtmlView.ts
0 → 100644
View file @
af6a8e74
/**
* Created by rockyl on 2020-01-07.
*/
import
{
FloatDisplay
}
from
"../../../2d/display"
;
export
class
HtmlView
extends
FloatDisplay
{
}
src/zeroing/game-warpper/nodes/Label.ts
View file @
af6a8e74
...
...
@@ -61,12 +61,14 @@ export class Label extends TextField {
if
(
this
.
_htmlText
!=
value
)
{
this
.
_htmlText
=
value
;
let
matchResult
=
value
.
match
(
ESCAPE_REG_EXP
);
if
(
this
.
_htmlText
){
let
matchResult
=
value
.
match
(
ESCAPE_REG_EXP
);
if
(
matchResult
)
{
this
.
dealEscape
(
value
,
matchResult
,
this
.
onHtmlMutated
);
}
else
{
this
.
text
=
htmlToPureText
(
value
);
if
(
matchResult
)
{
this
.
dealEscape
(
value
,
matchResult
,
this
.
onHtmlMutated
);
}
else
{
this
.
text
=
htmlToPureText
(
value
);
}
}
}
}
...
...
src/zeroing/game-warpper/nodes/index.ts
View file @
af6a8e74
...
...
@@ -9,3 +9,4 @@ export * from './TextInput'
export
*
from
'./ScrollView'
export
*
from
'./ScrollList'
export
*
from
'./BitmapText'
export
*
from
'./HtmlView'
src/zeroing/game-warpper/view-interpreter.ts
View file @
af6a8e74
...
...
@@ -3,7 +3,7 @@
*/
import
{
Container
}
from
"../../2d/display"
;
import
{
Rect
,
Image
,
Label
,
Circle
,
ScrollView
,
TextInput
,
ScrollList
,
BitmapText
}
from
"./nodes"
;
import
{
Rect
,
Image
,
Label
,
Circle
,
ScrollView
,
TextInput
,
ScrollList
,
BitmapText
,
HtmlView
}
from
"./nodes"
;
import
{
injectProperties
,
instantiateScript
,}
from
"../utils"
;
const
nodeTypeMapping
=
{
...
...
@@ -16,6 +16,7 @@ const nodeTypeMapping = {
scrollView
:
ScrollView
,
scrollList
:
ScrollList
,
bitmapText
:
BitmapText
,
htmlView
:
HtmlView
,
};
export
function
registerNodeType
(
name
,
def
)
{
...
...
@@ -42,15 +43,6 @@ function instantiateView(config) {
node
.
__originConfig
=
config
;
injectProperties
(
node
,
properties
);
if
(
scripts
&&
scripts
.
length
>
0
)
{
for
(
let
scriptConfig
of
scripts
)
{
instantiateScript
(
node
,
scriptConfig
);
}
}
if
(
events
)
{
node
.
eventsProxy
.
start
(
events
);
}
if
(
children
&&
children
.
length
>
0
)
{
for
(
let
childConfig
of
children
)
{
const
childNode
=
instantiateView
(
childConfig
);
...
...
@@ -60,5 +52,14 @@ function instantiateView(config) {
}
}
if
(
scripts
&&
scripts
.
length
>
0
)
{
for
(
let
scriptConfig
of
scripts
)
{
instantiateScript
(
node
,
scriptConfig
);
}
}
if
(
events
&&
node
.
eventsProxy
)
{
node
.
eventsProxy
.
start
(
events
);
}
return
node
;
}
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