enum EToggleActivationTypeComputer
{
	None = 0,
	Raise = 1,
}

enum EComputerAnimationState
{
	None = 0,
	Opened = 1,
	Closed = 2,
}

struct ComputerQuickHackData
{
	[ customEditor = "TweakDBGroupInheritance;Interactions.InteractionChoice;Interactions.MountChoice" ]
	instanceeditable var alternativeName : TweakDBID;
	instanceeditable var factName : CName;
	instanceeditable var factValue : Int32;
	instanceeditable var operationType : EMathOperationType;
}

class ToggleOpenComputer extends ActionBool
{

	public function SetProperties( isOpen : Bool )
	{
		actionName = 'ToggleOpen';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'Open', isOpen, 'LocKey#273', 'LocKey#274' );
	}

	public static function IsDefaultConditionMet( device : ComputerControllerPS, const context : ref< GetActionsContext > ) : Bool
	{
		if( IsAvailable( device ) && IsClearanceValid( context.clearance ) )
		{
			return true;
		}
		return false;
	}

	public static function IsAvailable( device : ComputerControllerPS ) : Bool
	{
		if( ( ( device.IsDisabled() || device.GetAnimationState() == EComputerAnimationState.None ) || device.IsPersonalLinkConnected() ) || device.IsPersonalLinkConnecting() )
		{
			return false;
		}
		return true;
	}

	public static function IsClearanceValid( clearance : Clearance ) : Bool
	{
		if( Clearance.IsInRange( clearance, DefaultActionsParametersHolder.GetToggleOpenClearance() ) )
		{
			return true;
		}
		return false;
	}

	public override function GetTweakDBChoiceRecord() : String
	{
		if( !( ( ( Bool )prop.first ) ) )
		{
			return "Open";
		}
		else
		{
			return "Close";
		}
	}

	public override function GetInkWidgetTweakDBID() : TweakDBID
	{
		return T"DevicesUIDefinitions.GenericActionWidget";
	}

}

class ComputerController extends TerminalController
{

	public const override function GetPS() : ComputerControllerPS
	{
		return ( ( ComputerControllerPS )( GetBasePS() ) );
	}

}

struct ComputerSetup extends TerminalSetup
{
	[ category = "Menus" ]
	instanceeditable var m_startingMenu : EComputerMenuType;
	[ category = "Menus" ]
	instanceeditable persistent var m_mailsMenu : Bool;
	default m_mailsMenu = true;
	[ category = "Menus" ]
	instanceeditable persistent var m_filesMenu : Bool;
	default m_filesMenu = true;
	[ category = "Menus" ]
	instanceeditable persistent var m_systemMenu : Bool;
	default m_systemMenu = true;
	[ category = "Menus" ]
	instanceeditable persistent var m_internetMenu : Bool;
	default m_internetMenu = true;
	[ category = "Menus" ]
	instanceeditable persistent var m_newsFeedMenu : Bool;
	default m_newsFeedMenu = false;
	[ category = "Menus" ][ customEditor = "TweakDBGroupInheritance;ComputerUIPresets.DefaultPreset" ]
	editable var m_stylePreset : TweakDBID;
	default m_stylePreset = T"ComputerUIPresets.DefaultPreset";
	[ category = "Menus" ]
	instanceeditable var m_hideTopNavigationBar : Bool;
	default m_hideTopNavigationBar = false;
	[ category = "Documents" ]
	const instanceeditable persistent var m_mailsStructure : array< GenericDataContent >;
	[ category = "Documents" ]
	const instanceeditable persistent var m_filesStructure : array< GenericDataContent >;
	[ category = "Newsfeed" ]
	const instanceeditable var m_newsFeed : array< SNewsFeedElementData >;
	[ category = "Newsfeed" ]
	instanceeditable var m_newsFeedInterval : Float;
	default m_newsFeedInterval = 5.0;
	[ category = "Internet" ]
	instanceeditable var m_internetSubnet : SInternetData;
	[ category = "Animations" ]
	instanceeditable persistent var m_animationState : EComputerAnimationState;
	default m_animationState = EComputerAnimationState.None;
	[ category = "Animations" ]
	instanceeditable var m_animationStateSetFactName : CName;
	instanceeditable var m_ignoreSleepMode : Bool;
}

class ComputerControllerPS extends TerminalControllerPS
{
	default m_deviceName = "LocKey#48";
	default m_tweakDBRecord = T"Devices.Computer";
	default m_tweakDBDescriptionRecord = T"device_descriptions.Computer";
	default m_hasAuthorizationModule = true;
	default m_hasUICameraZoom = true;
	protected instanceeditable persistent var m_computerSetup : ComputerSetup;
	protected instanceeditable var m_quickHackSetup : ComputerQuickHackData;
	protected instanceeditable var m_activatorActionSetup : EToggleActivationTypeComputer;
	protected instanceeditable inlined var m_computerSkillChecks : HackEngContainer;
	protected persistent var m_openedMailAdress : SDocumentAdress;
	protected persistent var m_openedFileAdress : SDocumentAdress;
	protected persistent var m_quickhackPerformed : Bool;
	private var m_isInSleepMode : Bool;
	default m_isInSleepMode = true;
	private var m_computerUIpreset : ComputerStyleUIDefinition_Record;

	public const function GetInitialMenuType() : EComputerMenuType
	{
		return m_computerSetup.m_startingMenu;
	}

	public const function GetActivatorType() : EToggleActivationTypeComputer
	{
		return m_activatorActionSetup;
	}

	public const function GetHideTopNavigationBar() : Bool
	{
		return m_computerSetup.m_hideTopNavigationBar;
	}

	public const function IsInSleepMode() : Bool
	{
		if( !( HasUICameraZoom() ) )
		{
			return false;
		}
		if( m_computerSetup.m_ignoreSleepMode )
		{
			return false;
		}
		return m_isInSleepMode;
	}

