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

(Enhancement) Implement some way to draw plugins on top of everything else #3054

Closed
Starmapo opened this issue Feb 29, 2024 · 8 comments · Fixed by #3057
Closed

(Enhancement) Implement some way to draw plugins on top of everything else #3054

Starmapo opened this issue Feb 29, 2024 · 8 comments · Fixed by #3057

Comments

@Starmapo
Copy link
Contributor

It would be nice to be able to have a plugin be drawn on top of all other objects, as it's currently forced to be drawn under everything else. For example, this can be used for a plugin that displays achievement objects on the screen (which is what I was trying to implement a while ago), an FPS/memory display, etc.

I'm not sure what's the best way to go about this, as FlxG.plugins takes any FlxBasic instance, and I think it'll be confusing to add a variable that only works for plugins.

Please let me know your thoughts on this suggestion.

@Geokureli
Copy link
Member

I agree it seems weird to have a drawOnTop field for plugins. maybe it makes more sense to just always draw plugins on top? I can't imagine a time when someone would want to draw a plugin under everything.

The above is still a breaking change, so until 6.0.0 You might want to just call FlxG.plugins.draw() manually in your state to draw it on top of everything. not ideal but works with minimal effort

@Starmapo
Copy link
Contributor Author

Sounds good! And I agree that I can't imagine a situation where you'd want a plugin drawn behind everything.

@Geokureli
Copy link
Member

Some ideas:

  1. Add FlxG.plugins.drawOnTop, which defaults to false for backwards compatibility (Less complicated, less features)
  2. Add a drawOnTop arg to FlxG.plugins.addPlugin that defaults to false. internally there will be 2 lists of plugins and the remove and get methods will check both (More complicated, more features)

@Starmapo
Copy link
Contributor Author

I actually did have the second idea in mind, it seems like the best option if we're going to allow the previous method (even if I don't know any situation where you'd want it). Will have to think about what to do with FlxG.plugins.list though, unless the 2 new lists are just updated separately from that.

@Geokureli
Copy link
Member

I'm actually leaning towards option 1, it still allows for objects on bottom, if desired, and if someone wants both then I would love for them to share their use case in a github issue. Also option 2 gets hairy when talking about edge cases, like if they try to add the same plugin instance to both or if they want to move something from one to the other

@Starmapo
Copy link
Contributor Author

Yeah that's fair, option 1 it is then.

@Geokureli
Copy link
Member

Geokureli commented Mar 1, 2024

If you wanted to make a PR that'd be cool otherwise I dunno when I'll get around to it. and feel free to explore option 2 if you want

@Starmapo
Copy link
Contributor Author

Starmapo commented Mar 1, 2024

Alright sure, I'll make the PR when I get the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants