class GenericNotificationBaseAction extends IScriptable
{

	public virtual function Execute( data : IScriptable ) : Bool
	{
		return false;
	}

	public virtual function GetLabel() : String
	{
		return "";
	}

}

class TrackQuestNotificationAction extends GenericNotificationBaseAction
{
	var m_questEntry : weak< JournalQuest >;
	var m_journalMgr : weak< JournalManager >;

	public override function Execute( data : IScriptable ) : Bool
	{
		m_journalMgr.TrackEntry( m_questEntry );
		TrackFirstObjective( m_questEntry );
		return true;
	}

	public override function GetLabel() : String
	{
		return "LocKey#42567";
	}

	private function TrackFirstObjective( questEntry : weak< JournalEntry > ) : Bool
	{
		var phaseEntries : array< weak< JournalEntry > >;
		var objectiveEntries : array< weak< JournalEntry > >;
		var filter : JournalRequestStateFilter;
		var i : Int32;
		filter.active = true;
		m_journalMgr.GetChildren( questEntry, filter, phaseEntries );
		for( i = 0; i < phaseEntries.Size(); i += 1 )
		{
			m_journalMgr.GetChildren( phaseEntries[ i ], filter, objectiveEntries );
			if( objectiveEntries.Size() > 0 )
			{
				m_journalMgr.TrackEntry( objectiveEntries[ 0 ] );
				return true;
			}
		}
		return false;
	}

}

class OpenMessengerNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;
	var m_journalEntry : weak< JournalEntry >;

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

	public override function GetLabel() : String
	{
		return "Open Messenger";
	}

	private function ShowMessenger()
	{
		var evt : PhoneMessagePopupEvent;
		evt = new PhoneMessagePopupEvent;
		evt.m_data = new JournalNotificationData;
		evt.m_data.journalEntry = m_journalEntry;
		evt.m_data.queueName = 'modal_popup';
		evt.m_data.notificationName = 'base\gameplay\gui\widgets\notifications\phone_message_popup.inkwidget';
		evt.m_data.isBlocking = true;
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class RefreshSmsMessagerEvent extends Event
{
	var m_data : JournalNotificationData;
}

class KeepPhoneOpenWhenInHubMenuEvent extends Event
{
}

class FocusSmsMessagerEvent extends Event
{
}

class UnfocusSmsMessagerEvent extends Event
{
}

class RequestSmsMessagerCloseEvent extends Event
{
}

class ShowSmsMessagerEvent extends Event
{
}

class HideSmsMessagerEvent extends Event
{
}

class OpenSmsMessengerEvent extends PhoneMessagePopupEvent
{
}

class CloseSmsMessengerEvent extends Event
{
}

class SmsMessangerInitalizedEvent extends Event
{
}

class OpenSmsMessengerAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;
	var m_journalEntry : weak< JournalEntry >;

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

	public override function GetLabel() : String
	{
		return "[DB] Open Messenger";
	}

	private function ShowMessenger()
	{
		var evt : OpenSmsMessengerEvent;
		evt = new OpenSmsMessengerEvent;
		evt.m_data = new JournalNotificationData;
		evt.m_data.journalEntry = m_journalEntry;
		evt.m_data.mode = JournalNotificationMode.HUD;
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class OpenPhoneMessageAction extends GenericNotificationBaseAction
{
	var m_phoneSystem : weak< PhoneSystem >;
	var m_journalEntry : weak< JournalEntry >;

	public override function Execute( data : IScriptable ) : Bool
	{
		var request : UsePhoneRequest;
		request = new UsePhoneRequest;
		request.MessageToOpen = m_journalEntry;
		m_phoneSystem.QueueRequest( request );
		return true;
	}

	public override function GetLabel() : String
	{
		return "[DB] Open Message";
	}

}

class ItemNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;

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

	public override function GetLabel() : String
	{
		return GetLocalizedText( "UI-Notifications-OpenInventory" );
	}

	private function ShowInventory()
	{
		var evt : StartHubMenuEvent;
		evt = new StartHubMenuEvent;
		evt.SetStartMenu( 'inventory_screen' );
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class OpenPerksNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;

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

	public override function GetLabel() : String
	{
		return GetLocalizedText( "UI-Notifications-OpenPerks" );
	}

	private function ShowPerks()
	{
		var evt : StartHubMenuEvent;
		evt = new StartHubMenuEvent;
		evt.SetStartMenu( 'new_perks' );
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class OpenSkillsMenuData extends IScriptable
{
	var openSkills : Bool;
}

class OpenSkillsNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;

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

	public override function GetLabel() : String
	{
		return GetLocalizedText( "UI-Notifications-OpenSkills" );
	}

	private function ShowSkills()
	{
		var evt : StartHubMenuEvent;
		var userData : OpenSkillsMenuData;
		userData = new OpenSkillsMenuData;
		userData.openSkills = true;
		evt = new StartHubMenuEvent;
		evt.SetStartMenu( 'new_perks', 'skills', userData );
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class OpenShardNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : UISystem;

	public override function Execute( data : IScriptable ) : Bool
	{
		var userData : ShardCollectedNotificationViewData;
		var evt : NotifyShardRead;
		userData = ( ( ShardCollectedNotificationViewData )( data ) );
		evt = new NotifyShardRead;
		evt.title = userData.shardTitle;
		evt.text = userData.text;
		evt.entry = userData.entry;
		evt.isCrypted = userData.isCrypted;
		evt.itemID = userData.itemID;
		evt.m_imageId = userData.m_imageId;
		m_eventDispatcher.QueueEvent( evt );
		return true;
	}

	public override function GetLabel() : String
	{
		return GetLocalizedText( "Gameplay-Devices-Interactions-ReadMessage" );
	}

}

class OpenWorldMapNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;

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

	public override function GetLabel() : String
	{
		return "LocKey#52348";
	}

	private function ShowWorldMap()
	{
		var evt : StartHubMenuEvent;
		evt = new StartHubMenuEvent;
		evt.SetStartMenu( 'world_map' );
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

class OpenTarotCollectionNotificationAction extends GenericNotificationBaseAction
{
	var m_eventDispatcher : weak< worlduiIGameController >;

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

	public override function GetLabel() : String
	{
		return "LocKey#77676";
	}

	private function ShowTarotCollection()
	{
		var evt : StartHubMenuEvent;
		evt = new StartHubMenuEvent;
		evt.SetStartMenu( 'tarot_main' );
		m_eventDispatcher.QueueBroadcastEvent( evt );
	}

}

