-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sample direction that FCs are going towards [RFR] #3258
Conversation
Hooray Jenkins reported success with all tests good! |
@@ -77,6 +76,11 @@ | |||
public static final String DUMP_SHADERS = "DumpShaders"; | |||
public static final String VOLUMETRIC_FOG = "VolumetricFog"; | |||
|
|||
public static final SimpleUri WINDOW_POS_X_ = new SimpleUri("engine:windowPosX"); | |||
public static final SimpleUri WINDOW_POS_Y_ = new SimpleUri("engine:windowPosY"); |
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 think both of these can be put together into a single Setting<Vector2i>
for easier access. However, this change will break things, so it may be better off in a separate PR.
Edit: This change already breaks things, so the change can be made in this PR if decided upon.
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 actually favour this change, for reasons other than easier access. Rather than subscribe to either width and height, you can simply subscribe to one property. So I think let's make it a Vector2i
in this PR, unless someone has a problem. This PR will be kinda messy and break-all-the-things either way.
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 think it would be at least interesting to see a Vector2i setting in action. Let's give it a try.
I consider this PR a great insight into the current shortcomings of FlexibleConfig, and thank you @vampcat for this effort. A couple of points:
|
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.
With some initial tests, I feel like making a static class with methods like getRenderingFc()
might be a good idea, so as to avoid things like (Integer)context.get(FlexibleConfigManager.class).get("engine:rendering").get("engine:windowPosX").getValue()
, but that goes against the spirit of the context, so we can just split the above line into two.
It also feels like a good idea to have a get(Class clazz)
constructor, so that we can morph the above statement into renderingFc.get("engine:windowPosX", Integer.class)
or something. Feedback would be appreciated on this.
@@ -28,13 +31,9 @@ | |||
|
|||
/** | |||
*/ | |||
@SuppressWarnings("WeakerAccess") |
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.
Added because the public String <settingName>
often gave a access can be private
when in fact, since these settings should be available to everyone, it should be public.
@@ -77,6 +76,11 @@ | |||
public static final String DUMP_SHADERS = "DumpShaders"; | |||
public static final String VOLUMETRIC_FOG = "VolumetricFog"; | |||
|
|||
public static final SimpleUri WINDOW_POS_X_ = new SimpleUri("engine:windowPosX"); |
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.
The _
at the end is temporary, and will be removed as soon as I migrate all settings over.
@@ -77,6 +76,11 @@ | |||
public static final String DUMP_SHADERS = "DumpShaders"; | |||
public static final String VOLUMETRIC_FOG = "VolumetricFog"; | |||
|
|||
public static final SimpleUri WINDOW_POS_X_ = new SimpleUri("engine:windowPosX"); | |||
public static final SimpleUri WINDOW_POS_Y_ = new SimpleUri("engine:windowPosY"); |
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 actually favour this change, for reasons other than easier access. Rather than subscribe to either width and height, you can simply subscribe to one property. So I think let's make it a Vector2i
in this PR, unless someone has a problem. This PR will be kinda messy and break-all-the-things either way.
@@ -78,7 +81,7 @@ public void setDisplayModeSetting(DisplayModeSetting displayModeSetting, boolean | |||
switch (displayModeSetting) { | |||
case FULLSCREEN: | |||
Display.setDisplayMode(Display.getDesktopDisplayMode()); | |||
Display.setLocation(config.getWindowPosX(), config.getWindowPosY()); | |||
Display.setLocation((Integer)config.getFlexibleConfig().get(WINDOW_POS_X_).getValue(), (Integer)config.getFlexibleConfig().get(WINDOW_POS_Y_).getValue()); |
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 definitely don't like this cast, but I can't see any way around it for now.
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.
Why, what's wrong with the cast?
That been said, get config.getFlexibleConfig() once and call it renderingConfig. It will reduce the clutter a bit.
P.S. I am aware config is of RenderingConfig type and it might be a bit confusing. Eventually that variable will go away though, right? When we get the config from the FCManager directly? And in fact, why can't we do it already?
Also, @eviltak I totally agree about the overloaded String counterparts, I was about to make that change either way :D Regarding the wrapper (point 2) : Not just the constants, the casting as well. The difference between Not sure what you mean by the |
@vampcat So you mean a wrapper class with wrapper methods for each setting like it currently is? While I can see the aesthetic appeal, it kind of defeats the purpose of using a FlexibleConfig, IMHO. As for the casts, I see no way of avoiding them unless:
or
|
Yes, it kinda defeats the purpose of FCs. Which is why I've tried to avoid that approach in this PR. However, as you can see, it feels way too verbose. Hence this PR - to get more eyes to look at it :D I kinda like the cast approach, but again, that makes the code too verbose. |
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.
Some minor changes and request for clarifications.
@@ -77,6 +76,11 @@ | |||
public static final String DUMP_SHADERS = "DumpShaders"; | |||
public static final String VOLUMETRIC_FOG = "VolumetricFog"; | |||
|
|||
public static final SimpleUri WINDOW_POS_X_ = new SimpleUri("engine:windowPosX"); | |||
public static final SimpleUri WINDOW_POS_Y_ = new SimpleUri("engine:windowPosY"); |
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 think it would be at least interesting to see a Vector2i setting in action. Let's give it a try.
this.flexibleConfig = flexibleConfig; | ||
|
||
// flexibleConfig.add(new SettingImpl<>(new SimpleUri("engine:pixelFormat"), 24)); | ||
flexibleConfig.add(new SettingImpl<>(new SimpleUri("engine:windowPosX"), 0)); |
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.
Would it be possible to wrap these lines into a private method so that we could write:
addSetting(simpleUri, defaultValue);
I'm guessing there is some generics voodoo that can be used for this circumstances, so that the method pass the default value to the fc.add
method without knowing its type?
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.
Yes, it will be possible to do that. The type shall be inferred from the default value. I proposed something similar in the last couple of comments on my PR. This change will also have the added benefit of not requiring the SettingImpl
class being exposed to the API, satiating @oniatus's concerns. I also think that the add(Setting setting)
method should entirely be removed to prevent setting publishers from putting in their own potentially malicious Setting
implementations, but that may be something to discuss at another time.
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.
@eviltak: what do you have in mind when you think about a malicious setting implementation?
Regarding the SettingImpl class, I'm not bought on the idea that it shouldn't be public.
@@ -63,7 +67,8 @@ public void preInitialise(Context rootContext) { | |||
flexibleConfigManager.addConfig(new SimpleUri("engine:rendering"), renderingFlexibleConfig); | |||
|
|||
flexibleConfigManager.loadAllConfigs(); | |||
// Add settings to RenderingFC | |||
|
|||
config.getRendering().loadDefaultRenderingConfig(renderingFlexibleConfig); |
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'm confused by this line. What does this do? Loads default values from the existing rendering config into the rendering FC?
@@ -78,7 +81,7 @@ public void setDisplayModeSetting(DisplayModeSetting displayModeSetting, boolean | |||
switch (displayModeSetting) { | |||
case FULLSCREEN: | |||
Display.setDisplayMode(Display.getDesktopDisplayMode()); | |||
Display.setLocation(config.getWindowPosX(), config.getWindowPosY()); | |||
Display.setLocation((Integer)config.getFlexibleConfig().get(WINDOW_POS_X_).getValue(), (Integer)config.getFlexibleConfig().get(WINDOW_POS_Y_).getValue()); |
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.
Why, what's wrong with the cast?
That been said, get config.getFlexibleConfig() once and call it renderingConfig. It will reduce the clutter a bit.
P.S. I am aware config is of RenderingConfig type and it might be a bit confusing. Eventually that variable will go away though, right? When we get the config from the FCManager directly? And in fact, why can't we do it already?
@@ -94,7 +97,7 @@ public void setDisplayModeSetting(DisplayModeSetting displayModeSetting, boolean | |||
case WINDOWED: | |||
System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); | |||
Display.setDisplayMode(config.getDisplayMode()); | |||
Display.setLocation(config.getWindowPosX(), config.getWindowPosY()); | |||
Display.setLocation((Integer)config.getFlexibleConfig().get(WINDOW_POS_X_).getValue(), (Integer)config.getFlexibleConfig().get(WINDOW_POS_Y_).getValue()); |
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.
Same as above, about getting the renderingConfig once.
config.setWindowPosX(Display.getX()); | ||
config.setWindowPosY(Display.getY()); | ||
config.getFlexibleConfig().get(WINDOW_POS_X_).setValue(Display.getX()); | ||
config.getFlexibleConfig().get(WINDOW_POS_Y_).setValue(Display.getY()); |
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.
Same as above.
Readdressing something I briefly mentioned in a review comment (should address your clarification requests @emanuele3d): I believe that we should change the current
In code, A similar approach for similar reasons can be taken towards the @vampcat @oniatus @emanuele3d please put forward your thoughts and suggestions. |
@eviltak, you need to look at your own communication and reasoning style as this really doesn't work. Let me clarify:
This ignores and is in direct contradiction of my intention to get some experience first and then reassess. So, generally speaking it's a no.
This is your personal judgement and I disagree. So, it's another no.
This is another no, as we don't want to change the engine source to allow for additional setting types.
This imperious tone is absolutely out of place: you do not get to decide, at most suggest. Fourth no. Furthermore, I was curious about what you intended with malicious code and the example you provide doesn't sound malicious at all, just bad programming. If a module behaves like that it will be easily forgotten, never to be loaded again. Summary: lots of circular reasoning, poor arguments and unacceptable communication style. We work with what we have, we get some experience with it and we reassess later. Perhaps there will be scope for some of the changes you suggest @eviltak, but for the time being I don't want to discuss them again as it's a waste of time. |
@vampcat, please address my comments and let's see where we end up. Also, we should keep in mind is that what looks verbose now, in a single FC, with lots of repetition, will eventually be decentralized into many parts of the code, i.e. individual nodes adding or obtaining their own settings. So, we are going through a lot of cut&pasting right now, but eventually, a node developer or a module developers will only add or obtain the setting he or she is interested in: the whole list will be visible only UI side, and not necessarily all at once. |
@emanuele3d while I am otherwise ok with your judgement of my comment, you may have mistook the statement you called imperious. In no way am I domineering or making decisions for others through that statement -- it is simply a direct consequence of my proposal. |
Closing this PR as FCs have been replaced with AutoConfigs in #3723. |
A small test to see how well FCs replace our current settings.