Skip to content

Commit

Permalink
v2023.5.3 patch
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlucerne committed May 19, 2023
1 parent 5508128 commit 7d62ec8
Show file tree
Hide file tree
Showing 48 changed files with 1,023 additions and 553 deletions.
27 changes: 19 additions & 8 deletions Editor/ModIO.EditorCode/SettingsAssetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
[CustomEditor(typeof(SettingsAsset))]
public class SettingsAssetEditor : Editor
{
private SerializedProperty serverURL;
private SerializedProperty gameId;
private SerializedProperty gameKey;
private SerializedProperty languageCode;
SerializedProperty serverURL;
SerializedProperty gameId;
SerializedProperty gameKey;
SerializedProperty languageCode;
int previousGameId = 0;

private void OnEnable()
void OnEnable()
{
//get references to SerializedProperties
var serverSettingsProperty = serializedObject.FindProperty("serverSettings");
Expand All @@ -24,7 +25,7 @@ private void OnEnable()
public override void OnInspectorGUI()
{
//Grab any changes to the original object data
this.serializedObject.UpdateIfRequiredOrScript();
serializedObject.UpdateIfRequiredOrScript();

SettingsAsset myTarget = (SettingsAsset)target;

Expand Down Expand Up @@ -65,7 +66,7 @@ public override void OnInspectorGUI()
}
if(GUILayout.Button("Insert URL for Production API"))
{
serverURL.stringValue = "https://api.mod.io/v1";
serverURL.stringValue = $"https://g-{gameId.intValue}.modapi.io/v1";
//remove focus from other fields
GUI.FocusControl(null);
}
Expand All @@ -83,8 +84,18 @@ public override void OnInspectorGUI()
}
}

// If the gameId has been changed, update the url
if(gameId.intValue != previousGameId)
{
if(myTarget.serverSettings.serverURL != "https://api.test.mod.io/v1")
{
serverURL.stringValue = $"https://g-{gameId.intValue}.modapi.io/v1";
}
previousGameId = gameId.intValue;
}

//Save the new values
this.serializedObject.ApplyModifiedProperties();
serializedObject.ApplyModifiedProperties();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#if UNITY_EDITOR

using System.Threading.Tasks;

