Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : Effects do not pause when game window has no focus
New Topic New Poll Post Reply
Poster Message
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Effects do not pause when game window has no focus (0)  
Noticed here, all game effects play even when the game has no focus. The most annoying thing this causes is the speech textboxes disappearing, but I can imagine situations where this can lead to an unhappy architect that their cool effect can be accidentally missed.

This is a small problem but there is no simple way to fix it, so here is my (very technical proposal). Probably not many people besides @mrimer will be interested.




Right now every game effect is responsible for counting its time on its own. It can do it fully manually (Like CImageOverlayEffect does) or use the TimeElapsed() function for help.

What I'd like to change is to modify Draw() method in CEffect and have it accept another argument, which would be the amount of time that has passed since last draw. Then they'd use that value as a reference when calculating new time. Each EffectList would be responsible for tracking its own delta time, and it'd be possible to tell an EffectList to freeze its delta time, meaning every further Draw() would receive 0 delta time, unless unfrozen. So when focus is lost we'd just send a freeze signal to the lists, and on focus regained unfreeze them.

It would be a significant change in terms out the number of files touched, but ultimately it'd be a simple change in every file and I think it'd result in cleaner logic that's more extensible in the future.

____________________________
My website | Facebook | Twitter
10-18-2020 at 09:42 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5058
Registered: 02-04-2003
IP: Logged
icon Re: Effects do not pause when game window has no focus (0)  
I appreciate the proposal! I agree this seems like an extensive change, but I like the concept of adding another "indirection pivot" in the code so that this time logic can be controlled from a single point in the future.

If you're in the mood to make this change, I'm all for it.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
10-19-2020 at 07:58 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Re: Effects do not pause when game window has no focus (+1)  
You don't have to tell me twice. Hopefully will have the big PR up today!

____________________________
My website | Facebook | Twitter

[Last edited by skell at 10-20-2020 08:12 PM]
10-20-2020 at 08:12 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Re: Effects do not pause when game window has no focus (+1)  
The PR will be big but not today. What I've achieved so far:

- Removed crapload of duplicate code in all effects
- Effects's Draw() receives two more arguments - delta time and time elapsed, and the calculation is done in one common place
- Removed all usage of SDL_Ticks() in effects code
- Checked a couple of effects and they look good!

What's still left to do:
- Individualize delta calculation for effect, so that DrawEffectsOfType can work together with DrawEffects (Right now if you called DrawEffectsOfType and then DrawEffects, all the effects of type other than the first one would not update because the last update is stored in effect list)
- Figure out how freezing effects works and rework it to not be passed as argument but rather a property of CEffectsList
- Test every single effect if it looks, or appears to look correctly

Oh and heads up - you will likely need some small changes for RPG to build again.

____________________________
My website | Facebook | Twitter
10-20-2020 at 10:31 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5058
Registered: 02-04-2003
IP: Logged
icon Re: Effects do not pause when game window has no focus (0)  
skell wrote:
- Removed crapload of duplicate code in all effects
The refactoring looks good! To be pedantic, I think you removed at least a metric crapload of duplicate code.
Oh and heads up - you will likely need some small changes for RPG to build again.
Okay :)

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 10-21-2020 09:44 PM]
10-21-2020 at 09:44 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Re: Effects do not pause when game window has no focus (+5)  
Done, all effects and Beethro's face will now not animate when game has no focus. This includes speech boxes so things will be consistent with how speech pauses.

This comes with a huge revamp of effects and shadows so it would be great for testers to check everything they can think of.

PR

____________________________
My website | Facebook | Twitter
10-28-2020 at 06:27 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : Effects do not pause when game window has no focus
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.