Skip to content

Commit

Permalink
use string parser for sprite sheet src property
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasschultes committed Jan 16, 2024
1 parent 8456240 commit 0ab5225
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/Core/StyleSheetParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ class SpritesheetPropertyParser final : public AbstractPropertyParser {

PropertyDictionary properties;
PropertySpecification specification;
PropertyId id_rx, id_ry, id_rw, id_rh, id_resolution;
PropertyId id_src, id_rx, id_ry, id_rw, id_rh, id_resolution;
ShorthandId id_rectangle;

public:
SpritesheetPropertyParser() : specification(4, 1)
{
id_src = specification.RegisterProperty("src", "", false, false).AddParser("string").GetId();
id_rx = specification.RegisterProperty("rectangle-x", "", false, false).AddParser("length").GetId();
id_ry = specification.RegisterProperty("rectangle-y", "", false, false).AddParser("length").GetId();
id_rw = specification.RegisterProperty("rectangle-w", "", false, false).AddParser("length").GetId();
Expand All @@ -115,7 +116,16 @@ class SpritesheetPropertyParser final : public AbstractPropertyParser {
{
if (name == "src")
{
image_source = value;
if(!specification.ParsePropertyDeclaration(properties, id_src, value))
return false;

if(const Property* property = properties.GetProperty(id_src))
{
if(property->unit == Unit::STRING)
image_source = property->Get<String>();
} else {
image_source = value;
}
}
else if (name == "resolution")
{
Expand Down

0 comments on commit 0ab5225

Please sign in to comment.