diff --git a/Config/FilterPlugin.ini b/Config/FilterPlugin.ini index ccebca2..116e447 100644 --- a/Config/FilterPlugin.ini +++ b/Config/FilterPlugin.ini @@ -6,3 +6,6 @@ ; /README.txt ; /Extras/... ; /Binaries/ThirdParty/*.dll +/Img/... +/Resources/... +/README.md \ No newline at end of file diff --git a/Source/ThirdParty/mod.io-sdk-v0.11.3-DEV/bin/visualc++/x64/modio.dll b/Source/ThirdParty/mod.io-sdk-v0.11.3-DEV/bin/visualc++/x64/modio.dll index 177a85a..691c412 100644 Binary files a/Source/ThirdParty/mod.io-sdk-v0.11.3-DEV/bin/visualc++/x64/modio.dll and b/Source/ThirdParty/mod.io-sdk-v0.11.3-DEV/bin/visualc++/x64/modio.dll differ diff --git a/Source/modio/Private/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.cpp b/Source/modio/Private/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.cpp new file mode 100644 index 0000000..23ff6c5 --- /dev/null +++ b/Source/modio/Private/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.cpp @@ -0,0 +1,49 @@ +// Copyright 2019 modio. All Rights Reserved. +// Released under MIT. + +#include "BlueprintCallbackProxies/CallbackProxy_SetModEventListener.h" +#include "ModioUE4Utility.h" +#include "ModioSubsystem.h" +#include "Engine/Engine.h" + +UCallbackProxy_SetModEventListener::UCallbackProxy_SetModEventListener(const FObjectInitializer &ObjectInitializer) + : Super(ObjectInitializer) +{ +} + +UCallbackProxy_SetModEventListener *UCallbackProxy_SetModEventListener::SetModEventListener(UObject *WorldContext) +{ + UCallbackProxy_SetModEventListener *Proxy = NewObject(); + Proxy->SetFlags(RF_StrongRefOnFrame); + Proxy->WorldContextObject = WorldContext; + return Proxy; +} + +void UCallbackProxy_SetModEventListener::Activate() +{ + UWorld* World = GEngine->GetWorldFromContextObject( WorldContextObject, EGetWorldErrorMode::LogAndReturnNull ); + FModioSubsystemPtr Modio = FModioSubsystem::Get( World ); + if( Modio.IsValid() ) + { + Modio->SetModEventListener( FModioModEventArrayDelegate::CreateUObject( this, &UCallbackProxy_SetModEventListener::OnModEventDelegate ) ); + } + else + { + // @todonow: Make something more pretty than this + FModioResponse Response; + TArray ModEvents; + OnFailure.Broadcast( Response, ModEvents ); + } +} + +void UCallbackProxy_SetModEventListener::OnModEventDelegate(FModioResponse Response, const TArray &ModEvents) +{ + if (Response.Code >= 200 && Response.Code < 300) + { + OnSuccess.Broadcast(Response, ModEvents); + } + else + { + OnFailure.Broadcast(Response, ModEvents); + } +} \ No newline at end of file diff --git a/Source/modio/Private/ModioSubsystem.cpp b/Source/modio/Private/ModioSubsystem.cpp index 1d85b19..647d68c 100644 --- a/Source/modio/Private/ModioSubsystem.cpp +++ b/Source/modio/Private/ModioSubsystem.cpp @@ -13,6 +13,7 @@ FModioListenerDelegate FModioSubsystem::ModioOnModDownloadDelegate; FModioListenerDelegate FModioSubsystem::ModioOnModUploadDelegate; +FModioModEventArrayDelegate FModioSubsystem::ModioOnModEventDelegate; FModioSubsystem::FModioSubsystem() : bInitialized(false) @@ -687,6 +688,11 @@ void FModioSubsystem::SetModfileUploadListener(FModioListenerDelegate Delegate) FModioSubsystem::ModioOnModUploadDelegate = Delegate; } +void FModioSubsystem::SetModEventListener(FModioModEventArrayDelegate Delegate) +{ + FModioSubsystem::ModioOnModEventDelegate = Delegate; +} + TEnumAsByte FModioSubsystem::GetModState(int32 ModId) { u32 ModState = modioGetModState((u32)ModId); @@ -714,6 +720,13 @@ void onModUpload(u32 response_code, u32 mod_id) FModioSubsystem::ModioOnModUploadDelegate.ExecuteIfBound( (int32)response_code, (int32)mod_id ); } +void onModEvent(ModioResponse ModioResponse, ModioModEvent* ModioEventsArray, u32 ModioEventsArraySize) +{ + FModioResponse Response; + InitializeResponse( Response, ModioResponse ); + FModioSubsystem::ModioOnModEventDelegate.ExecuteIfBound( Response, ConvertToTArrayModEvents(ModioEventsArray, ModioEventsArraySize) ); +} + void FModioSubsystem::Init( const FString& RootDirectory, uint32 GameId, const FString& ApiKey, bool bIsLiveEnvironment, bool bInstallOnModDownload, bool bRetrieveModsFromOtherGames ) { check(!bInitialized); @@ -729,6 +742,8 @@ void FModioSubsystem::Init( const FString& RootDirectory, uint32 GameId, const F modioSetUploadListener(&onModUpload); + modioSetEventListener(&onModEvent); + bInitialized = true; } diff --git a/Source/modio/Public/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.h b/Source/modio/Public/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.h new file mode 100644 index 0000000..14b1bf0 --- /dev/null +++ b/Source/modio/Public/BlueprintCallbackProxies/CallbackProxy_SetModEventListener.h @@ -0,0 +1,39 @@ +// Copyright 2019 modio. All Rights Reserved. +// Released under MIT. + +#pragma once + +#include "Schemas/ModioModEvent.h" +#include "ModioSubsystem.h" +#include "Net/OnlineBlueprintCallProxyBase.h" +#include "CallbackProxy_SetModEventListener.generated.h" + +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( + FOnModEventResult, + FModioResponse, + Response, + const TArray &, + ModEvents); + +UCLASS() +class MODIO_API UCallbackProxy_SetModEventListener : public UOnlineBlueprintCallProxyBase +{ + GENERATED_UCLASS_BODY() + + // The world context object in which this call is taking place + UPROPERTY() + UObject* WorldContextObject; + + UPROPERTY(BlueprintAssignable) + FOnModEventResult OnSuccess; + + UPROPERTY(BlueprintAssignable) + FOnModEventResult OnFailure; + + UFUNCTION(BlueprintCallable, Category = "mod.io", meta = (BlueprintInternalUseOnly = "true", DefaultToSelf="WorldContext")) + static UCallbackProxy_SetModEventListener *SetModEventListener(UObject *WorldContext); + + virtual void Activate() override; + + virtual void OnModEventDelegate(FModioResponse Response, const TArray &ModEvents); +}; \ No newline at end of file diff --git a/Source/modio/Public/ModioSubsystem.h b/Source/modio/Public/ModioSubsystem.h index b464533..15c4349 100644 --- a/Source/modio/Public/ModioSubsystem.h +++ b/Source/modio/Public/ModioSubsystem.h @@ -12,6 +12,7 @@ #include "Schemas/ModioInstalledMod.h" #include "Schemas/ModioQueuedModDownload.h" #include "Schemas/ModioQueuedModfileUpload.h" +#include "Schemas/ModioModEvent.h" #include "Enums/ModioModSortType.h" #include "Enums/ModioModState.h" #include "Enums/ModioRatingType.h" @@ -143,6 +144,8 @@ struct MODIO_API FModioSubsystem : public TSharedFromThis GetModState(int32 ModId); /** Places the given mod at the top of the donload queue */ @@ -207,6 +210,7 @@ struct MODIO_API FModioSubsystem : public TSharedFromThis