/*
 * 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 "OpenVulkanoAppDelegate.h"

#include "Base/AppEvents.hpp"
#include "Base/Logger.hpp"
#include "Host/SystemInfo.hpp"
#include "Math/ByteSize.hpp"

using namespace OpenVulkano;

@interface OpenVulkanoAppDelegate ()

@end

@implementation OpenVulkanoAppDelegate

- (id)init
{
	[super init];
	Logger::SetupLogger();
	return self;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
	AppEvents::OnWillResignActive();
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
	AppEvents::OnDidEnterBackground();
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
	AppEvents::OnWillEnterForeground();
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
	AppEvents::OnDidBecomeActive();
}

- (void)applicationWillTerminate:(UIApplication *)application
{
	AppEvents::OnWillTerminate();
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
	Logger::MANAGER->warn("Received Memory Warning! RAM Max {}; Available {}; Used: {}", ByteSize(SystemInfo::GetAppRamMax()), ByteSize(SystemInfo::GetAppRamAvailable()), ByteSize(SystemInfo::GetAppRamUsed()));
	AppEvents::OnReceivedMemoryWarning();
}

@end
