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        /// This is a [weak property][objc2::topics::weak_property].
93        /// Setter for [`matchmakerDelegate`][Self::matchmakerDelegate].
94        #[unsafe(method(setMatchmakerDelegate:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setMatchmakerDelegate(
97            &self,
98            matchmaker_delegate: Option<&ProtocolObject<dyn GKMatchmakerViewControllerDelegate>>,
99        );
100
101        #[cfg(feature = "GKMatchmaker")]
102        #[unsafe(method(matchRequest))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn matchRequest(&self) -> Retained<GKMatchRequest>;
105
106        /// 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.
107        #[unsafe(method(isHosted))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn isHosted(&self) -> bool;
110
111        /// Setter for [`isHosted`][Self::isHosted].
112        #[unsafe(method(setHosted:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setHosted(&self, hosted: bool);
115
116        /// 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)
117        #[unsafe(method(matchmakingMode))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn matchmakingMode(&self) -> GKMatchmakingMode;
120
121        /// Setter for [`matchmakingMode`][Self::matchmakingMode].
122        #[unsafe(method(setMatchmakingMode:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setMatchmakingMode(&self, matchmaking_mode: GKMatchmakingMode);
125
126        /// A BOOL value to allow the GKMatchMakerViewController to return control to the game once the minimum number of players are connected.
127        /// By default the value is NO, and the multiplayer match can only proceed after all players are connected.
128        /// 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.
129        #[unsafe(method(canStartWithMinimumPlayers))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn canStartWithMinimumPlayers(&self) -> bool;
132
133        /// Setter for [`canStartWithMinimumPlayers`][Self::canStartWithMinimumPlayers].
134        #[unsafe(method(setCanStartWithMinimumPlayers:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn setCanStartWithMinimumPlayers(&self, can_start_with_minimum_players: bool);
137
138        #[cfg(feature = "GKMatchmaker")]
139        /// Initialize with a matchmaking request, allowing the user to send invites and/or start matchmaking
140        #[unsafe(method(initWithMatchRequest:))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn initWithMatchRequest(
143            this: Allocated<Self>,
144            request: &GKMatchRequest,
145        ) -> Option<Retained<Self>>;
146
147        #[cfg(feature = "GKMatchmaker")]
148        /// Initialize with an accepted invite, allowing the user to see the status of other invited players and get notified when the game starts
149        #[unsafe(method(initWithInvite:))]
150        #[unsafe(method_family = init)]
151        pub unsafe fn initWithInvite(
152            this: Allocated<Self>,
153            invite: &GKInvite,
154        ) -> Option<Retained<Self>>;
155
156        #[cfg(feature = "GKMatch")]
157        /// Add additional players (not currently connected) to an existing peer-to-peer match.
158        /// Apps should elect a single device to do this, otherwise conflicts could arise resulting in unexpected connection errors.
159        #[unsafe(method(addPlayersToMatch:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn addPlayersToMatch(&self, r#match: &GKMatch);
162
163        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
164        #[unsafe(method(setHostedPlayer:didConnect:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setHostedPlayer_didConnect(&self, player: &GKPlayer, connected: bool);
167
168        /// deprecated, set the message on the match request instead
169        #[deprecated = "No longer supported."]
170        #[unsafe(method(defaultInvitationMessage))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn defaultInvitationMessage(&self) -> Option<Retained<NSString>>;
173
174        /// Setter for [`defaultInvitationMessage`][Self::defaultInvitationMessage].
175        #[deprecated = "No longer supported."]
176        #[unsafe(method(setDefaultInvitationMessage:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setDefaultInvitationMessage(
179            &self,
180            default_invitation_message: Option<&NSString>,
181        );
182    );
183}
184
185/// Methods declared on superclass `NSViewController`.
186#[cfg(feature = "objc2-app-kit")]
187#[cfg(target_os = "macos")]
188impl GKMatchmakerViewController {
189    extern_methods!(
190        #[unsafe(method(initWithNibName:bundle:))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn initWithNibName_bundle(
193            this: Allocated<Self>,
194            nib_name_or_nil: Option<&NSNibName>,
195            nib_bundle_or_nil: Option<&NSBundle>,
196        ) -> Retained<Self>;
197
198        #[unsafe(method(initWithCoder:))]
199        #[unsafe(method_family = init)]
200        pub unsafe fn initWithCoder(
201            this: Allocated<Self>,
202            coder: &NSCoder,
203        ) -> Option<Retained<Self>>;
204    );
205}
206
207/// Methods declared on superclass `NSResponder`.
208#[cfg(feature = "objc2-app-kit")]
209#[cfg(target_os = "macos")]
210impl GKMatchmakerViewController {
211    extern_methods!(
212        #[unsafe(method(init))]
213        #[unsafe(method_family = init)]
214        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215    );
216}
217
218/// Methods declared on superclass `NSObject`.
219#[cfg(feature = "objc2-app-kit")]
220#[cfg(target_os = "macos")]
221impl GKMatchmakerViewController {
222    extern_methods!(
223        #[unsafe(method(new))]
224        #[unsafe(method_family = new)]
225        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
226    );
227}
228
229/// Obsoleted.
230#[cfg(feature = "objc2-app-kit")]
231#[cfg(target_os = "macos")]
232impl GKMatchmakerViewController {
233    extern_methods!(
234        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
235        #[deprecated]
236        #[unsafe(method(setHostedPlayer:connected:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setHostedPlayer_connected(&self, player_id: &NSString, connected: bool);
239
240        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
241        #[deprecated]
242        #[unsafe(method(setHostedPlayerReady:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setHostedPlayerReady(&self, player_id: &NSString);
245    );
246}
247
248extern_protocol!(
249    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmakerviewcontrollerdelegate?language=objc)
250    pub unsafe trait GKMatchmakerViewControllerDelegate: NSObjectProtocol {
251        #[cfg(feature = "objc2-app-kit")]
252        #[cfg(target_os = "macos")]
253        /// The user has cancelled matchmaking
254        #[unsafe(method(matchmakerViewControllerWasCancelled:))]
255        #[unsafe(method_family = none)]
256        unsafe fn matchmakerViewControllerWasCancelled(
257            &self,
258            view_controller: &GKMatchmakerViewController,
259        );
260
261        #[cfg(feature = "objc2-app-kit")]
262        #[cfg(target_os = "macos")]
263        /// Matchmaking has failed with an error
264        #[unsafe(method(matchmakerViewController:didFailWithError:))]
265        #[unsafe(method_family = none)]
266        unsafe fn matchmakerViewController_didFailWithError(
267            &self,
268            view_controller: &GKMatchmakerViewController,
269            error: &NSError,
270        );
271
272        #[cfg(all(feature = "GKMatch", feature = "objc2-app-kit"))]
273        #[cfg(target_os = "macos")]
274        /// A peer-to-peer match has been found, the game should start
275        #[optional]
276        #[unsafe(method(matchmakerViewController:didFindMatch:))]
277        #[unsafe(method_family = none)]
278        unsafe fn matchmakerViewController_didFindMatch(
279            &self,
280            view_controller: &GKMatchmakerViewController,
281            r#match: &GKMatch,
282        );
283
284        #[cfg(all(
285            feature = "GKBasePlayer",
286            feature = "GKPlayer",
287            feature = "objc2-app-kit"
288        ))]
289        #[cfg(target_os = "macos")]
290        /// Players have been found for a server-hosted game, the game should start
291        #[optional]
292        #[unsafe(method(matchmakerViewController:didFindHostedPlayers:))]
293        #[unsafe(method_family = none)]
294        unsafe fn matchmakerViewController_didFindHostedPlayers(
295            &self,
296            view_controller: &GKMatchmakerViewController,
297            players: &NSArray<GKPlayer>,
298        );
299
300        #[cfg(all(
301            feature = "GKBasePlayer",
302            feature = "GKPlayer",
303            feature = "objc2-app-kit"
304        ))]
305        #[cfg(target_os = "macos")]
306        /// 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:)
307        #[optional]
308        #[unsafe(method(matchmakerViewController:hostedPlayerDidAccept:))]
309        #[unsafe(method_family = none)]
310        unsafe fn matchmakerViewController_hostedPlayerDidAccept(
311            &self,
312            view_controller: &GKMatchmakerViewController,
313            player: &GKPlayer,
314        );
315
316        #[cfg(all(
317            feature = "GKBasePlayer",
318            feature = "GKDefines",
319            feature = "GKPlayer",
320            feature = "block2",
321            feature = "objc2-app-kit"
322        ))]
323        #[cfg(target_os = "macos")]
324        /// The game should provide `GKMatchProperties` for the `GKPlayer` that has been invited.
325        /// If implemented, this function must call `completionHandler`: failing to do so will hang matchmaking.
326        #[optional]
327        #[unsafe(method(matchmakerViewController:getMatchPropertiesForRecipient:withCompletionHandler:))]
328        #[unsafe(method_family = none)]
329        unsafe fn matchmakerViewController_getMatchPropertiesForRecipient_withCompletionHandler(
330            &self,
331            view_controller: &GKMatchmakerViewController,
332            recipient: &GKPlayer,
333            completion_handler: &block2::DynBlock<dyn Fn(NonNull<GKMatchProperties>)>,
334        );
335
336        #[cfg(feature = "objc2-app-kit")]
337        #[cfg(target_os = "macos")]
338        /// * These protocol methods are obsoleted. They will never be invoked and their implementation does nothing**
339        #[deprecated]
340        #[optional]
341        #[unsafe(method(matchmakerViewController:didFindPlayers:))]
342        #[unsafe(method_family = none)]
343        unsafe fn matchmakerViewController_didFindPlayers(
344            &self,
345            view_controller: &GKMatchmakerViewController,
346            player_i_ds: &NSArray<NSString>,
347        );
348
349        #[cfg(feature = "objc2-app-kit")]
350        #[cfg(target_os = "macos")]
351        #[deprecated]
352        #[optional]
353        #[unsafe(method(matchmakerViewController:didReceiveAcceptFromHostedPlayer:))]
354        #[unsafe(method_family = none)]
355        unsafe fn matchmakerViewController_didReceiveAcceptFromHostedPlayer(
356            &self,
357            view_controller: &GKMatchmakerViewController,
358            player_id: &NSString,
359        );
360    }
361);