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"
}
\ No newline at end of file
{
"id"
:
"engine"
,
"url"
:
"engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"
}
\ No newline at end of file
src/2d/ui/ScrollListBase.ts
View file @
fc82b76e
...
...
@@ -40,11 +40,11 @@ export abstract class ScrollListItemBase extends Container {
export
class
ScrollListBase
extends
ScrollViewBase
{
private
_items
:
Array
<
ScrollListItemBase
>
=
null
;
private
_itemRow
:
number
;
private
_itemCol
:
number
;
private
_itemCount
:
number
;
private
_isInit
:
number
=
0
;
public
data
:
Array
<
any
>
=
[];
private
downL
:
DisplayObject
=
null
;
private
_cols
:
number
=
1
;
private
_disParam
:
string
;
private
_lastFirstId
:
number
=
-
1
;
private
_updateId
:
number
=
-
1
;
...
...
@@ -54,7 +54,7 @@ export class ScrollListBase extends ScrollViewBase {
@
dirtyFieldTrigger
public
itemHeight
:
number
=
0
;
@
dirtyFieldTrigger
public
itemCol
:
number
;
public
cols
:
number
=
1
;
@
dirtyFieldTrigger
public
itemClass
:
any
;
...
...
@@ -84,7 +84,7 @@ export class ScrollListBase extends ScrollViewBase {
}
protected
onNextFrame
(
event
)
{
this
.
_
updateViewRect
();
this
.
updateViewRect
();
}
onModify
(
value
,
key
)
{
...
...
@@ -95,7 +95,7 @@ export class ScrollListBase extends ScrollViewBase {
case
'itemH'
:
break
;
case
'itemCol'
:
case
'
_
itemCol'
:
break
;
case
'itemClass'
:
...
...
@@ -106,7 +106,7 @@ export class ScrollListBase extends ScrollViewBase {
protected
calMaxDistance
():
any
{
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 {
}
s
.
_isInit
=
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) {
s.downL[s.paramXY] = Math.max(s.distance, s.maxDistance);
var wh = s.downL.getWH();
...
...
@@ -135,15 +135,18 @@ export class ScrollListBase extends ScrollViewBase {
private
flushData
()
{
let
s
:
ScrollListBase
=
this
;
const
items
=
s
.
_items
;
if
(
items
.
length
<=
0
){
return
;
}
if
(
s
.
_isInit
>
0
)
{
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
;
if
(
id
!=
s
.
_lastFirstId
)
{
s
.
_lastFirstId
=
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
)
{
items
.
unshift
(
items
.
pop
());
}
else
{
...
...
@@ -161,8 +164,8 @@ export class ScrollListBase extends ScrollViewBase {
if
(
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
.
_disParam
]
=
(
id
%
s
.
_cols
)
*
s
.
itemCol
;
item
[
s
.
paramXY
]
=
Math
.
floor
(
id
/
s
.
cols
)
*
s
.
_itemRow
;
item
[
s
.
_disParam
]
=
(
id
%
s
.
cols
)
*
s
.
_
itemCol
;
//如果没有数据则隐藏
if
(
s
.
data
[
id
])
{
item
.
sli_id
=
id
;
...
...
@@ -188,7 +191,7 @@ export class ScrollListBase extends ScrollViewBase {
public
updateViewRect
():
void
{
super
.
updateViewRect
();
let
s
=
this
;
if
(
s
.
_itemRow
&&
s
.
itemCol
)
{
if
(
s
.
itemWidth
&&
s
.
itemHeight
)
{
s
.
_updateViewRect
();
}
}
...
...
@@ -196,15 +199,21 @@ export class ScrollListBase extends ScrollViewBase {
protected
_updateViewRect
()
{
let
s
:
ScrollListBase
=
this
;
if
(
s
.
_direction
===
SCROLL_DIRECTION
.
VERTICAL
)
{
if
(
s
.
itemHeight
<=
0
){
return
;
}
s
.
_disParam
=
"x"
;
s
.
_itemRow
=
s
.
itemHeight
;
s
.
itemCol
=
s
.
itemWidth
;
s
.
_
itemCol
=
s
.
itemWidth
;
}
else
{
if
(
s
.
itemWidth
<=
0
){
return
;
}
s
.
_disParam
=
"y"
;
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
)
{
for
(
let
i
=
s
.
_itemCount
;
i
<
newCount
;
i
++
)
{
...
...
src/zeroing/game-warpper/data-center.ts
View file @
fc82b76e
...
...
@@ -3,8 +3,8 @@
*
* 数据中心
*/
import
{
EventDispatcher
}
from
"../../2d/events"
;
import
{
arrayFind
,
getDataByPath
}
from
"../utils"
;
import
{
EventDispatcher
}
from
"../../2d/events
/index
"
;
import
{
arrayFind
,
getDataByPath
}
from
"../utils
/index
"
;
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
{
store
=
{};
watcher
s
=
[];
dataMapping
s
=
[];
constructor
()
{
super
();
...
...
@@ -66,9 +66,9 @@ export class DataCenter extends EventDispatcher {
* @param throwException
*/
getDataByName
(
name
,
throwException
?)
{
let
watcher
=
this
.
getWatcher
(
name
);
if
(
watcher
)
{
return
getDataByPath
(
this
.
store
,
watcher
.
path
,
throwException
);
let
dataMapping
=
this
.
getDataMapping
(
name
);
if
(
dataMapping
)
{
return
getDataByPath
(
this
.
store
,
dataMapping
.
path
,
throwException
);
}
}
...
...
@@ -82,9 +82,9 @@ export class DataCenter extends EventDispatcher {
for
(
let
escape
of
escapes
)
{
let
args
=
escape
.
split
(
'|'
);
let
name
=
args
[
0
];
let
watcher
=
this
.
getWatcher
(
name
);
let
dataMapping
=
this
.
getDataMapping
(
name
);
try
{
let
data
:
any
=
this
.
getDataByPath
(
watcher
.
path
,
undefined
,
true
);
let
data
:
any
=
this
.
getDataByPath
(
dataMapping
.
path
,
undefined
,
true
);
if
(
args
[
1
]
!==
undefined
)
{
data
=
data
[
args
[
1
]];
}
...
...
@@ -150,12 +150,12 @@ export class DataCenter extends EventDispatcher {
}
if
(
dispatch
)
{
for
(
let
watcher
of
this
.
watcher
s
)
{
if
(
watcher
.
path
.
indexOf
(
groupName
)
===
0
)
{
this
.
dispatchEvent
(
watcher
.
name
,
{
name
:
watcher
.
name
,
path
:
watcher
.
path
,
data
:
this
.
getDataByPath
(
watcher
.
path
),
for
(
let
dataMapping
of
this
.
dataMapping
s
)
{
if
(
dataMapping
.
path
.
indexOf
(
groupName
)
===
0
)
{
this
.
dispatchEvent
(
dataMapping
.
name
,
{
name
:
dataMapping
.
name
,
path
:
dataMapping
.
path
,
data
:
this
.
getDataByPath
(
dataMapping
.
path
),
});
}
}
...
...
@@ -169,21 +169,21 @@ export class DataCenter extends EventDispatcher {
}
/**
* 添加数据
侦听
* 添加数据
映射
* @param name
* @param path
*/
watch
(
name
,
path
)
{
let
watcher
=
{
name
,
path
};
this
.
watchers
.
push
(
watcher
);
dataMapping
(
name
,
path
)
{
let
dataMapping
=
{
name
,
path
};
this
.
dataMappings
.
push
(
dataMapping
);
}
/**
* 根据名字获取
侦听者
* 根据名字获取
映射
* @param name
*/
get
Watcher
(
name
)
{
return
arrayFind
(
this
.
watchers
,
watcher
=>
watcher
.
name
===
name
);
get
DataMapping
(
name
)
{
return
arrayFind
(
this
.
dataMappings
,
dataMapping
=>
dataMapping
.
name
===
name
);
}
/**
...
...
@@ -192,7 +192,7 @@ export class DataCenter extends EventDispatcher {
*/
registerDataMapping
(
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 @@
*/
import
{
TextField
}
from
"../../../2d/text/index"
;
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 {
protected
onNextFrame
(
event
)
{
this
.
firstItem
=
<
Container
>
this
.
removeChildAt
(
0
);
this
.
_
updateViewRect
();
this
.
updateViewRect
();
}
protected
createItem
():
any
{
...
...
src/zeroing/game-warpper/view-interpreter.ts
View file @
fc82b76e
...
...
@@ -3,7 +3,7 @@
*/
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"
;
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