use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
#[unsafe(super(GKPlayer, GKBasePlayer, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
pub struct GKLocalPlayer;
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
extern_conformance!(
unsafe impl NSCopying for GKLocalPlayer {}
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
unsafe impl CopyingHelper for GKLocalPlayer {
type Result = Self;
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
extern_conformance!(
unsafe impl NSObjectProtocol for GKLocalPlayer {}
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[unsafe(method(local))]
#[unsafe(method_family = none)]
pub unsafe fn local() -> Retained<GKLocalPlayer>;
#[unsafe(method(localPlayer))]
#[unsafe(method_family = none)]
pub unsafe fn localPlayer() -> Retained<GKLocalPlayer>;
#[unsafe(method(isAuthenticated))]
#[unsafe(method_family = none)]
pub unsafe fn isAuthenticated(&self) -> bool;
#[unsafe(method(isUnderage))]
#[unsafe(method_family = none)]
pub unsafe fn isUnderage(&self) -> bool;
#[unsafe(method(isMultiplayerGamingRestricted))]
#[unsafe(method_family = none)]
pub unsafe fn isMultiplayerGamingRestricted(&self) -> bool;
#[unsafe(method(isPersonalizedCommunicationRestricted))]
#[unsafe(method_family = none)]
pub unsafe fn isPersonalizedCommunicationRestricted(&self) -> bool;
#[cfg(feature = "block2")]
#[unsafe(method(loadRecentPlayersWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadRecentPlayersWithCompletionHandler(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
>,
);
#[cfg(feature = "block2")]
#[unsafe(method(loadChallengableFriendsWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadChallengableFriendsWithCompletionHandler(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
>,
);
#[cfg(feature = "block2")]
#[unsafe(method(setDefaultLeaderboardIdentifier:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultLeaderboardIdentifier_completionHandler(
&self,
leaderboard_identifier: &NSString,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
#[unsafe(method(loadDefaultLeaderboardIdentifierWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadDefaultLeaderboardIdentifierWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSString, *mut NSError)>>,
);
#[cfg(feature = "block2")]
#[unsafe(method(fetchItemsForIdentityVerificationSignature:))]
#[unsafe(method_family = none)]
pub unsafe fn fetchItemsForIdentityVerificationSignature(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError)>,
>,
);
);
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[unsafe(method(anonymousGuestPlayerWithIdentifier:))]
#[unsafe(method_family = none)]
pub unsafe fn anonymousGuestPlayerWithIdentifier(
guest_identifier: &NSString,
) -> Retained<Self>;
);
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_protocol!(
#[cfg(all(
feature = "GKEventListener",
feature = "GKGameActivityListener",
feature = "GKMatchmaker",
feature = "GKSavedGameListener",
feature = "GKTurnBasedMatch"
))]
pub unsafe trait GKLocalPlayerListener:
GKChallengeListener
+ GKGameActivityListener
+ GKInviteEventListener
+ GKTurnBasedEventListener
+ GKSavedGameListener
{
}
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[cfg(all(
feature = "GKEventListener",
feature = "GKGameActivityListener",
feature = "GKMatchmaker",
feature = "GKSavedGameListener",
feature = "GKTurnBasedMatch"
))]
#[unsafe(method(registerListener:))]
#[unsafe(method_family = none)]
pub unsafe fn registerListener(&self, listener: &ProtocolObject<dyn GKLocalPlayerListener>);
#[cfg(all(
feature = "GKEventListener",
feature = "GKGameActivityListener",
feature = "GKMatchmaker",
feature = "GKSavedGameListener",
feature = "GKTurnBasedMatch"
))]
#[unsafe(method(unregisterListener:))]
#[unsafe(method_family = none)]
pub unsafe fn unregisterListener(
&self,
listener: &ProtocolObject<dyn GKLocalPlayerListener>,
);
#[unsafe(method(unregisterAllListeners))]
#[unsafe(method_family = none)]
pub unsafe fn unregisterAllListeners(&self);
);
}
extern "C" {
pub static GKPlayerAuthenticationDidChangeNotificationName: &'static NSNotificationName;
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(setDefaultLeaderboardCategoryID:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultLeaderboardCategoryID_completionHandler(
&self,
category_id: Option<&NSString>,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(loadDefaultLeaderboardCategoryIDWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadDefaultLeaderboardCategoryIDWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSString, *mut NSError)>>,
);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(authenticateWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn authenticateWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(loadFriendPlayersWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadFriendPlayersWithCompletionHandler(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
>,
);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(generateIdentityVerificationSignatureWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn generateIdentityVerificationSignatureWithCompletionHandler(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError)>,
>,
);
);
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(loadFriendsWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadFriendsWithCompletionHandler(
&self,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<NSString>, *mut NSError)>,
>,
);
#[deprecated]
#[unsafe(method(friends))]
#[unsafe(method_family = none)]
pub unsafe fn friends(&self) -> Option<Retained<NSArray<NSString>>>;
);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKFriendsAuthorizationStatus(pub NSInteger);
impl GKFriendsAuthorizationStatus {
#[doc(alias = "GKFriendsAuthorizationStatusNotDetermined")]
pub const NotDetermined: Self = Self(0);
#[doc(alias = "GKFriendsAuthorizationStatusRestricted")]
pub const Restricted: Self = Self(1);
#[doc(alias = "GKFriendsAuthorizationStatusDenied")]
pub const Denied: Self = Self(2);
#[doc(alias = "GKFriendsAuthorizationStatusAuthorized")]
pub const Authorized: Self = Self(3);
}
unsafe impl Encode for GKFriendsAuthorizationStatus {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for GKFriendsAuthorizationStatus {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[cfg(feature = "block2")]
#[unsafe(method(loadFriendsAuthorizationStatus:))]
#[unsafe(method_family = none)]
pub unsafe fn loadFriendsAuthorizationStatus(
&self,
completion_handler: &block2::DynBlock<
dyn Fn(GKFriendsAuthorizationStatus, *mut NSError),
>,
);
#[cfg(feature = "block2")]
#[unsafe(method(loadFriends:))]
#[unsafe(method_family = none)]
pub unsafe fn loadFriends(
&self,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[unsafe(method(loadFriendsWithIdentifiers:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadFriendsWithIdentifiers_completionHandler(
&self,
identifiers: &NSArray<NSString>,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
);
);
}
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
impl GKLocalPlayer {
extern_methods!(
#[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
#[unsafe(method(authenticateHandler))]
#[unsafe(method_family = none)]
pub unsafe fn authenticateHandler(
&self,
mtm: MainThreadMarker,
) -> *mut block2::DynBlock<dyn Fn(*mut NSViewController, *mut NSError)>;
#[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
#[unsafe(method(setAuthenticateHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setAuthenticateHandler(
&self,
authenticate_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSViewController, *mut NSError)>,
>,
);
#[unsafe(method(isPresentingFriendRequestViewController))]
#[unsafe(method_family = none)]
pub unsafe fn isPresentingFriendRequestViewController(&self) -> bool;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
#[unsafe(method(presentFriendRequestCreatorFromViewController:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn presentFriendRequestCreatorFromViewController_error(
&self,
view_controller: &NSViewController,
) -> Result<(), Retained<NSError>>;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
#[unsafe(method(presentFriendRequestCreatorFromWindow:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn presentFriendRequestCreatorFromWindow_error(
&self,
window: Option<&NSWindow>,
) -> Result<(), Retained<NSError>>;
);
}