mirror of
https://github.com/Theaninova/BeatLanguageMapper.git
synced 2026-01-21 01:13:04 +00:00
Mk2Rev1
various bugfixes and such. also bookmarks, temp song loaderm and undo overhaul with near complete multiplayer, but menu items disabled. i really wish i could split this into multiple commits, but i don't know how to work unreal.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "7zpp.h"
|
||||
#include "ListCallback.h"
|
||||
#include "ProgressCallback.h"
|
||||
|
||||
using namespace SevenZip;
|
||||
/**
|
||||
* Forwards events from the 7zpp library to the UE4 listener.
|
||||
*/
|
||||
class ZIPUTILITY_API SevenZipCallbackHandler : public ListCallback, public ProgressCallback
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void OnProgress(const TString& archivePath, uint64 bytes) override;
|
||||
virtual void OnDone(const TString& archivePath) override;
|
||||
virtual void OnFileDone(const TString& archivePath, const TString& filePath, uint64 bytes) override;
|
||||
virtual void OnStartWithTotal(const TString& archivePath, unsigned __int64 totalBytes) override;
|
||||
virtual void OnFileFound(const TString& archivePath, const TString& filePath, int size) override;
|
||||
virtual void OnListingDone(const TString& archivePath) override;
|
||||
virtual bool OnCheckBreak() override;
|
||||
|
||||
uint64 BytesLeft = 0;
|
||||
uint64 TotalBytes = 0;
|
||||
UObject* ProgressDelegate = nullptr;
|
||||
FThreadSafeBool bCancelOperation = false;
|
||||
};
|
||||
@@ -0,0 +1,102 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZipUtilityInterface.h"
|
||||
#include "ZipOperation.h"
|
||||
#include "ZipFileFunctionLibrary.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum ZipUtilityCompressionFormat
|
||||
{
|
||||
COMPRESSION_FORMAT_UNKNOWN,
|
||||
COMPRESSION_FORMAT_SEVEN_ZIP,
|
||||
COMPRESSION_FORMAT_ZIP,
|
||||
COMPRESSION_FORMAT_GZIP,
|
||||
COMPRESSION_FORMAT_BZIP2,
|
||||
COMPRESSION_FORMAT_RAR,
|
||||
COMPRESSION_FORMAT_TAR,
|
||||
COMPRESSION_FORMAT_ISO,
|
||||
COMPRESSION_FORMAT_CAB,
|
||||
COMPRESSION_FORMAT_LZMA,
|
||||
COMPRESSION_FORMAT_LZMA86
|
||||
};
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum ZipUtilityCompressionLevel
|
||||
{
|
||||
COMPRESSION_LEVEL_NONE,
|
||||
COMPRESSION_LEVEL_FAST,
|
||||
COMPRESSION_LEVEL_NORMAL
|
||||
};
|
||||
|
||||
class SevenZipCallbackHandler;
|
||||
class UZipFileFunctionInternalCallback;
|
||||
|
||||
/**
|
||||
A blueprint function library encapsulating all zip operations for both C++ and blueprint use.
|
||||
For some operations a UZipOperation object may be returned, if you're interested in it, ensure
|
||||
you guard it from garbage collection by e.g. storing it as a UProperty, otherwise you may safely
|
||||
ignore it.
|
||||
*/
|
||||
|
||||
UCLASS(ClassGroup = ZipUtility, Blueprintable)
|
||||
class ZIPUTILITY_API UZipFileFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
~UZipFileFunctionLibrary();
|
||||
|
||||
/* Unzips file in archive containing Name via ListFilesInArchive/UnzipFiles. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static bool UnzipFileNamed(const FString& archivePath, const FString& Name, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Unzips file in archive containing Name at destination path via ListFilesInArchive/UnzipFilesTo. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static bool UnzipFileNamedTo(const FString& archivePath, const FString& Name, const FString& destinationPath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Unzips the given file indexes in archive at destination path. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static UZipOperation* UnzipFilesTo(const TArray<int32> fileIndices, const FString& archivePath, const FString& destinationPath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Unzips the given file indexes in archive at current path. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static UZipOperation* UnzipFiles(const TArray<int32> fileIndices, const FString& ArchivePath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Unzips archive at current path. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static UZipOperation* Unzip(const FString& ArchivePath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat Format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Lambda C++ simple variant*/
|
||||
static UZipOperation* UnzipWithLambda( const FString& ArchivePath,
|
||||
TFunction<void()> OnDoneCallback,
|
||||
TFunction<void(float)> OnProgressCallback = nullptr,
|
||||
ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Unzips archive at destination path. Automatically determines compression if unknown. Calls ZipUtilityInterface progress events. */
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static UZipOperation* UnzipTo(const FString& ArchivePath, const FString& DestinationPath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
/* Compresses the file or folder given at path and places the file in the same root folder. Calls ZipUtilityInterface progress events. Not all formats are supported for compression.*/
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static UZipOperation* Zip( const FString& FileOrFolderPath,
|
||||
UObject* ZipUtilityInterfaceDelegate,
|
||||
ZipUtilityCompressionFormat Format = COMPRESSION_FORMAT_SEVEN_ZIP,
|
||||
TEnumAsByte<ZipUtilityCompressionLevel> Level = COMPRESSION_LEVEL_NORMAL);
|
||||
|
||||
/* Lambda C++ simple variant*/
|
||||
static UZipOperation* ZipWithLambda( const FString& ArchivePath,
|
||||
TFunction<void()> OnDoneCallback,
|
||||
TFunction<void(float)> OnProgressCallback = nullptr,
|
||||
ZipUtilityCompressionFormat Format = COMPRESSION_FORMAT_UNKNOWN,
|
||||
TEnumAsByte<ZipUtilityCompressionLevel> Level = COMPRESSION_LEVEL_NORMAL);
|
||||
|
||||
|
||||
/*Queries Archive content list, calls ZipUtilityInterface list events (OnFileFound)*/
|
||||
UFUNCTION(BlueprintCallable, Category = ZipUtility)
|
||||
static bool ListFilesInArchive(const FString& ArchivePath, UObject* ZipUtilityInterfaceDelegate, ZipUtilityCompressionFormat format = COMPRESSION_FORMAT_UNKNOWN);
|
||||
|
||||
static FGraphEventRef RunLambdaOnGameThread(TFunction< void()> InFunction);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include "Object.h"
|
||||
#include "ZipOperation.generated.h"
|
||||
|
||||
class SevenZipCallbackHandler;
|
||||
/**
|
||||
* Used to track a zip/unzip operation on the WFULambdaRunnable ThreadPool and allows the ability to terminate the
|
||||
* operation early.
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class ZIPUTILITY_API UZipOperation : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UZipOperation();
|
||||
|
||||
// Stops this zip/unzip if it is still valid. This stop event can occur in two places:
|
||||
// 1. The ThreadPool queue, if it can be stopped here then the operation has not yet started.
|
||||
// 2. The SevenZip layer, once the operation has started, it can be canceled while still running.
|
||||
// Note that calling this carries no guarantees of a successful stop, the end result might be one of:
|
||||
// * The file still got extracted (you were too late)
|
||||
// * The file was never extracted (caught it on time)
|
||||
// * The file was created but is of zero size (oops)
|
||||
// * The file was created, is of non-zero size but is not all there (cut off in the middle)
|
||||
// So, it could be a good idea to do some file housekeeping afterward.
|
||||
UFUNCTION(BlueprintCallable, Category = "Zip Operation")
|
||||
void StopOperation();
|
||||
|
||||
// Set the callback handler
|
||||
void SetCallbackHandler(SevenZipCallbackHandler* Handler);
|
||||
|
||||
// Set the queued work
|
||||
void SetThreadPoolWorker(IQueuedWork* Work);
|
||||
|
||||
private:
|
||||
// A pointer to the callback for this operation. Once the operation completes, this
|
||||
// pointer will become invalid.
|
||||
SevenZipCallbackHandler* CallbackHandler;
|
||||
|
||||
// The work that was queued on the async threadpool in WFULambdaRunnable
|
||||
IQueuedWork* ThreadPoolWork;
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ZipUtilityInterface.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum EZipUtilityCompletionState
|
||||
{
|
||||
SUCCESS,
|
||||
FAILURE_NOT_FOUND,
|
||||
FAILURE_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UZipUtilityInterface : public UInterface
|
||||
{
|
||||
GENERATED_UINTERFACE_BODY()
|
||||
};
|
||||
|
||||
class ZIPUTILITY_API IZipUtilityInterface
|
||||
{
|
||||
GENERATED_IINTERFACE_BODY()
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Called during process as it completes. Currently updates on per file progress.
|
||||
* @param percentage - percentage done
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = ZipUtilityProgressEvents)
|
||||
void OnProgress(const FString& archive, float percentage, int32 bytes);
|
||||
|
||||
/**
|
||||
* Called when whole process is complete (e.g. unzipping completed on archive)
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = ZipUtilityProgressEvents)
|
||||
void OnDone(const FString& archive, EZipUtilityCompletionState CompletionState);
|
||||
|
||||
/**
|
||||
* Called at beginning of process (NB this only supports providing size information for up to 2gb) TODO: fix 32bit BP size issue
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = ZipUtilityProgressEvents)
|
||||
void OnStartProcess(const FString& archive, int32 bytes);
|
||||
|
||||
/**
|
||||
* Called when file process is complete
|
||||
* @param path - path of the file that finished
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = ZipUtilityProgressEvents)
|
||||
void OnFileDone(const FString& archive, const FString& file);
|
||||
|
||||
|
||||
/**
|
||||
* Called when a file is found in the archive (e.g. listing the entries in the archive)
|
||||
* @param path - path of file
|
||||
* @param size - compressed size
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = ZipUtilityListEvents)
|
||||
void OnFileFound(const FString& archive, const FString& file, int32 size);
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ModuleManager.h"
|
||||
|
||||
class ZIPUTILITY_API FZipUtilityModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
//CHN:
|
||||
//Maybe we need to use a public interface to fetch the module methods for C++? get a reference to zipfile etc
|
||||
|
||||
/**
|
||||
* Singleton-like access to this module's interface. This is just for convenience!
|
||||
* Beware of calling this during the shutdown phase, though. Your module might have been unloaded already.
|
||||
*
|
||||
* @return Returns singleton instance, loading the module on demand if needed
|
||||
*/
|
||||
static inline FZipUtilityModule& Get()
|
||||
{
|
||||
return FModuleManager::LoadModuleChecked< FZipUtilityModule >("ZipUtility");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true.
|
||||
*
|
||||
* @return True if the module is loaded and ready to use
|
||||
*/
|
||||
static inline bool IsAvailable()
|
||||
{
|
||||
return FModuleManager::Get().IsModuleLoaded("ZipUtility");
|
||||
}
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
Reference in New Issue
Block a user