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
fc82b76e
Commit
fc82b76e
authored
Feb 29, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复滚动列表多行列的问题
parent
4b4104a8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
41 deletions
+50
-41
manifest.json
manifest.json
+1
-1
ScrollListBase.ts
src/2d/ui/ScrollListBase.ts
+24
-15
data-center.ts
src/zeroing/game-warpper/data-center.ts
+22
-22
Label.ts
src/zeroing/game-warpper/nodes/Label.ts
+1
-1
ScrollList.ts
src/zeroing/game-warpper/nodes/ScrollList.ts
+1
-1
view-interpreter.ts
src/zeroing/game-warpper/view-interpreter.ts
+1
-1
No files found.
manifest.json
View file @
fc82b76e
{
"id"
:
"engine"
,
"url"
:
"engine.53262d62b13fbd758c11074e8875d82b17828de5.js"
}
{
"id"
:
"engine"
,
"url"
:
"engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"
}
\ No newline at end of file
\ No newline at end of file
src/2d/ui/ScrollListBase.ts
View file @
fc82b76e
...
@@ -40,11 +40,11 @@ export abstract class ScrollListItemBase extends Container {
...
@@ -40,11 +40,11 @@ export abstract class ScrollListItemBase extends Container {
export
class
ScrollListBase
extends
ScrollViewBase
{
export
class
ScrollListBase
extends
ScrollViewBase
{
private
_items
:
Array
<
ScrollListItemBase
>
=
null
;
private
_items
:
Array
<
ScrollListItemBase
>
=
null
;
private
_itemRow
:
number
;
private
_itemRow
:
number
;
private
_itemCol
:
number
;
private
_itemCount
:
number
;
private
_itemCount
:
number
;
private
_isInit
:
number
=
0
;
private
_isInit
:
number
=
0
;
public
data
:
Array
<
any
>
=
[];
public
data
:
Array
<
any
>
=
[];
private
downL
:
DisplayObject
=
null
;
private
downL
:
DisplayObject
=
null
;
private
_cols
:
number
=
1
;
private
_disParam
:
string
;
private
_disParam
:
string
;
private
_lastFirstId
:
number
=
-
1
;
private
_lastFirstId
:
number
=
-
1
;
private
_updateId
:
number
=
-
1
;
private
_updateId
:
number
=
-
1
;
...
@@ -54,7 +54,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -54,7 +54,7 @@ export class ScrollListBase extends ScrollViewBase {
@
dirtyFieldTrigger
@
dirtyFieldTrigger
public
itemHeight
:
number
=
0
;
public
itemHeight
:
number
=
0
;
@
dirtyFieldTrigger
@
dirtyFieldTrigger
public
itemCol
:
number
;
public
cols
:
number
=
1
;
@
dirtyFieldTrigger
@
dirtyFieldTrigger
public
itemClass
:
any
;
public
itemClass
:
any
;
...
@@ -84,7 +84,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -84,7 +84,7 @@ export class ScrollListBase extends ScrollViewBase {
}
}
protected
onNextFrame
(
event
)
{
protected
onNextFrame
(
event
)
{
this
.
_
updateViewRect
();
this
.
updateViewRect
();
}
}
onModify
(
value
,
key
)
{
onModify
(
value
,
key
)
{
...
@@ -95,7 +95,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -95,7 +95,7 @@ export class ScrollListBase extends ScrollViewBase {
case
'itemH'
:
case
'itemH'
:
break
;
break
;
case
'itemCol'
:
case
'
_
itemCol'
:
break
;
break
;
case
'itemClass'
:
case
'itemClass'
:
...
@@ -106,7 +106,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -106,7 +106,7 @@ export class ScrollListBase extends ScrollViewBase {
protected
calMaxDistance
():
any
{
protected
calMaxDistance
():
any
{
let
key
=
'item'
+
this
.
paramSize
.
substr
(
0
,
1
).
toUpperCase
()
+
this
.
paramSize
.
substr
(
1
);
let
key
=
'item'
+
this
.
paramSize
.
substr
(
0
,
1
).
toUpperCase
()
+
this
.
paramSize
.
substr
(
1
);
return
this
[
key
]
*
this
.
data
.
length
;
return
this
[
key
]
*
Math
.
ceil
(
this
.
data
.
length
/
this
.
cols
)
;
}
}
/**
/**
...
@@ -125,7 +125,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -125,7 +125,7 @@ export class ScrollListBase extends ScrollViewBase {
}
}
s
.
_isInit
=
1
;
s
.
_isInit
=
1
;
s
.
_lastFirstId
=
-
1
;
s
.
_lastFirstId
=
-
1
;
/*s.maxDistance = Math.ceil(s.data.length / s.
_
cols) * s._itemRow;
/*s.maxDistance = Math.ceil(s.data.length / s.cols) * s._itemRow;
if (s.downL) {
if (s.downL) {
s.downL[s.paramXY] = Math.max(s.distance, s.maxDistance);
s.downL[s.paramXY] = Math.max(s.distance, s.maxDistance);
var wh = s.downL.getWH();
var wh = s.downL.getWH();
...
@@ -135,15 +135,18 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -135,15 +135,18 @@ export class ScrollListBase extends ScrollViewBase {
private
flushData
()
{
private
flushData
()
{
let
s
:
ScrollListBase
=
this
;
let
s
:
ScrollListBase
=
this
;
const
items
=
s
.
_items
;
if
(
items
.
length
<=
0
){
return
;
}
if
(
s
.
_isInit
>
0
)
{
if
(
s
.
_isInit
>
0
)
{
if
(
s
.
_updateId
!=
s
.
viewPort
.
transform
.
_localID
)
{
if
(
s
.
_updateId
!=
s
.
viewPort
.
transform
.
_localID
)
{
const
items
=
s
.
_items
;
let
id
:
number
=
s
.
viewPort
[
s
.
paramXY
]
>
0
?
0
:
(
Math
.
abs
(
Math
.
floor
(
s
.
viewPort
[
s
.
paramXY
]
/
s
.
_itemRow
))
-
1
)
*
s
.
cols
;
let
id
:
number
=
s
.
viewPort
[
s
.
paramXY
]
>
0
?
0
:
(
Math
.
abs
(
Math
.
floor
(
s
.
viewPort
[
s
.
paramXY
]
/
s
.
_itemRow
))
-
1
)
*
s
.
_cols
;
id
=
id
<
0
?
0
:
id
;
id
=
id
<
0
?
0
:
id
;
if
(
id
!=
s
.
_lastFirstId
)
{
if
(
id
!=
s
.
_lastFirstId
)
{
s
.
_lastFirstId
=
id
;
s
.
_lastFirstId
=
id
;
if
(
id
!=
items
[
0
].
id
)
{
if
(
id
!=
items
[
0
].
id
)
{
for
(
let
r
=
0
;
r
<
s
.
_
cols
;
r
++
)
{
for
(
let
r
=
0
;
r
<
s
.
cols
;
r
++
)
{
if
(
s
.
speed
>
0
)
{
if
(
s
.
speed
>
0
)
{
items
.
unshift
(
items
.
pop
());
items
.
unshift
(
items
.
pop
());
}
else
{
}
else
{
...
@@ -161,8 +164,8 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -161,8 +164,8 @@ export class ScrollListBase extends ScrollViewBase {
if
(
s
.
data
[
id
]){
if
(
s
.
data
[
id
]){
item
.
_initData
(
s
.
data
[
id
]
?
id
:
-
1
,
s
.
data
[
id
]);
item
.
_initData
(
s
.
data
[
id
]
?
id
:
-
1
,
s
.
data
[
id
]);
}
}
item
[
s
.
paramXY
]
=
Math
.
floor
(
id
/
s
.
_
cols
)
*
s
.
_itemRow
;
item
[
s
.
paramXY
]
=
Math
.
floor
(
id
/
s
.
cols
)
*
s
.
_itemRow
;
item
[
s
.
_disParam
]
=
(
id
%
s
.
_cols
)
*
s
.
itemCol
;
item
[
s
.
_disParam
]
=
(
id
%
s
.
cols
)
*
s
.
_
itemCol
;
//如果没有数据则隐藏
//如果没有数据则隐藏
if
(
s
.
data
[
id
])
{
if
(
s
.
data
[
id
])
{
item
.
sli_id
=
id
;
item
.
sli_id
=
id
;
...
@@ -188,7 +191,7 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -188,7 +191,7 @@ export class ScrollListBase extends ScrollViewBase {
public
updateViewRect
():
void
{
public
updateViewRect
():
void
{
super
.
updateViewRect
();
super
.
updateViewRect
();
let
s
=
this
;
let
s
=
this
;
if
(
s
.
_itemRow
&&
s
.
itemCol
)
{
if
(
s
.
itemWidth
&&
s
.
itemHeight
)
{
s
.
_updateViewRect
();
s
.
_updateViewRect
();
}
}
}
}
...
@@ -196,15 +199,21 @@ export class ScrollListBase extends ScrollViewBase {
...
@@ -196,15 +199,21 @@ export class ScrollListBase extends ScrollViewBase {
protected
_updateViewRect
()
{
protected
_updateViewRect
()
{
let
s
:
ScrollListBase
=
this
;
let
s
:
ScrollListBase
=
this
;
if
(
s
.
_direction
===
SCROLL_DIRECTION
.
VERTICAL
)
{
if
(
s
.
_direction
===
SCROLL_DIRECTION
.
VERTICAL
)
{
if
(
s
.
itemHeight
<=
0
){
return
;
}
s
.
_disParam
=
"x"
;
s
.
_disParam
=
"x"
;
s
.
_itemRow
=
s
.
itemHeight
;
s
.
_itemRow
=
s
.
itemHeight
;
s
.
itemCol
=
s
.
itemWidth
;
s
.
_
itemCol
=
s
.
itemWidth
;
}
else
{
}
else
{
if
(
s
.
itemWidth
<=
0
){
return
;
}
s
.
_disParam
=
"y"
;
s
.
_disParam
=
"y"
;
s
.
_itemRow
=
s
.
itemWidth
;
s
.
_itemRow
=
s
.
itemWidth
;
s
.
itemCol
=
s
.
itemHeight
;
s
.
_
itemCol
=
s
.
itemHeight
;
}
}
let
newCount
:
number
=
(
Math
.
ceil
(
s
.
distance
/
s
.
_itemRow
)
+
1
)
*
s
.
_
cols
;
let
newCount
:
number
=
(
Math
.
ceil
(
s
.
distance
/
s
.
_itemRow
)
+
1
)
*
s
.
cols
;
if
(
newCount
!=
s
.
_itemCount
)
{
if
(
newCount
!=
s
.
_itemCount
)
{
if
(
newCount
>
s
.
_itemCount
)
{
if
(
newCount
>
s
.
_itemCount
)
{
for
(
let
i
=
s
.
_itemCount
;
i
<
newCount
;
i
++
)
{
for
(
let
i
=
s
.
_itemCount
;
i
<
newCount
;
i
++
)
{
...
...
src/zeroing/game-warpper/data-center.ts
View file @
fc82b76e
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*
*
* 数据中心
* 数据中心
*/
*/
import
{
EventDispatcher
}
from
"../../2d/events"
;
import
{
EventDispatcher
}
from
"../../2d/events
/index
"
;
import
{
arrayFind
,
getDataByPath
}
from
"../utils"
;
import
{
arrayFind
,
getDataByPath
}
from
"../utils
/index
"
;
import
{
DATA_CENTER_EVENT
,
globalEvent
}
from
"../decorators/events"
;
import
{
DATA_CENTER_EVENT
,
globalEvent
}
from
"../decorators/events"
;
/**
/**
...
@@ -12,7 +12,7 @@ import {DATA_CENTER_EVENT, globalEvent} from "../decorators/events";
...
@@ -12,7 +12,7 @@ import {DATA_CENTER_EVENT, globalEvent} from "../decorators/events";
*/
*/
export
class
DataCenter
extends
EventDispatcher
{
export
class
DataCenter
extends
EventDispatcher
{
store
=
{};
store
=
{};
watcher
s
=
[];
dataMapping
s
=
[];
constructor
()
{
constructor
()
{
super
();
super
();
...
@@ -66,9 +66,9 @@ export class DataCenter extends EventDispatcher {
...
@@ -66,9 +66,9 @@ export class DataCenter extends EventDispatcher {
* @param throwException
* @param throwException
*/
*/
getDataByName
(
name
,
throwException
?)
{
getDataByName
(
name
,
throwException
?)
{
let
watcher
=
this
.
getWatcher
(
name
);
let
dataMapping
=
this
.
getDataMapping
(
name
);
if
(
watcher
)
{
if
(
dataMapping
)
{
return
getDataByPath
(
this
.
store
,
watcher
.
path
,
throwException
);
return
getDataByPath
(
this
.
store
,
dataMapping
.
path
,
throwException
);
}
}
}
}
...
@@ -82,9 +82,9 @@ export class DataCenter extends EventDispatcher {
...
@@ -82,9 +82,9 @@ export class DataCenter extends EventDispatcher {
for
(
let
escape
of
escapes
)
{
for
(
let
escape
of
escapes
)
{
let
args
=
escape
.
split
(
'|'
);
let
args
=
escape
.
split
(
'|'
);
let
name
=
args
[
0
];
let
name
=
args
[
0
];
let
watcher
=
this
.
getWatcher
(
name
);
let
dataMapping
=
this
.
getDataMapping
(
name
);
try
{
try
{
let
data
:
any
=
this
.
getDataByPath
(
watcher
.
path
,
undefined
,
true
);
let
data
:
any
=
this
.
getDataByPath
(
dataMapping
.
path
,
undefined
,
true
);
if
(
args
[
1
]
!==
undefined
)
{
if
(
args
[
1
]
!==
undefined
)
{
data
=
data
[
args
[
1
]];
data
=
data
[
args
[
1
]];
}
}
...
@@ -150,12 +150,12 @@ export class DataCenter extends EventDispatcher {
...
@@ -150,12 +150,12 @@ export class DataCenter extends EventDispatcher {
}
}
if
(
dispatch
)
{
if
(
dispatch
)
{
for
(
let
watcher
of
this
.
watcher
s
)
{
for
(
let
dataMapping
of
this
.
dataMapping
s
)
{
if
(
watcher
.
path
.
indexOf
(
groupName
)
===
0
)
{
if
(
dataMapping
.
path
.
indexOf
(
groupName
)
===
0
)
{
this
.
dispatchEvent
(
watcher
.
name
,
{
this
.
dispatchEvent
(
dataMapping
.
name
,
{
name
:
watcher
.
name
,
name
:
dataMapping
.
name
,
path
:
watcher
.
path
,
path
:
dataMapping
.
path
,
data
:
this
.
getDataByPath
(
watcher
.
path
),
data
:
this
.
getDataByPath
(
dataMapping
.
path
),
});
});
}
}
}
}
...
@@ -169,21 +169,21 @@ export class DataCenter extends EventDispatcher {
...
@@ -169,21 +169,21 @@ export class DataCenter extends EventDispatcher {
}
}
/**
/**
* 添加数据
侦听
* 添加数据
映射
* @param name
* @param name
* @param path
* @param path
*/
*/
watch
(
name
,
path
)
{
dataMapping
(
name
,
path
)
{
let
watcher
=
{
name
,
path
};
let
dataMapping
=
{
name
,
path
};
this
.
watchers
.
push
(
watcher
);
this
.
dataMappings
.
push
(
dataMapping
);
}
}
/**
/**
* 根据名字获取
侦听者
* 根据名字获取
映射
* @param name
* @param name
*/
*/
get
Watcher
(
name
)
{
get
DataMapping
(
name
)
{
return
arrayFind
(
this
.
watchers
,
watcher
=>
watcher
.
name
===
name
);
return
arrayFind
(
this
.
dataMappings
,
dataMapping
=>
dataMapping
.
name
===
name
);
}
}
/**
/**
...
@@ -192,7 +192,7 @@ export class DataCenter extends EventDispatcher {
...
@@ -192,7 +192,7 @@ export class DataCenter extends EventDispatcher {
*/
*/
registerDataMapping
(
dataMapping
)
{
registerDataMapping
(
dataMapping
)
{
for
(
let
item
of
dataMapping
)
{
for
(
let
item
of
dataMapping
)
{
this
.
watch
(
item
.
name
,
item
.
path
);
this
.
dataMapping
(
item
.
name
,
item
.
path
);
}
}
}
}
...
...
src/zeroing/game-warpper/nodes/Label.ts
View file @
fc82b76e
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*/
*/
import
{
TextField
}
from
"../../../2d/text/index"
;
import
{
TextField
}
from
"../../../2d/text/index"
;
import
{
dataCenter
}
from
"../data-center"
;
import
{
dataCenter
}
from
"../data-center"
;
import
{
ESCAPE_REG_EXP
,
htmlToPureText
}
from
"../../utils"
;
import
{
ESCAPE_REG_EXP
,
htmlToPureText
}
from
"../../utils
/index
"
;
/**
/**
* 文本
* 文本
...
...
src/zeroing/game-warpper/nodes/ScrollList.ts
View file @
fc82b76e
...
@@ -38,7 +38,7 @@ export class ScrollList extends ScrollListBase {
...
@@ -38,7 +38,7 @@ export class ScrollList extends ScrollListBase {
protected
onNextFrame
(
event
)
{
protected
onNextFrame
(
event
)
{
this
.
firstItem
=
<
Container
>
this
.
removeChildAt
(
0
);
this
.
firstItem
=
<
Container
>
this
.
removeChildAt
(
0
);
this
.
_
updateViewRect
();
this
.
updateViewRect
();
}
}
protected
createItem
():
any
{
protected
createItem
():
any
{
...
...
src/zeroing/game-warpper/view-interpreter.ts
View file @
fc82b76e
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*/
*/
import
{
Container
}
from
"../../2d/display/index"
;
import
{
Container
}
from
"../../2d/display/index"
;
import
{
Rect
,
Image
,
Label
,
Circle
,
ScrollView
,
TextInput
,
ScrollList
,
BitmapText
,
HtmlView
}
from
"./nodes"
;
import
{
Rect
,
Image
,
Label
,
Circle
,
ScrollView
,
TextInput
,
ScrollList
,
BitmapText
,
HtmlView
}
from
"./nodes
/index
"
;
import
{
injectProperties
,
instantiateScript
,}
from
"../utils/index"
;
import
{
injectProperties
,
instantiateScript
,}
from
"../utils/index"
;
const
nodeTypeMapping
=
{
const
nodeTypeMapping
=
{
...
...
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