Skip to content

Commit 726e071

Browse files
committed
Added UGC Support and Made some bug fixes
1 parent 553c21c commit 726e071

File tree

61 files changed

+2466
-137
lines changed

Some content is hidden

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

61 files changed

+2466
-137
lines changed

Assets/LootLocker/Admin/Editor/AdminServerAPI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected override void RefreshTokenAndCompleteCall(ServerRequest cacheServerReq
4343
}
4444
else
4545
{
46-
Debug.LogError("Admin token refresh failed");
46+
LootLockerSDKAdminManager.DebugMessage("Admin token refresh failed");
4747
LootLockerResponse res = new LootLockerResponse();
4848
res.statusCode = 401;
4949
res.Error = "Admin token Expired";
@@ -53,7 +53,7 @@ protected override void RefreshTokenAndCompleteCall(ServerRequest cacheServerReq
5353
}
5454
else
5555
{
56-
Debug.LogError("Admin token refresh failed");
56+
LootLockerSDKAdminManager.DebugMessage("Admin token refresh failed",true);
5757
LootLockerResponse res = new LootLockerResponse();
5858
res.statusCode = 401;
5959
res.Error = "Admin token Expired";

Assets/LootLocker/Admin/Editor/AdminUserTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public void SetupTwoFactorAuthentication()
1313
{
1414
if (response.success)
1515
{
16-
Debug.LogError("Successful setup two factor authentication: " + response.text);
16+
LootLockerSDKAdminManager.DebugMessage("Successful setup two factor authentication: " + response.text);
1717
}
1818
else
1919
{
20-
Debug.LogError("failed to set two factor authentication: " + response.Error);
20+
LootLockerSDKAdminManager.DebugMessage("failed to set two factor authentication: " + response.Error, true);
2121
}
2222
});
2323
}

Assets/LootLocker/Admin/Editor/LootLockerSDKAdminManager.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void Init()
2626

2727
static bool LoadConfig()
2828
{
29-
Debug.LogWarning("Loading admin config..");
29+
LootLockerSDKAdminManager.DebugMessage("Loading admin config..");
3030

3131
if (LootLockerAdminConfig.current == null)
3232
LootLockerAdminConfig.current = Resources.Load("Config/LootLockerAdminConfig") as LootLockerAdminConfig;
@@ -40,17 +40,21 @@ static bool LoadConfig()
4040

4141
}
4242

43-
public static void DebugMessage(string message)
43+
public static void DebugMessage(string message, bool IsError = false)
4444
{
45-
Debug.Log("Response: " + message);
45+
#if UNITY_EDITOR
46+
if (IsError)
47+
Debug.LogError(message);
48+
else
49+
Debug.Log(message);
50+
#endif
4651
}
4752

4853
public static bool CheckInitialized()
4954
{
5055
if (!initialized)
5156
{
5257
Init();
53-
//DebugMessage("Please initialize before calling sdk functions");
5458
return true;
5559
}
5660

@@ -61,7 +65,7 @@ public static bool CheckInitialized()
6165
catch (Exception ex)
6266
{
6367

64-
Debug.LogWarning("Couldn't change activeConfig on ServerAPI to Admin config. " + ex);
68+
LootLockerSDKAdminManager.DebugMessage("Couldn't change activeConfig on ServerAPI to Admin config. " + ex, true);
6569

6670
}
6771

Assets/LootLocker/Admin/Editor/Panel/Assets.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public partial class LootlockerAdminPanel : EditorWindow
2020

2121
void PopulateAssets(string search = null)
2222
{
23-
Debug.Log("Getting assets..");
23+
LootLockerSDKAdminManager.DebugMessage("Getting assets..");
2424

2525
currentView = View.Loading;
2626

@@ -32,23 +32,23 @@ void PopulateAssets(string search = null)
3232
{
3333
Contexts = contextResponse.Contexts;
3434
ContextNames = Contexts.Select(x => x.name).ToArray();
35-
Debug.Log("Successful got all contexts: " + contextResponse.text);
35+
LootLockerSDKAdminManager.DebugMessage("Successful got all contexts: " + contextResponse.text);
3636
}
3737
else
3838
{
39-
Debug.LogError("failed to get all contexts: " + contextResponse.Error);
39+
LootLockerSDKAdminManager.DebugMessage("failed to get all contexts: " + contextResponse.Error, true);
4040
}
4141

4242
if (response.success)
4343
{
4444
assetsResponse = response;
4545
currentView = View.Assets;
4646
Repaint();
47-
Debug.Log("Successful got all assets: " + response.text);
47+
LootLockerSDKAdminManager.DebugMessage("Successful got all assets: " + response.text);
4848
}
4949
else
5050
{
51-
Debug.LogError("failed to get all assets: " + response.Error);
51+
LootLockerSDKAdminManager.DebugMessage("failed to get all assets: " + response.Error, true);
5252
}
5353

5454
});

Assets/LootLocker/Admin/Editor/Panel/Files.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ void DrawCreateFileView()
270270
}
271271
else
272272
{
273-
274273
EditorGUILayout.LabelField("File name: " + Path.GetFileName(filePath),
275274
new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleLeft },
276275
GUILayout.MaxWidth(1000), GUILayout.Height(25));

Assets/LootLocker/Admin/Requests/AdminAssetsRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static void GetAssets(Action<GetAssetsResponse> onComplete, string search
9696
response.Error = serverResponse.Error;
9797
onComplete?.Invoke(response);
9898
}
99-
}, useAuthToken: true, isAdminCall: true);
99+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
100100
}
101101

