Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contain all layer types in an enum #131

Merged
merged 8 commits into from
Jan 26, 2022
Merged

Conversation

aleokdev
Copy link
Contributor

Closes #130 & supersedes #53.
Fits all layer types into a single LayerType enum and places all common data (ID, name, properties, etc) into a struct.

@aleokdev aleokdev added enhancement breaking This change breaks backwards-compatibility labels Jan 25, 2022
@aleokdev aleokdev added this to the 0.10.0 milestone Jan 25, 2022
@aleokdev aleokdev requested a review from bjorn January 25, 2022 20:04
@aleokdev aleokdev self-assigned this Jan 25, 2022
src/tile.rs Outdated Show resolved Hide resolved
tests/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you went ahead with this change, and I think it turned out pretty nice!

It's also interesting to see how you can juggle those properties around, to make them part of Layer instead of each specific layer type.

Btw, why is it still marked as draft, even though it appears to compile and test out fine? (Edit: Ah, because you still want to add support for groups as well)

src/layers.rs Outdated Show resolved Hide resolved
src/layers.rs Show resolved Hide resolved
src/layers.rs Outdated Show resolved Hide resolved
@aleokdev
Copy link
Contributor Author

Btw, why is it still marked as draft, even though it appears to compile and test out fine?

Just because I wasn't 100% sure of the final interface. Group layers will get their own PR, since they weren't implemented even before these changes.

@aleokdev aleokdev marked this pull request as ready for review January 26, 2022 10:51
@bjorn bjorn mentioned this pull request Jan 26, 2022
tests/lib.rs Outdated
@@ -21,15 +22,15 @@ fn test_gzip_and_zlib_encoded_and_raw_are_the_same() {
assert_eq!(z, c);
assert_eq!(z, zstd);

if let LayerData::Finite(tiles) = &c.layers[0].tiles {
if let LayerData::Finite(tiles) = &c.layers[0].layer_type.as_tile_layer().unwrap().tiles {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what if we would put as_tile_layer on the Layer, so that we could get &c.layers[0].as_tile_layer()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, saw this too late

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo not a good decision because as_tile_layer only borrows LayerType, not the entire Layer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this type of consideration is still new to me. :-)

bjorn
bjorn previously approved these changes Jan 26, 2022
@bjorn
Copy link
Member

bjorn commented Jan 26, 2022

+218 −168... always the same, if you clean and remove lots of duplicate code, you still usually end up with more code! :S

bjorn
bjorn previously approved these changes Jan 26, 2022
@aleokdev
Copy link
Contributor Author

aleokdev commented Jan 26, 2022

Okay, I swear this is the last time I ask you to re-review :p

Edit: Nevermind, build's broken x_x

@aleokdev aleokdev requested a review from bjorn January 26, 2022 17:23
@aleokdev aleokdev merged commit 968073b into mapeditor:master Jan 26, 2022
@bjorn bjorn mentioned this pull request Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change breaks backwards-compatibility enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have layer common data in a single struct
2 participants