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
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
34488ce5
Commit
34488ce5
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
audioVolumne is of type float, not int
also, float properties exist, apparently
parent
eeb78b3f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Properties.hs
+19
-4
19 additions, 4 deletions
lib/Properties.hs
lib/Tiled.hs
+24
-12
24 additions, 12 deletions
lib/Tiled.hs
with
43 additions
and
16 deletions
lib/Properties.hs
+
19
−
4
View file @
34488ce5
...
...
@@ -297,7 +297,7 @@ checkTileLayerProperty p@(Property name _value) = case name of
"playAudioLoop"
->
deprecatedUseInstead
"audioLoop"
"audioVolume"
->
do
is
Bool
p
is
OrdInRange
unwrapFloat
0
1
p
requireProperty
"playAudio"
"openWebsite"
->
do
uselessEmptyLayer
...
...
@@ -502,6 +502,12 @@ unwrapInt (Property name value) f = case value of
_
->
complain
$
"type error: property "
<>
prettyprint
name
<>
" should be of type int."
unwrapFloat
::
Property
->
(
Float
->
LintWriter
a
)
->
LintWriter
a
unwrapFloat
(
Property
name
value
)
f
=
case
value
of
FloatProp
float
->
f
float
_
->
complain
$
"type error: property "
<>
prettyprint
name
<>
" should be of type float."
unwrapPath
::
Text
->
(
RelPath
->
LintWriter
a
)
->
LintWriter
a
unwrapPath
str
f
=
case
parsePath
str
of
OkRelPath
p
@
(
Path
up
_
_
)
->
do
...
...
@@ -548,7 +554,16 @@ isString = flip unwrapString (const $ pure ())
isBool
::
Property
->
LintWriter
a
isBool
=
flip
unwrapBool
(
const
$
pure
()
)
isIntInRange
::
Int
->
Int
->
Property
->
LintWriter
a
isIntInRange
l
r
p
@
(
Property
name
_
)
=
unwrapInt
p
$
\
int
->
isIntInRange
::
Int
->
Int
->
Property
->
LintWriter
b
isIntInRange
=
isOrdInRange
@
Int
unwrapInt
isOrdInRange
::
(
Ord
a
,
Show
a
)
=>
(
Property
->
(
a
->
LintWriter
b
)
->
LintWriter
b
)
->
a
->
a
->
Property
->
LintWriter
b
isOrdInRange
unwrapa
l
r
p
@
(
Property
name
_
)
=
unwrapa
p
$
\
int
->
if
l
<
int
&&
int
<
r
then
pure
()
else
complain
$
"Property "
<>
prettyprint
name
<>
" should be between"
<>
showText
l
<>
" and "
<>
showText
r
<>
"."
else
complain
$
"Property "
<>
prettyprint
name
<>
" should be between "
<>
showText
l
<>
" and "
<>
showText
r
<>
"."
This diff is collapsed.
Click to expand it.
lib/Tiled.hs
+
24
−
12
View file @
34488ce5
...
...
@@ -62,7 +62,7 @@ data Property = Property Text PropertyValue
-- | The value of a custom tiled property.
-- It is strongly typed via a tag in the json representation,
-- and needs a custom ToJSON and FromJSON instance because of that.
data
PropertyValue
=
StrProp
Text
|
BoolProp
Bool
|
IntProp
Int
data
PropertyValue
=
StrProp
Text
|
BoolProp
Bool
|
IntProp
Int
|
FloatProp
Float
deriving
(
Eq
,
Generic
,
Show
)
instance
IsString
PropertyValue
where
...
...
@@ -81,22 +81,34 @@ instance FromJSON Property where
A
.
String
"int"
->
do
val
<-
o
.:
"value"
pure
$
Property
name
(
IntProp
val
)
A
.
String
"float"
->
do
val
<-
o
.:
"value"
pure
$
Property
name
(
FloatProp
val
)
ty
->
fail
$
"properties can only have types string, int, bool, but encountered type"
<>
show
ty
parseJSON
invalid
=
typeMismatch
"Property"
invalid
instance
ToJSON
Property
where
toJSON
(
Property
name
val
)
=
case
val
of
StrProp
str
->
object
[
"type"
.=
A
.
String
"string"
StrProp
str
->
object
[
"type"
.=
A
.
String
"string"
,
"name"
.=
name
,
"value"
.=
str
]
BoolProp
bool
->
object
[
"type"
.=
A
.
String
"bool"
BoolProp
bool
->
object
[
"type"
.=
A
.
String
"bool"
,
"name"
.=
name
,
"value"
.=
bool
]
IntProp
int
->
object
[
"type"
.=
A
.
String
"int"
IntProp
int
->
object
[
"type"
.=
A
.
String
"int"
,
"name"
.=
name
,
"value"
.=
int
]
FloatProp
float
->
object
[
"type"
.=
A
.
String
"float"
,
"name"
.=
name
,
"value"
.=
int
]
,
"value"
.=
float
]
data
Point
=
Point
{
pointX
::
Double
,
pointY
::
Double
...
...
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