Skip to content

Commit 08a5424

Browse files
committed
fixed config issues
1 parent e377c12 commit 08a5424

File tree

5 files changed

+56
-111
lines changed

5 files changed

+56
-111
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public class LootLockerEndPoints
144144

145145
//Drop Tables
146146
[Header("Drop Tables")]
147-
public static EndPointClass ComputeAndLockDropTable = new EndPointClass("v1/player/droptables/{0}/compute", LootLockerHTTPMethod.POST);
147+
public static EndPointClass ComputeAndLockDropTable = new EndPointClass("v1/player/droptables/{0}/compute?asset_details={1}", LootLockerHTTPMethod.POST);
148148
public static EndPointClass PickDropsFromDropTable = new EndPointClass("v1/player/droptables/{0}/pick", LootLockerHTTPMethod.POST);
149149
}
150150
}

Runtime/Editor/ProjectSettings.cs

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,34 @@
22
using System.Collections.Generic;
33
using UnityEditor;
44
using UnityEngine;
5+
using UnityEngine.UIElements;
56

67
namespace LootLocker.Admin
78
{
89
public class ProjectSettings : SettingsProvider
910
{
10-
private LootLockerConfig gameSettings;
11+
private static LootLockerConfig gameSettings;
12+
private SerializedObject m_CustomSettings;
13+
internal static SerializedObject GetSerializedSettings()
14+
{
15+
return new SerializedObject(gameSettings);
16+
}
1117
public ProjectSettings(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path, scopes, keywords)
1218
{
1319
}
14-
20+
public override void OnActivate(string searchContext, VisualElement rootElement)
21+
{
22+
if (gameSettings == null)
23+
{
24+
gameSettings = LootLockerConfig.Get();
25+
}
26+
// This function is called when the user clicks on the MyCustom element in the Settings window.
27+
m_CustomSettings = GetSerializedSettings();
28+
}
1529
public override void OnGUI(string searchContext)
1630
{
31+
m_CustomSettings.Update();
32+
1733
if (gameSettings == null)
1834
{
1935
gameSettings = LootLockerConfig.Get();
@@ -27,56 +43,54 @@ public override void OnGUI(string searchContext)
2743
DrawGameSettings();
2844
}
2945
}
46+
m_CustomSettings.ApplyModifiedProperties();
3047
}
3148

3249
private void DrawGameSettings()
3350
{
34-
string apiKey = gameSettings.apiKey;
3551
EditorGUI.BeginChangeCheck();
36-
apiKey = EditorGUILayout.TextField("API Key", apiKey);
52+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("apiKey"));
3753
if (EditorGUI.EndChangeCheck())
3854
{
39-
gameSettings.apiKey = apiKey;
55+
gameSettings.apiKey = m_CustomSettings.FindProperty("apiKey").stringValue;
4056
}
4157

42-
string gameVersion = gameSettings.game_version;
4358
EditorGUI.BeginChangeCheck();
44-
gameVersion = EditorGUILayout.TextField("Game Version", gameVersion);
59+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("game_version"));
4560
if (EditorGUI.EndChangeCheck())
4661
{
47-
gameSettings.game_version = gameVersion;
62+
gameSettings.game_version = m_CustomSettings.FindProperty("game_version").stringValue;
4863
}
4964

50-
LootLockerConfig.platformType platform = gameSettings.platform;
5165
EditorGUI.BeginChangeCheck();
52-
platform = (LootLockerConfig.platformType)EditorGUILayout.EnumPopup("Platform", platform);
66+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("platform"));
5367
if (EditorGUI.EndChangeCheck())
5468
{
55-
gameSettings.platform = platform;
69+
gameSettings.platform = (LootLockerConfig.platformType)m_CustomSettings.FindProperty("platform").enumValueIndex;
5670
}
5771

58-
bool onDevelopmentMode = gameSettings.developmentMode;
5972
EditorGUI.BeginChangeCheck();
60-
onDevelopmentMode = EditorGUILayout.Toggle("On Development Mode", onDevelopmentMode);
73+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("developmentMode"));
74+
6175
if (EditorGUI.EndChangeCheck())
6276
{
63-
gameSettings.developmentMode = onDevelopmentMode;
77+
gameSettings.developmentMode = m_CustomSettings.FindProperty("developmentMode").boolValue;
6478
}
6579

66-
LootLockerConfig.DebugLevel debugLevel = gameSettings.currentDebugLevel;
6780
EditorGUI.BeginChangeCheck();
68-
debugLevel = (LootLockerConfig.DebugLevel)EditorGUILayout.EnumPopup("Current Debug Level", debugLevel);
81+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("currentDebugLevel"));
82+
6983
if (EditorGUI.EndChangeCheck())
7084
{
71-
gameSettings.currentDebugLevel = debugLevel;
85+
gameSettings.currentDebugLevel = (LootLockerConfig.DebugLevel)m_CustomSettings.FindProperty("currentDebugLevel").enumValueIndex;
7286
}
7387

