Skip to content

Commit

Permalink
2.5.1174
Browse files Browse the repository at this point in the history
* Implement GetModDependenciesAsync
  • Loading branch information
stephenwhittle committed Sep 2, 2021
1 parent cf58afc commit 8ff5c26
Show file tree
Hide file tree
Showing 13 changed files with 477 additions and 69 deletions.
228 changes: 186 additions & 42 deletions Doc/documentation.html

Large diffs are not rendered by default.

Binary file added Doc/img/nd_img_K2_GetModDependenciesAsync.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 19 additions & 5 deletions Source/Modio/GeneratedSource/SDKModMetadata.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
*
* This file is part of the mod.io SDK.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-sdk/blob/main/LICENSE>)
*
*
*/

#pragma once
Expand All @@ -19,6 +19,7 @@
#include "modio/core/entities/ModioModInfo.h"
#include "modio/core/entities/ModioModInfoList.h"
#include "modio/core/entities/ModioModTagOptions.h"
#include "modio/detail/ops/mod/GetModDependenciesOp.h"
#include "modio/detail/ops/mod/GetModDetailsOp.h"
#include "modio/detail/ops/mod/GetModInfoOp.h"
#include "modio/detail/ops/mod/GetModMediaAvatarOp.h"
Expand Down Expand Up @@ -129,4 +130,17 @@ namespace Modio
Modio::Detail::Services::GetGlobalContext().get_executor());
}
}

void GetModDependenciesAsync(
Modio::ModID ModID,
std::function<void(Modio::ErrorCode, Modio::Optional<Modio::ModDependencyList> Dependencies)> Callback)
{
if (Modio::Detail::RequireSDKIsInitialized(Callback) && Modio::Detail::RequireNotRateLimited(Callback))
{
return asio::async_compose<std::function<void(Modio::ErrorCode, Modio::Optional<Modio::ModDependencyList>)>,
void(Modio::ErrorCode, Modio::Optional<Modio::ModDependencyList>)>(
Modio::Detail::GetModDependenciesOp(ModID, Modio::Detail::SDKSessionData::CurrentGameID()), Callback,
Modio::Detail::Services::GetGlobalContext().get_executor());
}
}
} // namespace Modio
10 changes: 10 additions & 0 deletions Source/Modio/Private/Internal/Convert/ModDependency.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include "Internal/ModioConvert.h"

FORCEINLINE FModioModDependency ToUnreal(const Modio::ModDependency& In)
{
FModioModDependency Out;
Out.ModID = ToUnreal(In.ModID);
Out.ModName = ToUnreal(In.ModName);
return Out;
}
22 changes: 22 additions & 0 deletions Source/Modio/Private/Libraries/ModioModDependenciesLibrary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*/

#include "Libraries/ModioModDependenciesLibrary.h"

const TArray<FModioModDependency>& UModioModDependenciesLibrary::GetDependencies(const FModioModDependencyList& DependencyList)
{
return DependencyList.InternalList;
}

const FModioPagedResult& UModioModDependenciesLibrary::GetPagedResult(
const FModioModDependencyList& DependencyList)
{
return DependencyList.PagedResult;
}
25 changes: 19 additions & 6 deletions Source/Modio/Private/Libraries/ModioOptionalLibrary.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/*
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*
*/

#include "Libraries/ModioOptionalLibrary.h"
#include "Types/ModioModInfoList.h"
#include "Types/ModioModTagOptions.h"
#include "Types/ModioUser.h"
#include "Types/ModioModDependencyList.h"

template<typename BPOptionalType>
bool IsSetInternal(const BPOptionalType& Optional)
Expand Down Expand Up @@ -104,8 +105,20 @@ bool UModioOptionalLibrary::IsSet_ModioOptionalTerms(const FModioOptionalTerms&
return IsSetInternal(OptionalTerms);
}


bool UModioOptionalLibrary::GetValue_ModioOptionalTerms(const FModioOptionalTerms& OptionalTerms, FModioTerms& Terms)
{
return GetValueInternal(OptionalTerms, Terms);
}

bool UModioOptionalLibrary::IsSet_ModioOptionalModDependencyList(
const struct FModioOptionalModDependencyList& OptionalDependencyList)
{
return IsSetInternal(OptionalDependencyList);
}

bool UModioOptionalLibrary::GetValue_ModioOptionalModDependencyList(
const struct FModioOptionalModDependencyList& OptionalDependencyList,
struct FModioModDependencyList& DependencyList)
{
return GetValueInternal(OptionalDependencyList, DependencyList);
}
42 changes: 33 additions & 9 deletions Source/Modio/Private/ModioSubsystem.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*
*/

#include "ModioSubsystem.h"
Expand All @@ -15,6 +15,7 @@
#include "Internal/Convert/FilterParams.h"
#include "Internal/Convert/InitializeOptions.h"
#include "Internal/Convert/ModCollectionEntry.h"
#include "Internal/Convert/ModDependency.h"
#include "Internal/Convert/ModInfo.h"
#include "Internal/Convert/ModInfoList.h"
#include "Internal/Convert/ModManagementEvent.h"
Expand Down Expand Up @@ -510,15 +511,13 @@ void UModioSubsystem::ForceUninstallModAsync(FModioModID ModToRemove, FOnErrorOn
[Callback](FModioErrorCode ec) { Callback.ExecuteIfBound(ec); });
}

void UModioSubsystem::SubmitModRatingAsync(FModioModID Mod, EModioRating Rating,
FOnErrorOnlyDelegateFast Callback)
void UModioSubsystem::SubmitModRatingAsync(FModioModID Mod, EModioRating Rating, FOnErrorOnlyDelegateFast Callback)
{
Modio::SubmitModRatingAsync(ToModio(Mod), ToModio(Rating),
[Callback](FModioErrorCode ec) { Callback.ExecuteIfBound(ec); });
}

