Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
aa897bb7
Commit
aa897bb7
authored
Dec 18, 2021
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
fixed parsing of tiled objects
(points behave slightly differntly than I thought)
parent
96a3cc24
No related branches found
No related tags found
No related merge requests found
Pipeline
#10023
passed
Dec 18, 2021
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/Properties.hs
+9
-8
9 additions, 8 deletions
lib/Properties.hs
lib/Tiled.hs
+10
-23
10 additions, 23 deletions
lib/Tiled.hs
lib/Types.hs
+3
-0
3 additions, 0 deletions
lib/Types.hs
with
22 additions
and
31 deletions
lib/Properties.hs
+
9
−
8
View file @
aa897bb7
...
...
@@ -211,7 +211,7 @@ checkLayer = do
forM_
(
getProperties
layer
)
checkObjectGroupProperty
unless
(
layerName
layer
==
"floorLayer"
)
$
when
(
null
public
Objects
||
public
Objects
==
Just
mempty
)
$
when
(
null
(
layer
Objects
layer
)
||
layer
Objects
layer
==
Just
mempty
)
$
warn
"objectgroup layer (which aren't the floorLayer)
\
\
are useless if they are empty."
...
...
@@ -234,16 +234,17 @@ checkObjectProperty obj p@(Property name _) = case name of
unwrapString
p
$
\
str
->
unwrapBadgeToken
str
$
\
token
->
do
case
obj
of
ObjectPoint
{
..
}
->
offersBadge
(
Badge
token
(
BadgePoint
objectX
objectY
))
ObjectRectangle
{
..
}
->
if
isJust
objectEllipse
then
offersBadge
$
Badge
token
(
BadgeRect
objectX
objectY
objectWidth
objectHeight
)
else
complain
"ellipses are not supported."
ObjectPolygon
{}
->
complain
"polygons are not supported."
ObjectPolyline
{}
->
complain
"polylines are not supported."
ObjectText
{}
->
complain
"cannot use texts to define badge areas."
ObjectRectangle
{
..
}
->
if
objectEllipse
==
Just
True
then
complain
"ellipses are not supported."
else
offersBadge
$
Badge
token
$
case
(
objectWidth
,
objectHeight
)
of
(
Just
w
,
Just
h
)
|
w
/=
0
&&
h
/=
0
->
BadgeRect
objectX
objectY
w
h
_
->
BadgePoint
objectX
objectY
_
->
warn
$
"unknown object property "
<>
prettyprint
name
<>
"."
...
...
This diff is collapsed.
Click to expand it.
lib/Tiled.hs
+
10
−
23
View file @
aa897bb7
...
...
@@ -121,32 +121,19 @@ instance ToJSON Point where
-- | all kinds of objects that can occur in object layers, even
-- | those that we don't want to allow.
data
Object
=
Object
Point
data
Object
=
Object
Rectangle
{
objectId
::
Int
,
objectName
::
Maybe
String
,
objectProperties
::
Maybe
(
Vector
Property
)
,
objectVisible
::
Maybe
Bool
,
objectX
::
Double
,
objectY
::
Double
,
objectHeight
::
Double
,
objectWidth
::
Double
,
objectRotation
::
Double
,
objectGid
::
Maybe
GlobalId
,
objectType
::
Text
,
objectPoint
::
Bool
}
|
ObjectRectangle
{
objectId
::
Int
,
objectName
::
Maybe
String
,
objectProperties
::
Maybe
(
Vector
Property
)
,
objectVisible
::
Maybe
Bool
,
objectX
::
Double
,
objectY
::
Double
,
objectRotation
::
Double
,
objectGid
::
Maybe
GlobalId
,
objectWidth
::
Double
,
objectHeight
::
Double
,
objectWidth
::
Maybe
Double
,
objectHeight
::
Maybe
Double
,
objectEllipse
::
Maybe
Bool
,
objectPoint
::
Maybe
Bool
,
objectType
::
Text
}
|
ObjectPolygon
...
...
@@ -158,8 +145,8 @@ data Object = ObjectPoint
,
objectY
::
Double
,
objectRotation
::
Double
,
objectGid
::
Maybe
GlobalId
,
objectWidth
::
Double
,
objectHeight
::
Double
,
objectWidth
::
Maybe
Double
,
objectHeight
::
Maybe
Double
,
objectType
::
Text
,
objectPolygon
::
Vector
Point
}
...
...
@@ -172,9 +159,9 @@ data Object = ObjectPoint
,
objectY
::
Double
,
objectRotation
::
Double
,
objectGid
::
Maybe
GlobalId
,
objectWidth
::
Double
,
objectWidth
::
Maybe
Double
,
objectHeight
::
Maybe
Double
,
objectType
::
Text
,
objectHeight
::
Double
,
objectPolyline
::
Vector
Point
}
|
ObjectText
...
...
@@ -187,8 +174,8 @@ data Object = ObjectPoint
,
objectRotation
::
Double
,
objectGid
::
Maybe
GlobalId
,
objectText
::
A
.
Value
,
objectWidth
::
Double
,
objectHeight
::
Double
,
objectWidth
::
Maybe
Double
,
objectHeight
::
Maybe
Double
,
objectEllipse
::
Maybe
Bool
,
objectType
::
Text
}
deriving
(
Eq
,
Generic
,
Show
)
...
...
This diff is collapsed.
Click to expand it.
lib/Types.hs
+
3
−
0
View file @
aa897bb7
...
...
@@ -93,6 +93,9 @@ instance ToJSON Lint where
toJSON
(
Offers
l
)
=
A
.
object
[
"msg"
.=
prettyprint
l
,
"level"
.=
A
.
String
"Entrypoint Info"
]
toJSON
(
Badge
_
)
=
A
.
object
[
"msg"
.=
A
.
String
"found a badge"
,
"level"
.=
A
.
String
"Badge Info"
]
instance
ToJSON
Hint
where
toJSON
(
Hint
l
m
)
=
A
.
object
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment