Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NSViewController to macOS platform code #6513

Open
Valeryn4 opened this issue Mar 16, 2023 · 1 comment
Open

Add NSViewController to macOS platform code #6513

Valeryn4 opened this issue Mar 16, 2023 · 1 comment

Comments

@Valeryn4
Copy link

Valeryn4 commented Mar 16, 2023

Describe the project you are working on

I'm trying to implement iCloud and GameCenter.

Godot does not provide an NSViewController.
Because of this, the developer does not have access to the API.
It is impossible to activate various controllers and monitor their life.
We cannot use the full functionality of the billing, game center, control the operation of some windows (request Review).

Providing an NSViewController, just like UIViewController (in the iphone), will solve the problems.

Describe the problem or limitation you are having in your project

I need to provide an NSViewController for GameCenter. Otherwise, it will not work.

Example GameCenter
Doc.

Before you can access any Game Center data and use GameKit features, you need to authenticate the local player to ensure the player signs in to Game Center on the device running your game. Set this property to a method that GameKit invokes during the authentication process. If viewController is nil, Game Center authenticates the player and the player can start your game. Otherwise, present the view controller so the player can perform any additional actions to complete authentication.

For more information about the authentication of the local player, see Authenticating a Player.

GKLocalPlayer *player = [GKLocalPlayer localPlayer];
 player.authenticateHandler = (^(NSViewController *controller, NSError *error) {
            NSViewController *root_controller = [[[NSApplication sharedApplication] keyWindow] contentViewController]; 
            if (controller) { 
                [root_controller presentViewControllerAsModalWindow:controller]; /// NEED CONTROLLER
            }

Describe the feature / enhancement and how it helps to overcome the problem or limitation

move NSView from NSWindow to NSViewController.
add NSViewController to NSWindow.contentViewController

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

change from

	window_view = [[GodotContentView alloc] init];
	if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) {
		[window_view setWantsLayer:TRUE];
	}

	window_size.width = p_desired.width;
	window_size.height = p_desired.height;

	if (displayScale > 1.0) {
		[window_view setWantsBestResolutionOpenGLSurface:YES];
		//if (current_videomode.resizable)
		[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
	} else {
		[window_view setWantsBestResolutionOpenGLSurface:NO];
	}

	[window_object setColorSpace:[NSColorSpace sRGBColorSpace]];

	//[window_object setTitle:[NSString stringWithUTF8String:"GodotEnginies"]];
	[window_object setContentView:window_view];
	[window_object setDelegate:window_delegate];

to

	view = [[GodotContentView alloc] init]; // <<<<<<<
	if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) {
		[view setWantsLayer:TRUE];
	}

	window_size.width = p_desired.width;
	window_size.height = p_desired.height;

	if (displayScale > 1.0) {
		[window_view setWantsBestResolutionOpenGLSurface:YES];
		//if (current_videomode.resizable)
		[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
	} else {
		[view setWantsBestResolutionOpenGLSurface:NO];
	}

	[window_object setColorSpace:[NSColorSpace sRGBColorSpace]];

        view_controller = [[GodotViewController alloc] init]; // <<<<<<<<<<<<<<
	view_controller.view = view; // <<<<<<<<<<
	window_object.contentViewController = view_controller; // <<<<<
	[window_object setDelegate:window_delegate];

I don't program in Obj-C.
But there is API preparation for the Game Center. That's the kind of decision that came to my mind. But perhaps there is a better approach.

If this enhancement will not be used often, can it be worked around with a few lines of script?

no

Is there a reason why this should be core and not an add-on in the asset library?

platform dependence

@Calinou Calinou changed the title MacOS. Add NSViewController to platform code Add NSViewController to macOS platform code Mar 16, 2023
@Grublady
Copy link

Grublady commented Aug 4, 2024

Related to #1612?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants