Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Added mod event listener and updated plugin filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Oct 7, 2019
1 parent a14c25a commit 7e37e0f
Show file tree
Hide file tree
Showing 42 changed files with 110 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Config/FilterPlugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll
/Img/...
/Resources/...
/README.md
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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<UCallbackProxy_SetModEventListener>();
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<FModioModEvent> ModEvents;
OnFailure.Broadcast( Response, ModEvents );
}
}

void UCallbackProxy_SetModEventListener::OnModEventDelegate(FModioResponse Response, const TArray<FModioModEvent> &ModEvents)
{
if (Response.Code >= 200 && Response.Code < 300)
{
OnSuccess.Broadcast(Response, ModEvents);
}
else
{
OnFailure.Broadcast(Response, ModEvents);
}
}
15 changes: 15 additions & 0 deletions Source/modio/Private/ModioSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

FModioListenerDelegate FModioSubsystem::ModioOnModDownloadDelegate;
FModioListenerDelegate FModioSubsystem::ModioOnModUploadDelegate;
FModioModEventArrayDelegate FModioSubsystem::ModioOnModEventDelegate;

FModioSubsystem::FModioSubsystem() :
bInitialized(false)
Expand Down Expand Up @@ -687,6 +688,11 @@ void FModioSubsystem::SetModfileUploadListener(FModioListenerDelegate Delegate)
FModioSubsystem::ModioOnModUploadDelegate = Delegate;
}

void FModioSubsystem::SetModEventListener(FModioModEventArrayDelegate Delegate)
{
FModioSubsystem::ModioOnModEventDelegate = Delegate;
}

TEnumAsByte<EModioModState> FModioSubsystem::GetModState(int32 ModId)
{
u32 ModState = modioGetModState((u32)ModId);
Expand Down Expand Up @@ -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);
Expand All @@ -729,6 +742,8 @@ void FModioSubsystem::Init( const FString& RootDirectory, uint32 GameId, const F

modioSetUploadListener(&onModUpload);

modioSetEventListener(&onModEvent);

bInitialized = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<FModioModEvent> &,
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<FModioModEvent> &ModEvents);
};
4 changes: 4 additions & 0 deletions Source/modio/Public/ModioSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -143,6 +144,8 @@ struct MODIO_API FModioSubsystem : public TSharedFromThis<FModioSubsystem, ESPMo
void SetModDownloadListener(FModioListenerDelegate Delegate);
/** Callback triggered every time a local mod finished uploading to mod.io */
void SetModfileUploadListener(FModioListenerDelegate Delegate);
/** Callback triggered every time an event is found mod.io */
void SetModEventListener(FModioModEventArrayDelegate Delegate);
/** Returns the state of the corresponding mod */
TEnumAsByte<EModioModState> GetModState(int32 ModId);
/** Places the given mod at the top of the donload queue */
Expand Down Expand Up @@ -207,6 +210,7 @@ struct MODIO_API FModioSubsystem : public TSharedFromThis<FModioSubsystem, ESPMo
/** Download and upload delegate listeners */
static FModioListenerDelegate ModioOnModDownloadDelegate;
static FModioListenerDelegate ModioOnModUploadDelegate;
static FModioModEventArrayDelegate ModioOnModEventDelegate;

protected:
friend class FModioModule;
Expand Down
Binary file added img/BPExamples/email_exchange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/email_request.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/get_all_installed_mods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/get_all_mods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/get_download_queue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/install_downloaded_mods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/is_logged_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/logout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/on_mod_download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/on_modfile_upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/process.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/BPExamples/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioAvatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioDownload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioError.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioFilehash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioInstalledMod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioMedia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioMetadataKVP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioMod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioModCreator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioModDependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioModEditor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Structs/ModioModEvent.png
Binary file added img/Structs/ModioModTag.png
Binary file added img/Structs/ModioModfile.png
Binary file added img/Structs/ModioModfileCreator.png
Binary file added img/Structs/ModioQueuedModDownload.png
Binary file added img/Structs/ModioQueuedModfileUpload.png
Binary file added img/Structs/ModioRating.png
Binary file added img/Structs/ModioResponse.png
Binary file added img/Structs/ModioStats.png
Binary file added img/Structs/ModioUser.png
Binary file added img/Structs/ModioUserEvent.png

0 comments on commit 7e37e0f

Please sign in to comment.