objc2-game-kit 0.3.2

Bindings to the GameKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkgamecenterviewcontrollerstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKGameCenterViewControllerState(pub NSInteger);
impl GKGameCenterViewControllerState {
    #[doc(alias = "GKGameCenterViewControllerStateDefault")]
    pub const Default: Self = Self(-1);
    #[doc(alias = "GKGameCenterViewControllerStateLeaderboards")]
    pub const Leaderboards: Self = Self(0);
    #[doc(alias = "GKGameCenterViewControllerStateAchievements")]
    pub const Achievements: Self = Self(1);
    #[doc(alias = "GKGameCenterViewControllerStateChallenges")]
    #[deprecated]
    pub const Challenges: Self = Self(2);
    #[doc(alias = "GKGameCenterViewControllerStateLocalPlayerProfile")]
    pub const LocalPlayerProfile: Self = Self(3);
    #[doc(alias = "GKGameCenterViewControllerStateDashboard")]
    pub const Dashboard: Self = Self(4);
    #[doc(alias = "GKGameCenterViewControllerStateLocalPlayerFriendsList")]
    pub const LocalPlayerFriendsList: Self = Self(5);
}

unsafe impl Encode for GKGameCenterViewControllerState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for GKGameCenterViewControllerState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// View controller that provides the standard user interface for leaderboards, achievements, and challenges. Present modally from the top view controller.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkgamecenterviewcontroller?language=objc)
    #[unsafe(super(NSViewController, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    #[cfg(target_os = "macos")]
    #[deprecated]
    pub struct GKGameCenterViewController;
);

#[cfg(all(feature = "GKDialogController", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl GKViewController for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCoding for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSEditor for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSObjectProtocol for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSSeguePerforming for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for GKGameCenterViewController {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!();
}

/// Methods declared on superclass `NSViewController`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!(
        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSNibName>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!(
        #[unsafe(method(gameCenterDelegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn gameCenterDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn GKGameCenterControllerDelegate>>>;

        /// Setter for [`gameCenterDelegate`][Self::gameCenterDelegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setGameCenterDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGameCenterDelegate(
            &self,
            game_center_delegate: Option<&ProtocolObject<dyn GKGameCenterControllerDelegate>>,
        );

        /// Use this to display content associated with the specified state. For example setting the state to GKGameCenterViewControllerStateLeaderboards will display a list of leaderboard sets or leaderboards (if no sets). Setting state to GKGameCenterViewControllerStateAchievements will display a list of achievements.
        #[unsafe(method(initWithState:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithState(
            this: Allocated<Self>,
            state: GKGameCenterViewControllerState,
        ) -> Retained<Self>;

        #[cfg(feature = "GKLeaderboard")]
        /// Use this to display the scores for the specified leaderboardID, player scope and time scope. The time scope is only applicable to classic leaderboards. Recurring leaderboards will always be displayed initially with the results (scores) associated with the current instance of the leaderboard.
        #[unsafe(method(initWithLeaderboardID:playerScope:timeScope:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboardID_playerScope_timeScope(
            this: Allocated<Self>,
            leaderboard_id: &NSString,
            player_scope: GKLeaderboardPlayerScope,
            time_scope: GKLeaderboardTimeScope,
        ) -> Retained<Self>;

        #[cfg(feature = "GKLeaderboard")]
        /// Use this to display the scores for the specified leaderboard and player scope. Both classic and recurring leaderboards can use this method to initialize the view with their scores.
        #[unsafe(method(initWithLeaderboard:playerScope:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboard_playerScope(
            this: Allocated<Self>,
            leaderboard: &GKLeaderboard,
            player_scope: GKLeaderboardPlayerScope,
        ) -> Retained<Self>;

        /// Use this to display the leaderboard sets for the specified leaderboardSetID.
        #[unsafe(method(initWithLeaderboardSetID:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboardSetID(
            this: Allocated<Self>,
            leaderboard_set_id: &NSString,
        ) -> Retained<Self>;

        /// Use this to display the details associated with the specified achievementID
        #[unsafe(method(initWithAchievementID:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAchievementID(
            this: Allocated<Self>,
            achievement_id: &NSString,
        ) -> Retained<Self>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Use this to display the profile page associated with the specified player.
        #[unsafe(method(initWithPlayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPlayer(this: Allocated<Self>, player: &GKPlayer) -> Retained<Self>;
    );
}

/// Deprecated.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl GKGameCenterViewController {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(viewState))]
        #[unsafe(method_family = none)]
        pub unsafe fn viewState(&self) -> GKGameCenterViewControllerState;

        /// Setter for [`viewState`][Self::viewState].
        #[deprecated]
        #[unsafe(method(setViewState:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setViewState(&self, view_state: GKGameCenterViewControllerState);

        #[cfg(feature = "GKLeaderboard")]
        #[deprecated]
        #[unsafe(method(leaderboardTimeScope))]
        #[unsafe(method_family = none)]
        pub unsafe fn leaderboardTimeScope(&self) -> GKLeaderboardTimeScope;

        #[cfg(feature = "GKLeaderboard")]
        /// Setter for [`leaderboardTimeScope`][Self::leaderboardTimeScope].
        #[deprecated]
        #[unsafe(method(setLeaderboardTimeScope:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLeaderboardTimeScope(
            &self,
            leaderboard_time_scope: GKLeaderboardTimeScope,
        );

        #[deprecated]
        #[unsafe(method(leaderboardIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn leaderboardIdentifier(&self) -> Option<Retained<NSString>>;

        /// Setter for [`leaderboardIdentifier`][Self::leaderboardIdentifier].
        #[deprecated]
        #[unsafe(method(setLeaderboardIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLeaderboardIdentifier(&self, leaderboard_identifier: Option<&NSString>);

        #[deprecated]
        #[unsafe(method(leaderboardCategory))]
        #[unsafe(method_family = none)]
        pub unsafe fn leaderboardCategory(&self) -> Option<Retained<NSString>>;

        /// Setter for [`leaderboardCategory`][Self::leaderboardCategory].
        #[deprecated]
        #[unsafe(method(setLeaderboardCategory:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLeaderboardCategory(&self, leaderboard_category: Option<&NSString>);
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkgamecentercontrollerdelegate?language=objc)
    #[deprecated]
    pub unsafe trait GKGameCenterControllerDelegate: NSObjectProtocol {
        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(gameCenterViewControllerDidFinish:))]
        #[unsafe(method_family = none)]
        unsafe fn gameCenterViewControllerDidFinish(
            &self,
            game_center_view_controller: &GKGameCenterViewController,
        );
    }
);