Skip to content

Commit 1464563

Browse files
authored
Merge pull request #10 from modio/Syncing-v2024.7.1
Syncing v2024.7.1
2 parents f69afac + 2e390b7 commit 1464563

File tree

843 files changed

+45642
-2267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

843 files changed

+45642
-2267
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.IO;
3+
using UnityEngine;
4+
5+
#if UNITY_EDITOR
6+
using UnityEditor;
7+
8+
public static class CacheOpener
9+
{
10+
[MenuItem("Tools/mod.io/Open Cache")]
11+
public static void OpenCache()
12+
{
13+
try
14+
{
15+
string path = Path.GetFullPath($"{Application.persistentDataPath}/mod.io");
16+
#if UNITY_EDITOR_WIN || UNITY_EDITOR_LINUX
17+
// Supposedly Linux uses the same executable name as windows, though not 100% confident
18+
// so wrapping all this in a try catch.
19+
System.Diagnostics.Process.Start("explorer.exe", path);
20+
#elif UNITY_EDITOR_OSX
21+
System.Diagnostics.Process.Start("open", $"-R \"{path}\"");
22+
#endif
23+
}
24+
catch (Exception exception)
25+
{
26+
Debug.LogError($"Exception opening local cache: {exception.Message}\n{exception.StackTrace}");
27+
}
28+
}
29+
}
30+
#endif

Editor/ModIO.EditorCode/CacheOpener.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/ModIO.EditorCode/EditorMenu.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#if UNITY_EDITOR
2-
using UnityEngine;
3-
using UnityEditor;
42

53
using ModIO.Implementation;
64
using ModIO.Implementation.Platform;
5+
using UnityEditor;
6+
using UnityEngine;
77

