BlueprintUtilityBPLibrary.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // Copyright ECG . All Rights Reserved.
  2. #pragma once
  3. #include "DDSLoader.h"
  4. #include "Core.h"
  5. #include "Engine.h"
  6. //LoadImageAsync
  7. #include "DynamicLoader.h"
  8. #include "Kismet/BlueprintFunctionLibrary.h"
  9. #include "Runtime/Engine/Classes/Sound/SoundWave.h"
  10. #include "ProceduralMeshComponent.h"
  11. #include "Components/AudioComponent.h"
  12. #include "AudioDecompress.h"
  13. #include "AudioDevice.h"
  14. #include "ActiveSound.h"
  15. #include "Audio.h"
  16. #include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h"
  17. #include "VorbisAudioInfo.h"
  18. #include "BlueprintUtilityBPLibrary.generated.h"
  19. //DECLARE_LOG_CATEGORY_EXTERN(CategoryName, Log, All)
  20. /*
  21. *
  22. * BluePrint Function Collection
  23. *
  24. *
  25. * This Way To More
  26. * https://github.com/ecg82465/BluePrintTools
  27. */
  28. UENUM(BlueprintType)
  29. enum class DirType : uint8
  30. {
  31. GameDir,
  32. ContentDir
  33. };
  34. UCLASS()
  35. class UBlueprintUtilityBPLibrary : public UBlueprintFunctionLibrary
  36. {
  37. GENERATED_UCLASS_BODY()
  38. UFUNCTION(BlueprintCallable, meta = (DisplayName = "TEST", Keywords = "BlueprintUtility sample test testing"), Category = "BlueprintUtility")
  39. static float BlueprintUtilitySampleFunction(float Param);
  40. static FString GetFullPath(FString FilePath);
  41. /* RuntimeLoader */
  42. /** Load Texture2D */
  43. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|Loader", meta = (Keywords = "image png jpg jpeg bmp bitmap ico icon exr icns"))
  44. static UTexture2D* LoadTexture2DFromFile(const FString& FilePath, bool& IsValid, int32& Width, int32& Height);
  45. /** Load Texture2D No Blocking Game Logic */
  46. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Loader", meta = (Keywords = "image png jpg jpeg bmp bitmap ico icon exr icns"))
  47. static UImageLoader* LoadTexture2DFromFile_Async( const FString& FilePath,const FString& ID);
  48. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|Loader", meta = (Keywords = "image png jpg jpeg bmp bitmap ico icon exr icns"))
  49. static UTexture2D* BytesToTexture2d(const TArray<uint8> bytes);
  50. /** Load a Sound from a file! */
  51. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Loader", meta = (Keywords = ""))
  52. static class USoundWave* LoadOggDataFromFile(const FString& FilePath);
  53. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Loader", meta = (Keywords = ""))
  54. static class USoundWave* LoadWaveDataFromFile(const FString& FilePath);
  55. /** Config */
  56. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Config", meta = (Keywords = ""))
  57. static void ReadConfig(const FString& SectionName,const FString& ValueName, bool &succeed, FString &ReturnValue);
  58. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Config", meta = (Keywords = ""))
  59. static void WriteConfig(const FString& SectionName, const FString& ValueName, const FString &ReturnValue);
  60. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Config", meta = (Keywords = ""))
  61. static bool ReadCustomPathConfig(const FString&FilePath,const FString& SectionName, const FString& ValueName, FString &ReturnString);
  62. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Config", meta = (Keywords = ""))
  63. static void WriteCustomPathConfig(const FString&FilePath, const FString& SectionName, const FString& ValueName,const FString &WriteString);
  64. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|Config", meta = (Keywords = ""))
  65. static bool IsEditorMode( );
  66. /** RefrashAllSkeletal Trnasfrom In This Frame (Fix Animation Dither Error)*/
  67. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Animation", meta = (Keywords = ""))
  68. static void RefrashAllSkeletallAnimation();
  69. /** File */
  70. /** Read Or Write Custom Text */
  71. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  72. static bool ReadFile(const FString FilePath, FString& ReturnString);
  73. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  74. static bool WriteFile(const FString FilePath, const FString ReturnString);
  75. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  76. static bool WriteFileByte(TArray<uint8> bytes, const FString FilePath);
  77. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  78. static bool DeleteFile(const FString FilePath);
  79. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  80. static bool DeleteFiles(const FString FilePath);
  81. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  82. static bool CopyFile (const FString FilePath, const FString ToPath);
  83. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  84. static bool Texture2d2PNG(UTextureRenderTarget2D* TextureRenderTarget, const FString& FilePath);
  85. /** Get Path */
  86. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  87. static bool IsVaildPath(const FString FilePath);
  88. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|File", meta = (Keywords = ""))
  89. static FString GetGamePath(DirType E);
  90. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|OS", meta = (Keywords = "exe"))
  91. static AExeActor* OpenExe(UObject* SomeInWorldObject,const FString Path,const FString Args);
  92. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Functions", meta = (Keywords = "MD5"))
  93. static FString GenMD5(FString InputString);
  94. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Functions", meta = (Keywords = "MD5"))
  95. static FString GenSHA1(FString InputString);
  96. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Functions", meta = (Keywords = "MD5"))
  97. static FString EnCryptoPPSHA1(FString InputString, FString aes_key);
  98. UFUNCTION(BlueprintCallable, Category = "BlueprintUtility|Functions", meta = (Keywords = "View"))
  99. static bool CheckActorInView(UPrimitiveComponent* actorComp,float checktime);
  100. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|Functions", meta = (Keywords = "color"))
  101. static void GenColors(int Length, const FColor color, TArray<FColor>& OuterColor);
  102. UFUNCTION(BlueprintPure, Category = "BlueprintUtility|Functions", meta = (Keywords = "color"))
  103. static void UVtimes(FVector2D tims,const TArray<FVector2D> inputUV, TArray<FVector2D>& OuterUV);
  104. UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "BlueprintUtility|Functions", meta = (Keywords = "mesh"))
  105. static void GetProduralMeshInfo(UProceduralMeshComponent* InProcMesh, int32 SectionIndex, TArray<FVector>& Vertices, TArray<int32>& Triangles, TArray<FVector>& Normals, TArray<FVector2D>& UVs, TArray<FProcMeshTangent>& Tangents, TArray<FColor>& VerticesColor);
  106. private:
  107. static bool ReadWavWaveData(USoundWave* sw, TArray<uint8>* rawFile);
  108. static bool ReadOggWaveData(USoundWave* sw, TArray<uint8>* rawFile);
  109. };