Skip to content

Commit

Permalink
Show source icon in Discord RP (YARC-Official#494)
Browse files Browse the repository at this point in the history
* If multiplayer shows the Source Icon (YARC-Official#493)

* Refactored class to adhere to naming conventions

* Greatly simplified Discord icon code

---------

Co-authored-by: Paulo Cardoso <[email protected]>
  • Loading branch information
EliteAsian123 and nevespt authored Jun 25, 2023
1 parent e215701 commit 8079e00
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 279 deletions.
40 changes: 16 additions & 24 deletions Assets/Scenes/PersistantScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2065,30 +2065,22 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: cb438f304d0d4064fb1de229c53becde, type: 3}
m_Name:
m_EditorClassIdentifier:
songStartObject: {fileID: 0}
applicationID: 1091177744416637028
stableDetails:
defaultDetails: Hello there ladies and gentlemen!
defaultState: Are you ready to rock?
defaultLargeImage: icon_stable
defaultLargeText: Yet Another Rhythm Game
nightlyDetails:
defaultDetails: Hello there ladies and gentlemen!
defaultState: Are you ready to test?
defaultLargeImage: icon_nightly
defaultLargeText: Yet Another Rhythm Game - Nightly Build
devDetails:
defaultDetails: Hello there ladies and gentlemen!
defaultState: Are you ready to develop?
defaultLargeImage: icon_dev
defaultLargeText: Yet Another Rhythm Game - Developer Build
defaultSmallImage:
defaultSmallText:
currentDetails:
currenttState:
currentLargeText:
currentSmallImage:
currentSmallText:
_applicationID: 1091177744416637028
_stableDetails:
DefaultDetails: Hello there ladies and gentlemen!
DefaultState: Are you ready to rock?
DefaultLargeImage: icon_stable
DefaultLargeText: Yet Another Rhythm Game
_nightlyDetails:
DefaultDetails: Hello there ladies and gentlemen!
DefaultState: Are you ready to test?
DefaultLargeImage: icon_nightly
DefaultLargeText: Yet Another Rhythm Game - Nightly Build
_devDetails:
DefaultDetails: Hello there ladies and gentlemen!
DefaultState: Are you ready to develop?
DefaultLargeImage: icon_dev
DefaultLargeText: Yet Another Rhythm Game - Developer Build
--- !u!4 &874125451
Transform:
m_ObjectHideFlags: 0
Expand Down
24 changes: 18 additions & 6 deletions Assets/Script/Song/SongSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ public class Source {
}

public class ParsedSource {
public SourceType Type { get; private set; }

private string _icon;
private readonly string _icon;
private readonly Dictionary<string, string> _names;

public SourceType Type { get; private set; }
public bool IsFromBase { get; private set; }

private bool _isLoadingIcon;
private Sprite _iconCache;

public ParsedSource(string icon, Dictionary<string, string> names, SourceType type) {
public ParsedSource(string icon, Dictionary<string, string> names, SourceType type, bool isFromBase) {
_icon = icon;
_names = names;
Type = type;
IsFromBase = isFromBase;
}

public string GetDisplayName() {
Expand Down Expand Up @@ -97,13 +99,23 @@ public async UniTask<Sprite> GetIcon() {

return _iconCache;
}

public string GetIconURL() {
if (IsFromBase) {
return RAW_ICON_URL + $"base/icons/{_icon}.png";
}

return RAW_ICON_URL + $"extra/icons/{_icon}.png";
}
}

public static string SourcesFolder => Path.Combine(PathHelper.StreamingAssetsPath, "sources");

public const string SOURCE_REPO_FOLDER = "OpenSource-master";

public const string SOURCE_COMMIT_URL = "https://api.github.com/repos/YARC-Official/OpenSource/commits?per_page=1";
private const string SOURCE_COMMIT_URL = "https://api.github.com/repos/YARC-Official/OpenSource/commits?per_page=1";
private const string RAW_ICON_URL = "https://raw.githubusercontent.com/YARC-Official/OpenSource/master/";

public const string SOURCE_ZIP_URL = "https://github.com/YARC-Official/OpenSource/archive/refs/heads/master.zip";

private static readonly string[] SourceTypes = {
Expand Down Expand Up @@ -226,7 +238,7 @@ public static void ReadSources() {
"rb" => SourceType.RB,
"gh" => SourceType.GH,
_ => SourceType.Custom
});
}, sources.type == "base");

foreach (var id in source.ids) {
_sources.Add(id, parsed);
Expand Down
Loading

0 comments on commit 8079e00

Please sign in to comment.