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/gkaccesspointlocation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKAccessPointLocation(pub NSInteger);
impl GKAccessPointLocation {
    #[doc(alias = "GKAccessPointLocationTopLeading")]
    pub const TopLeading: Self = Self(0);
    #[doc(alias = "GKAccessPointLocationTopTrailing")]
    pub const TopTrailing: Self = Self(1);
    #[doc(alias = "GKAccessPointLocationBottomLeading")]
    pub const BottomLeading: Self = Self(2);
    #[doc(alias = "GKAccessPointLocationBottomTrailing")]
    pub const BottomTrailing: Self = Self(3);
}

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

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

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

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

impl GKAccessPoint {
    extern_methods!(
        #[unsafe(method(shared))]
        #[unsafe(method_family = none)]
        pub unsafe fn shared() -> Retained<GKAccessPoint>;

        /// set this true to enable access point in your app.  Setting this will cause the access point to appear after the notification banner is presented.  If it already was presented it will appear immediately
        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isActive(&self) -> bool;

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

        /// set this on tvOS to put the accessPoint into focused mode
        #[unsafe(method(isFocused))]
        #[unsafe(method_family = none)]
        pub unsafe fn isFocused(&self) -> bool;

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

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

        /// observable property that indicates when the access point is visible.
        #[unsafe(method(isPresentingGameCenter))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPresentingGameCenter(&self) -> bool;

        /// Set this property to true if you wish to show the highlights for most recent achievement, current rank on default leaderboard, etc
        #[deprecated = "No longer supported"]
        #[unsafe(method(showHighlights))]
        #[unsafe(method_family = none)]
        pub unsafe fn showHighlights(&self) -> bool;

        /// Setter for [`showHighlights`][Self::showHighlights].
        #[deprecated = "No longer supported"]
        #[unsafe(method(setShowHighlights:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowHighlights(&self, show_highlights: bool);

        /// These properties control the placement of the widget
        #[unsafe(method(location))]
        #[unsafe(method_family = none)]
        pub unsafe fn location(&self) -> GKAccessPointLocation;

        /// Setter for [`location`][Self::location].
        #[unsafe(method(setLocation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocation(&self, location: GKAccessPointLocation);

        /// observable property that contains the current frame needed to display the widget
        #[unsafe(method(frameInScreenCoordinates))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameInScreenCoordinates(&self) -> NSRect;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// the following is a platform specific window that you wish to have the access point in.  If not set then a best attempt will be made to choose the main window of the app.
        #[unsafe(method(parentWindow))]
        #[unsafe(method_family = none)]
        pub unsafe fn parentWindow(&self, mtm: MainThreadMarker) -> Option<Retained<NSWindow>>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// Setter for [`parentWindow`][Self::parentWindow].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setParentWindow:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setParentWindow(&self, parent_window: Option<&NSWindow>);

        #[cfg(feature = "block2")]
        /// this lets the developer trigger the access point as if the user had touched it.  This is useful for games that use controllers or the remote on AppleTV.  the argument lets you specify a specific state (default, profile, achievements, leaderboards) for GameCenterViewController
        #[unsafe(method(triggerAccessPointWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithHandler(&self, handler: &block2::DynBlock<dyn Fn()>);

        #[cfg(all(feature = "GKGameCenterViewController", feature = "block2"))]
        #[unsafe(method(triggerAccessPointWithState:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithState_handler(
            &self,
            state: GKGameCenterViewControllerState,
            handler: &block2::DynBlock<dyn Fn()>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(triggerAccessPointWithAchievementID:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithAchievementID_handler(
            &self,
            achievement_id: &NSString,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(triggerAccessPointWithLeaderboardSetID:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithLeaderboardSetID_handler(
            &self,
            leaderboard_set_id: &NSString,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(all(feature = "GKLeaderboard", feature = "block2"))]
        #[unsafe(method(triggerAccessPointWithLeaderboardID:playerScope:timeScope:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithLeaderboardID_playerScope_timeScope_handler(
            &self,
            leaderboard_id: &NSString,
            player_scope: GKLeaderboardPlayerScope,
            time_scope: GKLeaderboardTimeScope,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        #[unsafe(method(triggerAccessPointWithPlayer:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithPlayer_handler(
            &self,
            player: &GKPlayer,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// Displays the view that allows players to engage each other with activities and challenges.
        #[unsafe(method(triggerAccessPointForPlayTogetherWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointForPlayTogetherWithHandler(
            &self,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// Displays the view that allows players to engage each other with challenges.
        #[unsafe(method(triggerAccessPointForChallengesWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointForChallengesWithHandler(
            &self,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// Displays the challenge creation view for the provided challenge definition ID.
        #[unsafe(method(triggerAccessPointWithChallengeDefinitionID:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithChallengeDefinitionID_handler(
            &self,
            challenge_definition_id: &NSString,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// Displays the game activity creation view for the provided activity definition ID.
        #[unsafe(method(triggerAccessPointWithGameActivityDefinitionID:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithGameActivityDefinitionID_handler(
            &self,
            game_activity_definition_id: &NSString,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(all(feature = "GKGameActivity", feature = "block2"))]
        /// Displays the game activity view for the provided activity instance.
        #[unsafe(method(triggerAccessPointWithGameActivity:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointWithGameActivity_handler(
            &self,
            game_activity: &GKGameActivity,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// Brings up the invite friends view.
        #[unsafe(method(triggerAccessPointForFriendingWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn triggerAccessPointForFriendingWithHandler(
            &self,
            handler: Option<&block2::DynBlock<dyn Fn()>>,
        );
    );
}

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