Closed aszpreece closed 2 years ago
Hey @aszpreece and thank you very much for your PR!
I looked into it and i'm thinking that it is a desirable feature. I will be happy to merge, but I have a couple of questions and suggestions.
Suggestions:
Questions:
In that case it seems a bit redundant to have 2 properties for the same thing. Setting UpdateGameLoopWhenNotVisible to true or false on demand would be enough, but then the name of this property would be a bit missleading. I would suggest to rename this property to "ForceUpdate" or "ForceGameLoop".
Then it would look like this in the condition: if ((Visible || ForceUpdate)
The end user can then simply set ForceUpdate to true or false on demand - simple and clean.
What do you think about these changes? Would that work for you?
Hi @sqrMin1 Thanks for the response.
I agree with you about the test window. I had originally attempted to create a separate tab for the testing but I had some issues adding one with my IDE. If you are satisfied that the code is working correctly then I will be more than happy to remove the test code. The reasoning behind changing the animation code was so that the animation was only ever updated from the update loop and not the draw loop in order to demonstrate that the flags were working. I was under the impression that Draw was not called from the GameLoop timer code that I had modified, but this may have been a mistake. I will look into this again, but regardless we will be removing my changes to this anyway!
The reasoning behind two flags was that I had a need to be able to:
Allow updates to non visible game controls and
stop updates to the game window no matter what (hence the &&) but I agree that the naming could be misleading. I also don't know if this is a desirable feature for others. Perhaps it would be better to name such a flag StopGameLoopUpdate with the logic: if ((Visible || UpdateGameLoopWhenNotVisible ) && !StopGameLoopUpdate
. How do you feel about this?
My thoughts behind the (possibly obtuse) naming was to make it clear that it only affected the GameLoop and not the draw.
I hope this clears up any confusion!
…date.
Hi, Big thanks for this great library. I had a need in my own project for windows to keep updating even when they are not visible (i.e you have a different tab selected) and i thought it'd be useful for others. I also needed to be able to control whether or not the game loop update code should be called. To implement both of these I added two property flags to GameControl: UpdateGameLoopWhenNotVisible (defaults to false for backwards compatability) and ShouldUpdateGameLoop (defaults to true). These do what you would expect. For testing, I modified your welcome page test with two check boxes. I had to move the animation update logic to the 'Update' method, but that is about the only change.
Thanks again!