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

fix: avoid writing window size of 0 to the config Re: #4601 #4603

Closed
wants to merge 1 commit into from
Closed

fix: avoid writing window size of 0 to the config Re: #4601 #4603

wants to merge 1 commit into from

Conversation

mahela97
Copy link
Contributor

Contains

This PR will fix the Bug mentioned here #4596.

Approach - As in the suggestions in #4601, Now the config file doesn't end up writing zeros to the config.

How to test

Close the game when it is minimized and open the game again. Game window resolution will set to default values.

@DarkWeird
Copy link
Contributor

you can just append commits to your previous PR, or rewrite them with push force

@mahela97
Copy link
Contributor Author

you can just append commits to your previous PR, or rewrite them with push

Oh, I made separate PR because @keturn told me to work on this on a separate one. Shall I append this on the previous PR or keep this?

@DarkWeird
Copy link
Contributor

you can just append commits to your previous PR, or rewrite them with push

Oh, I made separate PR because @keturn told me to work on this on a separate one. Shall I append this on the previous PR or keep this?

Oh, Ok :)

@skaldarnar
Copy link
Member

For reference, #4160 sets the default resolution in the config and also explains where this size is coming from.

I thought there might be another place where we have these constants defined, but it seems that it completely comes from the config - which seems brittle enough. If, for some reason, the config contains (0, 0) as value the fallback solution does not work 😕

Therefore, I do think that preventing this in the rendering config directly is a better way to solve this.

(for the record, the way you retrieve the "default" here is not wrong, it's just that we can find a better solution 🙃 )

@mahela97
Copy link
Contributor Author

For reference, #4160 sets the default resolution in the config and also explains where this size is coming from.

I thought there might be another place where we have these constants defined, but it seems that it completely comes from the config - which seems brittle enough. If, for some reason, the config contains (0, 0) as value the fallback solution does not work 😕

Therefore, I do think that preventing this in the rendering config directly is a better way to solve this.

(for the record, the way you retrieve the "default" here is not wrong, it's just that we can find a better solution 🙃 )

As I think The bug occurs only if the config contains (0,0). The only way to get (0,0) is if we close the game while it is minimized. (Other than hardcoded the config file).
Also when I am retrieving the default values it retrieves the value which was the resolution of the last game session. (Not from the #4160. So actually they are not the default values. The bug is last game session is closed when it is minimized. So if that happens my PR will ignore the (0,0) and keep the config file unchanged.)
I tried to fix from the rendering config but I felt like this is the efficient way. 🙃🙃
So could you please check this again? 😄 Thank you

@keturn keturn self-requested a review April 6, 2021 21:00
@keturn keturn changed the title fix: auto-correct window resolution if set to (0,0) Re: #4601 fix: avoid writing window size of 0 to the config Re: #4601 Apr 9, 2021
Copy link
Member

@keturn keturn left a comment

Choose a reason for hiding this comment

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

Ah, so we only set this on shutdown? Instead of every time the window is moved? Good to know. Only have to worry about it being written one time in that case.

Comment on lines +125 to +129
if (widthBuffer[0]<= 0 && heightBuffer[0]<=0){
config.setWindowPosX(defaultX);
config.setWindowPosY(defaultY);
config.setWindowWidth(defaultWidth);
config.setWindowHeight(defaultHeight);
Copy link
Member

Choose a reason for hiding this comment

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

If we have no valid data for this, what if we skip these config.setWindow* calls entirely in that case? Would they keep their old values?

Other suggestion: make the the conditional on zero width or height, not and.

Copy link
Contributor Author

@mahela97 mahela97 Apr 9, 2021

Choose a reason for hiding this comment

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

Yes, that would keep the old values(Default as in #4160). But I suggest keeping it because it gives the user to adjust their screen size and position as they want and keep it so they do not want to re-adjust every time they open the game.

And yes. && should be ||. Thank you. My bad. :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm suggesting we do write the values when we have valid values, but skip it in the 0 case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh ok.... you are suggesting
if (widthBuffer[0]>0 && heightBuffer[0]>0 && xBuffer[0]>0 && yBuffer[0]>0){ config.setWindowWidth(widthBuffer[0]); config.setWindowHeight(heightBuffer[0]); config.setWindowPosX(xBuffer[0]); config.setWindowPosY(yBuffer[0]); }

Yes this is better. I tried it and working fine too. :)
So we don't need default x and y values.

@mahela97
Copy link
Contributor Author

mahela97 commented Apr 9, 2021

Ah, so we only set this on shutdown? Instead of every time the window is moved? Good to know. Only have to worry about it being written one time in that case.

Yes, it is just one time when the user closes the game.

@keturn
Copy link
Member

keturn commented Apr 10, 2021

replaced by #4619 (because this PR's branch went away)

@keturn keturn closed this Apr 10, 2021
@keturn keturn added Type: Bug Issues reporting and PRs fixing problems and removed Type: Bug Issues reporting and PRs fixing problems labels Apr 10, 2021
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 this pull request may close these issues.

4 participants