102102
public static void CreateAsset(CreateAssetRequest request, Action<CreateAssetResponse> onComplete)
@@ -131,7 +131,7 @@ public static void CreateAsset(CreateAssetRequest request, Action<CreateAssetRes
131131
response.Error = serverResponse.Error;
132132
onComplete?.Invoke(response);
133133
}
134-
}, useAuthToken: true, isAdminCall: true);
134+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
135135

136136
}
137137

@@ -156,7 +156,7 @@ public static void GetContexts(Action<GetContextsResponse> onComplete)
156156
response.Error = serverResponse.Error;
157157
onComplete?.Invoke(response);
158158
}
159-
}, useAuthToken: true, isAdminCall: true);
159+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
160160
}
161161

162162
}

Assets/LootLocker/Admin/Requests/AdminEventsRequests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static void CreatingEvent(Dictionary<string, object> requestData, Action<
292292
response.Error = serverResponse.Error;
293293
onComplete?.Invoke(response);
294294
}
295-
}, useAuthToken: true, isAdminCall: true);
295+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
296296

297297
}
298298

@@ -324,7 +324,7 @@ public static void UpdatingEvent(LootLockerGetRequest lootLockerGetRequest, Dict
324324
response.Error = serverResponse.Error;
325325
onComplete?.Invoke(response);
326326
}
327-
}, useAuthToken: true, isAdminCall: true);
327+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
328328

329329
}
330330

@@ -350,7 +350,7 @@ public static void GettingAllEvents(LootLockerGetRequest lootLockerGetRequest, A
350350
response.Error = serverResponse.Error;
351351
onComplete?.Invoke(response);
352352
}
353-
}, useAuthToken: true, isAdminCall: true);
353+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
354354

355355
}
356356

Assets/LootLocker/Admin/Requests/AdminFilesRequest.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ public static string UploadAFile(string filePath, string id, int gameId, Action<
8888
}
8989

9090
var eventId = Guid.NewGuid().ToString();
91-
ServerRequest.UploadFile(endPoint.endPoint, endPoint.httpMethod, System.IO.File.ReadAllBytes(filePath), formData, (serverResponse) =>
91+
92+
string[] splitFilePath = filePath.Split(new char[] { '\\', '/' });
93+
string defaultFileName = splitFilePath[splitFilePath.Length - 1];
94+
95+
ServerRequest.UploadFile(endPoint.endPoint, endPoint.httpMethod, System.IO.File.ReadAllBytes(filePath), defaultFileName,
96+
body: formData, onComplete: (serverResponse) =>
9297
{
9398
UploadAFileResponse response = new UploadAFileResponse();
9499
if (string.IsNullOrEmpty(serverResponse.Error))
@@ -105,7 +110,7 @@ public static string UploadAFile(string filePath, string id, int gameId, Action<
105110
response.Error = serverResponse.Error;
106111
onComplete?.Invoke(response);
107112
}
108-
}, useAuthToken: true, isAdminCall: true);
113+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
109114

110115
return eventId;
111116
}
@@ -134,7 +139,7 @@ public static void GetFiles(FileFilterType filter, Action<GetFilesResponse> onCo
134139
response.Error = serverResponse.Error;
135140
onComplete?.Invoke(response);
136141
}
137-
}, useAuthToken: true, isAdminCall: true);
142+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
138143
}
139144

140145
public static void DeleteFile(string fileId, Action<DeleteFileResponse> onComplete)
@@ -158,7 +163,7 @@ public static void DeleteFile(string fileId, Action<DeleteFileResponse> onComple
158163
response.Error = serverResponse.Error;
159164
onComplete?.Invoke(response);
160165
}
161-
}, useAuthToken: true, isAdminCall: true);
166+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
162167
}
163168

164169
public static void UpdateFile(string fileId, UpdateFileRequest request, Action<UpdateFileResponse> onComplete)
@@ -183,7 +188,7 @@ public static void UpdateFile(string fileId, UpdateFileRequest request, Action<U
183188
response.Error = serverResponse.Error;
184189
onComplete?.Invoke(response);
185190
}
186-
}, useAuthToken: true, isAdminCall: true);
191+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
187192
}
188193

189194

Assets/LootLocker/Admin/Requests/AdminMapsRequests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static void GettingAllMapsToAGame(LootLockerGetRequest lootLockerGetReque
117117
response.Error = serverResponse.Error;
118118
onComplete?.Invoke(response);
119119
}
120-
}, useAuthToken: true, isAdminCall: true);
120+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
121121

122122
}
123123

@@ -153,7 +153,7 @@ public static void CreatingMaps(CreatingMapsRequest data, bool sendAssetID, bool
153153
response.Error = serverResponse.Error;
154154
onComplete?.Invoke(response);
155155
}
156-
}, useAuthToken: true, isAdminCall: true);
156+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
157157
}
158158

159159
public static void UpdatingMaps(LootLockerGetRequest lootLockerGetRequest, CreatingMapsRequest data, Action<CreatingMapsResponse> onComplete)
@@ -184,7 +184,7 @@ public static void UpdatingMaps(LootLockerGetRequest lootLockerGetRequest, Creat
184184
response.Error = serverResponse.Error;
185185
onComplete?.Invoke(response);
186186
}
187-
}, useAuthToken: true, isAdminCall: true);
187+
}, useAuthToken: true, callerRole: enums.CallerRole.Admin);
188188
}
189189

190190

Assets/LootLocker/Admin/Requests/AdminPlayerRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void SearchingForPlayers(LootLockerGetRequest data, Action<Searchi
5959
response.Error = serverResponse.Error;
6060
onComplete?.Invoke(response);
6161
}
62-
}, true, true);
62+
}, true, callerRole: enums.CallerRole.Admin);
6363
}
6464

6565
}

0 commit comments

Comments
 (0)