Skip to content

Commit

Permalink
2.14.1380
Browse files Browse the repository at this point in the history
* NativeSDK updated
* build.cs updates to support NDA platforms
* `FModioInitializeOptions` now exposes `LocalSessionIdentifier`
  * Sessions are a local storage scope which optionally contains an
    authenticated mod.io user account
  * Sessions allow you to perform simple switching between users or save
    slots by shutting down and re-initializing the SDK with a new
session ID
  * This parameter defaults to the SID string of the current user on
    Windows, behaviour which will eventually be deprecated
  * Other platforms require you to explicitly set a value before calling
    `InitializeAsync`
  • Loading branch information
stephenwhittle committed Dec 6, 2021
1 parent dc47b36 commit e6ef053
Show file tree
Hide file tree
Showing 19 changed files with 228 additions and 72 deletions.
17 changes: 16 additions & 1 deletion Doc/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ <h1>mod.io UE4 Plugin Documentation</h1>
</li>
<li><a href="#_functions">Functions</a>
<ul class="sectlevel2">
<li><a href="#SetSessionIdentifier">Set Session Identifier</a></li>
<li><a href="#SetPortal">Set Portal</a></li>
<li><a href="#MakeInitializeOptions">Make Initialize Options</a></li>
<li><a href="#MakeGameId">Make Game Id</a></li>
Expand Down Expand Up @@ -4591,6 +4592,20 @@ <h2 id="_functions">Functions</h2>
<div class="sectionbody">
<hr>
<div class="sect2">
<h3 id="SetSessionIdentifier">Set Session Identifier</h3>
<div class="imageblock">
<div class="content">
<img src="img/nd_img_SetSessionIdentifier.png" alt="nd img SetSessionIdentifier">
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="c++"><span class="n">FModioInitializeOptions</span> <span class="n">SetSessionIdentifier</span><span class="p">(</span><span class="n">FModioInitializeOptions</span> <span class="n">Options</span><span class="p">,</span> <span class="n">FString</span> <span class="n">SessionIdentifier</span><span class="p">)</span></code></pre>
</div>
</div>
<hr>
</div>
<div class="sect2">
<h3 id="SetPortal">Set Portal</h3>
<div class="imageblock">
<div class="content">
Expand Down Expand Up @@ -6215,7 +6230,7 @@ <h4 id="_values_20" class="discrete">Values</h4>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2021-11-11 14:41:25 +1100
Last updated 2021-12-06 12:52:16 +1100
</div>
</div>
</body>
Expand Down
Binary file added Doc/img/nd_img_SetSessionIdentifier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions Source/Modio/GeneratedSource/ModioFileMetadata.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>)
*
*
*/

#ifdef MODIO_SEPARATE_COMPILATION
Expand All @@ -17,7 +17,6 @@
#include "modio/detail/ModioJsonHelpers.h"
#include "nlohmann/json.hpp"


namespace Modio
{
NLOHMANN_JSON_SERIALIZE_ENUM(FileMetadata::VirusScanStatus, {{FileMetadata::VirusScanStatus::NotScanned, 0},
Expand All @@ -43,6 +42,8 @@ namespace Modio
Detail::ParseSafe(Json, FileMetadata.Version, "version");
Detail::ParseSafe(Json, FileMetadata.Changelog, "changelog");
Detail::ParseSafe(Json, FileMetadata.MetadataBlob, "metadata_blob");
Detail::ParseSubobjectSafe(Json, FileMetadata.DownloadBinaryURL, "download", "binary_url");
Detail::ParseSubobjectSafe(Json, FileMetadata.DownloadExpiryDate, "download", "date_expires");
}

void to_json(nlohmann::json& Json, const Modio::FileMetadata& FileMetadata)
Expand All @@ -56,7 +57,8 @@ namespace Modio
{"filename", FileMetadata.Filename},
{"version", FileMetadata.Version},
{"changelog", FileMetadata.Changelog},
{"metadata_blob", FileMetadata.MetadataBlob}};
{"metadata_blob", FileMetadata.MetadataBlob},
{"download", nlohmann::json::object({{"binary_url", FileMetadata.DownloadBinaryURL},
{"date_expires", FileMetadata.DownloadExpiryDate}})}};
}
}

} // namespace Modio
13 changes: 12 additions & 1 deletion Source/Modio/GeneratedSource/ModioJsonHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ bool Modio::Detail::GetSubobjectSafe(const nlohmann::json& Json, const std::stri
OutSubobjectJson = Subobject;
return true;
}
else
{
Modio::Detail::Logger().Log(Modio::LogLevel::Warning, Modio::LogCategory::Core,
"Subobject is null for SubobjectKey: {}", SubobjectKey);
}
}
else
{
Modio::Detail::Logger().Log(Modio::LogLevel::Warning, Modio::LogCategory::Core,
"Json does not contain SubobjectKey: {}", SubobjectKey);
}

