class ComputerMainLayoutWidgetController extends inkLogicController
{
	[ category = "Widget Refs" ]
	protected editable var m_screenSaverSlot : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_wallpaperSlot : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_menuButtonList : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_menuContainer : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_internetContainer : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_offButton : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_windowCloseButton : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_windowContainer : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_windowHeader : inkTextRef;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_menuMailsID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_menuFilesID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_menuNewsFeedID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_menuMainID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_internetBrowserID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_screenSaverID : TweakDBID;
	[ category = "TweakDB" ][ customEditor = "TweakDBGroupInheritance;WidgetDefinition" ]
	protected editable var m_wallpaperID : TweakDBID;
	[ category = "Animations" ]
	protected editable var m_windowCloseAanimation : CName;
	default m_windowCloseAanimation = 'windowClose_16x9';
	[ category = "Animations" ]
	protected editable var m_windowOpenAanimation : CName;
	default m_windowOpenAanimation = 'windowOpen_16x9';
	protected var m_currentScreenSaverLibraryID : CName;
	protected var m_currentWallpaperLibraryID : CName;
	private var m_computerMenuButtonWidgetsData : array< SComputerMenuButtonWidgetPackage >;
	protected var m_mailsMenu : weak< inkWidget >;
	protected var m_filesMenu : weak< inkWidget >;
	protected var m_devicesMenu : weak< inkWidget >;
	protected var m_newsFeedMenu : weak< inkWidget >;
	protected var m_internetData : weak< inkWidget >;
	protected var m_mainMenu : weak< inkWidget >;
	protected var m_screenSaver : weak< inkWidget >;
	protected var m_wallpaper : weak< inkWidget >;
	protected var m_isInitialized : Bool;
	private var m_devicesMenuInitialized : Bool;
	private var m_isWindowOpened : Bool;
	private var m_activeWindowID : String;
	private var m_menuToOpen : EComputerMenuType;
	default m_menuToOpen = EComputerMenuType.INVALID;

	public virtual function Initialize( gameController : ComputerInkGameController )
	{
		HideWindow();
		SetScreenSaver( gameController, inkWidgetRef.Get( m_screenSaverSlot ) );
		SetWallpaper( gameController, inkWidgetRef.Get( m_wallpaperSlot ) );
		SetFilesMenu( gameController, GetFilesMenuContainer() );
		SetMailsMenu( gameController, GetMailsMenuContainer() );
		SetNewsFeedMenu( gameController, GetNewsfeedMenuContainer() );
		SetMainMenu( gameController );
		SetInternetMenu( gameController );
		m_isInitialized = true;
	}

	public virtual function InitializeMenuButtons( gameController : ComputerInkGameController, const widgetsData : ref< array< SComputerMenuButtonWidgetPackage > > )
	{
		var i : Int32;
		var widget : inkWidget;
		HideMenuButtonWidgets();
		for( i = 0; i < widgetsData.Size(); i += 1 )
		{
			widget = GetMenuButtonWidget( widgetsData[ i ], gameController );
			if( widget == NULL )
			{
				CreateMenuButtonWidgetAsync( gameController, inkWidgetRef.Get( m_menuButtonList ), widgetsData[ i ] );
			}
			else
			{
				InitializeMenuButtonWidget( gameController, widget, widgetsData[ i ] );
			}
		}
	}

	public virtual function SetTopNavigationBarHidden( isHidden : Bool )
	{
		inkWidgetRef.SetVisible( m_menuButtonList, !( isHidden ) );
		GetRootWidget().SetMargin( 0.0, ( ( isHidden ) ? ( -290.0 ) : ( 0.0 ) ), 0.0, 0.0 );
		GetWindow().SetScale( ( ( isHidden ) ? ( Vector2( 1.0, 1.0 ) ) : ( Vector2( 0.80000001, 0.80000001 ) ) ) );
		inkWidgetRef.SetInteractive( m_windowCloseButton, !( isHidden ) );
	}

	private function GetWindow() : weak< inkWidget >
	{
		var root : weak< inkCompoundWidget >;
		root = ( ( inkCompoundWidget )( GetRootWidget() ) );
		return root.GetWidget( 'window' );
	}

