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

Fixing Game Overlay check, for pausing game. #33

Open
SETENTIAdev opened this issue Feb 27, 2020 · 0 comments
Open

Fixing Game Overlay check, for pausing game. #33

SETENTIAdev opened this issue Feb 27, 2020 · 0 comments

Comments

@SETENTIAdev
Copy link

SETENTIAdev commented Feb 27, 2020

I just thought I might give some pointers on how I fixed GameOverlayActivated.

By default, some events won't be listened to, unless are specifically set.

My main concern was to pause the game when the overlay is up. Current calls, such as IsOverlayEnabled or BOverlayNeedsPresent didn't work for me, as the first just checks if the overlay is enabled (this is always true, unless user turned it off) and the later only is called for drawing purposes (to refresh the screen). Doesn't work as expected, will return true anytime something about the overlay renders over the screen. You don't want that.

By reading this issue I realized I could implement my own callbacks, and thats what I did. Make sure you read that link I mentioned so you know where to put this. Here's the code:
static const char* kEventTypeOnGameOverlayActivated = "GameOverlayActivated";

m_CallbackGameOverlayActivated( this, &CallbackHandler::OnGameOverlayActivated )

STEAM_CALLBACK( CallbackHandler, OnGameOverlayActivated, GameOverlayActivated_t , m_CallbackGameOverlayActivated );

void CallbackHandler::OnGameOverlayActivated( GameOverlayActivated_t *pCallback )
{
	SendEvent(Event(kEventTypeOnGameOverlayActivated, pCallback->m_bActive));
}

Where pCallback->m_bActive does come from?

You can read Steam API docs here: https://partner.steamgames.com/doc/api/ISteamFriends#GameOverlayActivated_t

You will need to build the wrapper again, by using build.bat

Then, over Steam.hx, on steamWrap_onEvent you can access the event, like this:

case "GameOverlayActivated": 
				if (success) 
					overlayActive = true;
				else
				overlayActive = false;
				
				trace("GameOverlayActivated " +overlayActive);

Our framework is HaxeFlixel, so we needed another function that is checked every frame, that sits in top of the current framework, so, the listener is added in our Main.hx:

addEventListener(Event.ENTER_FRAME, onEnterFrame);

Then you can do your magic by doing this:

private function onEnterFrame(_):Void
	{
		if (Steam.active)
		{
			Steam.onEnterFrame();
			
			FlxG.paused = Steam.overlayActive;
		}	
	}

I know this might be poorly explained, but is the meat of it. Hope it helps someone else.

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

No branches or pull requests

1 participant