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.

100 lines
4.0 KiB

  1. #include "ZipUtilityPrivatePCH.h"
  2. #include "ZipFileFunctionLibrary.h"
  3. #include "SevenZipCallbackHandler.h"
  4. void SevenZipCallbackHandler::OnProgress(const TString& archivePath, uint64 bytes)
  5. {
  6. const UObject* interfaceDelegate = ProgressDelegate;
  7. const uint64 bytesConst = bytes;
  8. const FString pathConst = FString(archivePath.c_str());
  9. if (bytes > 0) {
  10. const float ProgressPercentage = ((double)((TotalBytes)-(BytesLeft - bytes)) / (double)TotalBytes) * 100;
  11. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathConst, ProgressPercentage, bytesConst]
  12. {
  13. //UE_LOG(LogClass, Log, TEXT("Progress: %d bytes"), progress);
  14. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnProgress((UObject*)interfaceDelegate, pathConst, ProgressPercentage, bytesConst);
  15. });
  16. }
  17. }
  18. void SevenZipCallbackHandler::OnDone(const TString& archivePath)
  19. {
  20. const UObject* interfaceDelegate = ProgressDelegate;
  21. const FString pathConst = FString(archivePath.c_str());
  22. UZipFileFunctionLibrary::RunLambdaOnGameThread([pathConst, interfaceDelegate]
  23. {
  24. //UE_LOG(LogClass, Log, TEXT("All Done!"));
  25. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnDone((UObject*)interfaceDelegate, pathConst, EZipUtilityCompletionState::SUCCESS);
  26. });
  27. }
  28. void SevenZipCallbackHandler::OnFileDone(const TString& archivePath, const TString& filePath, uint64 bytes)
  29. {
  30. const UObject* interfaceDelegate = ProgressDelegate;
  31. const FString pathConst = FString(archivePath.c_str());
  32. const FString filePathConst = FString(filePath.c_str());
  33. const uint64 bytesConst = bytes;
  34. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathConst, filePathConst, bytesConst]
  35. {
  36. //UE_LOG(LogClass, Log, TEXT("File Done: %s, %d bytes"), filePathConst.c_str(), bytesConst);
  37. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnFileDone((UObject*)interfaceDelegate, pathConst, filePathConst);
  38. });
  39. //Handle byte decrementing
  40. if (bytes > 0) {
  41. BytesLeft -= bytes;
  42. const float ProgressPercentage = ((double)(TotalBytes - BytesLeft) / (double)TotalBytes) * 100;
  43. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathConst, ProgressPercentage, bytes]
  44. {
  45. //UE_LOG(LogClass, Log, TEXT("Progress: %d bytes"), progress);
  46. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnProgress((UObject*)interfaceDelegate, pathConst, ProgressPercentage, bytes);
  47. });
  48. }
  49. }
  50. void SevenZipCallbackHandler::OnStartWithTotal(const TString& archivePath, unsigned __int64 totalBytes)
  51. {
  52. TotalBytes = totalBytes;
  53. BytesLeft = TotalBytes;
  54. const UObject* interfaceDelegate = ProgressDelegate;
  55. const uint64 bytesConst = TotalBytes;
  56. const FString pathConst = FString(archivePath.c_str());
  57. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathConst, bytesConst]
  58. {
  59. //UE_LOG(LogClass, Log, TEXT("Starting with %d bytes"), bytesConst);
  60. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnStartProcess((UObject*)interfaceDelegate, pathConst, bytesConst);
  61. });
  62. }
  63. void SevenZipCallbackHandler::OnFileFound(const TString& archivePath, const TString& filePath, int size)
  64. {
  65. const UObject* interfaceDelegate = ProgressDelegate;
  66. const uint64 bytesConst = TotalBytes;
  67. const FString pathString = FString(archivePath.c_str());
  68. const FString fileString = FString(filePath.c_str());
  69. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathString, fileString, bytesConst]
  70. {
  71. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnFileFound((UObject*)interfaceDelegate, pathString, fileString, bytesConst);
  72. });
  73. }
  74. void SevenZipCallbackHandler::OnListingDone(const TString& archivePath)
  75. {
  76. const UObject* interfaceDelegate = ProgressDelegate;
  77. const FString pathString = FString(archivePath.c_str());
  78. UZipFileFunctionLibrary::RunLambdaOnGameThread([interfaceDelegate, pathString]
  79. {
  80. ((IZipUtilityInterface*)interfaceDelegate)->Execute_OnDone((UObject*)interfaceDelegate, pathString, EZipUtilityCompletionState::SUCCESS);
  81. });
  82. }
  83. bool SevenZipCallbackHandler::OnCheckBreak()
  84. {
  85. return bCancelOperation;
  86. }