return false;
}

Expand All @@ -39,6 +48,8 @@ bool Modio::Detail::ParseArraySizeSafe(const nlohmann::json& Json, std::size_t&
}
else
{
Modio::Detail::Logger().Log(Modio::LogLevel::Warning, Modio::LogCategory::Core,
"Json ParseArraySizeSafe failed for Key: {}", Key);
return false;
}
}
Expand Down
34 changes: 14 additions & 20 deletions Source/Modio/GeneratedSource/ModioModInfo.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>)
*
*
*/

#ifdef MODIO_SEPARATE_COMPILATION
Expand Down Expand Up @@ -64,19 +64,12 @@ namespace Modio
{
Detail::ParseSafe(Json, ModInfo.Stats, "stats");
}

{
Detail::ParseSafe(Json, ModInfo.YoutubeURLs, "media");
Detail::ParseSafe(Json, ModInfo.SketchfabURLs, "media");
}

if (Json.contains("media"))
{
// @todo: Inefficient: This parses out much more data than needed just to throw it away
Modio::Detail::GalleryList Gallery;
if (Detail::ParseSafe(Json, Gallery, "media"))
{
ModInfo.NumGalleryImages = Gallery.Size();
}
Detail::ParseSafe(Json.at("media"), ModInfo.YoutubeURLs.GetRawList(), "youtube");
Detail::ParseSafe(Json.at("media"), ModInfo.SketchfabURLs.GetRawList(), "sketchfab");
Detail::ParseSafe(Json.at("media"), ModInfo.GalleryImages, "images");
ModInfo.NumGalleryImages = ModInfo.GalleryImages.Size();
}
}

