115 lines
3.1 KiB
C++
115 lines
3.1 KiB
C++
|
|
// ===============================================
|
|||
|
|
// 3. SOURCE FILE (.CPP) - TOUS LES INCLUDES
|
|||
|
|
// ===============================================
|
|||
|
|
|
|||
|
|
// YourRundownController.cpp
|
|||
|
|
#include "RundownController.h"
|
|||
|
|
|
|||
|
|
#include "DTFluxUtilitiesModule.h"
|
|||
|
|
#include "Rundown/AvaRundown.h"
|
|||
|
|
#include "Rundown/AvaRundownPage.h"
|
|||
|
|
#include "Engine/Engine.h"
|
|||
|
|
#include "Engine/World.h"
|
|||
|
|
#include "UObject/UObjectGlobals.h"
|
|||
|
|
#include "UObject/ConstructorHelpers.h"
|
|||
|
|
#include "TimerManager.h"
|
|||
|
|
#include "Logging/LogMacros.h"
|
|||
|
|
#include "Components/StaticMeshComponent.h"
|
|||
|
|
#include "Materials/MaterialInterface.h"
|
|||
|
|
#include "Blueprint/UserWidget.h"
|
|||
|
|
|
|||
|
|
DEFINE_LOG_CATEGORY_STATIC(LogYourRundownController, Log, All);
|
|||
|
|
|
|||
|
|
// ===============================================
|
|||
|
|
// 4. IMPLÉMENTATION SIMPLE
|
|||
|
|
// ===============================================
|
|||
|
|
|
|||
|
|
ARundownController::ARundownController()
|
|||
|
|
{
|
|||
|
|
PrimaryActorTick.bCanEverTick = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool ARundownController::LoadRundown(const TSoftObjectPtr<UAvaRundown> RundownAsset)
|
|||
|
|
{
|
|||
|
|
if (RundownAsset.IsNull())
|
|||
|
|
{
|
|||
|
|
UE_LOG(logDTFluxUtilities, Error, TEXT("RundownAsset Null"));
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Charger l'asset rundown
|
|||
|
|
CurrentRundown = RundownAsset.LoadSynchronous();
|
|||
|
|
|
|||
|
|
if (!CurrentRundown)
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Error, TEXT("Failed to load rundown: %s"), *RundownAsset.ToString());
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Initialiser le contexte de playback
|
|||
|
|
CurrentRundown->InitializePlaybackContext();
|
|||
|
|
|
|||
|
|
UE_LOG(LogYourRundownController, Log, TEXT("Successfully loaded rundown: %s"), *RundownAsset.ToString());
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool ARundownController::PlayPage(int32 PageId)
|
|||
|
|
{
|
|||
|
|
if (!CurrentRundown)
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Error, TEXT("No rundown loaded. Call LoadRundown first."));
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Vérifier que la page existe
|
|||
|
|
const FAvaRundownPage& Page = CurrentRundown->GetPage(PageId);
|
|||
|
|
if (!Page.IsValidPage())
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Error, TEXT("Invalid page ID: %d"), PageId);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Jouer la page
|
|||
|
|
bool bSuccess = CurrentRundown->PlayPage(PageId, EAvaRundownPagePlayType::PlayFromStart);
|
|||
|
|
|
|||
|
|
if (bSuccess)
|
|||
|
|
{
|
|||
|
|
CurrentPageId = PageId;
|
|||
|
|
UE_LOG(LogYourRundownController, Log, TEXT("Playing page %d: %s"), PageId, *Page.GetPageName());
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Warning, TEXT("Failed to play page %d"), PageId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return bSuccess;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool ARundownController::StopPage(int32 PageId)
|
|||
|
|
{
|
|||
|
|
if (!CurrentRundown)
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Error, TEXT("No rundown loaded"));
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool bSuccess = CurrentRundown->StopPage(PageId, EAvaRundownPageStopOptions::Default, false);
|
|||
|
|
|
|||
|
|
if (bSuccess)
|
|||
|
|
{
|
|||
|
|
UE_LOG(LogYourRundownController, Log, TEXT("Stopped page %d"), PageId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return bSuccess;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FString ARundownController::ListePages()
|
|||
|
|
{
|
|||
|
|
if (!CurrentRundown)
|
|||
|
|
{
|
|||
|
|
UE_LOG(logDTFluxUtilities, Error, TEXT("No rundown loaded"));
|
|||
|
|
return FString();
|
|||
|
|
}
|
|||
|
|
return FString();
|
|||
|
|
}
|