88
namespace ModIO.EditorCode
99
{
10-
1110
/// <summary>summary</summary>
1211
public static class EditorMenu
1312
{
@@ -16,10 +15,11 @@ static EditorMenu()
1615
new MenuItem("Tools/mod.io/Edit Settings", false, 0);
1716
}
1817

18+
1919
[MenuItem("Tools/mod.io/Edit Settings", false, 0)]
2020
public static void EditSettingsAsset()
2121
{
22-
var settingsAsset = GetConfigAsset();
22+
SettingsAsset settingsAsset = GetConfigAsset();
2323

2424
EditorGUIUtility.PingObject(settingsAsset);
2525
Selection.activeObject = settingsAsset;
@@ -28,23 +28,19 @@ public static void EditSettingsAsset()
2828

2929
internal static SettingsAsset GetConfigAsset()
3030
{
31-
var settingsAsset = Resources.Load<SettingsAsset>(SettingsAsset.FilePath);
31+
SettingsAsset settingsAsset = Resources.Load<SettingsAsset>(SettingsAsset.FilePath);
3232

3333
// if it doesnt exist we create one
34-
if(settingsAsset == null)
34+
if (settingsAsset == null)
3535
{
3636
// create asset
3737
settingsAsset = ScriptableObject.CreateInstance<SettingsAsset>();
3838

3939
// ensure the directories exist before trying to create the asset
40-
if(!AssetDatabase.IsValidFolder("Assets/Resources"))
41-
{
40+
if (!AssetDatabase.IsValidFolder("Assets/Resources"))
4241
AssetDatabase.CreateFolder("Assets", "Resources");
43-
}
44-
if(!AssetDatabase.IsValidFolder("Assets/Resources/mod.io"))
45-
{
42+
if (!AssetDatabase.IsValidFolder("Assets/Resources/mod.io"))
4643
AssetDatabase.CreateFolder("Assets/Resources", "mod.io");
47-
}
4844

4945
AssetDatabase.CreateAsset(settingsAsset, $@"Assets/Resources/{SettingsAsset.FilePath}.asset");
5046

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#if UNITY_EDITOR
2+
using System.Collections.Generic;
3+
using ModIO.Implementation;
4+
using UnityEditor;
5+
using UnityEditor.UIElements;
6+
using UnityEngine;
7+
using UnityEngine.UIElements;
8+
9+
namespace ModIO.EditorCode
10+
{
11+
public class ModioSettingProvider : SettingsProvider
12+
{
13+
SettingsAsset _config;
14+
SerializedObject _serializedConfig;
15+
16+
ModioSettingProvider() :
17+
base("mod.io/Settings", SettingsScope.Project, new HashSet<string>(new[] { "modio", "gameId", "gameKey", "apiKey", "Server URL" }))
18+
{
19+
}
20+
21+
public override void OnActivate(string searchContext, VisualElement rootElement)
22+
{
23+
_config = EditorMenu.GetConfigAsset();
24+
_serializedConfig = new SerializedObject(_config);
25+
26+
rootElement.Add(new Label("mod.io Settings")
27+
{
28+
style =
29+
{
30+
marginLeft = 4,
31+
fontSize = 19,
32+
unityFontStyleAndWeight = FontStyle.Bold,
33+
},
34+
});
35+
rootElement.Add(new InspectorElement(_serializedConfig));
36+
}
37+
38+
[SettingsProvider]
39+
public static SettingsProvider OpenModioSettingsProvider() => new ModioSettingProvider();
40+
}
41+
}
42+
#endif

Editor/ModIO.EditorCode/ModioSettingProvider.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/ModIO.EditorCode/SettingsAssetEditor.cs

+56-26
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,68 @@
44
using UnityEditor;
55
using UnityEngine;
66

7-
[CustomEditor(typeof(SettingsAsset))]
7+
[CustomEditor(typeof( SettingsAsset ))]
88
public class SettingsAssetEditor : Editor
99
{
10-
SerializedProperty serverURL;
11-
SerializedProperty gameId;
12-
SerializedProperty gameKey;
13-
SerializedProperty languageCode;
14-
int previousGameId = 0;
15-
16-
void OnEnable()
10+
SerializedProperty gameId;
11+
SerializedProperty gameKey;
12+
SerializedProperty languageCode;
13+
int previousGameId;
14+
SerializedProperty serverURL;
15+
SerializedProperty useCommandLineArgumentOverrides;
16+
SerializedProperty _showMonetizationUIProperty;
17+
SerializedProperty _showEnabledModToggleProperty;
18+
19+
void OnEnable()
1720
{
1821
//get references to SerializedProperties
19-
var serverSettingsProperty = serializedObject.FindProperty("serverSettings");
22+
SerializedProperty serverSettingsProperty = serializedObject.FindProperty("serverSettings");
2023
serverURL = serverSettingsProperty.FindPropertyRelative("serverURL");
2124
gameId = serverSettingsProperty.FindPropertyRelative("gameId");
2225
gameKey = serverSettingsProperty.FindPropertyRelative("gameKey");
2326
languageCode = serverSettingsProperty.FindPropertyRelative("languageCode");
27+
useCommandLineArgumentOverrides = serverSettingsProperty.FindPropertyRelative("useCommandLineArgumentOverrides");
28+
29+
var uiSettingsProperty = serializedObject.FindProperty("uiSettings");
30+
31+
_showMonetizationUIProperty = uiSettingsProperty.FindPropertyRelative("ShowMonetizationUI");
32+
_showEnabledModToggleProperty = uiSettingsProperty.FindPropertyRelative("ShowEnabledModToggle");
2433
}
2534

2635
public override void OnInspectorGUI()
27-
{
36+
{
2837
//Grab any changes to the original object data
2938
serializedObject.UpdateIfRequiredOrScript();
3039

3140
SettingsAsset myTarget = (SettingsAsset)target;
3241

33-
base.OnInspectorGUI();
42+
DrawPropertiesExcluding(serializedObject, "m_Script");
3443

35-
EditorGUILayout.Space();
44+
EditorGUILayout.Space();
3645

37-
GUIStyle labelStyle = new GUIStyle();
38-
labelStyle.alignment = TextAnchor.MiddleCenter;
39-
labelStyle.fontStyle = FontStyle.Bold;
40-
labelStyle.normal.textColor = Color.white;
46+
GUIStyle labelStyle = new GUIStyle
47+
{
48+
alignment = TextAnchor.MiddleCenter,
49+
fontStyle = FontStyle.Bold,
50+
normal =
51+
{
52+
textColor = Color.white,
53+
},
54+
};
4155

42-
EditorGUILayout.LabelField("Server Settings", labelStyle);
56+
EditorGUILayout.LabelField("Server Settings", labelStyle);
4357

4458
EditorGUILayout.Space();
4559

46-
EditorGUILayout.PropertyField(gameId,new GUIContent("Game ID"));
47-
gameKey.stringValue = EditorGUILayout.PasswordField("API Key", gameKey.stringValue);
60+
EditorGUILayout.DelayedIntField(gameId, new GUIContent("Game ID"));
61+
using (EditorGUI.ChangeCheckScope passwordChange = new EditorGUI.ChangeCheckScope())
62+
{
63+
string tempPassword = EditorGUILayout.PasswordField("API Key", gameKey.stringValue);
64+
if (passwordChange.changed)
65+
gameKey.stringValue = tempPassword;
66+
}
4867

49-
if(myTarget.serverSettings.gameId == 0 || string.IsNullOrWhiteSpace(myTarget.serverSettings.gameKey))
68+
if (myTarget.serverSettings.gameId == 0 || string.IsNullOrWhiteSpace(myTarget.serverSettings.gameKey))
5069
{
5170
EditorGUILayout.Space();
5271

@@ -76,11 +95,14 @@ public override void OnInspectorGUI()
7695
EditorGUILayout.EndHorizontal();
7796

7897
EditorGUILayout.Space();
79-
} else {
98+
}
99+
else
100+
{
80101
EditorGUILayout.Space();
81102

82-
EditorGUILayout.PropertyField(serverURL, new GUIContent("Server URL"));
83-
EditorGUILayout.PropertyField(languageCode, new GUIContent("Language code"));
103+
EditorGUILayout.DelayedTextField(serverURL, new GUIContent("Server URL"));
104+
EditorGUILayout.DelayedTextField(languageCode, new GUIContent("Language code"));
105+
EditorGUILayout.PropertyField(useCommandLineArgumentOverrides, new GUIContent("Use Command Line Argument Override"));
84106

85107
EditorGUILayout.Space();
86108

@@ -96,16 +118,23 @@ public override void OnInspectorGUI()
96118
}
97119

98120
// If the gameId has been changed, update the url
99-
if (gameId.intValue != previousGameId)
121+
if (gameId.intValue != previousGameId)
100122
{
101123
if (IsURLProduction(serverURL.stringValue))
102124
serverURL.stringValue = GetURLProduction(gameId.intValue);
103125

104-
previousGameId = gameId.intValue;
105-
}
126+
previousGameId = gameId.intValue;
127+
}
128+
129+
EditorGUILayout.Space();
130+
EditorGUILayout.LabelField("UI Settings", labelStyle);
131+
132+
EditorGUILayout.PropertyField(_showMonetizationUIProperty);
133+
EditorGUILayout.PropertyField(_showEnabledModToggleProperty);
106134

107135
//Save the new values
108136
serializedObject.ApplyModifiedProperties();
137+
AssetDatabase.SaveAssetIfDirty(serializedObject?.targetObject);
109138

110139
return;
111140

@@ -123,6 +152,7 @@ void SetURLTest()
123152
}
124153

125154
internal static string GetURLProduction(int gameId) => $"https://g-{gameId}.modapi.io/v1";
155+
126156
static string GetURLTest(int gameId) => "https://api.test.mod.io/v1";
127157

128158
static bool IsURLProduction(string url) => Regex.IsMatch(url, @"https:\/\/g-\d*.modapi.io\/v1");

Experimental.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Experimental/modio-ui.unitypackage

20.8 MB
Binary file not shown.

Experimental/modio-ui.unitypackage.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Platform/Steam/Facepunch.meta

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#if UNITY_FACEPUNCH
2+
using Steamworks;
3+
#endif
4+
using UnityEngine;
5+
6+
namespace ModIO.Implementation.Platform
7+
{
8+
public class ModioPlatformExampleFacepunch : MonoBehaviour
9+
{
10+
[SerializeField] int appId;
11+
12+
void Awake()
13+
{
14+
bool supportedPlatform = !Application.isConsolePlatform;
15+
16+
#if !UNITY_FACEPUNCH
17+
supportedPlatform = false;
18+
#endif
19+
20+
if (!supportedPlatform)
21+
{
22+
Destroy(this);
23+
return;
24+
}
25+
26+
#if UNITY_FACEPUNCH
27+
try
28+
{
29+
SteamClient.Init((uint)appId, true);
30+
}
31+
catch (System.Exception e)
32+
{
33+
Debug.Log(e);
34+
return;
35+
}
36+
#endif
37+
38+
// --- This is the important line to include in your own implementation ---
39+
ModioPlatformFacepunch.SetAsPlatform();
40+
}
41+
42+
#if UNITY_FACEPUNCH
43+
void OnDisable()
44+
{
45+
SteamClient.Shutdown();
46+
}
47+
48+
void Update()
49+
{
50+
SteamClient.RunCallbacks();
51+
}
52+
#endif
53+
}
54+
}

Platform/Steam/Facepunch/ModioPlatformExampleFacepunch.cs.meta

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)