Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Window loses focus

Author
Message
ManOfActionTM
12
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 9th Apr 2014 07:05
I know, I've been posting a lot lately, but for the most part, the forums have been GREAT at answer questions.

Any easy way to find out if the app has lost focus in Windows?

It's not required, just kinda curious.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 9th Apr 2014 07:59
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Apr 2014 08:07 Edited at: 9th Apr 2014 08:08
why u need this?

i believe there is only GetResumed() if it get focus beack.
at android the app goto pause mode and do nothing
if u wanrt use other app there.

tier1 or tier2?

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
ManOfActionTM
12
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 9th Apr 2014 08:40
Tier 2.

We hope to release the game on PC someday, and currently, if it doesn't have focus, it continues to play, and then when you give it focus, it pauses--which for a PC is pretty much as badly implemented as possible.

For the time being, I have it #if'd out, but I'd like it to have better functionality in the future.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Apr 2014 09:30
in tier2, u need the window handle.
the best source about api is the msdn website.
http://msdn.microsoft.com/en-us

it paused because u use GetResumed(),true?
it can not pause from self.
why not let it run and use a pause key in game if the user want pause.
if it is run in window mode i do not want see a pause after focus
change.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
ManOfActionTM
12
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 9th Apr 2014 09:34
I agree, I'm just looking at what's happening now:

it doesn't pause when it is not in focus, but as soon as it gains focus, it pauses

That's pretty bad functionality. If it's going to pause on its own, at least for my game, you'd want it to pause if it LOST focus, as it is a timed game.

Ultimately, I'm just #if'ing out the statement for PCs, so all is good.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 9th Apr 2014 09:56
GetResumed doesn't work on Windows, because Windows properly multitasks. You need to find the HWND of the OpenGL window - which you could do using FindWindow() - and then have a timer which checks whether this is the foreground window using GetForeGgroundWindow(). You can pause if the HWND returned by that does not match the OGL Window's HWND.

DirectX provides events for this, but I don't know about OGL.

-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Apr 2014 10:09
@ManOfActionTM
the pause at got focus is odd... its a bug in agk core?

@JimHawkins
GetResumed gave me a 1 flag at windows, i tryed this morning.
but is was tier1.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
ManOfActionTM
12
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 9th Apr 2014 10:12
Markus, not sure, that's kinda what I was curious about, as it was really messing with my debugging.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th Apr 2014 22:24
Quote: "it doesn't pause when it is not in focus, but as soon as it gains focus, it pauses

That's pretty bad functionality. If it's going to pause on its own, at least for my game, you'd want it to pause if it LOST focus, as it is a timed game."


Yes this is super annoying in Windows.

https://code.google.com/p/agk/issues/detail?id=496&can=1&q=getresumed
Paul gives a hack here.
I think I got it working on dFenz, but since I've upgraded to a new AppGameKit version so my modification is no longer there.

You might be able to lock the mouse to the game screen with SetRawMousePosition() by setting a boundary for max/min mouse positions and if the mouse exceeds those positions then you can pause. It probably won't work on a fast mouse movement off the window though. I'd try the hack first.

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 10th Apr 2014 18:47
Was just reading the survey for AGK2 and saw that this feature was highly desired. No clue if they actually plan to do it though because we don't have a detailed roadmap for v2...

Login to post a reply

Server time is: 2024-05-11 16:27:28
Your offset time is: 2024-05-11 16:27:28