	public virtual function SetScreenSaver( gameController : ComputerInkGameController, parentWidget : weak< inkWidget > )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		var screenSaverRecord : WidgetDefinition_Record;
		var newLibraryID : CName;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_screenSaverID ) ) )
		{
			m_screenSaverID = T"DevicesUIDefinitions.ComputerScreenSaverWidget";
		}
		screenSaverRecord = TweakDBInterface.GetWidgetDefinitionRecord( m_screenSaverID );
		newLibraryID = gameController.GetCurrentFullLibraryID( screenSaverRecord, screenDef.screenDefinition.ComputerScreenType(), screenDef.style );
		if( m_currentScreenSaverLibraryID == newLibraryID )
		{
			return;
		}
		if( m_screenSaver != NULL )
		{
			( ( inkCompoundWidget )( inkWidgetRef.Get( m_screenSaverSlot ) ) ).RemoveChild( m_screenSaver );
		}
		m_currentScreenSaverLibraryID = newLibraryID;
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnScreenSaverSpawned', NULL, this );
		gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( m_screenSaverID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnScreenSaverSpawned( widget : inkWidget, userData : IScriptable )
	{
		m_screenSaver = widget;
		if( m_screenSaver )
		{
			m_screenSaver.SetAnchor( inkEAnchor.Centered );
			m_screenSaver.SetAnchorPoint( 0.5, 0.5 );
		}
	}

	public virtual function SetWallpaper( gameController : ComputerInkGameController, parentWidget : weak< inkWidget > )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		var screenSaverRecord : WidgetDefinition_Record;
		var newLibraryID : CName;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_wallpaperID ) ) )
		{
			m_wallpaperID = T"DevicesUIDefinitions.ComputerWallpaperWidget";
		}
		screenSaverRecord = TweakDBInterface.GetWidgetDefinitionRecord( m_wallpaperID );
		newLibraryID = gameController.GetCurrentFullLibraryID( screenSaverRecord, screenDef.screenDefinition.ComputerScreenType(), screenDef.style );
		if( m_currentWallpaperLibraryID == newLibraryID )
		{
			return;
		}
		if( m_screenSaver != NULL )
		{
			( ( inkCompoundWidget )( inkWidgetRef.Get( m_wallpaperSlot ) ) ).RemoveChild( m_wallpaper );
		}
		m_currentWallpaperLibraryID = newLibraryID;
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnWallpaperSpawned', NULL, this );
		gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( m_wallpaperID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnWallpaperSpawned( widget : inkWidget, userData : IScriptable )
	{
		m_wallpaper = widget;
		if( m_wallpaper )
		{
			m_wallpaper.SetAnchor( inkEAnchor.Centered );
			m_screenSaver.SetAnchorPoint( 0.5, 0.5 );
			m_wallpaper.SetVisible( false );
		}
	}

	public virtual function SetMailsMenu( gameController : ComputerInkGameController, parentWidget : weak< inkWidget > )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_menuMailsID ) ) )
		{
			m_menuMailsID = T"DevicesUIDefinitions.MenuMailsWidget";
		}
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnMailsMenuSpawned', NULL, gameController );
		gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( m_menuMailsID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnMailsMenuSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var gameController : ComputerInkGameController;
		var element : SBreadcrumbElementData;
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData )
		{
			gameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
		}
		if( gameController )
		{
			if( widget != NULL )
			{
				m_mailsMenu = widget;
				m_mailsMenu.SetAnchor( inkEAnchor.Fill );
			}
			element = gameController.GetActiveBreadcrumbElement();
			if( element.elementName == "mails" )
			{
				gameController.ShowMails();
			}
			else
			{
				m_mailsMenu.SetVisible( false );
			}
		}
	}

	public virtual function SetFilesMenu( gameController : ComputerInkGameController, parentWidget : weak< inkWidget > )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_menuFilesID ) ) )
		{
			m_menuFilesID = T"DevicesUIDefinitions.MenuFilesWidget";
		}
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnFilesMenuSpawned', NULL, gameController );
		gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( m_menuFilesID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnFilesMenuSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var gameController : ComputerInkGameController;
		var element : SBreadcrumbElementData;
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData )
		{
			gameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
		}
		if( gameController )
		{
			if( widget != NULL )
			{
				m_filesMenu = widget;
				m_filesMenu.SetAnchor( inkEAnchor.Fill );
			}
			element = gameController.GetActiveBreadcrumbElement();
			if( element.elementName == "files" )
			{
				gameController.ShowFiles();
			}
			else
			{
				m_filesMenu.SetVisible( false );
			}
		}
	}

	public virtual function SetDevicesMenu( widget : inkWidget )
	{
		m_devicesMenu = widget;
		m_devicesMenu.SetAnchor( inkEAnchor.Fill );
	}

	public virtual function SetNewsFeedMenu( gameController : ComputerInkGameController, parentWidget : weak< inkWidget > )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_menuNewsFeedID ) ) )
		{
			m_menuNewsFeedID = T"DevicesUIDefinitions.MenuNewsFeedWidget";
		}
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnNewsFeedMenuSpawned', NULL, gameController );
		gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( m_menuNewsFeedID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnNewsFeedMenuSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var gameController : ComputerInkGameController;
		var element : SBreadcrumbElementData;
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData )
		{
			gameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
		}
		if( gameController )
		{
			if( widget != NULL )
			{
				m_newsFeedMenu = widget;
				m_newsFeedMenu.SetAnchor( inkEAnchor.Fill );
			}
			element = gameController.GetActiveBreadcrumbElement();
			if( element.elementName == "newsFeed" )
			{
				gameController.ShowNewsfeed();
			}
			else
			{
				m_newsFeedMenu.SetVisible( false );
			}
		}
	}

	public virtual function SetMainMenu( gameController : ComputerInkGameController )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_menuMainID ) ) )
		{
			m_menuMainID = T"DevicesUIDefinitions.MenuMainWidget";
		}
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnMainMenuSpawned', NULL, gameController );
		gameController.RequestWidgetFromLibrary( inkWidgetRef.Get( m_menuContainer ), TweakDBInterface.GetWidgetDefinitionRecord( m_menuMainID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
	}

	protected event OnMainMenuSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var gameController : ComputerInkGameController;
		var element : SBreadcrumbElementData;
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData )
		{
			gameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
		}
		if( gameController )
		{
			if( widget != NULL )
			{
				m_mainMenu = widget;
				m_mainMenu.SetAnchor( inkEAnchor.Fill );
			}
			element = gameController.GetActiveBreadcrumbElement();
			if( element.elementName == "mainMenu" )
			{
				gameController.ShowMainMenu();
			}
			else
			{
				m_mainMenu.SetVisible( false );
			}
		}
	}

	public virtual function SetInternetMenu( gameController : ComputerInkGameController )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		screenDef = gameController.GetScreenDefinition();
		if( !( TDBID.IsValid( m_internetBrowserID ) ) )
		{
			m_internetBrowserID = T"DevicesUIDefinitions.InternetBrowserWidget";
		}
		spawnData = new AsyncSpawnData;
		spawnData.Initialize( this, 'OnInternetMenuSpawned', NULL, gameController );
		if( inkWidgetRef.IsValid( m_internetContainer ) )
		{
			gameController.RequestWidgetFromLibrary( inkWidgetRef.Get( m_internetContainer ), TweakDBInterface.GetWidgetDefinitionRecord( m_internetBrowserID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
		}
		else
		{
			gameController.RequestWidgetFromLibrary( inkWidgetRef.Get( m_menuContainer ), TweakDBInterface.GetWidgetDefinitionRecord( m_internetBrowserID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, , , spawnData );
		}
	}

	protected event OnInternetMenuSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var gameController : ComputerInkGameController;
		var element : SBreadcrumbElementData;
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData )
		{
			gameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
		}
		if( gameController )
		{
			if( widget != NULL )
			{
				m_internetData = widget;
				m_internetData.SetAnchor( inkEAnchor.Fill );
			}
			element = gameController.GetActiveBreadcrumbElement();
			if( element.elementName == "internet" )
			{
				gameController.ShowInternet();
			}
			else
			{
				m_internetData.SetVisible( false );
			}
		}
	}

	public function ShowScreenSaver()
	{
		inkWidgetRef.SetVisible( m_screenSaverSlot, true );
	}

	public function HideScreenSaver()
	{
		inkWidgetRef.SetVisible( m_screenSaverSlot, false );
	}

	public function ShowWallpaper()
	{
		m_wallpaper.SetVisible( true );
	}

	public function HideWallpaper()
	{
		if( m_wallpaper )
		{
			m_wallpaper.SetVisible( false );
		}
	}

	public virtual function ShowNewsfeed()
	{
		GetFileMenuController().HideFileThumbnailWidgets();
		GetMailMenuController().HideFileThumbnailWidgets();
		m_newsFeedMenu.SetVisible( true );
		m_mailsMenu.SetVisible( false );
		m_filesMenu.SetVisible( false );
		m_devicesMenu.SetVisible( false );
		m_mainMenu.SetVisible( false );
		m_internetData.SetVisible( false );
		ShowWindow( "LocKey#40", EComputerMenuType.NEWSFEED );
		if( m_menuToOpen == EComputerMenuType.NEWSFEED )
		{
			m_newsFeedMenu.SetVisible( false );
		}
	}

	public virtual function ShowMails()
	{
		GetFileMenuController().HideFileThumbnailWidgets();
		GetNewsFeedController().HideBannerWidgets();
		m_mailsMenu.SetVisible( true );
		m_filesMenu.SetVisible( false );
		m_devicesMenu.SetVisible( false );
		m_newsFeedMenu.SetVisible( false );
		m_mainMenu.SetVisible( false );
		m_internetData.SetVisible( false );
		HideFullBanner();
		ShowWindow( "LocKey#42", EComputerMenuType.MAILS );
		if( m_menuToOpen == EComputerMenuType.MAILS )
		{
			m_mailsMenu.SetVisible( false );
		}
	}

	public virtual function ShowFiles()
	{
		GetMailMenuController().HideFileThumbnailWidgets();
		GetNewsFeedController().HideBannerWidgets();
		m_filesMenu.SetVisible( true );
		m_mailsMenu.SetVisible( false );
		m_devicesMenu.SetVisible( false );
		m_newsFeedMenu.SetVisible( false );
		m_mainMenu.SetVisible( false );
		m_internetData.SetVisible( false );
		HideFullBanner();
		ShowWindow( "LocKey#41", EComputerMenuType.FILES );
		if( m_menuToOpen == EComputerMenuType.FILES )
		{
			m_filesMenu.SetVisible( false );
		}
	}

	public virtual function ShowDevices()
	{
		m_devicesMenu.SetVisible( true );
		m_mailsMenu.SetVisible( false );
		m_filesMenu.SetVisible( false );
		m_mainMenu.SetVisible( false );
		m_newsFeedMenu.SetVisible( false );
		m_internetData.SetVisible( false );
		HideFullBanner();
		ShowWindow( "LocKey#43", EComputerMenuType.SYSTEM );
		if( m_menuToOpen == EComputerMenuType.SYSTEM )
		{
			m_devicesMenu.SetVisible( false );
		}
	}

	public virtual function ShowMainMenu()
	{
		GetFileMenuController().HideFileThumbnailWidgets();
		GetNewsFeedController().HideBannerWidgets();
		GetMailMenuController().HideFileThumbnailWidgets();
		m_mailsMenu.SetVisible( false );
		m_filesMenu.SetVisible( false );
		m_devicesMenu.SetVisible( false );
		m_newsFeedMenu.SetVisible( false );
		m_internetData.SetVisible( false );
	}

	public virtual function ShowInternet( const startingPage : ref< String > )
	{
		GetNewsFeedController().HideBannerWidgets();
		GetFileMenuController().HideFileThumbnailWidgets();
		GetMailMenuController().HideFileThumbnailWidgets();
		GetInternetController().SetDefaultPage( startingPage );
		m_mailsMenu.SetVisible( false );
		m_filesMenu.SetVisible( false );
		m_devicesMenu.SetVisible( false );
		m_newsFeedMenu.SetVisible( false );
		m_internetData.SetVisible( true );
		m_mainMenu.SetVisible( false );
		HideFullBanner();
		ShowWindow( "LocKey#113", EComputerMenuType.INTERNET );
		if( m_menuToOpen == EComputerMenuType.INTERNET )
		{
			m_internetData.SetVisible( false );
		}
	}

	public function ShowWindow( const header : ref< String >, menuType : EComputerMenuType )
	{
		if( m_isWindowOpened && m_activeWindowID != header )
		{
			m_menuToOpen = menuType;
			HideWindow();
			return;
		}
		GetWindowContainer().SetVisible( true );
		GetWindowHeader().SetText( header );
		if( !( m_isWindowOpened ) && IsNameValid( m_windowOpenAanimation ) )
		{
			PlayLibraryAnimation( m_windowOpenAanimation ).RegisterToCallback( inkanimEventType.OnFinish, this, 'OnWindowOpened' );
		}
		m_isWindowOpened = true;
		m_activeWindowID = header;
	}

	protected event OnWindowOpened( e : inkAnimProxy )
	{
		e.UnregisterFromCallback( inkanimEventType.OnFinish, this, 'OnWindowOpened' );
	}

	public function HideWindow()
	{
		DeselectAllManuButtons();
		if( m_isWindowOpened && IsNameValid( m_windowCloseAanimation ) )
		{
			PlayLibraryAnimation( m_windowCloseAanimation ).RegisterToCallback( inkanimEventType.OnFinish, this, 'OnWindowClosed' );
		}
		else
		{
			GetWindowContainer().SetVisible( false );
		}
		m_isWindowOpened = false;
		m_activeWindowID = "";
	}

	protected event OnWindowClosed( e : inkAnimProxy )
	{
		e.UnregisterFromCallback( inkanimEventType.OnFinish, this, 'OnWindowClosed' );
		GetWindowContainer().SetVisible( false );
		ResolveWindowClose();
	}

	private function ResolveWindowClose()
	{
		var menuToOpen : EComputerMenuType;
		menuToOpen = m_menuToOpen;
		m_menuToOpen = EComputerMenuType.INVALID;
		if( menuToOpen == EComputerMenuType.INVALID )
		{
			return;
		}
		else if( menuToOpen == EComputerMenuType.INTERNET )
		{
			ShowInternet( GetInternetController().GetDefaultpage() );
		}
		else if( menuToOpen == EComputerMenuType.SYSTEM )
		{
			ShowDevices();
		}
		else if( menuToOpen == EComputerMenuType.MAILS )
		{
			ShowMails();
		}
		else if( menuToOpen == EComputerMenuType.FILES )
		{
			ShowFiles();
		}
		else if( menuToOpen == EComputerMenuType.NEWSFEED )
		{
			ShowNewsfeed();
		}
		else if( menuToOpen == EComputerMenuType.MAIN )
		{
			ShowMainMenu();
		}
	}

	public function MarkManuButtonAsSelected( controller : ComputerMenuButtonController )
	{
		var i : Int32;
		var currentController : ComputerMenuButtonController;
		for( i = 0; i < m_computerMenuButtonWidgetsData.Size(); i += 1 )
		{
			if( m_computerMenuButtonWidgetsData[ i ].widget != NULL )
			{
				currentController = ( ( ComputerMenuButtonController )( m_computerMenuButtonWidgetsData[ i ].widget.GetController() ) );
				if( currentController && ( currentController == controller ) )
				{
					currentController.ToggleSelection( true );
				}
				else
				{
					currentController.ToggleSelection( false );
				}
			}
		}
	}

	public function MarkManuButtonAsSelected( const menuID : ref< String > )
	{
		var i : Int32;
		var currentController : ComputerMenuButtonController;
		for( i = 0; i < m_computerMenuButtonWidgetsData.Size(); i += 1 )
		{
			if( m_computerMenuButtonWidgetsData[ i ].widget != NULL )
			{
				currentController = ( ( ComputerMenuButtonController )( m_computerMenuButtonWidgetsData[ i ].widget.GetController() ) );
				if( currentController && currentController.GetMenuID() == menuID )
				{
					currentController.ToggleSelection( true );
				}
				else
				{
					currentController.ToggleSelection( false );
				}
			}
		}
	}

	public function DeselectAllManuButtons()
	{
		var i : Int32;
		var currentController : ComputerMenuButtonController;
		for( i = 0; i < m_computerMenuButtonWidgetsData.Size(); i += 1 )
		{
			if( m_computerMenuButtonWidgetsData[ i ].widget != NULL )
			{
				currentController = ( ( ComputerMenuButtonController )( m_computerMenuButtonWidgetsData[ i ].widget.GetController() ) );
				if( currentController )
				{
					currentController.ToggleSelection( false );
				}
			}
		}
	}

	protected function GetWindowContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_windowContainer );
	}

	protected function GetWindowHeader() : weak< inkText >
	{
		return ( ( inkText )( inkTextRef.Get( m_windowHeader ) ) );
	}

	public function GetOffButton() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_offButton );
	}

	public function GetWindowCloseButton() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_windowCloseButton );
	}

	public function GetMenuContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_menuContainer );
	}

	public virtual function GetDevicesMenuContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_menuContainer );
	}

	public virtual function GetNewsfeedMenuContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_menuContainer );
	}

	public virtual function GetMailsMenuContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_menuContainer );
	}

	public virtual function GetFilesMenuContainer() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_menuContainer );
	}

	protected function GetFileMenuController() : ComputerMenuWidgetController
	{
		if( m_filesMenu )
		{
			return ( ( ComputerMenuWidgetController )( m_filesMenu.GetController() ) );
		}
		else
		{
			return NULL;
		}
	}

	public function GetFileThumbnailController( adress : SDocumentAdress ) : ComputerDocumentThumbnailWidgetController
	{
		return GetFileMenuController().GetThumbnailController( adress );
	}

	protected function GetMailMenuController() : ComputerMenuWidgetController
	{
		if( m_mailsMenu )
		{
			return ( ( ComputerMenuWidgetController )( m_mailsMenu.GetController() ) );
		}
		else
		{
			return NULL;
		}
	}

	public function GetMailThumbnailController( adress : SDocumentAdress ) : ComputerDocumentThumbnailWidgetController
	{
		return GetMailMenuController().GetThumbnailController( adress );
	}

	protected function GetNewsFeedController() : NewsFeedMenuWidgetController
	{
		if( m_newsFeedMenu )
		{
			return ( ( NewsFeedMenuWidgetController )( m_newsFeedMenu.GetController() ) );
		}
		else
		{
			return NULL;
		}
	}

	protected function GetMainMenuController() : ComputerMainMenuWidgetController
	{
		if( m_mainMenu )
		{
			return ( ( ComputerMainMenuWidgetController )( m_mainMenu.GetController() ) );
		}
		else
		{
			return NULL;
		}
	}

	protected function GetInternetController() : BrowserController
	{
		if( m_internetData )
		{
			return ( ( BrowserController )( m_internetData.GetController() ) );
		}
		else
		{
			return NULL;
		}
	}

	public function InitializeMails( gameController : ComputerInkGameController, const widgetsData : ref< array< SDocumentWidgetPackage > > )
	{
		var controller : ComputerMenuWidgetController;
		controller = GetMailMenuController();
		if( controller )
		{
			controller.InitializeFiles( gameController, widgetsData );
		}
	}

	public function InitializeFiles( gameController : ComputerInkGameController, const widgetsData : ref< array< SDocumentWidgetPackage > > )
	{
		var controller : ComputerMenuWidgetController;
		controller = GetFileMenuController();
		if( controller )
		{
			controller.InitializeFiles( gameController, widgetsData );
		}
	}

	public function InitializeMailsThumbnails( gameController : ComputerInkGameController, const widgetsData : ref< array< SDocumentThumbnailWidgetPackage > > )
	{
		var controller : ComputerMenuWidgetController;
		controller = GetMailMenuController();
		if( controller )
		{
			controller.InitializeFilesThumbnails( gameController, widgetsData );
		}
	}

	public function InitializeFilesThumbnails( gameController : ComputerInkGameController, const widgetsData : ref< array< SDocumentThumbnailWidgetPackage > > )
	{
		var controller : ComputerMenuWidgetController;
		controller = GetFileMenuController();
		if( controller )
		{
			controller.InitializeFilesThumbnails( gameController, widgetsData );
		}
	}

	public function InitializeBanners( gameController : ComputerInkGameController, const widgetsData : ref< array< SBannerWidgetPackage > > )
	{
		var controller : NewsFeedMenuWidgetController;
		controller = GetNewsFeedController();
		if( controller )
		{
			controller.InitializeBanners( gameController, widgetsData );
		}
	}

	public function InitializeMainMenuButtons( gameController : ComputerInkGameController, const widgetsData : ref< array< SComputerMenuButtonWidgetPackage > > )
	{
		var controller : ComputerMainMenuWidgetController;
		controller = GetMainMenuController();
		if( controller )
		{
			controller.InitializeMenuButtons( gameController, widgetsData );
		}
	}

	public function ShowFullBanner( gameController : ComputerInkGameController, const widgetData : ref< SBannerWidgetPackage > )
	{
		var controller : NewsFeedMenuWidgetController;
		controller = GetNewsFeedController();
		if( controller )
		{
			controller.ShowFullBanner( gameController, widgetData );
		}
	}

	public function HideNewsFeed()
	{
		HideBanners();
		HideFullBanner();
	}

	public function HideFullBanner()
	{
		GetNewsFeedController().HideFullBanner();
	}

	public function HideBanners()
	{
		var controller : NewsFeedMenuWidgetController;
		controller = GetNewsFeedController();
		if( controller )
		{
			controller.HideBannerWidgets();
		}
	}

	public function HideMails()
	{
		var controller : ComputerMenuWidgetController;
		controller = GetMailMenuController();
		if( controller )
		{
			controller.HideFileWidgets();
		}
	}

	public function MarkMailThumbnailAsSelected( controller : ComputerDocumentThumbnailWidgetController )
	{
		var menuController : ComputerMenuWidgetController;
		menuController = GetMailMenuController();
		if( menuController )
		{
			menuController.MarkThumbnailAsSelected( controller );
		}
	}

	public function MarkMailThumbnailAsSelected( adress : SDocumentAdress )
	{
		var menuController : ComputerMenuWidgetController;
		menuController = GetMailMenuController();
		if( menuController )
		{
			menuController.MarkThumbnailAsSelected( adress );
		}
	}

	public function HideFiles()
	{
		var controller : ComputerMenuWidgetController;
		controller = GetFileMenuController();
		if( controller )
		{
			controller.HideFileWidgets();
		}
	}

	public function MarkFileThumbnailAsSelected( controller : ComputerDocumentThumbnailWidgetController )
	{
		var menuController : ComputerMenuWidgetController;
		menuController = GetFileMenuController();
		if( menuController )
		{
			menuController.MarkThumbnailAsSelected( controller );
		}
	}

	public function HideDevices()
	{
		if( m_devicesMenu )
		{
			m_devicesMenu.SetVisible( false );
		}
	}

	public function HideMainMenu()
	{
		if( m_mainMenu )
		{
			m_mainMenu.SetVisible( false );
		}
	}

	public function HideInternet()
	{
		if( m_internetData )
		{
			m_internetData.SetVisible( false );
		}
	}

	protected function CreateMenuButtonWidgetAsync( gameController : ComputerInkGameController, parentWidget : weak< inkWidget >, widgetData : SComputerMenuButtonWidgetPackage )
	{
		var screenDef : ScreenDefinitionPackage;
		var spawnData : AsyncSpawnData;
		if( HasMenuButtonWidgetData( widgetData, gameController ) )
		{
			return;
		}
		screenDef = gameController.GetScreenDefinition();
		spawnData = new AsyncSpawnData;
		if( ( ( inkHorizontalPanel )( parentWidget ) ) )
		{
			widgetData.orientation = inkEOrientation.Horizontal;
		}
		else if( ( ( inkVerticalPanel )( parentWidget ) ) )
		{
			widgetData.orientation = inkEOrientation.Vertical;
		}
		spawnData.Initialize( this, 'OnMenuButtonWidgetSpawned', widgetData, gameController );
		widgetData.libraryID = gameController.RequestWidgetFromLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( widgetData.widgetTweakDBID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, widgetData.libraryID, widgetData.libraryPath, spawnData );
		AddMenuButtonWidgetData( widgetData, gameController );
	}

	protected event OnMenuButtonWidgetSpawned( widget : inkWidget, userData : IScriptable )
	{
		var spawnData : AsyncSpawnData;
		var widgetData : SComputerMenuButtonWidgetPackage;
		var deviceGameController : ComputerInkGameController;
		if( widget != NULL )
		{
			widget.SetSizeRule( inkESizeRule.Fixed );
		}
		spawnData = ( ( AsyncSpawnData )( userData ) );
		if( spawnData != NULL )
		{
			deviceGameController = ( ( ComputerInkGameController )( spawnData.m_controller ) );
			widgetData = ( ( SComputerMenuButtonWidgetPackage )spawnData.m_widgetData );
			if( widgetData.orientation == inkEOrientation.Horizontal )
			{
				widget.SetHAlign( inkEHorizontalAlign.Left );
			}
			else if( widgetData.orientation == inkEOrientation.Vertical )
			{
				widget.SetVAlign( inkEVerticalAlign.Top );
			}
			if( deviceGameController != NULL )
			{
				widgetData.widget = widget;
				widgetData.libraryID = spawnData.m_libraryID;
				UpdateMenuButtonWidgetData( widgetData, GetMenuButtonWidgetDataIndex( widgetData, deviceGameController ) );
				InitializeMenuButtonWidget( deviceGameController, widget, widgetData );
			}
		}
	}

	public function CreateMenuButtonWidget( gameController : ComputerInkGameController, parentWidget : weak< inkWidget >, widgetData : SComputerMenuButtonWidgetPackage ) : weak< inkWidget >
	{
		var widget : inkWidget;
		var screenDef : ScreenDefinitionPackage;
		screenDef = gameController.GetScreenDefinition();
		widget = gameController.FindWidgetInLibrary( parentWidget, TweakDBInterface.GetWidgetDefinitionRecord( widgetData.widgetTweakDBID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style, widgetData.libraryID, widgetData.libraryPath );
		if( ( ( inkHorizontalPanel )( parentWidget ) ) )
		{
			widget.SetHAlign( inkEHorizontalAlign.Left );
		}
		else if( ( ( inkVerticalPanel )( parentWidget ) ) )
		{
			widget.SetVAlign( inkEVerticalAlign.Top );
		}
		widget.SetSizeRule( inkESizeRule.Fixed );
		return widget;
	}

	protected function InitializeMenuButtonWidget( gameController : ComputerInkGameController, widget : inkWidget, widgetData : SComputerMenuButtonWidgetPackage )
	{
		var controller : ComputerMenuButtonController;
		controller = ( ( ComputerMenuButtonController )( widget.GetController() ) );
		if( controller != NULL )
		{
			controller.Initialize( gameController, widgetData );
		}
		widget.SetVisible( true );
	}

	protected function HasMenuButtonWidgetData( widgetData : SComputerMenuButtonWidgetPackage, gameController : ComputerInkGameController ) : Bool
	{
		return GetMenuButtonWidgetDataIndex( widgetData, gameController ) >= 0;
	}

	protected function GetMenuButtonWidget( widgetData : SComputerMenuButtonWidgetPackage, gameController : ComputerInkGameController ) : weak< inkWidget >
	{
		var index : Int32;
		index = GetMenuButtonWidgetDataIndex( widgetData, gameController );
		if( ( index >= 0 ) && ( index < m_computerMenuButtonWidgetsData.Size() ) )
		{
			return m_computerMenuButtonWidgetsData[ index ].widget;
		}
		return NULL;
	}

	protected function GetMenuButtonWidgetDataIndex( widgetData : SComputerMenuButtonWidgetPackage, gameController : ComputerInkGameController ) : Int32
	{
		var i : Int32;
		var screenDef : ScreenDefinitionPackage;
		screenDef = gameController.GetScreenDefinition();
		widgetData.libraryID = gameController.GetCurrentFullLibraryID( TweakDBInterface.GetWidgetDefinitionRecord( widgetData.widgetTweakDBID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style );
		for( i = 0; i < m_computerMenuButtonWidgetsData.Size(); i += 1 )
		{
			if( ( ( ( m_computerMenuButtonWidgetsData[ i ].ownerID == widgetData.ownerID && m_computerMenuButtonWidgetsData[ i ].widgetName == widgetData.widgetName ) && ( m_computerMenuButtonWidgetsData[ i ].widgetTweakDBID == widgetData.widgetTweakDBID ) ) && m_computerMenuButtonWidgetsData[ i ].libraryPath == widgetData.libraryPath ) && m_computerMenuButtonWidgetsData[ i ].libraryID == widgetData.libraryID )
			{
				return i;
			}
		}
		return -1;
	}

	protected function AddMenuButtonWidgetData( widgetData : SComputerMenuButtonWidgetPackage, gameController : ComputerInkGameController )
	{
		var screenDef : ScreenDefinitionPackage;
		screenDef = gameController.GetScreenDefinition();
		widgetData.libraryID = gameController.GetCurrentFullLibraryID( TweakDBInterface.GetWidgetDefinitionRecord( widgetData.widgetTweakDBID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style );
		m_computerMenuButtonWidgetsData.PushBack( widgetData );
	}

	protected function AddMenuButtonWidget( widget : inkWidget, widgetData : SComputerMenuButtonWidgetPackage, gameController : ComputerInkGameController ) : weak< inkWidget >
	{
		var screenDef : ScreenDefinitionPackage;
		screenDef = gameController.GetScreenDefinition();
		widgetData.libraryID = gameController.GetCurrentFullLibraryID( TweakDBInterface.GetWidgetDefinitionRecord( widgetData.widgetTweakDBID ), screenDef.screenDefinition.ComputerScreenType(), screenDef.style );
		widgetData.widget = widget;
		m_computerMenuButtonWidgetsData.PushBack( widgetData );
		return widgetData.widget;
	}

	protected function UpdateMenuButtonWidgetData( widgetData : SComputerMenuButtonWidgetPackage, index : Int32 )
	{
		if( ( index >= 0 ) && ( index < m_computerMenuButtonWidgetsData.Size() ) )
		{
			m_computerMenuButtonWidgetsData[ index ] = widgetData;
		}
	}

	protected function HideMenuButtonWidgets()
	{
		var i : Int32;
		for( i = 0; i < m_computerMenuButtonWidgetsData.Size(); i += 1 )
		{
			if( m_computerMenuButtonWidgetsData[ i ].widget != NULL )
			{
				m_computerMenuButtonWidgetsData[ i ].widget.SetVisible( false );
			}
		}
	}

}