namespace ModIO.Implementation.Platform
{
/// <summary>Interface for retrieving platform services.</summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
#if UNITY_2019_4_OR_NEWER
using UnityEngine;

namespace ModIO.Implementation
{
Expand All @@ -19,3 +20,4 @@ public BuildSettings GetBuildSettings()
#endif // UNITY_STANDALONE_WIN && !UNITY_EDITOR
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
#if UNITY_2019_4_OR_NEWER
using UnityEngine;

namespace ModIO.Implementation
{
Expand All @@ -19,3 +20,4 @@ public BuildSettings GetBuildSettings()
#endif // UNITY_STANDALONE && !UNITY_EDITOR
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
#if UNITY_2019_4_OR_NEWER
using UnityEngine;

namespace ModIO.Implementation
{
Expand All @@ -19,3 +20,4 @@ public BuildSettings GetBuildSettings()
#endif // UNITY_STANDALONE_WIN && !UNITY_EDITOR
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || (MODIO_COMPILE_ALL && UNITY_EDITOR) || UNITY_WSA
#if UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || (MODIO_COMPILE_ALL && UNITY_EDITOR) || UNITY_WSA || !UNITY_2019_4_OR_NEWER

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -278,4 +278,4 @@ public ResultAnd<List<string>> ListAllFiles(string directoryPath)

#pragma warning restore 1998 // These async functions don't use await!

#endif // UNITY_STANDALONE_WIN || (MODIO_COMPILE_ALL && UNITY_EDITOR)
#endif // UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || (MODIO_COMPILE_ALL && UNITY_EDITOR) || UNITY_WSA || !UNITY_2019_4_OR_NEWER
64 changes: 49 additions & 15 deletions Runtime/Classes/ModProfileDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using JetBrains.Annotations;
using System.Collections.Generic;
using UnityEngine;

namespace ModIO
Expand All @@ -16,13 +16,13 @@ public class ModProfileDetails
/// <summary>
/// Make sure to set this field when submitting a request to Edit a Mod Profile
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public ModId? modId;

/// <summary>
/// Whether this mod will appear as public or hidden.
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public bool? visible;

/// <summary>
Expand All @@ -31,62 +31,73 @@ public class ModProfileDetails
/// you supply a high resolution image with a 16 / 9 ratio. mod.io will use this image to
/// make three thumbnails for the dimensions 320x180, 640x360 and 1280x720
/// </summary>
[CanBeNull]
/// <remarks>Can be null if using EditModProfile</remarks>
/// <seealso cref="ModIOUnity.EditModProfile"/>
#if UNITY_2019_4_OR_NEWER
public Texture2D logo;
#else
public byte[] logo;
#endif

/// <summary>
/// Image files that will be included in the mod profile details.
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
#if UNITY_2019_4_OR_NEWER
public Texture2D[] images;
#else
public List<byte[]> images;
#endif

/// <summary>
/// Name of your mod
/// </summary>
[CanBeNull]
/// <remarks>Can be null if using EditModProfile</remarks>
/// <seealso cref="ModIOUnity.EditModProfile"/>
public string name;

/// <summary>
/// Path for the mod on mod.io. For example: https://gamename.mod.io/mod-name-id-here.
/// If no name_id is specified the <see cref="name"/> will be used. For example: 'Stellaris
/// Shader Mod' will become 'stellaris-shader-mod'. Cannot exceed 80 characters
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public string name_id;

/// <summary>
/// Summary for your mod, giving a brief overview of what it's about.
/// Cannot exceed 250 characters.
/// </summary>
/// <remarks>This field must be assigned when submitting a new Mod Profile</remarks>
[CanBeNull]
/// <remarks>Can be null if using EditModProfile</remarks>
/// <seealso cref="ModIOUnity.EditModProfile"/>
public string summary;

/// <summary>
/// Detailed description for your mod, which can include details such as 'About', 'Features',
/// 'Install Instructions', 'FAQ', etc. HTML supported and encouraged
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public string description;

/// <summary>
/// Official homepage for your mod. Must be a valid URL
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public string homepage_url;

/// <summary>
/// This will create a cap on the number of subscribers for this mod. Set to 0 to allow
/// for infinite subscribers.
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public int? maxSubscribers;

/// <summary>
/// This is a Bitwise enum so you can assign multiple values
/// </summary>
/// <seealso cref="ContentWarnings"/>
[CanBeNull]
/// <remarks>Can be null</remarks>
public ContentWarnings? contentWarning;

/// <summary>
Expand All @@ -95,14 +106,14 @@ public class ModProfileDetails
/// </summary>
/// <seealso cref="ModfileDetails"/>
/// <remarks>the metadata has a maximum size of 50,000 characters.</remarks>
[CanBeNull]
/// <remarks>Can be null</remarks>
public string metadata;

/// <summary>
/// The tags this mod profile has. Only tags that are supported by the parent game can be
/// applied. (Invalid tags will be ignored)
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public string[] tags;

/// <summary>
Expand All @@ -111,7 +122,30 @@ public class ModProfileDetails
/// 1 = Ability to comment (default)
/// ? = Add the options you want together, to enable multiple options
/// </summary>
[CanBeNull]
/// <remarks>Can be null</remarks>
public CommunityOptions? communityOptions = CommunityOptions.AllowCommenting;

internal byte[] GetLogo()
{
#if UNITY_2019_4_OR_NEWER
return logo.EncodeToPNG();
#else
return logo;
#endif
}

internal List<byte[]> GetGalleryImages()
{
#if UNITY_2019_4_OR_NEWER
List<byte[]> gallery = new List<byte[]>();
foreach(var texture in images)
{
gallery.Add(texture.EncodeToPNG());
}
return gallery;
#else
return images;
#endif
}
}
}
13 changes: 6 additions & 7 deletions Runtime/Classes/Report.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using JetBrains.Annotations;
using ModIO.Implementation;
using ModIO.Implementation;

namespace ModIO
{
Expand All @@ -15,11 +14,11 @@ public class Report
/// </summary>
/// <param name="modId">the id of the mod being reported</param>
/// <param name="type">the type of report</param>
/// <param name="summary">explanation of the issue being reported</param>
/// <param name="user">user reporting the issue</param>
/// <param name="contactEmail">user email address</param>
public Report(ModId modId, ReportType type, [NotNull] string summary, [NotNull] string user,
[NotNull] string contactEmail)
/// <param name="summary">CANNOT BE NULL explanation of the issue being reported</param>
/// <param name="user">CANNOT BE NULL user reporting the issue</param>
/// <param name="contactEmail">CANNOT BE NULL user email address</param>
public Report(ModId modId, ReportType type, string summary, string user,
string contactEmail)
{
id = modId;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.IO;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using JetBrains.Annotations;
using UnityEngine;

namespace ModIO.Implementation
{
Expand Down Expand Up @@ -70,7 +68,7 @@ protected async Task CompressStream(string entryName, Stream fileStream, ZipOutp
}


protected ResultAnd<MemoryStream> Abort(ResultAnd<MemoryStream> resultAnd, [CanBeNull] string details)
protected ResultAnd<MemoryStream> Abort(ResultAnd<MemoryStream> resultAnd, string details)
{
Logger.Log(LogLevel.Verbose,
$"FAILED COMPRESSION [{resultAnd.result.code}] {details}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using JetBrains.Annotations;

namespace ModIO.Implementation
{
Expand All @@ -18,7 +17,7 @@ internal class CompressOperationDirectory : CompressOperationBase

private string directory;

public CompressOperationDirectory(string directory, [CanBeNull] ProgressHandle progressHandle = null)
public CompressOperationDirectory(string directory, ProgressHandle progressHandle = null)
: base(progressHandle)
{
this.directory = directory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
using System.IO;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using JetBrains.Annotations;
using UnityEngine;

namespace ModIO.Implementation
{
internal class CompressOperationMultiple : CompressOperationBase
{
public IEnumerable<byte[]> data;

public CompressOperationMultiple(IEnumerable<byte[]> compressed, [CanBeNull] ProgressHandle progressHandle)
public CompressOperationMultiple(IEnumerable<byte[]> compressed, ProgressHandle progressHandle)
: base(progressHandle)
{
this.data = compressed;
Expand Down
3 changes: 1 addition & 2 deletions Runtime/ModIO.Implementation/Classes/ExtractOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.IO;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using JetBrains.Annotations;

namespace ModIO.Implementation
{
Expand All @@ -20,7 +19,7 @@ internal class ExtractOperation : IModIOZipOperation
Task IModIOZipOperation.GetOperation() => null;

public ExtractOperation(long modId, long fileId,
[CanBeNull] ProgressHandle progressHandle = null)
ProgressHandle progressHandle = null)
{
this.modId = modId;
this.fileId = fileId;
Expand Down
Loading

0 comments on commit 7d62ec8

Please sign in to comment.