74-
bool allowTokenRefresh = gameSettings.allowTokenRefresh;
7588
EditorGUI.BeginChangeCheck();
76-
allowTokenRefresh = EditorGUILayout.Toggle("Allow Token Refresh", allowTokenRefresh);
89+
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("allowTokenRefresh"));
90+
7791
if (EditorGUI.EndChangeCheck())
7892
{
79-
gameSettings.allowTokenRefresh = allowTokenRefresh;
93+
gameSettings.allowTokenRefresh = m_CustomSettings.FindProperty("allowTokenRefresh").boolValue;
8094
}
8195
}
8296

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 6 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,82 +1310,6 @@ public static void RemovingFilesFromAssetCandidates(int assetId, int fileId, Act
13101310
}
13111311
#endregion
13121312

1313-
#region Events
1314-
public static void GettingAllEvents(Action<LootLockerEventResponse> onComplete)
1315-
{
1316-
if (!CheckInitialized())
1317-
{
1318-
LootLockerEventResponse response = new LootLockerEventResponse();
1319-
response.success = false;
1320-
response.status = false;
1321-
response.hasError = true;
1322-
response.Error = "SDk not initialised";
1323-
response.text = "SDk not initialised";
1324-
onComplete?.Invoke(response);
1325-
return;
1326-
}
1327-
LootLockerAPIManager.GettingAllEvents(onComplete);
1328-
}
1329-
1330-
public static void GettingASingleEvent(int missionId, Action<LootLockerSingleEventResponse> onComplete)
1331-
{
1332-
if (!CheckInitialized())
1333-
{
1334-
LootLockerSingleEventResponse response = new LootLockerSingleEventResponse();
1335-
response.success = false;
1336-
response.status = false;
1337-
response.hasError = true;
1338-
response.Error = "SDk not initialised";
1339-
response.text = "SDk not initialised";
1340-
onComplete?.Invoke(response);
1341-
return;
1342-
}
1343-
LootLockerGetRequest data = new LootLockerGetRequest();
1344-
data.getRequests.Add(missionId.ToString());
1345-
LootLockerAPIManager.GettingASingleEvent(data, onComplete);
1346-
}
1347-
1348-
public static void StartingEvent(int missionId, Action<LootLockerStartinEventResponse> onComplete)
1349-
{
1350-
if (!CheckInitialized())
1351-
{
1352-
LootLockerStartinEventResponse response = new LootLockerStartinEventResponse();
1353-
response.success = false;
1354-
response.status = false;
1355-
response.hasError = true;
1356-
response.Error = "SDk not initialised";
1357-
response.text = "SDk not initialised";
1358-
onComplete?.Invoke(response);
1359-
return;
1360-
}
1361-
LootLockerGetRequest data = new LootLockerGetRequest();
1362-
data.getRequests.Add(missionId.ToString());
1363-
LootLockerAPIManager.StartingEvent(data, onComplete);
1364-
}
1365-
1366-
public static void FinishingEvent(int missionId, string signature, string finishTime, string finishScore, LootLockerCheckpointTimes[] checkpointsScores, Action<LootLockerFinishEventResponse> onComplete)
1367-
{
1368-
if (!CheckInitialized())
1369-
{
1370-
LootLockerFinishEventResponse response = new LootLockerFinishEventResponse();
1371-
response.success = false;
1372-
response.status = false;
1373-
response.hasError = true;
1374-
response.Error = "SDk not initialised";
1375-
response.text = "SDk not initialised";
1376-
onComplete?.Invoke(response);
1377-
return;
1378-
}
1379-
LootLockerEventPayload payload = new LootLockerEventPayload { finish_score = finishScore, finish_time = finishTime };
1380-
payload.checkpoint_times = checkpointsScores;
1381-
FinishEventRequest data = new FinishEventRequest { signature = signature, payload = payload };
1382-
LootLockerGetRequest lootLockerGetRequest = new LootLockerGetRequest();
1383-
lootLockerGetRequest.getRequests.Add(missionId.ToString());
1384-
LootLockerAPIManager.FinishingEvent(lootLockerGetRequest, data, onComplete);
1385-
}
1386-
1387-
#endregion
1388-
13891313
#region Missions
13901314
public static void GettingAllMissions(Action<LootLockerGettingAllMissionsResponse> onComplete)
13911315
{
@@ -1657,7 +1581,7 @@ public static void GetMessages(Action<LootLockerGetMessagesResponse> onComplete)
16571581

16581582
#endregion
16591583

1660-
#region Events
1584+
#region TriggerEvents
16611585
public static void TriggeringAnEvent(string eventName, Action<LootLockerTriggerAnEventResponse> onComplete)
16621586
{
16631587
if (!CheckInitialized())
@@ -1815,7 +1739,8 @@ public static void SubmitScore(string member_id, int score, int id, Action<LootL
18151739

18161740
LootLockerAPIManager.SubmitScore(request, id.ToString(), onComplete);
18171741
}
1818-
public static void ComputeAndLockDropTable(int tableId, Action<LootLockerComputeAndLockDropTableResponse> onComplete)
1742+
1743+
public static void ComputeAndLockDropTable(int tableInstanceId, Action<LootLockerComputeAndLockDropTableResponse> onComplete)
18191744
{
18201745
if (!CheckInitialized())
18211746
{
@@ -1827,10 +1752,10 @@ public static void ComputeAndLockDropTable(int tableId, Action<LootLockerCompute
18271752
onComplete?.Invoke(response);
18281753
return;
18291754
}
1830-
LootLockerAPIManager.ComputeAndLockDropTable(tableId, onComplete);
1755+
LootLockerAPIManager.ComputeAndLockDropTable(tableInstanceId, onComplete);
18311756
}
18321757

1833-
public static void PickDropsFromDropTable(int[] picks, int tableId, Action<LootLockerPickDropsFromDropTableResponse> onComplete)
1758+
public static void PickDropsFromDropTable(int[] picks, int tableInstanceId, Action<LootLockerPickDropsFromDropTableResponse> onComplete)
18341759
{
18351760
if (!CheckInitialized())
18361761
{
@@ -1845,7 +1770,7 @@ public static void PickDropsFromDropTable(int[] picks, int tableId, Action<LootL
18451770
PickDropsFromDropTableRequest data = new PickDropsFromDropTableRequest();
18461771
data.picks = picks;
18471772

1848-
LootLockerAPIManager.PickDropsFromDropTable(data, tableId, onComplete);
1773+
LootLockerAPIManager.PickDropsFromDropTable(data, tableInstanceId, onComplete);
18491774
}
18501775
#endregion
18511776
}

Runtime/Game/Requests/DropTableRequest.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ namespace LootLocker
4747
{
4848
public partial class LootLockerAPIManager
4949
{
50-
public static void ComputeAndLockDropTable(int tableId, Action<LootLockerComputeAndLockDropTableResponse> onComplete)
50+
public static void ComputeAndLockDropTable(int tableInstanceId, Action<LootLockerComputeAndLockDropTableResponse> onComplete, bool AddAssetDetails = false, string tag = "")
5151
{
5252
EndPointClass requestEndPoint = LootLockerEndPoints.PickDropsFromDropTable;
53-
54-
string endPoint = string.Format(requestEndPoint.endPoint, tableId);
53+
54+
string endPoint = string.Format(requestEndPoint.endPoint, tableInstanceId, AddAssetDetails.ToString().ToLower());
55+
56+
if (!string.IsNullOrEmpty(tag))
57+
{
58+
string tempEndpoint = $"&tag={tag}";
59+
endPoint += tempEndpoint;
60+
}
5561

5662
LootLockerServerRequest.CallAPI(endPoint, requestEndPoint.httpMethod, null, onComplete: (serverResponse) =>
5763
{
@@ -67,14 +73,14 @@ public static void ComputeAndLockDropTable(int tableId, Action<LootLockerCompute
6773
}, useAuthToken: true, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.User);
6874
}
6975

70-
public static void PickDropsFromDropTable(PickDropsFromDropTableRequest data, int tableId, Action<LootLockerPickDropsFromDropTableResponse> onComplete)
76+
public static void PickDropsFromDropTable(PickDropsFromDropTableRequest data, int tableInstanceId, Action<LootLockerPickDropsFromDropTableResponse> onComplete)
7177
{
7278
EndPointClass requestEndPoint = LootLockerEndPoints.PickDropsFromDropTable;
7379
string json = "";
7480
if (data == null) return;
7581
else json = JsonConvert.SerializeObject(data);
7682

77-
string endPoint = string.Format(requestEndPoint.endPoint, tableId);
83+
string endPoint = string.Format(requestEndPoint.endPoint, tableInstanceId);
7884

7985
LootLockerServerRequest.CallAPI(endPoint, requestEndPoint.httpMethod, json, onComplete: (serverResponse) =>
8086
{

Runtime/Game/Resources/Config/LootLockerConfig.asset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ MonoBehaviour:
1212
m_Script: {fileID: 11500000, guid: 229899d0a9432e949bee860825252188, type: 3}
1313
m_Name: LootLockerConfig
1414
m_EditorClassIdentifier:
15-
apiKey: 1f42799da6f88f1b3effe02c83f3777149392436
16-
token:
15+
apiKey: d68e80882e497af07338bdff0aa9822c9e609a68
16+
token: 64e5f6d949cfc75ab8470444c91648d8bf6475ef
1717
gameID: 0
18-
game_version: 1.0.0.
18+
game_version: 1.0.0.4
1919
deviceID: defaultPlayerId
20-
platform: 0
20+
platform: 2
2121
developmentMode: 1
2222
url: https://api.lootlocker.io/game/v1
2323
adminUrl: https://api.lootlocker.io/admin

0 commit comments

Comments
 (0)