Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM_4-1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
JM_4-1
Commits
ba29541b
Commit
ba29541b
authored
Sep 25, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 换行 填空
parent
50064f04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
31 deletions
+90
-31
Unit.ts
src/app/play/Unit.ts
+50
-14
play.component.ts
src/app/play/play.component.ts
+40
-17
No files found.
src/app/play/Unit.ts
View file @
ba29541b
...
...
@@ -838,6 +838,7 @@ export class RichTextOld extends Label {
export
class
RichText
extends
Label
{
...
...
@@ -846,6 +847,9 @@ export class RichText extends Label {
row
=
1
;
textBaseline
=
"
middle
"
;
isShowWordBg
=
false
;
wordBgData
;
constructor
(
ctx
?:
any
)
{
super
(
ctx
);
...
...
@@ -864,7 +868,10 @@ export class RichText extends Label {
return
tmpTextH
+
tmpDisH
;
}
getSubTextRect
(
subText
)
{
getSubTextRect
(
subText
,
targetIndex
=
0
)
{
const
tmpLabel
=
new
RichText
();
tmpLabel
.
fontSize
=
this
.
fontSize
;
...
...
@@ -875,21 +882,28 @@ export class RichText extends Label {
tmpLabel
.
width
=
this
.
width
;
tmpLabel
.
height
=
this
.
height
;
const
index
=
this
.
text
.
indexOf
(
subText
);
tmpLabel
.
text
=
this
.
text
.
substring
(
0
,
index
);
tmpLabel
.
refreshSize
();
// console.log('subText: ', subText);
// const indexArr = searchSubStr(this.text, subText);
// console.log('indexArr: ', indexArr);
// const index = indexArr[targetIndex];
const
index
=
this
.
text
.
indexOf
(
subText
,
targetIndex
);
const
x
=
tmpLabel
.
width
;
tmpLabel
.
text
=
subText
;
tmpLabel
.
refreshSize
();
if
(
!
index
)
{
return
;
}
// const index = this.text.indexOf(subText);
// console.log('!!!index: ', index);
const
width
=
tmpLabel
.
width
;
const
data
=
this
.
wordBgData
[
index
.
toString
()];
// console.log('!!!wordBgData: ', this.wordBgData);
// console.log('!!!data: ', data);
return
data
;
const
y
=
this
.
fontSize
/
2
;
const
height
=
this
.
fontSize
;
return
{
x
,
y
,
width
,
height
}
}
...
...
@@ -916,16 +930,39 @@ export class RichText extends Label {
const
w
=
selfW
-
this
.
offW
*
2
;
const
disH
=
(
this
.
fontSize
+
this
.
disH
)
*
this
.
scaleY
;
let
isPushWordData
=
false
;
if
(
this
.
isShowWordBg
&&
!
this
.
wordBgData
)
{
this
.
wordBgData
=
{};
isPushWordData
=
true
;
}
let
wordIndex
=
-
1
;
for
(
const
c
of
chr
)
{
if
(
isPushWordData
)
{
}
for
(
const
c
of
chr
)
{
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
c
)).
width
<=
w
)
{
if
(
c
==
'
\n
'
)
{
row
.
push
(
temp
);
temp
=
''
;
}
else
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
c
)).
width
<=
w
)
{
temp
+=
'
'
+
c
;
}
else
{
row
.
push
(
temp
);
temp
=
'
'
+
c
;
}
if
(
isPushWordData
)
{
wordIndex
=
this
.
text
.
indexOf
(
c
,
wordIndex
+
1
);
const
key
=
wordIndex
.
toString
();
const
rectX
=
this
.
ctx
.
measureText
(
temp
).
width
const
rectY
=
(
row
.
length
)
*
disH
/
this
.
scaleY
const
rectW
=
this
.
ctx
.
measureText
(
c
).
width
;
const
rectH
=
this
.
fontSize
;
this
.
wordBgData
[
key
]
=
{
rect
:
{
x
:
rectX
,
y
:
rectY
,
width
:
rectW
,
height
:
rectH
},
text
:
c
,
index
:
wordIndex
}
}
}
row
.
push
(
temp
);
...
...
@@ -965,7 +1002,6 @@ export class RichText extends Label {
export
class
LineRect
extends
MySprite
{
lineColor
=
'
#ffffff
'
;
...
...
src/app/play/play.component.ts
View file @
ba29541b
...
...
@@ -1105,23 +1105,44 @@ export class PlayComponent implements OnInit, OnDestroy {
richText
.
y
=
curY
;
richText
.
text
=
arr
[
i
].
text
;
const
rect
=
richText
.
getSubTextRect
(
'
____________________
'
);
richText
.
isShowWordBg
=
true
;
richText
.
update
();
const
rectData
=
richText
.
getSubTextRect
(
'
____________________
'
);
const
rect
=
rectData
.
rect
;
// index = rectData.index + 1;
const
edgeW
=
5
*
this
.
mapScale
;
const
edgeH
=
10
*
this
.
mapScale
;
const
colorRect
=
new
ShapeRectNew
();
rect
.
height
+=
30
;
colorRect
.
setSize
(
rect
.
width
,
rect
.
height
,
1
);
colorRect
.
fillColor
=
'
#ff0000
'
const
offX
=
13
;
colorRect
.
x
=
rect
.
x
+
offX
;
colorRect
.
y
=
-
rect
.
height
/
2
;
console
.
log
(
'
rect.height:
'
,
rect
.
height
);
colorRect
.
setSize
(
rect
.
width
+
edgeW
*
2
,
rect
.
height
+
edgeH
*
2
,
10
*
this
.
mapScale
);
colorRect
.
x
=
rect
.
x
-
rect
.
width
-
edgeW
;
colorRect
.
y
=
rect
.
y
-
rect
.
height
/
2
-
edgeH
*
0.7
;
colorRect
.
alpha
=
0
;
richText
.
addChild
(
colorRect
);
this
.
sentenceEmptyArr
.
push
(
colorRect
);
// const colorRect = new ShapeRectNew();
// rect.height += 30;
// colorRect.setSize(rect.width, rect.height, 1);
// colorRect.fillColor = '#ff0000'
// const offX = 13;
// colorRect.x = rect.x + offX;
// colorRect.y = -rect.height / 2;
// console.log('rect.height: ', rect.height);
// colorRect.alpha = 0.5;
// richText.addChild(colorRect);
// this.sentenceEmptyArr.push(colorRect);
curY
+=
richText
.
getAreaHeight
()
*
this
.
mapScale
+
disH
;
richText
[
'
data
'
]
=
arr
[
i
];
...
...
@@ -1415,7 +1436,7 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
}
if
(
this
.
maskPic
.
visible
)
{
if
(
this
.
maskPic
?
.
visible
)
{
return
;
}
this
.
downFlag
=
true
;
...
...
@@ -1509,11 +1530,7 @@ export class PlayComponent implements OnInit, OnDestroy {
event
.
preventDefault
()
}
if
(
this
.
resultSv
)
{
this
.
resultSv
.
onTouchMove
(
this
.
mx
,
this
.
my
);
}
else
{
this
.
scrollView
.
onTouchMove
(
this
.
mx
,
this
.
my
);
}
if
(
!
this
.
curMoveItem
)
{
...
...
@@ -1524,6 +1541,12 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
}
if
(
this
.
resultSv
)
{
this
.
resultSv
.
onTouchMove
(
this
.
mx
,
this
.
my
);
}
else
{
this
.
scrollView
.
onTouchMove
(
this
.
mx
,
this
.
my
);
}
this
.
curMoveItem
.
x
=
this
.
mx
;
this
.
curMoveItem
.
y
=
this
.
my
;
...
...
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