class UIInGameNotificationViewData extends GenericNotificationViewData
{
	var animContainer : weak< inGameMenuAnimContainer >;
	var notificationType : UIInGameNotificationType;

	public override function CanMerge( data : GenericNotificationViewData ) : Bool
	{
		return ( ( notificationType == ( ( UIInGameNotificationViewData )( data ) ).notificationType ) ? ( ( ( animContainer ) ? ( animContainer.m_animProxy.IsPlaying() ) : ( true ) ) ) : ( false ) );
	}

	public override function OnRemoveNotification( data : IScriptable ) : Bool
	{
		return true;
	}

}

class UIInGameNotificationQueue extends gameuiGenericNotificationGameController
{
	private editable var m_duration : Float;
	default m_duration = 5.0f;

	public export override function GetShouldSaveState() : Bool
	{
		return false;
	}

	private function AdjustScreenPosition()
	{
		var blackbars : Vector2;
		var safezones : Vector2;
		blackbars = GetBlackBarFullscreenWidgetOffsets();
		safezones = GetHudSafezoneWidgetOffsets();
		GetRootWidget().SetTranslation( Vector2( blackbars.X + safezones.X, blackbars.Y + safezones.Y ) );
	}

	protected event OnUINotification( evt : UIInGameNotificationEvent )
	{
		var notificationData : gameuiGenericNotificationData;
		var userData : UIInGameNotificationViewData;
		var widgetLibraryItemName : CName;
		widgetLibraryItemName = 'ingame_popups_side';
		userData = new UIInGameNotificationViewData;
		AdjustScreenPosition();
		switch( evt.m_notificationType )
		{
			case UIInGameNotificationType.GenericNotification:
				userData.title = evt.m_title;
			break;
			case UIInGameNotificationType.CombatRestriction:
				userData.title = "UI-Notifications-CombatRestriction";
			break;
			case UIInGameNotificationType.ActionRestriction:
				userData.title = "UI-Notifications-ActionBlocked";
			break;
			case UIInGameNotificationType.CantSaveActionRestriction:
				userData.title = "UI-Notifications-CantSave-Generic";
			break;
			case UIInGameNotificationType.CantSaveCombatRestriction:
				userData.title = "UI-Notifications-CantSave-Combat";
			break;
			case UIInGameNotificationType.CantSaveQuestRestriction:
				userData.title = "UI-Notifications-CantSave-Generic";
			break;
			case UIInGameNotificationType.CantSaveDeathRestriction:
				userData.title = "UI-Notifications-CantSave-Dead";
			break;
			case UIInGameNotificationType.NotEnoughSlotsSaveResctriction:
				userData.title = "UI-Notifications-SaveNotEnoughSlots";
			break;
			case UIInGameNotificationType.NotEnoughSpaceSaveResctriction:
				userData.title = "UI-Notifications-SaveNotEnoughSpace";
			break;
			case UIInGameNotificationType.PhotoModeDisabledRestriction:
				userData.title = "UI-PhotoMode-NotSupported";
			break;
			case UIInGameNotificationType.SandevistanInCallRestriction:
				userData.title = "UI-Notifications-SandevistanInCallRestriction";
			break;
			case UIInGameNotificationType.ExpansionInstalled:
				userData.title = "UI-DLC-EP1-Reloading-InGameNotificationTitle";
			userData.text = "UI-DLC-EP1-InGameNotification";
			m_duration = 25.0;
			widgetLibraryItemName = 'ingame_popups_expansion';
			break;
		}
		userData.soundEvent = 'QuestSuccessPopup';
		userData.soundAction = 'OnOpen';
		userData.animContainer = evt.m_animContainer;
		userData.notificationType = evt.m_notificationType;
		notificationData.time = m_duration;
		notificationData.widgetLibraryItemName = widgetLibraryItemName;
		notificationData.notificationData = userData;
		if( evt.m_overrideCurrentNotification )
		{
			RemoveNotification( evt );
		}
		AddNewNotificationData( notificationData );
	}

	protected event OnUINotificationRemove( evt : UIInGameNotificationRemoveEvent )
	{
		RemoveNotification( evt );
	}

}

class UIInGameNotification extends GenericNotificationController
{

