A modded EditSaber for making beat saber maps.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
10 KiB

  1. # ZipUtility Plugin
  2. [![GitHub release](https://img.shields.io/github/release/getnamo/ziputility-ue4.svg)](https://github.com/getnamo/ziputility-ue4/releases)
  3. [![Github All Releases](https://img.shields.io/github/downloads/getnamo/ziputility-ue4/total.svg)](https://github.com/getnamo/ziputility-ue4/releases)
  4. Event driven, blueprint accessible flexible 7zip compression, archiver, and file manipulation plugin for Unreal Engine 4. Built on [7zip-cpp](https://github.com/getnamo/7zip-cpp) modernization of the [SevenZip++](http://bitbucket.org/cmcnab/sevenzip/wiki/Home) C++ wrapper for accessing the 7-zip COM-like API in 7z.dll and 7za.dll.
  5. Supports the following compression algorithms:
  6. 7Zip, GZip, BZip2, RAR, TAR, ISO, CAB, LZMA, LZMA86.
  7. Plugin works in Windows only.
  8. [Main Forum Thread](https://forums.unrealengine.com/showthread.php?95022-Plugin-ZipUtility-(7zip))
  9. ## Quick Install & Setup ##
  10. 1. [Download](https://github.com/getnamo/ZipUtility-ue4/releases)
  11. 2. Create new or choose project.
  12. 3. Browse to your project folder (typically found at Documents/Unreal Project/{Your Project Root})
  13. 4. Copy *Plugins* folder into your Project root.
  14. 5. Restart the Editor and open your project again. Plugin is now ready to use.
  15. ## Blueprint Access
  16. Right click anywhere in a desired blueprint to access the plugin Blueprint Function Library methods. The plugin is completely multi-threaded and will not block your game thread, fire and forget.
  17. ![Right Click](http://i.imgur.com/ERYn5sM.png)
  18. *Optional but highly recommended:* Add `ZipUtilityInterface` to your blueprint if you wish to be notified of the progress, e.g. when your archive has finished unzipping or if you wish to display a progress bar.
  19. ![Add Interface](http://i.imgur.com/9NrpOfm.png)
  20. After you've added the interface and hit Compile on your blueprint you'll have access to the Progress and List events
  21. ![Events](http://i.imgur.com/fQFtkgA.png)
  22. They're explained in further detail below.
  23. ## Zipping and Compressing Files
  24. To Zip up a folder or file, right click your event graph and add the `Zip` function.
  25. Specify a path to a folder or file as a target.
  26. Leave the Compression format to the default SevenZip or specify a format of choice, the plugin automatically appends the default extension based on the compression format. Note that not all compression formats work for compression (e.g. RAR is extract only).
  27. ![Zip Function Call](Docs/zip.png)
  28. ## Unzipping and Extracting Files
  29. To Unzip up a file, right click your event graph and add the `Unzip` function.
  30. Specify the full path to a suitable archive file.
  31. The plugin automatically detects the compression format used in the archive, but you can alternatively specify a specific format using the `UnzipWithFormat` method.
  32. ![Unzip Function Call](Docs/unzip.png)
  33. ## Listing Contents in an Archive
  34. To list files in your archive, right click your event graph and add the `ListFilesInArchive` function.
  35. Specify the full path to a suitable archive file. This function requires the use of the `ZipUtilityInterface` callback `OnFileFound`, so ensure you have `ZipUtilityInterface` added to your blueprint.
  36. ![List Files Function Call](http://i.imgur.com/uqkI2Gn.png)
  37. The `OnFileFound` event gets called for every file in the archive with its path and size given in bytes. This function does not extract the contents, but instead allows you to inspect files before committing to extracting their contents.
  38. ## Events & Progress Updates
  39. By right-clicking in your blueprint and adding various `ZipUtility` events, you can get the status of zip/unzip operations as they occur. All callbacks are received on the game thread. To receive callbacks you must satisfy two requirements:
  40. 1. Implement the `ZipUtilityInterface` interface in your blueprint from the Class Settings menu
  41. 2. Pass a reference to `self` (or a reference to the class that implements `ZipUtilityInterface`) to all zip/unzip functions
  42. All events pass along the name of the archive being operated on. Since multiple events can be running in parallel, the archive name is useful to uniquely match events with operations.
  43. ### Event Table
  44. | Event | Details |
  45. | ------------- | ------------- |
  46. | `OnStartProcess` | Called when the zip/unzip operation begins |
  47. | `OnProgress` | Called periodically while a zip/unzip operation is running to provide the overall status of the operation |
  48. | `OnFileDone` | Called for every file that is done being zipped/unzipped |
  49. | `OnDone` | Called when the entire zip/unzip operation has completed |
  50. | `OnFileFound` | Called for every file that is found as the result of a `ListFilesInArchive` call |
  51. ![Progress Updates](Docs/event.png)
  52. ## Stopping Operations
  53. Most of the Zip and Unzip methods return a pointer to a `ZipOperation`. This pointer can be used to terminate an operation that is still running by calling the `StopOperation` function.
  54. The returned pointer to `ZipOperation` will be Garbage Collected if it is not stored as an Object Reference or in C++ in a `UPROPERTY` declared pointer. So don't store `ZipOperation` as a soft reference/pointer. It is safe to completely ignore the returned `ZipOperation` if you do not care about manually terminating the operation.
  55. ![Unzip Function Call](Docs/stopoperation.png)
  56. ## Convenience File Functions
  57. ### Move/Rename a File
  58. Specify full path for the file you wish to move and it's destination
  59. ![Move File](http://i.imgur.com/aPu6gdJ.png)
  60. To rename it, simply change the destination name
  61. ![Rename Folder](http://i.imgur.com/RICA41e.png)
  62. ### Create/Make Directory
  63. ![Make Directory](http://i.imgur.com/8ocCOPF.png)
  64. ### List Contents of Folder
  65. Expects self to be a `FileListInterface`
  66. ![List Contents](http://i.imgur.com/PPhyxFE.png)
  67. ## C++
  68. ### Setup
  69. To use the C++ code from the plugin add it as a dependency module in your project build.cs e.g.
  70. ```c#
  71. PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ZipUtility"});
  72. ```
  73. then ```#include "ZipFileFunctionLibrary.h"``` in the places where you'd like to use the plugin functionality.
  74. ### [Lambda](http://en.cppreference.com/w/cpp/language/lambda)
  75. #### [UnzipWithLambda](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/ZipUtility/Public/ZipFileFunctionLibrary.h#L63)
  76. call the static function with *done* and *progress* callback lambdas e.g. if you're interested in both
  77. ```c++
  78. UZipFileFunctionLibrary::UnzipWithLambda(FString("C:/path/to/your/zip.7z"),
  79. []()
  80. {
  81. //Called when done
  82. },
  83. [](float Percent)
  84. {
  85. //called when progress updates with % done
  86. });
  87. ```
  88. replace either with nullptr if you're not interested in that callback
  89. #### [ZipWithLambda](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/ZipUtility/Public/ZipFileFunctionLibrary.h#L80)
  90. call the static function with *done* and *progress* callback lambdas e.g. if you're interested in both
  91. ```c++
  92. UZipFileFunctionLibrary::ZipWithLambda(FString("C:/path/to/your/zip.7z"),
  93. []()
  94. {
  95. //Called when done
  96. },
  97. [](float Percent)
  98. {
  99. //called when progress updates with % done
  100. });
  101. ```
  102. replace either with nullptr if you're not interested in that callback
  103. ### Your own class with [IZipUtilityInterface](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/ZipUtility/Public/ZipUtilityInterface.h)
  104. Let's say you have a class called `UMyClass`. You then add the `IZipUtilityInterface` to it via multiple inheritance e.g.
  105. ```c++
  106. class UMyClass : public UObject, public IZipUtilityInterface
  107. {
  108. GENERATED_BODY()
  109. ...
  110. };
  111. ```
  112. Because the events are of the type [BlueprintNativeEvent](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/BlueprintNativeEvent/) you add the C++ implementation of the events like so
  113. ```c++
  114. class UMyClass : public UObject, public IZipUtilityInterface
  115. {
  116. GENERATED_BODY()
  117. ...
  118. //event overrides
  119. virtual void OnProgress_Implementation(const FString& archive, float percentage, int32 bytes) override;
  120. virtual void OnDone_Implementation(const FString& archive, EZipUtilityCompletionState CompletionState) override;
  121. virtual void OnStartProcess_Implementation(const FString& archive, int32 bytes) override;
  122. virtual void OnFileDone_Implementation(const FString& archive, const FString& file) override;
  123. virtual void OnFileFound_Implementation(const FString& archive, const FString& file, int32 size) override;
  124. };
  125. ```
  126. ensure you have at least an empty implementation for each function
  127. ```c++
  128. void UMyClass::OnProgress_Implementation(const FString& archive, float percentage, int32 bytes)
  129. {
  130. //your code here
  131. }
  132. ```
  133. To call a `ZipUtility` function you first get a valid pointer to your class (I leave that up to you) e.g.
  134. ```c++
  135. UMyClass* MyZipClass = NewObject<UMyClass>(); //or you may already have a valid pointer from allocating elsewhere
  136. ```
  137. then to e.g. unzip you pass the pointer to your class with the `IZipUtilityInterface` as your second parameter (and if you use them, any other optional parameters such as compression format). If you are calling the zip functions from within the class that implements `IZipUtilityInterface` then you can simply pass `this`:
  138. ```c++
  139. UZipFileFunctionLibrary::Unzip(FString("C:/path/to/your/zip.7z"), MyZipClass);
  140. ```
  141. See [ZipFileFunctionLibrary.h](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/ZipUtility/Public/ZipFileFunctionLibrary.h) for all the function signatures.
  142. See [ZULambdaDelegate.h](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/ZipUtility/Private/ZULambdaDelegate.h) for an example class using the above setup to convert `IZipUtilityInterface` interface calls into lambda functions.
  143. ### Windows Utility
  144. For windows utility functions, the callback setup is similar, kindly refer to [WindowsFileUtilityFunctionLibrary.h](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/WindowsUtility/Public/WindowsFileUtilityFunctionLibrary.h) which may use [IWFUFileListInterface](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/WindowsUtility/Public/WFUFileListInterface.h) or [IWFUFolderWatchInterface](https://github.com/getnamo/ZipUtility-ue4/blob/master/Source/WindowsUtility/Public/WFUFolderWatchInterface.h) depending on functions used.
  145. ## License
  146. MIT for ZipUtility and 7z-cpp
  147. LGPL for 7za.dll, LGPL + Unrar for 7z.dll
  148. See license file for details.
  149. ## Help
  150. Add any issues you run across to https://github.com/getnamo/ZipUtility-ue4/issues
  151. or post to the [unreal forum thread](https://forums.unrealengine.com/showthread.php?95022-Plugin-ZipUtility-(7zip)).