/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ExampleViewController.h"
#import "Host/iOS/OpenVulkanoAppDelegate.h"

#include "Base/Logger.hpp"

@interface SceneDelegate : UIResponder<UIWindowSceneDelegate>
@end

@implementation SceneDelegate
@synthesize window = _window;
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
	if ([scene isKindOfClass:[UIWindowScene class]]) {
		UIWindowScene* wScene = (UIWindowScene*)scene;
		self.window = [[UIWindow alloc] initWithWindowScene:wScene];

		MainMenuViewController* rootViewController = [[MainMenuViewController alloc] init];
		UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
		
		self.window.rootViewController = navigationController;
		[self.window makeKeyAndVisible];
	}
}
@end

@interface AppDelegate : OpenVulkanoAppDelegate
@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
	// Override point for customization after application launch.
	return YES;
}

- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
	UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:nil sessionRole:UIWindowSceneSessionRoleApplication];
	configuration.delegateClass = SceneDelegate.class;
	return configuration;
}
@end

int main(int argCount, char** args)
{
	using namespace OpenVulkano;
	Logger::SetupLogger();
	@autoreleasepool
	{
		return UIApplicationMain(argCount, args, nil, NSStringFromClass([AppDelegate class]));
	}
}