Expand All @@ -98,8 +91,9 @@ namespace Modio
{"submitted_by", Info.ProfileSubmittedBy},
{"summary", Info.ProfileSummary},
{"stats", Info.Stats},
{"media", Info.YoutubeURLs}
};
{"media", nlohmann::json::object({{"youtube", Info.YoutubeURLs.GetRawList()},
{"sketchfab", Info.SketchfabURLs.GetRawList()},
{"images", Info.GalleryImages}})}};
}

}
} // namespace Modio
1 change: 1 addition & 0 deletions Source/Modio/GeneratedSource/ModioSDKSessionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ namespace Modio
Modio::Detail::Buffer SDKSessionData::SerializeUserData()
{
nlohmann::json Data(Get().UserData);
Data["version"] = 1;
std::string UserData = Data.dump();
Modio::Detail::Buffer DataBuffer(UserData.size());
std::copy(UserData.begin(), UserData.end(), DataBuffer.begin());
Expand Down
142 changes: 125 additions & 17 deletions Source/Modio/Modio.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,110 @@
using System.IO;
using System.Collections.Generic;
using UnrealBuildTool;
using Tools.DotNETCommon;
using System.Linq;

public class Modio : ModuleRules
{
private bool PlatformMatches(UnrealTargetPlatform PlatformToCheck, string PlatformIdentifier)
{
UnrealTargetPlatform Platform;
bool ParsedSuccessfully = UnrealTargetPlatform.TryParse(PlatformIdentifier, out Platform);
return ParsedSuccessfully && (PlatformToCheck == Platform);
}
public class ModioPlatformConfigFile
{
public class PlatformConfig
{
public List<string> IncludeDirectories = new List<string>();
public List<string> PlatformSpecificDefines = new List<string>();
public List<string> ModuleDependencies = new List<string>();
}
public Dictionary<string, PlatformConfig> Platforms;
public List<string> IncludeDirectories;
public List<string> PlatformSpecificDefines;
public List<string> ModuleDependencies = new List<string>();
};

private void DumpNativePlatformConfig(ModioPlatformConfigFile.PlatformConfig Config)
{
foreach(string IncludeDirectory in Config.IncludeDirectories)
{
Log.TraceInformation("Include: " + IncludeDirectory);
}
foreach (string Define in Config.PlatformSpecificDefines)
{
Log.TraceInformation("Define: " + Define);
}
}

private ModioPlatformConfigFile.PlatformConfig LoadNativePlatformConfig()
{
ModioPlatformConfigFile.PlatformConfig MergedConfig = null;

foreach (var PlatformDirectory in Directory.EnumerateDirectories(Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform")))
{
if (File.Exists(Path.Combine(PlatformDirectory, "ueplatform.json")))
{
//Ensure changes to the platform jsons result in a rebuild of the plugin
ExternalDependencies.Add(Path.Combine(PlatformDirectory, "ueplatform.json"));

ModioPlatformConfigFile CurrentConfig = Json.Load<ModioPlatformConfigFile>(new FileReference(Path.Combine(PlatformDirectory, "ueplatform.json")));
if (CurrentConfig != null)
{
bool bFoundPlatformConfig = false;
foreach (KeyValuePair<string, ModioPlatformConfigFile.PlatformConfig> Platform in CurrentConfig.Platforms)
{
if (PlatformMatches(Target.Platform, Platform.Key))
{
Log.TraceInformation("Merging in platform configuration " + Platform.Key);
//This is the first matching platform we've found, so create our config
if (MergedConfig == null)
{
MergedConfig = new ModioPlatformConfigFile.PlatformConfig();
}

MergedConfig.IncludeDirectories.AddRange(Platform.Value.IncludeDirectories);
MergedConfig.PlatformSpecificDefines.AddRange(Platform.Value.PlatformSpecificDefines);
MergedConfig.ModuleDependencies.AddRange(Platform.Value.ModuleDependencies);

bFoundPlatformConfig = true;
}
}
//Only merge in the base data for this file, if one of the platforms inside it was a match
if (bFoundPlatformConfig)
{
MergedConfig.IncludeDirectories.AddRange(CurrentConfig.IncludeDirectories);
MergedConfig.PlatformSpecificDefines.AddRange(CurrentConfig.PlatformSpecificDefines);
MergedConfig.ModuleDependencies.AddRange(CurrentConfig.ModuleDependencies);
}
}
}
}
if (MergedConfig != null)
{
//Treat all platform specific includes as relative to the root native platform directory
MergedConfig.IncludeDirectories =
MergedConfig.IncludeDirectories.Select((string IncludeDir) => Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform", IncludeDir)).ToList();
}
return MergedConfig;
}

public Modio(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.NoSharedPCHs;
PrivatePCHHeaderFile = "Private/ModioPrivatePCH.h";
bEnableUndefinedIdentifierWarnings = false;
bEnforceIWYU = true;
bAllowConfidentialPlatformDefines = true;
//bUseUnity = false;
ModioPlatformConfigFile.PlatformConfig PlatformConfig = LoadNativePlatformConfig();

if (PlatformConfig == null)
{
throw new BuildException("Could not locate native platform configuration file. If you are using a confidential platform, please ensure you have placed the platform code into the correct directory.");
}
DumpNativePlatformConfig(PlatformConfig);
//Add stub generated header
{
string GeneratedHeaderPath = Path.Combine(ModuleDirectory, "GeneratedHeader");
Expand Down Expand Up @@ -58,7 +152,7 @@ public Modio(ReadOnlyTargetRules Target) : base(Target)

PublicSystemIncludePaths.AddRange(new string[] {
});

// Add common private includes from the Native SDK
PrivateIncludePaths.AddRange(new string[]
{
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/ext/json/single_include"),
Expand All @@ -69,13 +163,16 @@ public Modio(ReadOnlyTargetRules Target) : base(Target)
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/ext/utfcpp/source"),
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/ext/httpparser/src"),
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform/interface"),
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform/ms-common/include"),
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform/win32/win32"),
Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/modio"),
Path.Combine(GeneratedHeaderPath, "Private"),
Path.Combine(GeneratedHeaderPath, "Public")
});

//Import private platform-specific includes from the Native SDK
PrivateIncludePaths.AddRange(PlatformConfig.IncludeDirectories);

}

// Add native SDK implementation to this module so we don't have to create an extraneous module
// TODO: @modio-ue4 cleanup by using UE_4_26_OR_LATER so we can use ConditionalAddModuleDirectory

Expand All @@ -92,16 +189,23 @@ public Modio(ReadOnlyTargetRules Target) : base(Target)
Directory.CreateDirectory(GeneratedSourcePath);

//Copy all implementation headers (ipp files) to a generated source directory with the cpp extension so they will get compiled/linked
List<string> IPPFiles = new List<string>(Directory.GetFiles(Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/modio"), "*.ipp", SearchOption.AllDirectories));
IPPFiles.AddRange(Directory.GetFiles(Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform/ms-common"), "*.ipp", SearchOption.AllDirectories));
IPPFiles.AddRange(Directory.GetFiles(Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/platform/win32"), "*.ipp", SearchOption.AllDirectories));

foreach (string IPPFile in IPPFiles)
{
//Add the original file in our upstream repository as a dependency, so if a user edits it we will copy it over
ExternalDependencies.Add(IPPFile);
string DestinationPath = Path.Combine(GeneratedSourcePath, Path.ChangeExtension(Path.GetFileName(IPPFile), ".cpp"));
File.Copy(IPPFile, DestinationPath, true);

List<string> IPPFiles = new List<string>(Directory.GetFiles(Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/modio"), "*.ipp", SearchOption.AllDirectories));

// Add platform-specific include directories
foreach (string IncludePath in PlatformConfig.IncludeDirectories)
{
IPPFiles.AddRange(Directory.GetFiles(IncludePath, "*.ipp", SearchOption.AllDirectories));
}

foreach (string IPPFile in IPPFiles)
{
//Add the original file in our upstream repository as a dependency, so if a user edits it we will copy it over
ExternalDependencies.Add(IPPFile);
string DestinationPath = Path.Combine(GeneratedSourcePath, Path.ChangeExtension(Path.GetFileName(IPPFile), ".cpp"));
File.Copy(IPPFile, DestinationPath, true);
}
}

//Only supported from 4.26 onwards - workaround at the moment is for the GeneratedSourcePath to live inside the module directory
Expand All @@ -120,6 +224,8 @@ public Modio(ReadOnlyTargetRules Target) : base(Target)
// ... add private dependencies that you statically link with here ...
});

PrivateDependencyModuleNames.AddRange(PlatformConfig.ModuleDependencies.ToArray());

DynamicallyLoadedModuleNames.AddRange(new string[] {
// ... add any modules that your module loads dynamically here ...
});
Expand All @@ -141,18 +247,20 @@ public Modio(ReadOnlyTargetRules Target) : base(Target)
// Enable Unreal-specific headers in the native SDK
PrivateDefinitions.Add("MODIO_PLATFORM_UNREAL");
// Disable header-only mode
PublicDefinitions.Add("MODIO_SEPARATE_COMPILATION=1");
PrivateDefinitions.Add("MODIO_SEPARATE_COMPILATION=1");
// Disable unnecessary inlining as a result of header-only mode not being used
PublicDefinitions.Add("MODIO_IMPL=");
PrivateDefinitions.Add("MODIO_IMPL=");

// Pass-through the target platform
PublicDefinitions.Add("MODIO_TARGET_PLATFORM_ID=\"WIN\"");
foreach (string CompilerDefine in PlatformConfig.PlatformSpecificDefines)
{
PrivateDefinitions.Add(CompilerDefine);
}

// Pass-through of SDK version identifier with Unreal prefix
string VersionFilePath = Path.Combine(ModuleDirectory, "../ThirdParty/NativeSDK/.modio");
string VersionString = File.ReadAllText(VersionFilePath);
VersionString = VersionString.Trim();
PublicDefinitions.Add(string.Format("MODIO_COMMIT_HASH=\"UNREAL-{0}\"", VersionString));
PrivateDefinitions.Add(string.Format("MODIO_COMMIT_HASH=\"UNREAL-{0}\"", VersionString));

// Add dependency on version file so if it is changed we trigger a rebuild
ExternalDependencies.Add(VersionFilePath);
Expand Down
2 changes: 1 addition & 1 deletion Source/Modio/Private/Internal/Convert/FilterParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#pragma once
#include "Internal/ModioConvert.h"
#include "Internal/ModioPrivateDefines.h"

#include "ModioSDK.h"
#include "Types/ModioFilterParams.h"

MODIO_BEGIN_CONVERT_SWITCHES
FORCEINLINE Modio::FilterParams::SortDirection ToModio(EModioSortDirection SortDirection)
Expand Down
Loading

0 comments on commit e6ef053

Please sign in to comment.