Skip to content

Commit

Permalink
add ability to show/hide access point button
Browse files Browse the repository at this point in the history
  • Loading branch information
mateo-kozomara committed Aug 29, 2022
1 parent 42861cf commit b1e625d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,33 @@ import flash.events.EventDispatcher;
_context.call("loadPlayerPhoto", playerId);
}

/**
* Show GameCenter dashboard
*/
public function showDashboard() : void
{
if(isSupported)
_context.call("showDashboard");
}

/**
* Show GameCenter access point
*/
public function showAccessPoint() : void
{
if(isSupported)
_context.call("showAccessPoint");
}

/**
* Hide GameCenter access point
*/
public function hideAccessPoint() : void
{
if(isSupported)
_context.call("hideAccessPoint");
}

// --------------------------------------------------------------------------------------//
// //
// PRIVATE API //
Expand Down
22 changes: 21 additions & 1 deletion ios/AirGameCenter/AirGameCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,24 @@ - (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCen
return nil;
}

DEFINE_ANE_FUNCTION(showAccessPoint) {
if (@available(iOS 14.0, macOS 11.0, *)) {
[GKAccessPoint shared].showHighlights = true;
[GKAccessPoint shared].location = GKAccessPointLocationTopTrailing;
[[GKAccessPoint shared] setActive:true];
}

return nil;
}

DEFINE_ANE_FUNCTION(hideAccessPoint) {
if (@available(iOS 14.0, macOS 11.0, *)) {
[[GKAccessPoint shared] setActive:false];
}

return nil;
}


#pragma mark - ANE setup

Expand All @@ -710,7 +728,9 @@ void AirGameCenterContextInitializer(void* extData, const uint8_t* ctxType, FREC
MAP_FUNCTION(reportAchievement, NULL),
MAP_FUNCTION(loadRecentPlayers, NULL),
MAP_FUNCTION(loadPlayerPhoto, NULL),
MAP_FUNCTION(showDashboard, NULL)
MAP_FUNCTION(showDashboard, NULL),
MAP_FUNCTION(showAccessPoint, NULL),
MAP_FUNCTION(hideAccessPoint, NULL)
};

*numFunctionsToTest = sizeof(functions) / sizeof(FRENamedFunction);
Expand Down

0 comments on commit b1e625d

Please sign in to comment.