	public function SetIsInSleepMode( value : Bool )
	{
		m_isInSleepMode = value;
	}

	public const function GetAnimationState() : EComputerAnimationState
	{
		return m_computerSetup.m_animationState;
	}

	public function SetAnimationState( state : EComputerAnimationState )
	{
		m_computerSetup.m_animationState = state;
	}

	public const function GetAnimationStateFactName() : CName
	{
		return m_computerSetup.m_animationStateSetFactName;
	}

	public const override function ShouldShowExamineIntaraction() : Bool
	{
		if( GetAnimationState() == EComputerAnimationState.Closed )
		{
			return false;
		}
		else
		{
			return super.ShouldShowExamineIntaraction();
		}
	}

	public const function DataInitialized() : Bool
	{
		if( ( ( m_computerSetup.m_mailsStructure.Size() > 0 ) || ( m_computerSetup.m_filesStructure.Size() > 0 ) ) || ( m_computerSetup.m_newsFeed.Size() > 0 ) )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	protected event OnInstantiated()
	{
		super.OnInstantiated();
		if( !( IsStringValid( m_deviceName ) ) )
		{
			m_deviceName = "LocKey#48";
		}
	}

	protected override function GetSkillCheckContainerForSetup() : BaseSkillCheckContainer
	{
		return m_computerSkillChecks;
	}

	protected override function LogicReady()
	{
		super.LogicReady();
		m_computerUIpreset = TweakDBInterface.GetComputerStyleUIDefinitionRecord( m_computerSetup.m_stylePreset );
	}

	public export function PushResaveData( data : ComputerPersistentData ) {}

	protected override function GameAttached() {}

	protected const override function GenerateContext( requestType : gamedeviceRequestType, providedClearance : Clearance, optional providedProcessInitiator : GameObject, optional providedRequestor : EntityID ) : GetActionsContext
	{
		var generatedContext : GetActionsContext;
		generatedContext = super.GenerateContext( requestType, providedClearance, providedProcessInitiator, providedRequestor );
		generatedContext.ignoresAuthorization = m_computerSetup.m_ignoreSlaveAuthorizationModule;
		generatedContext.allowsRemoteAuthorization = m_computerSetup.m_allowRemoteAuthorization;
		return generatedContext;
	}

	protected const override function CanCreateAnyQuickHackActions() : Bool
	{
		return true;
	}

	protected override function GetQuickHackActions( out outActions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		var currentAction : ScriptableDeviceAction;
		GetQuickHacksFromSlave( outActions, context );
		if( !( m_quickhackPerformed ) && IsNameValid( m_quickHackSetup.factName ) )
		{
			currentAction = ActionCreateFactQuickHack();
			currentAction.SetObjectActionID( T"DeviceAction.DataExtractionClassHack" );
			outActions.PushBack( currentAction );
		}
		if( CanPlayerTakeOverControl() )
		{
			currentAction = ActionToggleTakeOverControl();
			currentAction.SetObjectActionID( T"DeviceAction.TakeControlClassHack" );
			outActions.PushBack( currentAction );
		}
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenSuicide", T"QuickHack.SuicideHackBase" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		currentAction.SetInactiveWithReason( GlitchScreen.IsDefaultConditionMet( this, context ), "LocKey#7003" );
		outActions.PushBack( currentAction );
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenBlind", T"QuickHack.BlindHack" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		currentAction.SetInactiveWithReason( GlitchScreen.IsDefaultConditionMet( this, context ), "LocKey#7003" );
		outActions.PushBack( currentAction );
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenGrenade", T"QuickHack.GrenadeHackBase" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		currentAction.SetInactiveWithReason( GlitchScreen.IsDefaultConditionMet( this, context ), "LocKey#7003" );
		outActions.PushBack( currentAction );
		currentAction = ActionQuickHackDistraction();
		currentAction.SetObjectActionID( T"DeviceAction.MalfunctionClassHack" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		currentAction.SetInactiveWithReason( QuickHackDistraction.IsDefaultConditionMet( this, context ), "LocKey#7003" );
		outActions.PushBack( currentAction );
		if( IsGlitching() || IsDistracting() )
		{
			SetActionsInactiveAll( outActions, "LocKey#7004" );
		}
		FinalizeGetQuickHackActions( outActions, context );
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		super.GetActions( actions, context );
		if( ToggleOpenComputer.IsDefaultConditionMet( this, context ) )
		{
			actions.PushBack( ActionToggleOpen() );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	public override function GetQuestActionByName( actionName : CName ) : DeviceAction
	{
		var action : DeviceAction;
		action = super.GetQuestActionByName( actionName );
		if( action == NULL )
		{
			switch( actionName )
			{
				case 'ToggleOpen':
					action = ActionToggleOpen();
				break;
			}
		}
		return action;
	}

	public override function GetQuestActions( out actions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		super.GetQuestActions( actions, context );
		actions.PushBack( ActionToggleOpen() );
	}

	public virtual function ActionToggleOpen() : ToggleOpenComputer
	{
		var action : ToggleOpenComputer;
		action = new ToggleOpenComputer;
		action.clearanceLevel = DefaultActionsParametersHolder.GetToggleOpenClearance();
		action.SetUp( this );
		action.SetProperties( GetAnimationState() == EComputerAnimationState.Opened );
		action.AddDeviceName( GetDeviceName() );
		action.OverrideInteractionRecord( T"Interactions.CloseLaptop", T"Interactions.OpenLaptop" );
		action.CreateActionWidgetPackage();
		return action;
	}

	public function OnToggleOpen( evt : ToggleOpenComputer ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		if( IsDisabled() || GetAnimationState() == EComputerAnimationState.None )
		{
			return SendActionFailedEvent( evt, evt.GetRequesterID(), "Unpowered or Disabled" );
		}
		if( GetAnimationState() == EComputerAnimationState.Opened )
		{
			SetAnimationState( EComputerAnimationState.Closed );
		}
		else if( GetAnimationState() == EComputerAnimationState.Closed )
		{
			SetAnimationState( EComputerAnimationState.Opened );
		}
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	protected function ActionCreateFactQuickHack() : FactQuickHack
	{
		var action : FactQuickHack;
		action = new FactQuickHack;
		action.SetUp( this );
		action.AddDeviceName( m_deviceName );
		action.SetProperties( m_quickHackSetup );
		if( TDBID.IsValid( m_quickHackSetup.alternativeName ) )
		{
			action.CreateInteraction( , , m_quickHackSetup.alternativeName );
		}
		else
		{
			action.CreateInteraction();
		}
		return action;
	}

	public function OnCreateFactQuickHack( evt : FactQuickHack ) : EntityNotificationType
	{
		m_quickhackPerformed = true;
		return EntityNotificationType.SendThisEventToEntity;
	}

	public const override function GetBlackboardDef() : ComputerDeviceBlackboardDef
	{
		return GetAllBlackboardDefs().ComputerDeviceBlackboard;
	}

	private function DisableMenu( menuType : EComputerMenuType )
	{
		if( menuType == EComputerMenuType.MAILS )
		{
			m_computerSetup.m_mailsMenu = false;
		}
		else if( menuType == EComputerMenuType.FILES )
		{
			m_computerSetup.m_filesMenu = false;
		}
		else if( menuType == EComputerMenuType.SYSTEM )
		{
			m_computerSetup.m_systemMenu = false;
		}
		else if( menuType == EComputerMenuType.INTERNET )
		{
			m_computerSetup.m_internetMenu = false;
		}
		else if( menuType == EComputerMenuType.NEWSFEED )
		{
			m_computerSetup.m_newsFeedMenu = false;
		}
	}

	private function EnableMenu( menuType : EComputerMenuType )
	{
		if( menuType == EComputerMenuType.MAILS )
		{
			m_computerSetup.m_mailsMenu = true;
		}
		else if( menuType == EComputerMenuType.FILES )
		{
			m_computerSetup.m_filesMenu = true;
		}
		else if( menuType == EComputerMenuType.SYSTEM )
		{
			m_computerSetup.m_systemMenu = true;
		}
		else if( menuType == EComputerMenuType.INTERNET )
		{
			m_computerSetup.m_internetMenu = true;
		}
		else if( menuType == EComputerMenuType.NEWSFEED )
		{
			m_computerSetup.m_newsFeedMenu = true;
		}
	}

	private function IsMenuEnabled( menuType : EComputerMenuType ) : Bool
	{
		var returnValue : Bool;
		if( menuType == EComputerMenuType.MAILS )
		{
			returnValue = m_computerSetup.m_mailsMenu;
		}
		else if( menuType == EComputerMenuType.FILES )
		{
			returnValue = m_computerSetup.m_filesMenu;
		}
		else if( menuType == EComputerMenuType.SYSTEM )
		{
			returnValue = m_computerSetup.m_systemMenu;
		}
		else if( menuType == EComputerMenuType.INTERNET )
		{
			returnValue = m_computerSetup.m_internetMenu;
		}
		else if( menuType == EComputerMenuType.NEWSFEED )
		{
			returnValue = m_computerSetup.m_newsFeedMenu;
		}
		return returnValue;
	}

	public const function GetNewsfeedInterval() : Float
	{
		return m_computerSetup.m_newsFeedInterval;
	}

	public const function HasNewsfeed() : Bool
	{
		return m_computerSetup.m_newsFeed.Size() > 0;
	}

	public function UpdateBanners()
	{
		var i : Int32;
		var bannerID : Int32;
		for( i = 0; i < m_computerSetup.m_newsFeed.Size(); i += 1 )
		{
			bannerID = m_computerSetup.m_newsFeed[ i ].currentBanner;
			if( bannerID < ( m_computerSetup.m_newsFeed[ i ].banners.Size() - 1 ) )
			{
				bannerID += 1;
			}
			else if( bannerID == ( m_computerSetup.m_newsFeed[ i ].banners.Size() - 1 ) )
			{
				bannerID = 0;
			}
			m_computerSetup.m_newsFeed[ i ].currentBanner = bannerID;
		}
	}

	public virtual function OnRequestDocumentWidgetUpdate( evt : RequestDocumentWidgetUpdateEvent )
	{
		if( evt.documentType == EDocumentType.FILE )
		{
			RequestFileWidgetUpdate( GetBlackboard(), evt.documentAdress );
		}
		else if( evt.documentType == EDocumentType.MAIL )
		{
			RequestMailWidgetUpdate( GetBlackboard(), evt.documentAdress );
		}
	}

	public virtual function OnRequestDocumentThumbnailWidgetsUpdate( evt : RequestDocumentThumbnailWidgetsUpdateEvent )
	{
		if( evt.documentType == EDocumentType.FILE )
		{
			RequestFileThumbnailWidgetsUpdate( GetBlackboard() );
		}
		else if( evt.documentType == EDocumentType.MAIL )
		{
			RequestMailThumbnailWidgetsUpdate( GetBlackboard() );
		}
	}

	public virtual function OnRequestMenuWidgetsUpdate( evt : RequestComputerMenuWidgetsUpdateEvent )
	{
		RequestMenuButtonWidgetsUpdate( GetBlackboard() );
	}

	public function RequestBannerWidgetsUpdate( blackboard : IBlackboard )
	{
		var widgetsData : array< SBannerWidgetPackage >;
		widgetsData = GetBannerWidgets();
		if( blackboard )
		{
			blackboard.SetVariant( GetBlackboardDef().BannerWidgetsData, widgetsData );
			blackboard.SignalVariant( GetBlackboardDef().BannerWidgetsData );
			blackboard.FireCallbacks();
		}
	}

	public virtual function RequestFileWidgetUpdate( blackboard : IBlackboard, documentAdress : SDocumentAdress )
	{
		var widgetsData : array< SDocumentWidgetPackage >;
		var documentData : SDocumentWidgetPackage;
		documentData = GetFileWidget( documentAdress );
		if( IsStringValid( documentData.title ) )
		{
			widgetsData.PushBack( documentData );
			if( blackboard )
			{
				blackboard.SetVariant( GetBlackboardDef().FileWidgetsData, widgetsData );
				blackboard.SignalVariant( GetBlackboardDef().FileWidgetsData );
				blackboard.FireCallbacks();
			}
		}
	}

	public virtual function RequestMailWidgetUpdate( blackboard : IBlackboard, documentAdress : SDocumentAdress )
	{
		var widgetsData : array< SDocumentWidgetPackage >;
		var documentData : SDocumentWidgetPackage;
		documentData = GetMailWidget( documentAdress );
		if( IsStringValid( documentData.title ) )
		{
			widgetsData.PushBack( documentData );
			if( blackboard )
			{
				blackboard.SetVariant( GetBlackboardDef().MailWidgetsData, widgetsData );
				blackboard.SignalVariant( GetBlackboardDef().MailWidgetsData );
				blackboard.FireCallbacks();
			}
		}
	}

	public virtual function RequestMailThumbnailWidgetsUpdate( blackboard : IBlackboard )
	{
		var widgetsData : array< SDocumentThumbnailWidgetPackage >;
		widgetsData = GetMailThumbnailWidgets();
		if( blackboard )
		{
			blackboard.SetVariant( GetBlackboardDef().MailThumbnailWidgetsData, widgetsData );
			blackboard.SignalVariant( GetBlackboardDef().MailThumbnailWidgetsData );
			blackboard.FireCallbacks();
		}
	}

	public virtual function RequestFileThumbnailWidgetsUpdate( blackboard : IBlackboard )
	{
		var widgetsData : array< SDocumentThumbnailWidgetPackage >;
		widgetsData = GetFileThumbnailWidgets();
		if( blackboard )
		{
			blackboard.SetVariant( GetBlackboardDef().FileThumbnailWidgetsData, widgetsData );
			blackboard.SignalVariant( GetBlackboardDef().FileThumbnailWidgetsData );
			blackboard.FireCallbacks();
		}
	}

	public virtual function RequestMenuButtonWidgetsUpdate( blackboard : IBlackboard )
	{
		var widgetsData : array< SComputerMenuButtonWidgetPackage >;
		widgetsData = GetMenuButtonWidgets();
		if( blackboard )
		{
			blackboard.SetVariant( GetBlackboardDef().MenuButtonWidgetsData, widgetsData );
			blackboard.SignalVariant( GetBlackboardDef().MenuButtonWidgetsData );
			blackboard.FireCallbacks();
		}
	}

	public virtual function RequestMainMenuButtonWidgetsUpdate( blackboard : IBlackboard )
	{
		var widgetsData : array< SComputerMenuButtonWidgetPackage >;
		widgetsData = GetMainMenuButtonWidgets();
		if( blackboard )
		{
			blackboard.SetVariant( GetBlackboardDef().MainMenuButtonWidgetsData, widgetsData );
			blackboard.SignalVariant( GetBlackboardDef().MainMenuButtonWidgetsData );
			blackboard.FireCallbacks();
		}
	}

	protected virtual function GetBannerWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.BannerWidget().GetID();
	}

	private function GetBannerWidgets() : array< SBannerWidgetPackage >
	{
		var i : Int32;
		var currentBanner : Int32;
		var widgetPackage : SBannerWidgetPackage;
		var widgetsData : array< SBannerWidgetPackage >;
		var tweakID : TweakDBID;
		tweakID = GetBannerWidgetTweakDBID();
		widgetPackage.widgetTweakDBID = tweakID;
		SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
		widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
		if( !( widgetPackage.isValid ) )
		{
			return widgetsData;
		}
		for( i = 0; i < m_computerSetup.m_newsFeed.Size(); i += 1 )
		{
			currentBanner = m_computerSetup.m_newsFeed[ i ].currentBanner;
			widgetPackage.title = m_computerSetup.m_newsFeed[ i ].banners[ currentBanner ].title;
			widgetPackage.content = m_computerSetup.m_newsFeed[ i ].banners[ currentBanner ].content;
			widgetPackage.widgetName = ( ( ( "banner" + "_" ) + ( ( String )( currentBanner ) ) ) + "_" ) + ( ( String )( i ) );
			widgetPackage.ownerID = GetID();
			widgetPackage.description = m_computerSetup.m_newsFeed[ i ].banners[ currentBanner ].description;
			widgetsData.PushBack( widgetPackage );
		}
		return widgetsData;
	}

	protected virtual function GetFileWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.FileWidget().GetID();
	}

	public function GetFileWidget( documentAdress : SDocumentAdress ) : SDocumentWidgetPackage
	{
		var widgetPackage : SDocumentWidgetPackage;
		var dataElement : DataElement;
		var tweakID : TweakDBID;
		var journalFile : weak< JournalFile >;
		dataElement = m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ];
		if( IsDataElementValid( dataElement ) )
		{
			tweakID = GetFileWidgetTweakDBID();
			widgetPackage.widgetTweakDBID = tweakID;
			SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
			widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
			if( !( widgetPackage.isValid ) )
			{
				return widgetPackage;
			}
			journalFile = GetJournalFileEntry( dataElement );
			if( journalFile != NULL )
			{
				widgetPackage.title = journalFile.GetTitle();
				widgetPackage.content = journalFile.GetContent();
				widgetPackage.videoPath = journalFile.GetVideoResourcePath();
				widgetPackage.image = journalFile.GetImageTweak();
			}
			else
			{
				widgetPackage.title = dataElement.title;
				widgetPackage.content = dataElement.content;
			}
			widgetPackage.owner = dataElement.owner;
			widgetPackage.widgetName = ( ( ( "file" + "_" ) + ( ( String )( documentAdress.folderID ) ) ) + "_" ) + ( ( String )( documentAdress.documentID ) );
			widgetPackage.date = dataElement.date;
			widgetPackage.isEncrypted = dataElement.isEncrypted;
			widgetPackage.questInfo = dataElement.questInfo;
			widgetPackage.ownerID = GetID();
			widgetPackage.wasRead = dataElement.wasRead;
			widgetPackage.documentType = EDocumentType.FILE;
		}
		return widgetPackage;
	}

	protected virtual function GetMailWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.MailWidget().GetID();
	}

	public function GetMailWidget( documentAdress : SDocumentAdress ) : SDocumentWidgetPackage
	{
		var widgetPackage : SDocumentWidgetPackage;
		var dataElement : DataElement;
		var tweakID : TweakDBID;
		var journalEmail : weak< JournalEmail >;
		dataElement = m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ];
		if( IsDataElementValid( dataElement ) )
		{
			tweakID = GetMailWidgetTweakDBID();
			SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
			widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
			if( !( widgetPackage.isValid ) )
			{
				return widgetPackage;
			}
			widgetPackage.widgetTweakDBID = tweakID;
			journalEmail = GetJournalMailEntry( dataElement );
			if( journalEmail != NULL )
			{
				widgetPackage.owner = journalEmail.GetSender();
				widgetPackage.date = journalEmail.GetAddressee();
				widgetPackage.title = journalEmail.GetTitle();
				widgetPackage.content = journalEmail.GetContent();
				widgetPackage.image = journalEmail.GetImageTweak();
				widgetPackage.videoPath = journalEmail.GetVideoResourcePath();
			}
			else
			{
				widgetPackage.owner = dataElement.owner;
				widgetPackage.date = dataElement.date;
				widgetPackage.title = dataElement.title;
				widgetPackage.content = dataElement.content;
			}
			widgetPackage.widgetName = ( ( ( "mail" + "_" ) + ( ( String )( documentAdress.folderID ) ) ) + "_" ) + ( ( String )( documentAdress.documentID ) );
			widgetPackage.isEncrypted = dataElement.isEncrypted;
			widgetPackage.questInfo = dataElement.questInfo;
			widgetPackage.ownerID = GetID();
			widgetPackage.wasRead = dataElement.wasRead;
			widgetPackage.documentType = EDocumentType.MAIL;
		}
		return widgetPackage;
	}

