-
Notifications
You must be signed in to change notification settings - Fork 41
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
Refactor unit map layers #1083
Refactor unit map layers #1083
Conversation
Encapsulating unit drawing in a class will allow for more complex options because it reduces the conceptual complexity of the code.
If one wants to draw a unit type, there's a very fitting function get_unittype_sprite in the tileset. There is no reason for the map view to duplicate this functionality with another implementation.
They were no longer used. This commit also removes the unit type parameter from fill_sprite_array functions, which was also never used.
It's used only once in the function. What was the reason for making it a parameter in the first place?
It was only ever set to tile_city(ptile). It is better to call it in the implementation, otherwise one could wonder when pcity isn't the city on the tile being drawn.
'backdrop' was made useless when removing 'pcity'.
We have layer::do_draw_unit, so use it. Also simplify away the XOR.
519674c
to
816a04e
Compare
Only those units that are focused should be drawn on the corresponding layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take this chance to move layers to a separate folder ? I think something like, client/layers/layer_*.cpp/h is better. But I'll approve anyways, since that can be done in a different PR, where we reorganize everything within client. Apart from that, rest look good to me.
Thanks for the review! I agree that layer classes should eventually be moved to another folder, but I'm not sure how to call it: it could be for instance |
This PR refactors the code that draws units on the map and some code around it. I wanted to implement #429 but figured that some refactoring was needed first. This PR introduces no behavior change.
Things to check