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

extern_class!(
    /// GKAchievementDescription is a full description of the achievement as defined before app submission in App Store Connect.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkachievementdescription?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKAchievementDescription;
);

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

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

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

impl GKAchievementDescription {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Asynchronously load all achievement descriptions
        #[unsafe(method(loadAchievementDescriptionsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadAchievementDescriptionsWithCompletionHandler(
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKAchievementDescription>, *mut NSError)>,
            >,
        );

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

        /// The group identifier for the achievement, if one exists.
        #[unsafe(method(groupIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn groupIdentifier(&self) -> Option<Retained<NSString>>;

        /// The title of the achievement.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Retained<NSString>;

        /// The description for an unachieved achievement.
        #[unsafe(method(achievedDescription))]
        #[unsafe(method_family = none)]
        pub unsafe fn achievedDescription(&self) -> Retained<NSString>;

        /// The description for an achieved achievement.
        #[unsafe(method(unachievedDescription))]
        #[unsafe(method_family = none)]
        pub unsafe fn unachievedDescription(&self) -> Retained<NSString>;

        /// Maximum points available for completing this achievement.
        #[unsafe(method(maximumPoints))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumPoints(&self) -> NSInteger;

        /// Whether or not the achievement should be listed or displayed if not yet unhidden by the game.
        #[unsafe(method(isHidden))]
        #[unsafe(method_family = none)]
        pub unsafe fn isHidden(&self) -> bool;

        /// Whether or not the achievement will be reported by the game when the user earns it again. This allows the achievement to be used for challenges when the recipient has previously earned it.
        #[unsafe(method(isReplayable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isReplayable(&self) -> bool;

        /// If present, the rarity of the achievement expressed as a percentage of players that earned it. Null if not enough data is available to compute it.
        #[unsafe(method(rarityPercent))]
        #[unsafe(method_family = none)]
        pub unsafe fn rarityPercent(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "GKReleaseState")]
        /// The release state of the achievement in App Store Connect.
        #[unsafe(method(releaseState))]
        #[unsafe(method_family = none)]
        pub unsafe fn releaseState(&self) -> GKReleaseState;

        /// The identifier of the game activity associated with this achievement, as configured by the developer in App Store Connect.
        #[unsafe(method(activityIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn activityIdentifier(&self) -> Retained<NSString>;

        /// The properties when associating this achievement with a game activity, as configured by the developer in App Store Connect.
        #[unsafe(method(activityProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn activityProperties(&self) -> Retained<NSDictionary<NSString, NSString>>;
    );
}

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

/// UI.
impl GKAchievementDescription {
    extern_methods!(
        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[deprecated]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;

        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        #[unsafe(method(loadImageWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadImageWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>>,
        );

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(incompleteAchievementImage))]
        #[unsafe(method_family = none)]
        pub unsafe fn incompleteAchievementImage() -> Retained<NSImage>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(placeholderCompletedAchievementImage))]
        #[unsafe(method_family = none)]
        pub unsafe fn placeholderCompletedAchievementImage() -> Retained<NSImage>;
    );
}