void UModioSubsystem::K2_SubmitModRatingAsync(FModioModID Mod, EModioRating Rating,
FOnErrorOnlyDelegate Callback)
void UModioSubsystem::K2_SubmitModRatingAsync(FModioModID Mod, EModioRating Rating, FOnErrorOnlyDelegate Callback)
{
SubmitModRatingAsync(Mod, Rating, FOnErrorOnlyDelegateFast::CreateLambda([Callback](FModioErrorCode ec) {
Callback.ExecuteIfBound(ec);
Expand All @@ -534,7 +533,32 @@ void UModioSubsystem::K2_ReportContentAsync(FModioReportParams Report, FOnErrorO
{
ReportContentAsync(Report, FOnErrorOnlyDelegateFast::CreateLambda(
[Callback](FModioErrorCode ec) { Callback.ExecuteIfBound(ec); }));
}

void UModioSubsystem::GetModDependenciesAsync(FModioModID ModID, FOnGetModDependenciesDelegateFast Callback)
{
Modio::GetModDependenciesAsync(
ToModio(ModID), [Callback](Modio::ErrorCode ec, Modio::Optional<Modio::ModDependencyList> Dependencies) {
if (Dependencies)
{
FModioModDependencyList Out;
Out.InternalList = ToUnreal<FModioModDependency>(Dependencies->GetRawList());
Out.PagedResult = FModioPagedResult(Dependencies.value());
Callback.ExecuteIfBound(ec, Out);
}
else
{
Callback.ExecuteIfBound(ec, {});
}
});
}

MODIO_API void UModioSubsystem::K2_GetModDependenciesAsync(FModioModID ModID, FOnGetModDependenciesDelegate Callback)
{
GetModDependenciesAsync(ModID, FOnGetModDependenciesDelegateFast::CreateLambda(
[Callback](FModioErrorCode ec, TOptional<FModioModDependencyList> Dependencies) {
Callback.ExecuteIfBound(ec, FModioOptionalModDependencyList(MoveTempIfPossible(Dependencies)));
}));
}

/// File scope implementations
Expand Down
16 changes: 16 additions & 0 deletions Source/Modio/Private/Types/ModioModDependencyListUImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*/
#include "Templates/UnrealTemplate.h"
#include "Types/ModioModDependencyList.h"


FModioOptionalModDependencyList::FModioOptionalModDependencyList(TOptional<FModioModDependencyList>&& ModDependencies)
: Internal(MoveTemp(ModDependencies))
{}
40 changes: 40 additions & 0 deletions Source/Modio/Public/Libraries/ModioModDependenciesLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*/

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "Types/ModioModDependencyList.h"

// clang-format off
#include "ModioModDependenciesLibrary.generated.h"
// clang-format on

UCLASS()
class UModioModDependenciesLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

/**
* Get the tags in a mod tag options list
* @param ModTags
* @return
*/
UFUNCTION(BlueprintPure, Category = "mod.io|Utilities")
static const TArray<FModioModDependency>& GetDependencies(const FModioModDependencyList& ModTags);

/**
* Get the paged result that contains information of the data returned
* @param ModTags
* @return
*/
UFUNCTION(BlueprintPure, Category = "mod.io|Utilities")
static const FModioPagedResult& GetPagedResult(const FModioModDependencyList& ModTags);
};
25 changes: 25 additions & 0 deletions Source/Modio/Public/Libraries/ModioOptionalLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Types/ModioModTagOptions.h"
#include "Types/ModioTerms.h"
#include "Types/ModioImage.h"
#include "Types/ModioModDependencyList.h"

// clang-format off
#include "ModioOptionalLibrary.generated.h"
Expand Down Expand Up @@ -176,4 +177,28 @@ class UModioOptionalLibrary : public UBlueprintFunctionLibrary
static bool GetValue_ModioOptionalTerms(
const struct FModioOptionalTerms& OptionalTerms,
struct FModioTerms& Terms);

/**
* Check if the optional mod dependency list has a valid value
*
* @param OptionalDependencyList - The optional to check
* @return true if it has a value set
*/
UFUNCTION(BlueprintPure, Category = "mod.io|Utilities|Optional",
meta = (DisplayName = "IsSet (ModioOptionalModDependencyList)", CompactNodeTitle = "IsSet"))
static bool IsSet_ModioOptionalModDependencyList(
const struct FModioOptionalModDependencyList& OptionalDependencyList);

/**
* Get the dependency list from the optional if it's set
*
* @param OptionalDependencyList -
* @param DependencyList - if this returned false, then this will be defaulted
* @return true if the optional has a value set
*/
UFUNCTION(BlueprintPure, Category = "mod.io|Utilities|Optional",
DisplayName = "GetValue (ModioOptionalModDependencyList)")
static bool GetValue_ModioOptionalModDependencyList(
const struct FModioOptionalModDependencyList& OptionalDependencyList,
struct FModioModDependencyList& DependencyList);
};
42 changes: 36 additions & 6 deletions Source/Modio/Public/ModioSubsystem.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
/*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
*
* This file is part of the mod.io UE4 Plugin.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-ue4/blob/main/LICENSE>)
*
*
*/

#pragma once
Expand All @@ -19,6 +19,7 @@
#include "Types/ModioImage.h"
#include "Types/ModioInitializeOptions.h"
#include "Types/ModioModCollectionEntry.h"
#include "Types/ModioModDependencyList.h"
#include "Types/ModioModInfo.h"
#include "Types/ModioModInfoList.h"
#include "Types/ModioModManagementEvent.h"
Expand All @@ -40,6 +41,7 @@ DECLARE_DELEGATE_TwoParams(FOnGetModInfoDelegateFast, FModioErrorCode, TOptional
DECLARE_DELEGATE_TwoParams(FOnGetMediaDelegateFast, FModioErrorCode, TOptional<FModioImage>);
DECLARE_DELEGATE_TwoParams(FOnGetModTagOptionsDelegateFast, FModioErrorCode, TOptional<FModioModTagOptions>);
DECLARE_DELEGATE_TwoParams(FOnGetTermsOfUseDelegateFast, FModioErrorCode, TOptional<FModioTerms>);
DECLARE_DELEGATE_TwoParams(FOnGetModDependenciesDelegateFast, FModioErrorCode, TOptional<FModioModDependencyList>);

// Blueprint version of delegates
DECLARE_DYNAMIC_DELEGATE_OneParam(FOnErrorOnlyDelegate, FModioErrorCode, ErrorCode);
Expand All @@ -51,6 +53,8 @@ DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnGetMediaDelegate, FModioErrorCode, ErrorCo
DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnGetModTagOptionsDelegate, FModioErrorCode, ErrorCode, FModioOptionalModTagOptions,
ModTagOptions);
DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnGetTermsOfUseDelegate, FModioErrorCode, ErrorCode, FModioOptionalTerms, Terms);
DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnGetModDependenciesDelegate, FModioErrorCode, ErrorCode,
FModioOptionalModDependencyList, Dependencies);

/**
* @brief Thin wrapper around the mod.io SDK. This mostly wraps all the functions available in modio/ModioSDK.h that's
Expand Down Expand Up @@ -318,6 +322,19 @@ class UModioSubsystem : public UEngineSubsystem
**/
MODIO_API void GetModTagOptionsAsync(FOnGetModTagOptionsDelegateFast Callback);

/**
* @brief For a given Mod ID, fetches a list of any mods that the creator has marked as dependencies
* @param ModID The mod to retrieve dependencies for
* @param Callback Callback providing a status code and an optional ModTagOptions object containing the available
* tags
* @requires initialized-sdk
* @requires no-rate-limiting
* @errorcategory NetworkError|Couldn't connect to mod.io servers
* @error GenericError::SDKNotInitialized|SDK not initialized
* @experimental
**/
MODIO_API void GetModDependenciesAsync(FModioModID ModID, FOnGetModDependenciesDelegateFast Callback);

/**
* @brief Begins email authentication for the current session by requesting a one-time code be sent to the
* specified email address if it is associated with a Mod.io account
Expand Down Expand Up @@ -397,7 +414,6 @@ class UModioSubsystem : public UEngineSubsystem
**/
MODIO_API void GetUserMediaAsync(EModioAvatarSize AvatarSize, FOnGetMediaDelegateFast Callback);


/**
* @brief Submits a rating for a mod on behalf of the current user. Submit a neutral rating to effectively clear a
* rating already submitted by a user. Submitting other values will overwrite any existing rating submitted by this
Expand Down Expand Up @@ -626,6 +642,20 @@ class UModioSubsystem : public UEngineSubsystem
UFUNCTION(BlueprintCallable, DisplayName = "GetModTagOptionsAsync", Category = "mod.io|Mods")
MODIO_API void K2_GetModTagOptionsAsync(FOnGetModTagOptionsDelegate Callback);

/**
* @brief For a given Mod ID, fetches a list of any mods that the creator has marked as dependencies
* @param ModID The mod to retrieve dependencies for
* @param Callback Callback providing a status code and an optional ModTagOptions object containing the available
* tags
* @requires initialized-sdk
* @requires no-rate-limiting
* @errorcategory NetworkError|Couldn't connect to mod.io servers
* @error GenericError::SDKNotInitialized|SDK not initialized
* @experimental
**/
UFUNCTION(BlueprintCallable, DisplayName = "GetModDependenciesAsync", Category = "mod.io|Mods")
MODIO_API void K2_GetModDependenciesAsync(FModioModID ModID, FOnGetModDependenciesDelegate Callback);

/**
* @brief Begins email authentication for the current session by requesting a one-time code be sent to the
* specified email address if it is associated with a Mod.io account
Expand Down
Loading

0 comments on commit 8ff5c26

Please sign in to comment.