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::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkachievement?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKAchievement;
);

extern_conformance!(
    unsafe impl NSCoding for GKAchievement {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKAchievement {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for GKAchievement {}
);

impl GKAchievement {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Asynchronously load all achievements for the local player
        #[unsafe(method(loadAchievementsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadAchievementsWithCompletionHandler(
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKAchievement>, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        /// Reset the achievements progress for the local player. All the entries for the local player are removed from the server. Error will be nil on success.
        /// Possible reasons for error:
        /// 1. Local player not authenticated
        /// 2. Communications failure
        #[unsafe(method(resetAchievementsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn resetAchievementsWithCompletionHandler(
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        /// Designated initializer
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSString,
        ) -> Retained<Self>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Initialize the achievement for a specific player. Use to submit participant achievements when ending a turn-based match.
        #[unsafe(method(initWithIdentifier:player:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier_player(
            this: Allocated<Self>,
            identifier: &NSString,
            player: &GKPlayer,
        ) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// Report an array of achievements to the server. Percent complete is required. Points, completed state are set based on percentComplete. isHidden is set to NO anytime this method is invoked. Date is optional. Error will be nil on success.
        /// Possible reasons for error:
        /// 1. Local player not authenticated
        /// 2. Communications failure
        /// 3. Reported Achievement does not exist
        #[unsafe(method(reportAchievements:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn reportAchievements_withCompletionHandler(
            achievements: &NSArray<GKAchievement>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        /// Achievement identifier
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        /// Setter for [`identifier`][Self::identifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIdentifier(&self, identifier: &NSString);

        /// Required, Percentage of achievement complete.
        #[unsafe(method(percentComplete))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentComplete(&self) -> c_double;

        /// Setter for [`percentComplete`][Self::percentComplete].
        #[unsafe(method(setPercentComplete:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPercentComplete(&self, percent_complete: c_double);

        /// Set to NO until percentComplete = 100.
        #[unsafe(method(isCompleted))]
        #[unsafe(method_family = none)]
        pub unsafe fn isCompleted(&self) -> bool;

        /// Date the achievement was last reported. Read-only. Created at initialization
        #[unsafe(method(lastReportedDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn lastReportedDate(&self) -> Retained<NSDate>;

        /// A banner will be momentarily displayed after reporting a completed achievement
        #[unsafe(method(showsCompletionBanner))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsCompletionBanner(&self) -> bool;

        /// Setter for [`showsCompletionBanner`][Self::showsCompletionBanner].
        #[unsafe(method(setShowsCompletionBanner:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsCompletionBanner(&self, shows_completion_banner: bool);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// The identifier of the player that earned the achievement.
        #[unsafe(method(player))]
        #[unsafe(method_family = none)]
        pub unsafe fn player(&self) -> Retained<GKPlayer>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKAchievement {
    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>;
    );
}

/// Deprecated.
impl GKAchievement {
    extern_methods!(
        #[cfg(feature = "block2")]
        #[deprecated]
        #[unsafe(method(reportAchievementWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn reportAchievementWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[deprecated]
        #[unsafe(method(isHidden))]
        #[unsafe(method_family = none)]
        pub unsafe fn isHidden(&self) -> bool;
    );
}

/// Obsoleted.
impl GKAchievement {
    extern_methods!(
        /// * This method is obsolete. Calling this initializer does nothing and will return nil **
        #[deprecated]
        #[unsafe(method(initWithIdentifier:forPlayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier_forPlayer(
            this: Allocated<Self>,
            identifier: Option<&NSString>,
            player_id: &NSString,
        ) -> Option<Retained<Self>>;

        /// * This property is obsolete. **
        #[deprecated]
        #[unsafe(method(playerID))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerID(&self) -> Option<Retained<NSString>>;
    );
}