	protected virtual function GetMailThumbnailWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.MailThumbnailWidget().GetID();
	}

	public function GetMailThumbnailWidgets() : array< SDocumentThumbnailWidgetPackage >
	{
		var i : Int32;
		var k : Int32;
		var widgetPackages : array< SDocumentThumbnailWidgetPackage >;
		var dataElement : DataElement;
		var widgetPackage : SDocumentThumbnailWidgetPackage;
		var tweakID : TweakDBID;
		var journalEmail : weak< JournalEmail >;
		var documentAdress : SDocumentAdress;
		tweakID = GetMailThumbnailWidgetTweakDBID();
		widgetPackage.widgetTweakDBID = tweakID;
		SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
		widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
		if( !( widgetPackage.isValid ) )
		{
			return widgetPackages;
		}
		for( i = 0; i < m_computerSetup.m_mailsStructure.Size(); i += 1 )
		{
			for( k = 0; k < m_computerSetup.m_mailsStructure[ i ].content.Size(); k += 1 )
			{
				dataElement = m_computerSetup.m_mailsStructure[ i ].content[ k ];
				if( !( IsDataElementValid( dataElement ) ) )
				{
					continue;
				}
				journalEmail = GetJournalMailEntry( dataElement );
				if( journalEmail != NULL )
				{
					widgetPackage.displayName = journalEmail.GetTitle();
				}
				else
				{
					widgetPackage.displayName = dataElement.title;
				}
				documentAdress.folderID = i;
				documentAdress.documentID = k;
				widgetPackage.widgetName = ( ( ( "mailThumbnail" + "_" ) + ( ( String )( i ) ) ) + "_" ) + ( ( String )( k ) );
				widgetPackage.folderName = m_computerSetup.m_mailsStructure[ i ].name;
				widgetPackage.documentAdress = documentAdress;
				widgetPackage.isOpened = ( documentAdress.folderID == m_openedMailAdress.folderID ) && ( documentAdress.documentID == m_openedMailAdress.documentID );
				widgetPackage.documentType = EDocumentType.MAIL;
				widgetPackage.ownerID = GetID();
				widgetPackage.questInfo = dataElement.questInfo;
				widgetPackage.wasRead = dataElement.wasRead;
				widgetPackages.PushBack( widgetPackage );
			}
		}
		return widgetPackages;
	}

	protected virtual function GetFileThumbnailWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.FileThumbnailWidget().GetID();
	}

	public function GetFileThumbnailWidgets() : array< SDocumentThumbnailWidgetPackage >
	{
		var i : Int32;
		var k : Int32;
		var dataElement : DataElement;
		var widgetPackage : SDocumentThumbnailWidgetPackage;
		var widgetPackages : array< SDocumentThumbnailWidgetPackage >;
		var tweakID : TweakDBID;
		var journalFile : weak< JournalFile >;
		var documentAdress : SDocumentAdress;
		tweakID = GetFileThumbnailWidgetTweakDBID();
		widgetPackage.widgetTweakDBID = tweakID;
		SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
		widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
		if( !( widgetPackage.isValid ) )
		{
			return widgetPackages;
		}
		for( i = 0; i < m_computerSetup.m_filesStructure.Size(); i += 1 )
		{
			for( k = 0; k < m_computerSetup.m_filesStructure[ i ].content.Size(); k += 1 )
			{
				dataElement = m_computerSetup.m_filesStructure[ i ].content[ k ];
				if( !( IsDataElementValid( dataElement ) ) )
				{
					continue;
				}
				journalFile = GetJournalFileEntry( dataElement );
				if( journalFile != NULL )
				{
					widgetPackage.displayName = journalFile.GetTitle();
				}
				else
				{
					widgetPackage.displayName = dataElement.title;
				}
				documentAdress.folderID = i;
				documentAdress.documentID = k;
				widgetPackage.widgetName = ( ( ( "mailThumbnail" + "_" ) + ( ( String )( i ) ) ) + "_" ) + ( ( String )( k ) );
				widgetPackage.folderName = m_computerSetup.m_filesStructure[ i ].name;
				widgetPackage.documentAdress = documentAdress;
				widgetPackage.isOpened = ( documentAdress.folderID == m_openedFileAdress.folderID ) && ( documentAdress.documentID == m_openedFileAdress.documentID );
				widgetPackage.documentType = EDocumentType.FILE;
				widgetPackage.ownerID = GetID();
				widgetPackage.questInfo = dataElement.questInfo;
				widgetPackage.wasRead = dataElement.wasRead;
				widgetPackages.PushBack( widgetPackage );
			}
		}
		return widgetPackages;
	}

	protected virtual function GetMenuButtonWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.MenuButtonWidget().GetID();
	}

	public function GetMenuButtonWidgets() : array< SComputerMenuButtonWidgetPackage >
	{
		var i : Int32;
		var devices : array< DeviceComponentPS >;
		var widgetPackage : SComputerMenuButtonWidgetPackage;
		var widgetPackages : array< SComputerMenuButtonWidgetPackage >;
		var tweakID : TweakDBID;
		tweakID = GetMenuButtonWidgetTweakDBID();
		widgetPackage.widgetTweakDBID = tweakID;
		SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
		widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
		if( !( widgetPackage.isValid ) )
		{
			return widgetPackages;
		}
		if( IsMenuEnabled( EComputerMenuType.MAILS ) )
		{
			for( i = 0; i < m_computerSetup.m_mailsStructure.Size(); i += 1 )
			{
				widgetPackage.counter += GetEnabledDocumentsCount( m_computerSetup.m_mailsStructure[ i ].content, true );
			}
			if( m_computerSetup.m_mailsStructure.Size() > 0 )
			{
				widgetPackage.widgetName = "mails";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Inbox";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconMail';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.FILES ) )
		{
			for( i = 0; i < m_computerSetup.m_filesStructure.Size(); i += 1 )
			{
				widgetPackage.counter += GetEnabledDocumentsCount( m_computerSetup.m_filesStructure[ i ].content, true );
			}
			if( m_computerSetup.m_filesStructure.Size() > 0 )
			{
				widgetPackage.widgetName = "files";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Files";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconFiles';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.NEWSFEED ) )
		{
		}
		if( IsMenuEnabled( EComputerMenuType.SYSTEM ) )
		{
			devices = GetImmediateSlaves();
			if( devices.Size() > 0 )
			{
				widgetPackage.counter = GetEnabledDevicesCount( devices );
				widgetPackage.widgetName = "devices";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-System";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconNetwork';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.INTERNET ) )
		{
			widgetPackage.widgetName = "internet";
			widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Internet";
			widgetPackage.ownerID = GetID();
			widgetPackage.iconID = 'iconInternet';
			widgetPackages.PushBack( widgetPackage );
		}
		return widgetPackages;
	}

	protected virtual function GetMainMenuButtonWidgetTweakDBID() : TweakDBID
	{
		return m_computerUIpreset.MainMenuButtonWidget().GetID();
	}

	public function GetMainMenuButtonWidgets() : array< SComputerMenuButtonWidgetPackage >
	{
		var i : Int32;
		var devices : array< DeviceComponentPS >;
		var widgetPackage : SComputerMenuButtonWidgetPackage;
		var widgetPackages : array< SComputerMenuButtonWidgetPackage >;
		var tweakID : TweakDBID;
		tweakID = GetMainMenuButtonWidgetTweakDBID();
		widgetPackage.widgetTweakDBID = tweakID;
		SWidgetPackageBase.ResolveWidgetTweakDBData( tweakID, widgetPackage.libraryID, widgetPackage.libraryPath );
		widgetPackage.isValid = ResRef.IsValid( widgetPackage.libraryPath ) || IsNameValid( widgetPackage.libraryID );
		if( !( widgetPackage.isValid ) )
		{
			return widgetPackages;
		}
		if( IsMenuEnabled( EComputerMenuType.MAILS ) )
		{
			for( i = 0; i < m_computerSetup.m_mailsStructure.Size(); i += 1 )
			{
				widgetPackage.counter += GetEnabledDocumentsCount( m_computerSetup.m_mailsStructure[ i ].content, true );
			}
			if( m_computerSetup.m_mailsStructure.Size() > 0 )
			{
				widgetPackage.widgetName = "mails";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Inbox";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconMail';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.FILES ) )
		{
			for( i = 0; i < m_computerSetup.m_filesStructure.Size(); i += 1 )
			{
				widgetPackage.counter += GetEnabledDocumentsCount( m_computerSetup.m_filesStructure[ i ].content, true );
			}
			if( m_computerSetup.m_filesStructure.Size() > 0 )
			{
				widgetPackage.widgetName = "files";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Files";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconFiles';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.NEWSFEED ) )
		{
			if( m_computerSetup.m_newsFeed.Size() > 0 )
			{
				widgetPackage.counter = m_computerSetup.m_newsFeed.Size();
				widgetPackage.widgetName = "newsFeed";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-NewsFeed";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'systemLogo';
				widgetPackages.PushBack( widgetPackage );
				widgetPackage.counter = 0;
			}
		}
		if( IsMenuEnabled( EComputerMenuType.MAILS ) )
		{
			devices = GetImmediateSlaves();
			if( devices.Size() > 0 )
			{
				widgetPackage.counter = GetEnabledDevicesCount( devices );
				widgetPackage.widgetName = "devices";
				widgetPackage.displayName = "Gameplay-Devices-Computers-Common-System";
				widgetPackage.ownerID = GetID();
				widgetPackage.iconID = 'iconNetwork';
				widgetPackages.PushBack( widgetPackage );
			}
			widgetPackage.counter = 0;
		}
		if( IsMenuEnabled( EComputerMenuType.INTERNET ) )
		{
			widgetPackage.widgetName = "internet";
			widgetPackage.displayName = "Gameplay-Devices-Computers-Common-Internet";
			widgetPackage.ownerID = GetID();
			widgetPackage.iconID = 'iconInternet';
			widgetPackages.PushBack( widgetPackage );
		}
		return widgetPackages;
	}

	private function IsDataElementValid( const data : ref< DataElement > ) : Bool
	{
		return data.isEnabled && ( data.journalPath.IsValid() || IsStringValid( data.title ) );
	}

	private function GetEnabledDocumentsCount( const documents : ref< array< DataElement > >, optional unredOnly : Bool ) : Int32
	{
		var i : Int32;
		var counter : Int32;
		for( i = 0; i < documents.Size(); i += 1 )
		{
			if( IsDataElementValid( documents[ i ] ) )
			{
				if( unredOnly && documents[ i ].wasRead )
				{
					continue;
				}
				counter += 1;
			}
		}
		return counter;
	}

	private function GetEnabledDevicesCount( const devices : ref< array< DeviceComponentPS > > ) : Int32
	{
		var i : Int32;
		var currentDevice : ScriptableDeviceComponentPS;
		var counter : Int32;
		for( i = 0; i < devices.Size(); i += 1 )
		{
			if( ( ( ScriptableDeviceComponentPS )( devices[ i ] ) ) )
			{
				currentDevice = ( ( ScriptableDeviceComponentPS )( devices[ i ] ) );
				if( currentDevice.IsDisabled() || IsPartOfAnyVirtualSystem( currentDevice ) )
				{
					continue;
				}
				counter += 1;
			}
		}
		return counter + GetVirtualSystemsCount();
	}

	public const function GetFileStructure( data : ref< ComputerUIData > )
	{
		data.mails = m_computerSetup.m_mailsStructure;
		data.files = m_computerSetup.m_filesStructure;
	}

	public const function GetOpenedMailAdress() : SDocumentAdress
	{
		return m_openedMailAdress;
	}

	public const function GetOpenedFileAdress() : SDocumentAdress
	{
		return m_openedFileAdress;
	}

	public const function GetInternetData() : SInternetData
	{
		return m_computerSetup.m_internetSubnet;
	}

	public function SetOpenedMailAdress( documentAdress : SDocumentAdress )
	{
		var wasAlreadyRed : Bool;
		if( ( documentAdress.folderID >= 0 ) && ( documentAdress.documentID >= 0 ) )
		{
			m_openedMailAdress = documentAdress;
			wasAlreadyRed = m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].wasRead;
			m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].wasRead = true;
			if( !( wasAlreadyRed ) )
			{
				RequestMenuButtonWidgetsUpdate( GetBlackboard() );
			}
		}
	}

	public function SetOpenedFileAdress( documentAdress : SDocumentAdress )
	{
		var wasAlreadyRed : Bool;
		if( ( documentAdress.folderID >= 0 ) && ( documentAdress.documentID >= 0 ) )
		{
			m_openedFileAdress = documentAdress;
			wasAlreadyRed = m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].wasRead;
			m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].wasRead = true;
			if( !( wasAlreadyRed ) )
			{
				RequestMenuButtonWidgetsUpdate( GetBlackboard() );
			}
		}
	}

	public function ClearOpenedMailAdress()
	{
		var invalidAdres : SDocumentAdress;
		m_openedMailAdress = invalidAdres;
	}

	public function ClearOpenedFileAdress()
	{
		var invalidAdres : SDocumentAdress;
		m_openedFileAdress = invalidAdres;
	}

	public function EnableDocument( documentType : EDocumentType, documentAdress : SDocumentAdress, isEnabled : Bool )
	{
		var shouldRefresh : Bool;
		if( documentType == EDocumentType.MAIL )
		{
			shouldRefresh = m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEnabled != isEnabled;
			m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEnabled = isEnabled;
		}
		else
		{
			shouldRefresh = m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEnabled != isEnabled;
			m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEnabled = isEnabled;
		}
		if( shouldRefresh )
		{
			RequestMenuButtonWidgetsUpdate( GetBlackboard() );
			RefreshUI( GetBlackboard() );
		}
	}

	public function EnableDocumentsInFolder( documentType : EDocumentType, folderID : Int32, isEnabled : Bool )
	{
		var shouldRefresh : Bool;
		var i : Int32;
		if( documentType == EDocumentType.MAIL )
		{
			for( i = 0; i < m_computerSetup.m_mailsStructure[ folderID ].content.Size(); i += 1 )
			{
				shouldRefresh = m_computerSetup.m_mailsStructure[ folderID ].content[ i ].isEnabled != isEnabled;
				m_computerSetup.m_mailsStructure[ folderID ].content[ i ].isEnabled = isEnabled;
			}
		}
		else
		{
			for( i = 0; i < m_computerSetup.m_filesStructure[ folderID ].content.Size(); i += 1 )
			{
				shouldRefresh = m_computerSetup.m_filesStructure[ folderID ].content[ i ].isEnabled != isEnabled;
				m_computerSetup.m_filesStructure[ folderID ].content[ i ].isEnabled = isEnabled;
			}
		}
		if( shouldRefresh )
		{
			RequestMenuButtonWidgetsUpdate( GetBlackboard() );
			RefreshUI( GetBlackboard() );
		}
	}

	public const function GetDocumentAdressByName( documentType : EDocumentType, documentName : CName ) : SDocumentAdress
	{
		var i : Int32;
		var k : Int32;
		var adress : SDocumentAdress;
		if( documentType == EDocumentType.MAIL )
		{
			for( i = 0; i < m_computerSetup.m_mailsStructure.Size(); i += 1 )
			{
				for( k = 0; k < m_computerSetup.m_mailsStructure[ i ].content.Size(); k += 1 )
				{
					if( m_computerSetup.m_mailsStructure[ i ].content[ k ].documentName == documentName )
					{
						adress.folderID = i;
						adress.documentID = k;
						break;
					}
				}
			}
		}
		else
		{
			for( i = 0; i < m_computerSetup.m_filesStructure.Size(); i += 1 )
			{
				for( k = 0; k < m_computerSetup.m_filesStructure[ i ].content.Size(); k += 1 )
				{
					if( m_computerSetup.m_filesStructure[ i ].content[ k ].documentName == documentName )
					{
						adress.folderID = i;
						adress.documentID = k;
						break;
					}
				}
			}
		}
		return adress;
	}

	public function EnableDocumentsByName( documentType : EDocumentType, documentName : CName, isEnabled : Bool )
	{
		var shouldRefresh : Bool;
		var i : Int32;
		var k : Int32;
		if( documentType == EDocumentType.MAIL )
		{
			for( i = 0; i < m_computerSetup.m_mailsStructure.Size(); i += 1 )
			{
				for( k = 0; k < m_computerSetup.m_mailsStructure[ i ].content.Size(); k += 1 )
				{
					if( m_computerSetup.m_mailsStructure[ i ].content[ k ].documentName != documentName )
					{
						continue;
					}
					if( !( shouldRefresh ) )
					{
						shouldRefresh = m_computerSetup.m_mailsStructure[ i ].content[ k ].isEnabled != isEnabled;
					}
					m_computerSetup.m_mailsStructure[ i ].content[ k ].isEnabled = isEnabled;
				}
			}
		}
		else
		{
			for( i = 0; i < m_computerSetup.m_filesStructure.Size(); i += 1 )
			{
				for( k = 0; k < m_computerSetup.m_filesStructure[ i ].content.Size(); k += 1 )
				{
					if( m_computerSetup.m_filesStructure[ i ].content[ k ].documentName != documentName )
					{
						continue;
					}
					if( !( shouldRefresh ) )
					{
						shouldRefresh = m_computerSetup.m_filesStructure[ i ].content[ k ].isEnabled != isEnabled;
					}
					m_computerSetup.m_filesStructure[ i ].content[ k ].isEnabled = isEnabled;
				}
			}
		}
		if( shouldRefresh )
		{
			RequestMenuButtonWidgetsUpdate( GetBlackboard() );
			RefreshUI( GetBlackboard() );
		}
	}

	public function EncryptFile( documentAdress : SDocumentAdress )
	{
		m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEncrypted = true;
	}

	public function DecryptFile( documentAdress : SDocumentAdress )
	{
		m_computerSetup.m_filesStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEncrypted = false;
	}

	public function EncryptMail( documentAdress : SDocumentAdress )
	{
		m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEncrypted = true;
	}

	public function DecryptMail( documentAdress : SDocumentAdress )
	{
		m_computerSetup.m_mailsStructure[ documentAdress.folderID ].content[ documentAdress.documentID ].isEncrypted = false;
	}

	protected const override function GetKeypadWidgetStyle() : TweakDBID
	{
		return m_computerUIpreset.KeypadWidget().GetID();
	}

	public function PushData( const data : ref< ComputerPersistentData > ) {}

	public override function OnAuthorizeUser( evt : AuthorizeUser ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetAll();
		if( UserAuthorizationAttempt( evt.GetExecutor().GetEntityID(), evt.GetEnteredPassword() ) )
		{
			ResolveOtherSkillchecks();
		}
		Notify( notifier, evt );
		return EntityNotificationType.DoNotNotifyEntity;
	}

	protected override function OnFillTakeOverChainBBoardEvent( evt : FillTakeOverChainBBoardEvent ) : EntityNotificationType
	{
		FillTakeOverChainBB();
		return EntityNotificationType.DoNotNotifyEntity;
	}

	public override function TurnAuthorizationModuleOFF()
	{
		m_authorizationProperties.m_isAuthorizationModuleOn = false;
		m_computerSetup.m_ignoreSlaveAuthorizationModule = true;
	}

	protected function GetJournalMailEntry( const dataElement : ref< DataElement > ) : weak< JournalEmail >
	{
		var journalHash : Uint32;
		var journalManager : JournalManager;
		var journalEmail : weak< JournalEmail >;
		if( dataElement.journalPath == NULL )
		{
			return journalEmail;
		}
		journalHash = dataElement.journalPath.GetHash();
		journalManager = GameInstance.GetJournalManager( GetGameInstance() );
		return ( ( JournalEmail )( journalManager.GetEntry( journalHash ) ) );
	}

	protected function GetJournalFileEntry( const dataElement : ref< DataElement > ) : weak< JournalFile >
	{
		var journalHash : Uint32;
		var journalManager : JournalManager;
		var journalFile : weak< JournalFile >;
		if( dataElement.journalPath == NULL )
		{
			return journalFile;
		}
		journalHash = dataElement.journalPath.GetHash();
		journalManager = GameInstance.GetJournalManager( GetGameInstance() );
		return ( ( JournalFile )( journalManager.GetEntry( journalHash ) ) );
	}

	public override function OnToggleZoomInteraction( evt : ToggleZoomInteraction ) : EntityNotificationType
	{
		SetIsInSleepMode( false );
		return super.OnToggleZoomInteraction( evt );
	}

	public override function OnQuestForceCameraZoom( evt : QuestForceCameraZoom ) : EntityNotificationType
	{
		if( ( ( Bool )evt.prop.first ) )
		{
			SetIsInSleepMode( false );
		}
		return super.OnQuestForceCameraZoom( evt );
	}

}

