Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
702 changes: 648 additions & 54 deletions Assets/Samples/Playground/Scenes/Playground.unity

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Assets/Samples/Playground/Scripts/Feedback.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Assets/Samples/Playground/Scripts/Feedback/GetCategories.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;
using TaloGameServices;
using System.Threading.Tasks;
using System.Linq;

public class GetCategories : MonoBehaviour
{
public async void OnButtonClick()
{
await FetchCategories();
}

private async Task FetchCategories()
{
var categories = await Talo.Feedback.GetCategories();

if (categories.Length == 0)
{
ResponseMessage.SetText("No categories found. Create some in the Talo dashboard!");
}
else
{
var mapped = categories.Select((c) => $"{c.name} ({c.internalName})");
ResponseMessage.SetText($"Categories: " + string.Join(',', mapped));
}
}
}
11 changes: 11 additions & 0 deletions Assets/Samples/Playground/Scripts/Feedback/GetCategories.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/Samples/Playground/Scripts/Feedback/SendFeedback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;
using TaloGameServices;

public class SendFeedback : MonoBehaviour
{
public string internalName, feedbackComment;

public async void OnButtonClick()
{
await Talo.Feedback.Send(internalName, feedbackComment);
ResponseMessage.SetText($"Feedback sent for {internalName}: {feedbackComment}");
}
}
11 changes: 11 additions & 0 deletions Assets/Samples/Playground/Scripts/Feedback/SendFeedback.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ private async Task FetchEntries()
if (entries.Length == 0)
{
ResponseMessage.SetText($"No entries for page {page}");
} else
}
else
{
ResponseMessage.SetText(string.Join(", ", entries.Select((e) => e.ToString()).ToArray()));
}
Expand Down
3 changes: 2 additions & 1 deletion Assets/Samples/SavesDemo/Scripts/GlobalUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ private void OnSaveChosen(GameSave save)
SetDocumentVisibility(savesListUI, DisplayStyle.None);
SetDocumentVisibility(menuUI, DisplayStyle.None);
SetDocumentVisibility(gameUI, DisplayStyle.Flex);
} else
}
else
{
SetDocumentVisibility(gameUI, DisplayStyle.None);
SetDocumentVisibility(menuUI, DisplayStyle.Flex);
Expand Down
16 changes: 16 additions & 0 deletions Packages/com.trytalo.talo/Runtime/Entities/FeedbackCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace TaloGameServices
{
[Serializable]
public class FeedbackCategory
{
public int id;
public string internalName;
public string name;
public string description;
public bool anonymised;
public string createdAt;
public string updatedAt;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Packages/com.trytalo.talo/Runtime/Entities/SaveContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public SavedObject(LoadableData loadableData)
value = field.Value.ToString(),
type = field.Value.GetType().ToString()
}).ToArray();
} else
}
else
{
data = new SavedObjectData[]
{
Expand Down
30 changes: 30 additions & 0 deletions Packages/com.trytalo.talo/Runtime/FeedbackAPI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Threading.Tasks;
using UnityEngine;

namespace TaloGameServices
{
public class FeedbackAPI : BaseAPI
{
public FeedbackAPI(TaloManager manager) : base(manager, "/v1/game-feedback") { }

public async Task<FeedbackCategory[]> GetCategories()
{
var uri = new Uri(baseUrl + "/categories");

var json = await Call(uri, "GET");
var res = JsonUtility.FromJson<FeedbackCategoriesResponse>(json);
return res.feedbackCategories;
}

public async Task Send(string internalName, string comment)
{
Talo.IdentityCheck();

var uri = new Uri(baseUrl + $"/categories/{internalName}");
var content = JsonUtility.ToJson(new FeedbackPostRequest() { comment = comment });

await Call(uri, "POST", content);
}
}
}
11 changes: 11 additions & 0 deletions Packages/com.trytalo.talo/Runtime/FeedbackAPI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TaloGameServices
{
public class FeedbackPostRequest
{
public string comment;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TaloGameServices
{
[System.Serializable]
public class FeedbackCategoriesResponse
{
public FeedbackCategory[] feedbackCategories;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions Packages/com.trytalo.talo/Runtime/SavesAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public async Task<GameSave[]> GetSaves()
if (Talo.IsOffline())
{
if (offlineSaves != null) saves.AddRange(offlineSaves);
} else
}
else
{
Talo.IdentityCheck();

Expand Down Expand Up @@ -184,7 +185,8 @@ private void UpdateOfflineSaves(GameSave incomingSave)

offlineContent.saves = offlineContent.saves.Concat(new GameSave[] { incomingSave }).ToArray();
}
} else
}
else
{
// first entry into the saves file
incomingSave.id = -1;
Expand All @@ -208,7 +210,8 @@ public async Task<GameSave> CreateSave(string saveName, string content = null)
content = saveContent,
updatedAt = DateTime.UtcNow.ToString("O")
};
} else
}
else
{
Talo.IdentityCheck();

Expand Down Expand Up @@ -254,7 +257,8 @@ public async Task<GameSave> UpdateSave(int saveId, string newName = "")
if (!string.IsNullOrEmpty(newName)) save.name = newName;
save.content = saveContent;
save.updatedAt = DateTime.UtcNow.ToString("O");
} else
}
else
{
Talo.IdentityCheck();

Expand Down
10 changes: 9 additions & 1 deletion Packages/com.trytalo.talo/Runtime/Talo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Talo
internal static SavesAPI _saves;
internal static StatsAPI _stats;
internal static GameConfigAPI _gameConfig;
internal static FeedbackAPI _feedback;

private static PlayerAlias _currentAlias;

Expand Down Expand Up @@ -80,6 +81,11 @@ public static GameConfigAPI GameConfig
get => _gameConfig;
}

public static FeedbackAPI Feedback
{
get => _feedback;
}

static Talo()
{
TaloManager tm;
Expand All @@ -95,7 +101,8 @@ static Talo()

tm = new GameObject("Talo Manager").AddComponent<TaloManager>();
tm.settings = settings;
} else
}
else
{
tm = UnityEngine.Object.FindObjectOfType<TaloManager>();
}
Expand All @@ -106,6 +113,7 @@ static Talo()
_saves = new SavesAPI(tm);
_stats = new StatsAPI(tm);
_gameConfig = new GameConfigAPI(tm);
_feedback = new FeedbackAPI(tm);
}

public static bool HasIdentity()
Expand Down
5 changes: 3 additions & 2 deletions Packages/com.trytalo.talo/Runtime/Utils/RequestMock.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -68,7 +68,8 @@ public static string HandleCall(Uri uri, string method)
{
_oneTimeHandlers.Remove(handler.GetValueOrDefault());
return handler.GetValueOrDefault().response;
} else
}
else
{
throw new Exception($"Request handler not set for {method} {uri}");
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.trytalo.talo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.trytalo.talo",
"version": "0.17.0",
"displayName": "Talo Game Services",
"description": "Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud",
"description": "Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud\n- Get feedback directly from your players",
"unity": "2022.3",
"keywords": [],
"author": {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Build games faster and make better decisions with the [Talo](https://trytalo.com
- 📊 [Game stats](https://trytalo.com/stats) (global and per-player)
- ⚙️ [Live config](https://trytalo.com/live-config) (update your game config from the web, no releases required)
- 🔧 [Steamworks integration](https://trytalo.com/steamworks-integration)
- 💬 [Game feedback](https://trytalo.com/feedback)

## Docs

Expand Down
Loading