ue4plugins / LoadingScreen

A plugin for Unreal Engine 4 to expose simple controls for managing load screens.
MIT License
504 stars 163 forks source link

Not working in 4.13(Built from Source) #11

Open mrjamesweston opened 7 years ago

mrjamesweston commented 7 years ago

I've tried to get different video formats to work, but they've yet to work(in .wmv, .mp4 and more). It seems it's just the Unreal Engine 4.13 version

FinalSparkGamestudios commented 7 years ago

I'm not sure if this fixed everything. But here you have a dirty solution. Replace your LoadingScreenModule.cpp with

This:


#include "LoadingScreenPrivatePCH.h"
#include "ILoadingScreenModule.h"

#include "LoadingScreenSettings.h"
#include "MoviePlayer.h"

#include "SSimpleLoadingScreen.h"

#define LOCTEXT_NAMESPACE "LoadingScreen"

class FLoadingScreenModule : public ILoadingScreenModule
{
public:
    FLoadingScreenModule();

    /** IModuleInterface implementation */
    virtual void StartupModule() override;
    virtual void ShutdownModule() override;
    virtual bool IsGameModule() const override

    {
        return true;
    }

private:
    void HandlePrepareLoadingScreen();

    void BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription);

};

IMPLEMENT_MODULE(FLoadingScreenModule, LoadingScreen)

FLoadingScreenModule::FLoadingScreenModule()
{

}

void FLoadingScreenModule::StartupModule()
{
    if ( !IsRunningDedicatedServer() && FSlateApplication::IsInitialized() )
    {

        // Load for cooker reference
        const ULoadingScreenSettings* Settings = GetDefault<ULoadingScreenSettings>();
        for ( const FStringAssetReference& Ref : Settings->StartupScreen.Images )
        {
            Ref.TryLoad();
        }
        for ( const FStringAssetReference& Ref : Settings->DefaultScreen.Images )
        {
            Ref.TryLoad();
        }

        if ( IsMoviePlayerEnabled() )
        {

            GetMoviePlayer()->OnPrepareLoadingScreen().AddRaw(this, &FLoadingScreenModule::HandlePrepareLoadingScreen);
        }

        // Prepare the startup screen, the PrepareLoadingScreen callback won't be called
        // if we've already explictly setup the loading screen.
        BeginLoadingScreen(Settings->DefaultScreen);
    }
}

void FLoadingScreenModule::ShutdownModule()
{
    if ( !IsRunningDedicatedServer() )
    {

        GetMoviePlayer()->StopMovie();
    }
}

void FLoadingScreenModule::HandlePrepareLoadingScreen()
{
    UE_LOG(LogTemp, Warning, TEXT("Preparing loading screen...."));
    const ULoadingScreenSettings* Settings = GetDefault<ULoadingScreenSettings>();
    BeginLoadingScreen(Settings->DefaultScreen);
}

void FLoadingScreenModule::BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription)
{
    FLoadingScreenAttributes LoadingScreen;
    LoadingScreen.MinimumLoadingScreenDisplayTime = ScreenDescription.MinimumLoadingScreenDisplayTime;
    LoadingScreen.bAutoCompleteWhenLoadingCompletes = ScreenDescription.bAutoCompleteWhenLoadingCompletes;
    LoadingScreen.bMoviesAreSkippable = ScreenDescription.bMoviesAreSkippable;
    LoadingScreen.bWaitForManualStop = ScreenDescription.bWaitForManualStop;
    LoadingScreen.MoviePaths = ScreenDescription.MoviePaths;
    LoadingScreen.PlaybackType = EMoviePlaybackType::MT_LoadingLoop;

    if ( ScreenDescription.bShowUIOverlay )
    {
        LoadingScreen.WidgetLoadingScreen = SNew(SSimpleLoadingScreen, ScreenDescription);
    }

        GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);

}

#undef LOCTEXT_NAMESPACE