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
94674e57
Commit
94674e57
authored
May 26, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并主分支
parent
0eb76352
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
81 deletions
+175
-81
Container.ts
src/2d/display/Container.ts
+1
-1
Stage.ts
src/2d/display/Stage.ts
+4
-1
TextField.ts
src/2d/text/TextField.ts
+164
-78
EditorStage.ts
src/zeroing/game-warpper/EditorStage.ts
+6
-1
No files found.
src/2d/display/Container.ts
View file @
94674e57
...
...
@@ -9,7 +9,7 @@ import {applyAutoAdjust} from "../../zeroing/decorators/auto-adjust";
import
{
applyScript
}
from
"../../zeroing/decorators/scripts"
;
import
{
applyEvents
}
from
"../../zeroing/decorators/events"
;
import
{
afterConstructor
}
from
"../../zeroing/decorators/after-constructor"
;
import
{
injectProperties
,
instantiateScript
}
from
"../../zeroing/utils/index"
;
import
{
injectProperties
,
instantiateScript
,
toBoolean
}
from
"../../zeroing/utils/index"
;
import
{
isUI
}
from
"../../zeroing/game-warpper/nodes/IUIComponent"
;
import
Transform
from
"../math/Transform"
;
...
...
src/2d/display/Stage.ts
View file @
94674e57
...
...
@@ -349,6 +349,7 @@ export class Stage extends Container {
* @param {number} renderType 渲染类型2canvas
* @param {boolean} transparent 透明否,默认透明true,此时bgColor无效
* @param {number} bgColor 背景颜色十六进制
* @param autoResize 是否自动重置尺寸
* @public
* @since 1.0.0
*/
...
...
@@ -360,7 +361,8 @@ export class Stage extends Container {
scaleMode
:
string
=
StageScaleMode
.
FIXED_WIDTH
,
renderType
:
RENDERER_TYPE
=
RENDERER_TYPE
.
WEBGL
,
transparent
:
boolean
=
true
,
bgColor
:
number
=
0x000000
bgColor
:
number
=
0x000000
,
autoResize
:
boolean
=
false
,
)
{
super
();
let
s
:
Stage
=
this
;
...
...
@@ -376,6 +378,7 @@ export class Stage extends Container {
s
.
rootDiv
=
div
;
s
.
setFrameRate
(
frameRate
);
s
.
_scaleMode
=
scaleMode
;
s
.
autoResize
=
autoResize
;
//s.anchorX = desW >> 1;
//s.anchorY = desH >> 1;
...
...
src/2d/text/TextField.ts
View file @
94674e57
...
...
@@ -166,49 +166,49 @@ export class TextField extends Sprite {
// }
// }
// private _textHeight: number = 0;
get
width
():
number
{
if
(
!
this
.
_width
&&
this
.
_width
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
else
{
return
this
.
_width
;
}
}
set
width
(
value
:
number
)
{
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
this
.
_width
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
get
height
():
number
{
if
(
!
this
.
_height
&&
this
.
_height
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
else
{
return
this
.
_height
;
}
}
set
height
(
value
:
number
)
{
if
(
this
.
_height
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
this
.
_height
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
// private _textHeight: number = 0;
get
width
():
number
{
if
(
!
this
.
_width
&&
this
.
_width
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
else
{
return
this
.
_width
;
}
}
set
width
(
value
:
number
)
{
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
this
.
_width
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
get
height
():
number
{
if
(
!
this
.
_height
&&
this
.
_height
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
else
{
return
this
.
_height
;
}
}
set
height
(
value
:
number
)
{
if
(
this
.
_height
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
this
.
_height
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
/**
* 行间距
...
...
@@ -500,6 +500,86 @@ export class TextField extends Sprite {
private
_border
:
boolean
=
false
;
/**
* 设置或获取阴影颜色
* @property property
* @public
* @since 1.0.6
* @param value
*/
public
set
shadowColor
(
value
:
string
)
{
if
(
this
.
_shadowColor
!=
value
)
{
this
.
_shadowColor
=
value
;
this
.
dirty
=
true
;
}
}
public
get
shadowColor
():
string
{
return
this
.
_shadowColor
;
}
private
_shadowColor
:
string
=
'#000'
;
/**
* 设置或获取阴影模糊度
* @property property
* @public
* @since 1.0.6
* @param value
*/
public
set
shadowBlur
(
value
:
number
)
{
if
(
this
.
_shadowBlur
!=
value
)
{
this
.
_shadowBlur
=
value
;
this
.
dirty
=
true
;
}
}
public
get
shadowBlur
():
number
{
return
this
.
_shadowBlur
;
}
private
_shadowBlur
:
number
=
0
;
/**
* 设置或获取阴影偏移
* @property property
* @public
* @since 1.0.6
* @param value
*/
public
set
shadowOffset
(
value
:
ObservablePoint
)
{
if
(
this
.
_shadowOffset
!=
value
)
{
this
.
_shadowOffset
=
value
;
this
.
dirty
=
true
;
}
}
public
get
shadowOffset
():
ObservablePoint
{
return
this
.
_shadowOffset
;
}
get
shadowOffsetX
():
number
{
return
this
.
position
.
x
;
}
set
shadowOffsetX
(
value
:
number
)
{
this
.
_shadowOffset
.
x
=
value
;
}
get
shadowOffsetY
():
number
{
return
this
.
position
.
y
;
}
set
shadowOffsetY
(
value
:
number
)
{
this
.
_shadowOffset
.
y
=
value
;
}
private
_shadowOffset
:
ObservablePoint
=
new
ObservablePoint
(
this
.
onShadowOffsetChange
,
this
);
private
onShadowOffsetChange
()
{
this
.
dirty
=
true
;
}
private
_setupFont
(
font
,
size
,
bold
,
italic
)
{
let
fontStyle
:
any
=
size
;
fontStyle
+=
"px "
;
...
...
@@ -602,7 +682,7 @@ export class TextField extends Sprite {
if
(
!
text
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
s
.
_localBoundsSelf
.
clear
();
}
this
.
anchorTexture
=
{
x
:
0
,
y
:
0
};
...
...
@@ -653,7 +733,7 @@ export class TextField extends Sprite {
}
}
else
{
//textWidth取每行最大值,如果没设置过textWidth
const
shouldMeasureTextWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
?
true
:
false
;
const
shouldMeasureTextWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
;
let
index
=
0
;
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
let
str
=
hardLines
[
i
];
...
...
@@ -665,7 +745,7 @@ export class TextField extends Sprite {
index
++
;
}
if
(
shouldMeasureTextWidth
)
{
textWidth
=
Math
.
max
(
lineWidth
,
textWidth
)
;
textWidth
=
lineWidth
;
}
}
index
=
0
;
...
...
@@ -742,6 +822,12 @@ export class TextField extends Sprite {
}
}
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
tx
+
padding
,
padding
);
if
(
this
.
_shadowBlur
>
0
)
{
ctx
.
shadowBlur
=
this
.
_shadowBlur
;
ctx
.
shadowColor
=
this
.
_shadowColor
;
ctx
.
shadowOffsetX
=
this
.
_shadowOffset
.
x
;
ctx
.
shadowOffsetY
=
this
.
_shadowOffset
.
y
;
}
s
.
_prepContext
(
ctx
);
let
lineH
=
s
.
_lineSpacing
+
s
.
size
;
//如果有_textHeight,就需要应用竖直对齐
...
...
@@ -834,38 +920,38 @@ export class TextField extends Sprite {
}
}
/**
* 更新自己的bounds,计算全局
* @private
*/
_calculateBounds
()
{
const
{
width
,
height
}
=
this
.
_localBoundsSelf
;
var
matrix
=
this
.
transform
.
worldMatrix
;
this
.
_bounds
.
x
=
matrix
.
tx
;
this
.
_bounds
.
y
=
matrix
.
ty
;
this
.
_bounds
.
width
=
width
;
this
.
_bounds
.
height
=
height
;
}
/**
* 更新texture及baseTexture属性
* 不考虑trim,
*/
updateTexture
()
{
const
canvas
=
this
.
canvas
;
const
texture
=
this
.
_texture
;
const
baseTexture
=
texture
.
baseTexture
;
baseTexture
.
hasLoaded
=
canvas
.
width
&&
canvas
.
height
?
true
:
false
;
baseTexture
.
width
=
canvas
.
width
;
baseTexture
.
height
=
canvas
.
height
;
//texture,已绑定过尺寸改变onBaseTextureUpdated
baseTexture
.
dispatchEvent
(
'update'
);
texture
.
valid
=
baseTexture
.
hasLoaded
;
texture
.
_frame
.
width
=
canvas
.
width
;
texture
.
_frame
.
height
=
canvas
.
height
;
texture
.
orig
.
width
=
texture
.
_frame
.
width
;
texture
.
orig
.
height
=
texture
.
_frame
.
height
;
}
/**
* 更新自己的bounds,计算全局
* @private
*/
_calculateBounds
()
{
const
{
width
,
height
}
=
this
.
_localBoundsSelf
;
var
matrix
=
this
.
transform
.
worldMatrix
;
this
.
_bounds
.
x
=
matrix
.
tx
;
this
.
_bounds
.
y
=
matrix
.
ty
;
this
.
_bounds
.
width
=
width
;
this
.
_bounds
.
height
=
height
;
}
/**
* 更新texture及baseTexture属性
* 不考虑trim,
*/
updateTexture
()
{
const
canvas
=
this
.
canvas
;
const
texture
=
this
.
_texture
;
const
baseTexture
=
texture
.
baseTexture
;
baseTexture
.
hasLoaded
=
canvas
.
width
&&
canvas
.
height
?
true
:
false
;
baseTexture
.
width
=
canvas
.
width
;
baseTexture
.
height
=
canvas
.
height
;
//texture,已绑定过尺寸改变onBaseTextureUpdated
baseTexture
.
dispatchEvent
(
'update'
);
texture
.
valid
=
baseTexture
.
hasLoaded
;
texture
.
_frame
.
width
=
canvas
.
width
;
texture
.
_frame
.
height
=
canvas
.
height
;
texture
.
orig
.
width
=
texture
.
_frame
.
width
;
texture
.
orig
.
height
=
texture
.
_frame
.
height
;
}
_renderCanvas
(
renderer
)
{
...
...
src/zeroing/game-warpper/EditorStage.ts
View file @
94674e57
...
...
@@ -8,6 +8,7 @@ import {instantiate} from "./view-interpreter";
import
{
injectProperties
,
objClone
}
from
"../utils/utils"
;
import
{
devicePixelRatio
}
from
"../../2d/const"
;
import
{
Point
}
from
"../../2d/math/Point"
;
import
{
alignMgr
}
from
"../decorators/AlignManager"
;
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
includeProps
=
[
'_width'
,
'_height'
,
'worldMatrix'
];
...
...
@@ -39,11 +40,15 @@ export class EditorStage extends Node {
this
.
name
=
'editor-stage'
;
stage
.
width
=
stage
.
viewRect
.
width
;
stage
.
height
=
stage
.
viewRect
.
height
;
this
.
percentWidth
=
100
;
this
.
percentHeight
=
100
;
}
launch
(
onStart
)
{
Stage
.
addUpdateObj
(
alignMgr
);
onStart
();
}
...
...
@@ -124,7 +129,7 @@ export class EditorStage extends Node {
//console.log('modifyProps:', key, offsetV, node[key]);
}
}
node
.
adjustProxy
.
adjustLayout
();
//
node.adjustProxy.adjustLayout();
return
true
;
}
else
{
console
.
warn
(
'node not found:'
,
nodePath
);
...
...
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