objc2_game_kit/generated/
GKMatchmakerViewController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmakingmode?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct GKMatchmakingMode(pub NSInteger);
18impl GKMatchmakingMode {
19    #[doc(alias = "GKMatchmakingModeDefault")]
20    pub const Default: Self = Self(0);
21    #[doc(alias = "GKMatchmakingModeNearbyOnly")]
22    pub const NearbyOnly: Self = Self(1);
23    #[doc(alias = "GKMatchmakingModeAutomatchOnly")]
24    pub const AutomatchOnly: Self = Self(2);
25    #[doc(alias = "GKMatchmakingModeInviteOnly")]
26    pub const InviteOnly: Self = Self(3);
27}
28
29unsafe impl Encode for GKMatchmakingMode {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for GKMatchmakingMode {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmakerviewcontroller?language=objc)
39    #[unsafe(super(NSViewController, NSResponder, NSObject))]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    #[cfg(feature = "objc2-app-kit")]
42    #[cfg(target_os = "macos")]
43    pub struct GKMatchmakerViewController;
44);
45
46#[cfg(all(feature = "GKDialogController", feature = "objc2-app-kit"))]
47#[cfg(target_os = "macos")]
48extern_conformance!(
49    unsafe impl GKViewController for GKMatchmakerViewController {}
50);
51
52#[cfg(feature = "objc2-app-kit")]
53#[cfg(target_os = "macos")]
54extern_conformance!(
55    unsafe impl NSCoding for GKMatchmakerViewController {}
56);
57
58#[cfg(feature = "objc2-app-kit")]
59#[cfg(target_os = "macos")]
60extern_conformance!(
61    unsafe impl NSEditor for GKMatchmakerViewController {}
62);
63
64#[cfg(feature = "objc2-app-kit")]
65#[cfg(target_os = "macos")]
66extern_conformance!(
67    unsafe impl NSObjectProtocol for GKMatchmakerViewController {}
68);
69
70#[cfg(feature = "objc2-app-kit")]
71#[cfg(target_os = "macos")]
72extern_conformance!(
73    unsafe impl NSSeguePerforming for GKMatchmakerViewController {}
74);
75
76#[cfg(feature = "objc2-app-kit")]
77#[cfg(target_os = "macos")]
78extern_conformance!(
79    unsafe impl NSUserInterfaceItemIdentification for GKMatchmakerViewController {}
80);
81
82#[cfg(feature = "objc2-app-kit")]
83#[cfg(target_os = "macos")]
84impl GKMatchmakerViewController {
85    extern_methods!(
86        #[unsafe(method(matchmakerDelegate))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn matchmakerDelegate(
89            &self,
90        ) -> Option<Retained<ProtocolObject<dyn GKMatchmakerViewControllerDelegate>>>;
91
92        /// Setter for [`matchmakerDelegate`][Self::matchmakerDelegate].
93        ///
94        /// This is a [weak property][objc2::topics::weak_property].
95        #[unsafe(method(setMatchmakerDelegate:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setMatchmakerDelegate(
98            &self,
99            matchmaker_delegate: Option<&ProtocolObject<dyn GKMatchmakerViewControllerDelegate>>,
100        );
101
102        #[cfg(feature = "GKMatchmaker")]
103        #[unsafe(method(matchRequest))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn matchRequest(&self) -> Retained<GKMatchRequest>;
106
107        /// set to YES to receive hosted (eg. not peer-to-peer) match results. Will cause the controller to return an array of players instead of a match.
108        #[unsafe(method(isHosted))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn isHosted(&self) -> bool;
111
112        /// Setter for [`isHosted`][Self::isHosted].
113        #[unsafe(method(setHosted:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setHosted(&self, hosted: bool);
116
117        /// this controls which mode of matchmaking to support in the UI (all, nearby only, automatch only, invite only).  Throws an exeption if you can not set to the desired mode (due to restrictions)
118        #[unsafe(method(matchmakingMode))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn matchmakingMode(&self) -> GKMatchmakingMode;
121
122        /// Setter for [`matchmakingMode`][Self::matchmakingMode].
123        #[unsafe(method(setMatchmakingMode:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setMatchmakingMode(&self, matchmaking_mode: GKMatchmakingMode);
126
127        /// A BOOL value to allow the GKMatchMakerViewController to return control to the game once the minimum number of players are connected.
128        /// By default the value is NO, and the multiplayer match can only proceed after all players are connected.
129        /// If the value is set to YES, then once the number of connected players is greater than or equal to minPlayers of the match request, matchmakerViewController:didFindMatch: will be called and the game can get the match instance, and update the game scene accordingly. The remaining players wil continue to connect.
130        #[unsafe(method(canStartWithMinimumPlayers))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn canStartWithMinimumPlayers(&self) -> bool;
133
134        /// Setter for [`canStartWithMinimumPlayers`][Self::canStartWithMinimumPlayers].
135        #[unsafe(method(setCanStartWithMinimumPlayers:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setCanStartWithMinimumPlayers(&self, can_start_with_minimum_players: bool);
138
139        #[cfg(feature = "GKMatchmaker")]
140        /// Initialize with a matchmaking request, allowing the user to send invites and/or start matchmaking
141        #[unsafe(method(initWithMatchRequest:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initWithMatchRequest(
144            this: Allocated<Self>,
145            request: &GKMatchRequest,
146        ) -> Option<Retained<Self>>;
147
148        #[cfg(feature = "GKMatchmaker")]
149        /// Initialize with an accepted invite, allowing the user to see the status of other invited players and get notified when the game starts
150        #[unsafe(method(initWithInvite:))]
151        #[unsafe(method_family = init)]
152        pub unsafe fn initWithInvite(
153            this: Allocated<Self>,
154            invite: &GKInvite,
155        ) -> Option<Retained<Self>>;
156
157        #[cfg(feature = "GKMatch")]
158        /// Add additional players (not currently connected) to an existing peer-to-peer match.
159        /// Apps should elect a single device to do this, otherwise conflicts could arise resulting in unexpected connection errors.
160        #[unsafe(method(addPlayersToMatch:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn addPlayersToMatch(&self, r#match: &GKMatch);
163
164        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
165        #[unsafe(method(setHostedPlayer:didConnect:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setHostedPlayer_didConnect(&self, player: &GKPlayer, connected: bool);
168
169        /// deprecated, set the message on the match request instead
170        #[deprecated = "No longer supported."]
171        #[unsafe(method(defaultInvitationMessage))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn defaultInvitationMessage(&self) -> Option<Retained<NSString>>;
174
175        /// Setter for [`defaultInvitationMessage`][Self::defaultInvitationMessage].
176        ///
177        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
178        #[deprecated = "No longer supported."]
179        #[unsafe(method(setDefaultInvitationMessage:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setDefaultInvitationMessage(
182            &self,
183            default_invitation_message: Option<&NSString>,
184        );
185    );
186}
187
188/// Methods declared on superclass `NSViewController`.
189#[cfg(feature = "objc2-app-kit")]
190#[cfg(target_os = "macos")]
191impl GKMatchmakerViewController {
192    extern_methods!(
193        #[unsafe(method(initWithNibName:bundle:))]
194        #[unsafe(method_family = init)]
195        pub unsafe fn initWithNibName_bundle(
196            this: Allocated<Self>,
197            nib_name_or_nil: Option<&NSNibName>,
198            nib_bundle_or_nil: Option<&NSBundle>,
199        ) -> Retained<Self>;
200
201        /// # Safety
202        ///
203        /// `coder` possibly has further requirements.
204        #[unsafe(method(initWithCoder:))]
205        #[unsafe(method_family = init)]
206        pub unsafe fn initWithCoder(
207            this: Allocated<Self>,
208            coder: &NSCoder,
209        ) -> Option<Retained<Self>>;
210    );
211}
212
213/// Methods declared on superclass `NSResponder`.
214#[cfg(feature = "objc2-app-kit")]
215#[cfg(target_os = "macos")]
216impl GKMatchmakerViewController {
217    extern_methods!(
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221    );
222}
223
224/// Methods declared on superclass `NSObject`.
225#[cfg(feature = "objc2-app-kit")]
226#[cfg(target_os = "macos")]
227impl GKMatchmakerViewController {
228    extern_methods!(
229        #[unsafe(method(new))]
230        #[unsafe(method_family = new)]
231        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
232    );
233}
234
235/// Obsoleted.
236#[cfg(feature = "objc2-app-kit")]
237#[cfg(target_os = "macos")]
238impl GKMatchmakerViewController {
239    extern_methods!(
240        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
241        #[deprecated]
242        #[unsafe(method(setHostedPlayer:connected:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setHostedPlayer_connected(&self, player_id: &NSString, connected: bool);
245
246        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
247        #[deprecated]
248        #[unsafe(method(setHostedPlayerReady:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setHostedPlayerReady(&self, player_id: &NSString);
251    );
252}
253
254extern_protocol!(
255    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmakerviewcontrollerdelegate?language=objc)
256    pub unsafe trait GKMatchmakerViewControllerDelegate: NSObjectProtocol {
257        #[cfg(feature = "objc2-app-kit")]
258        #[cfg(target_os = "macos")]
259        /// The user has cancelled matchmaking
260        #[unsafe(method(matchmakerViewControllerWasCancelled:))]
261        #[unsafe(method_family = none)]
262        unsafe fn matchmakerViewControllerWasCancelled(
263            &self,
264            view_controller: &GKMatchmakerViewController,
265        );
266
267        #[cfg(feature = "objc2-app-kit")]
268        #[cfg(target_os = "macos")]
269        /// Matchmaking has failed with an error
270        #[unsafe(method(matchmakerViewController:didFailWithError:))]
271        #[unsafe(method_family = none)]
272        unsafe fn matchmakerViewController_didFailWithError(
273            &self,
274            view_controller: &GKMatchmakerViewController,
275            error: &NSError,
276        );
277
278        #[cfg(all(feature = "GKMatch", feature = "objc2-app-kit"))]
279        #[cfg(target_os = "macos")]
280        /// A peer-to-peer match has been found, the game should start
281        #[optional]
282        #[unsafe(method(matchmakerViewController:didFindMatch:))]
283        #[unsafe(method_family = none)]
284        unsafe fn matchmakerViewController_didFindMatch(
285            &self,
286            view_controller: &GKMatchmakerViewController,
287            r#match: &GKMatch,
288        );
289
290        #[cfg(all(
291            feature = "GKBasePlayer",
292            feature = "GKPlayer",
293            feature = "objc2-app-kit"
294        ))]
295        #[cfg(target_os = "macos")]
296        /// Players have been found for a server-hosted game, the game should start
297        #[optional]
298        #[unsafe(method(matchmakerViewController:didFindHostedPlayers:))]
299        #[unsafe(method_family = none)]
300        unsafe fn matchmakerViewController_didFindHostedPlayers(
301            &self,
302            view_controller: &GKMatchmakerViewController,
303            players: &NSArray<GKPlayer>,
304        );
305
306        #[cfg(all(
307            feature = "GKBasePlayer",
308            feature = "GKPlayer",
309            feature = "objc2-app-kit"
310        ))]
311        #[cfg(target_os = "macos")]
312        /// An invited player has accepted a hosted invite.  Apps should connect through the hosting server and then update the player's connected state (using setConnected:forHostedPlayer:)
313        #[optional]
314        #[unsafe(method(matchmakerViewController:hostedPlayerDidAccept:))]
315        #[unsafe(method_family = none)]
316        unsafe fn matchmakerViewController_hostedPlayerDidAccept(
317            &self,
318            view_controller: &GKMatchmakerViewController,
319            player: &GKPlayer,
320        );
321
322        #[cfg(all(
323            feature = "GKBasePlayer",
324            feature = "GKDefines",
325            feature = "GKPlayer",
326            feature = "block2",
327            feature = "objc2-app-kit"
328        ))]
329        #[cfg(target_os = "macos")]
330        /// The game should provide `GKMatchProperties` for the `GKPlayer` that has been invited.
331        /// If implemented, this function must call `completionHandler`: failing to do so will hang matchmaking.
332        #[optional]
333        #[unsafe(method(matchmakerViewController:getMatchPropertiesForRecipient:withCompletionHandler:))]
334        #[unsafe(method_family = none)]
335        unsafe fn matchmakerViewController_getMatchPropertiesForRecipient_withCompletionHandler(
336            &self,
337            view_controller: &GKMatchmakerViewController,
338            recipient: &GKPlayer,
339            completion_handler: &block2::DynBlock<dyn Fn(NonNull<GKMatchProperties>)>,
340        );
341
342        #[cfg(feature = "objc2-app-kit")]
343        #[cfg(target_os = "macos")]
344        /// * These protocol methods are obsoleted. They will never be invoked and their implementation does nothing**
345        #[deprecated]
346        #[optional]
347        #[unsafe(method(matchmakerViewController:didFindPlayers:))]
348        #[unsafe(method_family = none)]
349        unsafe fn matchmakerViewController_didFindPlayers(
350            &self,
351            view_controller: &GKMatchmakerViewController,
352            player_i_ds: &NSArray<NSString>,
353        );
354
355        #[cfg(feature = "objc2-app-kit")]
356        #[cfg(target_os = "macos")]
357        #[deprecated]
358        #[optional]
359        #[unsafe(method(matchmakerViewController:didReceiveAcceptFromHostedPlayer:))]
360        #[unsafe(method_family = none)]
361        unsafe fn matchmakerViewController_didReceiveAcceptFromHostedPlayer(
362            &self,
363            view_controller: &GKMatchmakerViewController,
364            player_id: &NSString,
365        );
366    }
367);