	public override function SetNotificationData( notificationData : GenericNotificationViewData )
	{
		var inGameNotificationData : UIInGameNotificationViewData;
		super.SetNotificationData( notificationData );
		inGameNotificationData = ( ( UIInGameNotificationViewData )( notificationData ) );
		if( inGameNotificationData.notificationType == UIInGameNotificationType.ExpansionInstalled )
		{
			inGameNotificationData.animContainer.m_animProxy = PlayLibraryAnimationOnAutoSelectedTargets( 'expasion_notification_intro', GetRootWidget() );
		}
		else
		{
			inGameNotificationData.animContainer.m_animProxy = PlayLibraryAnimationOnAutoSelectedTargets( 'notification_intro', GetRootWidget() );
		}
	}

}

class UIInGameNotificationEvent extends Event
{
	var m_notificationType : UIInGameNotificationType;
	var m_animContainer : weak< inGameMenuAnimContainer >;
	var m_title : String;
	var m_overrideCurrentNotification : Bool;

	public static function CreateSavingLockedEvent( const locks : ref< array< gameSaveLock > > ) : UIInGameNotificationEvent
	{
		var i : Int32;
		var notificationEvent : UIInGameNotificationEvent;
		notificationEvent = new UIInGameNotificationEvent;
		notificationEvent.m_notificationType = UIInGameNotificationType.CantSaveActionRestriction;
		for( i = 0; i < locks.Size(); i += 1 )
		{
			switch( locks[ i ].reason )
			{
				case gameSaveLockReason.Combat:
					if( ( ( Int32 )( notificationEvent.m_notificationType ) ) < ( ( Int32 )( UIInGameNotificationType.CantSaveCombatRestriction ) ) )
					{
						notificationEvent.m_notificationType = UIInGameNotificationType.CantSaveCombatRestriction;
					}
				break;
				case gameSaveLockReason.Scene:
				case gameSaveLockReason.Quest:
				case gameSaveLockReason.Boundary:
				case gameSaveLockReason.MainMenu:
				case gameSaveLockReason.LoadingScreen:
				case gameSaveLockReason.Tier:
					if( ( ( Int32 )( notificationEvent.m_notificationType ) ) < ( ( Int32 )( UIInGameNotificationType.CantSaveQuestRestriction ) ) )
					{
						notificationEvent.m_notificationType = UIInGameNotificationType.CantSaveQuestRestriction;
					}
				;
				break;
				case gameSaveLockReason.PlayerState:
					if( ( ( Int32 )( notificationEvent.m_notificationType ) ) < ( ( Int32 )( UIInGameNotificationType.CantSaveDeathRestriction ) ) )
					{
						notificationEvent.m_notificationType = UIInGameNotificationType.CantSaveDeathRestriction;
					}
				break;
				case gameSaveLockReason.NotEnoughSlots:
					if( ( ( Int32 )( notificationEvent.m_notificationType ) ) < ( ( Int32 )( UIInGameNotificationType.NotEnoughSlotsSaveResctriction ) ) )
					{
						notificationEvent.m_notificationType = UIInGameNotificationType.NotEnoughSlotsSaveResctriction;
					}
				break;
				case gameSaveLockReason.NotEnoughSpace:
					if( ( ( Int32 )( notificationEvent.m_notificationType ) ) < ( ( Int32 )( UIInGameNotificationType.NotEnoughSpaceSaveResctriction ) ) )
					{
						notificationEvent.m_notificationType = UIInGameNotificationType.NotEnoughSpaceSaveResctriction;
					}
				break;
			}
		}
		return notificationEvent;
	}

}

class UIInGameNotificationRemoveEvent extends Event
{
}

enum UIInGameNotificationType
{
	ActionRestriction = 0,
	CombatRestriction = 1,
	CantSaveActionRestriction = 2,
	CantSaveCombatRestriction = 3,
	CantSaveQuestRestriction = 4,
	CantSaveDeathRestriction = 5,
	NotEnoughSlotsSaveResctriction = 6,
	NotEnoughSpaceSaveResctriction = 7,
	PhotoModeDisabledRestriction = 8,
	SandevistanInCallRestriction = 9,
	ExpansionInstalled = 10,
	GenericNotification = 11,
}

