-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add a basic Overlay class and OverlayManager #117
Conversation
I would like your opinion on the direction of this system, whether this is going in the right direction, or you are imagining something completely different. If you think this is a nice base, I will continue working on the TODOs listed above. |
common/src/main/java/com/wynntils/features/user/DummyOverlayFeature.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/features/user/DummyOverlayFeature.java
Outdated
Show resolved
Hide resolved
I think this is heading in the direction of having them both separated from features but allows features to own overlays. Which is good, I do believe the TODO's should be implemented at the basic level before any clear judgement can be given. And while you work on it, having overlay have some sort of overlayconfig field which would be the thing stored cross instance (location and if it's enabled. Everything as seen by the settings) or it could be OverlayPosition and you'd add config annotation if you want it saved. But this is more of a "keep this in mind" thing |
This commit also makes OverlayManager centralized, removing the per-feature aspect of it.
I like the setup of inner classes for overlays, but I don't think doing everything via annotations/reflection is the cleanest way to accomplish this, especially with the idea in mind of registering multiple instances of the same overlay. My immediate thought is that overlays should be explicitly registered in a feature's public class SomeFeature extends UserFeature {
@Config(...)
OverlayPosition position1 = new OverlayPosition(...);
@Config(...)
OverlayPosition position2 = new OverlayPosition(...);
public void init() {
registerOverlay(new SomeOverlay(), position1);
registerOverlay(new SomeOverlay(), position2);
}
@Overlay(renderType = HUD) // etc
public static class SomeOverlay extends Overlay {
public void render(...) { ... }
}
} And then in Map<Overlay, OverlayPosition> overlays = new HashMap<>();
// ...
protected void registerOverlay(Overlay overlay, OverlayPosition position) {
overlays.put(overlay, position);
}
// ...
public final void enable() {
// ...
OverlayManager.registerAll(overlays);
// ...
} |
Looking good, but I have a few complaints. I feel that |
@Incompleteusern @P0keDev I implemented your suggestions, but the two of you had a little conflict of interest, so let me know if you don't like something. |
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.
Personally I would prefer it if overlay registration paralleled keybinds in its design (features keep track of their own overlays, register/unregister them to the central handler as needed). OverlayManager
could keep track of overlays' "parent" features in addition to this, if that's also important. All up for debate, however
I would also advocate for renaming the overlay stuff to parallel the names of our feature framework, i.e. Overlay
-> OverlayInfo
and OverlayBase
-> Overlay
common/src/main/java/com/wynntils/core/features/overlays/OverlayManager.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/core/features/FeatureRegistry.java
Outdated
Show resolved
Hide resolved
Overall, I think this is definitely heading in the right direction. I'll add some specific remarks in the code shortly, but let me first discuss one overall thing. I think the code is getting unnecessary complex due to the idea that enabling overlays mean instantiating them. Instead, I think we should treat overlays like features. Always instantiate them in the beginning. To enable/disable an overlay really just means to move it on or off the list of enabled overlays, which is traversed when calling the Second, while I originally championed the idea that we should allow a feature to have multiple instances of an overlay, I also must stress that this is a special case scenario (only info boxes seem to be relevant atm), and it's better if that part gets a bit messier, if it can make the normal case of one overlay instance per Overlay class simpler. I'm thinking something like this. Instead of registering OverlayPositions as
That is, the |
I second that. It really fits in better with what we have, and feels like more natural descriptions. |
common/src/main/java/com/wynntils/core/features/overlays/OverlayManager.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/core/features/overlays/OverlayManager.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/core/features/overlays/OverlayManager.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/core/features/overlays/OverlayManager.java
Show resolved
Hide resolved
common/src/main/java/com/wynntils/features/user/DummyOverlayFeature.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/wynntils/features/user/DummyOverlayFeature.java
Outdated
Show resolved
Hide resolved
I think this is starting to look pretty sweet! It feels like we're almost there, at the Perfect Overlay Design. :-) @kristofbolyai I think bundling the position in the Overlay class was exactly the right decision. I just have three issues surrounding the overlay position thing.
So even though I think an Overlay should hold it's position, we could perhaps allow it to be null, and not set from the constructor. And then maybe the OverlayManager can have some way of assigning default positions for the overlays? After all, it's a bit of a "holistic" system wide thing, to get a proper default where different overlays have good default that work with each other.
But we can also accept this PR as it is now, and continue working on these aspects as follow up issues. |
I would separate Overlay config saving into a PR, and then advanced Overlay characteristics into another one. |
@kristofbolyai I'm perfectly fine with that. Sometimes it's easier to have a checkpoint with a PR committed, and then you continue to refine details separately. Feel free to postpone any of my comments to a later PR, as long as they are adressed in some way or another later on. :-) |
@@ -162,12 +147,11 @@ public static void init() { | |||
registerFeature(new WynncraftButtonFeature()); | |||
registerFeature(new TooltipScaleFeature()); | |||
registerFeature(new DurabilityArcFeature()); | |||
// registerFeature(new DummyOverlayFeature()); TODO: We should have a way to register features with disabled state |
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.
I thought DebugFeatures did just that..?
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.
DebugFeatures should only enabled for dev environment, this should be never be
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.
We could move this into an examples folder and not register it?
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.
Whatever, it does not matter so much. I imagine we can remove this thing as soon as we start getting real examples of the Overlay system. I'm fine with a commented out line like this too.
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.
I just discovered that we have an @StartDisabled
annotation for Features. I assume this does what you wanted? :-D
common/src/main/java/com/wynntils/features/user/DummyOverlayFeature.java
Outdated
Show resolved
Hide resolved
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.
This looks soooo epic! 🥳
This PR is currently WIP, I created this so the team can see and discuss if they like this system.
TODOs (not fully in the scope of this PR, but I may include them):
Overlay
: This class is very bare bones at the moment, it should be improved. (This PR is focusing more on the OverlayManager and render system, the Overlay class should be detailed more in a separate PR)RenderEvent
: Adding moreElementType
s and canceling will allow us to "override" GUI parts like the health bar, necessary for some overlays.Here is the render of the example overlay I added, called
DummyOverlayFeature
: