Skip to content

Commit

Permalink
Version 6.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hardcpp committed Jul 21, 2023
1 parent b74b156 commit 362e29e
Show file tree
Hide file tree
Showing 826 changed files with 68,809 additions and 32,077 deletions.
356 changes: 286 additions & 70 deletions BeatSaberPlus/BeatSaberPlus.csproj

Large diffs are not rendered by default.

Binary file modified BeatSaberPlus/BeatSaberPlus.csproj.user
Binary file not shown.
14 changes: 9 additions & 5 deletions BeatSaberPlus/CP_SDK/Animation/AnimationControllerInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ public AnimationControllerInstance(Texture2D p_Texture, Rect[] p_UVs, ushort[] p
m_UVs = p_UVs;
Delays = p_Delays;

var l_Width = p_Texture.width;
var l_Height = p_Texture.height;
for (int l_Frame = 0; l_Frame < p_UVs.Length; ++l_Frame)
{
Frames[l_Frame] = Sprite.Create(p_Texture,
new Rect(p_UVs[l_Frame].x * p_Texture.width, p_UVs[l_Frame].y * p_Texture.height, p_UVs[l_Frame].width * p_Texture.width, p_UVs[l_Frame].height * p_Texture.height),
Vector2.zero,
100f,
var l_CurrentUV = p_UVs[l_Frame];
Frames[l_Frame] = Sprite.Create(
p_Texture,
new Rect(l_CurrentUV.x * l_Width, l_CurrentUV.y * l_Height, l_CurrentUV.width * l_Width, l_CurrentUV.height * l_Height),
new Vector2(0.0f, 0.0f),
100.0f,
0,
SpriteMeshType.FullRect
);
Expand All @@ -86,7 +90,7 @@ public AnimationControllerInstance(Texture2D p_Texture, Rect[] p_UVs, ushort[] p

FirstFrame = Frames[0];

m_LastFrameChange = (long)(Time.realtimeSinceStartup * 1000f);
m_LastFrameChange = (long)(Time.realtimeSinceStartup * 1000.0f);
}

////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions BeatSaberPlus/CP_SDK/Animation/AnimationLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public static void Load( EAnimationType p_Ty
/// <summary>
/// Process loaded animation
/// </summary>
/// <param name="p_AnimationInfo"></param>
/// <param name="p_Callback"></param>
/// <param name="p_AnimationInfo">Animation infos</param>
/// <param name="p_Callback">Callback</param>
/// <returns></returns>
public static IEnumerator Coroutine_ProcessLoadedAnimation(AnimationInfo p_AnimationInfo, Action<Texture2D, Rect[], ushort[], int, int> p_Callback)
private static IEnumerator Coroutine_ProcessLoadedAnimation(AnimationInfo p_AnimationInfo, Action<Texture2D, Rect[], ushort[], int, int> p_Callback)
{
if (p_AnimationInfo == null)
p_Callback?.Invoke(null, null, null, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion BeatSaberPlus/CP_SDK/Animation/WEBP/WEBPDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static async Task ProcessingThread( byte[] p_Raw,

try
{
p_StaticCallback?.Invoke(Unity.SpriteU.CreateFromTexture(l_Texture));
p_StaticCallback?.Invoke(Unity.SpriteU.CreateFromTextureWithBorders(l_Texture));
}
catch (System.Exception l_Exception)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Newtonsoft.Json;

namespace BeatSaberPlus
namespace CP_SDK
{
/// <summary>
/// BeatSaberPlus SDK config
/// ChatPlex SDK config
/// </summary>
internal class BSPConfig : CP_SDK.Config.JsonConfig<BSPConfig>
internal class CPConfig : Config.JsonConfig<CPConfig>
{
[JsonProperty] internal bool FirstRun = true;
[JsonProperty] internal bool FirstChatCoreRun = true;
Expand All @@ -18,7 +18,7 @@ internal class BSPConfig : CP_SDK.Config.JsonConfig<BSPConfig>
/// </summary>
/// <returns></returns>
public override string GetRelativePath()
=> "BeatSaberPlus/Config";
=> $"{ChatPlexSDK.ProductName}/Config";

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 6 additions & 6 deletions BeatSaberPlus/CP_SDK/Chat/ChatImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ChatImageProvider
internal static void Init()
{
m_CacheFolder = Path.Combine(ChatPlexSDK.BasePath, $"UserData/{ChatPlexSDK.ProductName}/Cache/Chat/");
m_WebClient = new Network.WebClient();
m_WebClient = new Network.WebClient("", TimeSpan.FromSeconds(10));
m_WebClient.Timeout = 10;

try
Expand Down Expand Up @@ -141,7 +141,7 @@ public static void TryCacheSingleImage(Interfaces.EChatResourceCategory p_Catego

if (string.IsNullOrEmpty(p_URL))
{
ChatPlexSDK.Logger.Error($"[CP_SDK.Chat][ImageProvider.DownloadContent] URI is null or empty in request for resource {p_URL}. Aborting!");
ChatPlexSDK.Logger.Error($"[CP_SDK.Chat][ChatImageProvider.TryCacheSingleImage] URI is null or empty in request for resource {p_URL} ID:{p_ID}. Aborting!");

m_CachedImageInfo[p_URL] = null;
p_Finally?.Invoke(null);
Expand Down Expand Up @@ -239,7 +239,7 @@ private static void DownloadContent(string p_URL, string p_CacheID, Action<byte[
m_ActiveDownloads[p_URL] -= p_Finally;
m_ActiveDownloads[p_URL] += p_Finally;

m_WebClient.DownloadAsync(p_URL, System.Threading.CancellationToken.None, (p_Result) =>
m_WebClient.GetAsync(p_URL, System.Threading.CancellationToken.None, (p_Result) =>
{
if (p_Result == null)
{
Expand All @@ -248,18 +248,18 @@ private static void DownloadContent(string p_URL, string p_CacheID, Action<byte[
return;
}

if (m_CacheEnabled && p_Result != null && p_Result.Length > 0)
if (m_CacheEnabled && p_Result?.BodyBytes != null && p_Result.BodyBytes.Length > 0)
{
Unity.MTThreadInvoker.EnqueueOnThread(() =>
{
if (!Directory.Exists(m_CacheFolder))
Directory.CreateDirectory(m_CacheFolder);

File.WriteAllBytes(m_CacheFolder + p_CacheID, p_Result);
File.WriteAllBytes(m_CacheFolder + p_CacheID, p_Result.BodyBytes);
});
}

m_ActiveDownloads[p_URL]?.Invoke(p_Result);
m_ActiveDownloads[p_URL]?.Invoke(p_Result.BodyBytes);
m_ActiveDownloads.TryRemove(p_URL, out var _);
});
}
Expand Down
18 changes: 10 additions & 8 deletions BeatSaberPlus/CP_SDK/Chat/ChatModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ public class ChatModSettings : Config.JsonConfig<ChatModSettings>
{
internal class _Emotes
{
[JsonProperty] internal bool ParseBTTVEmotes = true;
[JsonProperty] internal bool ParseFFZEmotes = true;
[JsonProperty] internal bool Parse7TVEmotes = true;
[JsonProperty] internal bool ParseEmojis = true;
[JsonProperty] internal bool ParseBTTVEmotes = true;
[JsonProperty] internal bool ParseFFZEmotes = true;
[JsonProperty] internal bool Parse7TVEmotes = true;
[JsonProperty] internal bool ParseEmojis = true;
[JsonProperty] internal bool ParseTemporaryChannels = true;
}

[JsonProperty] internal bool LaunchWebAppOnStartup = true;
Expand All @@ -26,10 +27,11 @@ internal class _Emotes
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

[JsonIgnore] public bool Emotes_ParseBTTVEmotes => Emotes.ParseBTTVEmotes;
[JsonIgnore] public bool Emotes_ParseFFZEmotes => Emotes.ParseFFZEmotes;
[JsonIgnore] public bool Emotes_Parse7TVEmotes => Emotes.Parse7TVEmotes;
[JsonIgnore] public bool Emotes_ParseEmojis => Emotes.ParseEmojis;
[JsonIgnore] public bool Emotes_ParseBTTVEmotes => Emotes.ParseBTTVEmotes;
[JsonIgnore] public bool Emotes_ParseFFZEmotes => Emotes.ParseFFZEmotes;
[JsonIgnore] public bool Emotes_Parse7TVEmotes => Emotes.Parse7TVEmotes;
[JsonIgnore] public bool Emotes_ParseEmojis => Emotes.ParseEmojis;
[JsonIgnore] public bool Emotes_ParseTemporaryChannels => Emotes.ParseTemporaryChannels;

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 8 additions & 0 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/EBadgeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CP_SDK.Chat.Interfaces
{
public enum EBadgeType
{
Image,
Emoji
}
}
14 changes: 4 additions & 10 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatBadge.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
namespace CP_SDK.Chat.Interfaces
{
public enum EBadgeType
{
Image,
Emoji
}

public interface IChatBadge
{
string Id { get; }
string Name { get; }
EBadgeType Type { get; }
string Content { get; }
string Id { get; }
string Name { get; }
EBadgeType Type { get; }
string Content { get; }
}
}
14 changes: 7 additions & 7 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{
public interface IChatChannel
{
string Name { get; }
string Id { get; }
bool IsTemp { get; }
string Prefix { get; }
bool CanSendMessages { get; }
bool Live { get; }
int ViewerCount { get; }
string Id { get; }
string Name { get; }
bool IsTemp { get; }
string Prefix { get; }
bool CanSendMessages { get; }
bool Live { get; }
int ViewerCount { get; }
}
}
16 changes: 8 additions & 8 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatChannelPointEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
public interface IChatChannelPointEvent
{
string RewardID { get; }
string TransactionID { get; }
string Title { get; }
string Prompt { get; }
string UserInput { get; }
int Cost { get; }
string Image { get; }
string BackgroundColor { get; }
string RewardID { get; }
string TransactionID { get; }
string Title { get; }
string Prompt { get; }
string UserInput { get; }
int Cost { get; }
string Image { get; }
string BackgroundColor { get; }
}
}
14 changes: 7 additions & 7 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatEmote.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using CP_SDK.Chat.Models;
using CP_SDK.Animation;

namespace CP_SDK.Chat.Interfaces
{
public interface IChatEmote
{
string Id { get; }
string Name { get; }
string Uri { get; }
int StartIndex { get; }
int EndIndex { get; }
Animation.EAnimationType Animation { get; }
string Id { get; }
string Name { get; }
string Uri { get; }
int StartIndex { get; }
int EndIndex { get; }
EAnimationType Animation { get; }
}
}
7 changes: 0 additions & 7 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatMessageHandler.cs

This file was deleted.

12 changes: 7 additions & 5 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatResourceData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace CP_SDK.Chat.Interfaces
using CP_SDK.Animation;

namespace CP_SDK.Chat.Interfaces
{
public enum EChatResourceCategory
{
Expand All @@ -9,9 +11,9 @@ public enum EChatResourceCategory

public interface IChatResourceData
{
string Uri { get; }
Animation.EAnimationType Animation { get; }
EChatResourceCategory Category { get; }
string Type { get; }
string Uri { get; }
EAnimationType Animation { get; }
EChatResourceCategory Category { get; }
string Type { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ namespace CP_SDK.Chat.Interfaces
public interface IChatResourceProvider<T>
{
ConcurrentDictionary<string, T> Resources { get; }
Task TryRequestResources(string category, string p_Token);
/// <summary>
/// Try request resources from the provider
/// </summary>
/// <param name="p_ChannelID">ID of the channel</param>
/// <param name="p_ChannelName">Name of the channel</param>
/// <param name="p_AccessToken">Access token for the API</param>
/// <returns></returns>
Task TryRequestResources(string p_ChannelID, string p_ChannelName, string p_AccessToken);
bool TryGetResource(string identifier, string category, out T data);
}
}
17 changes: 17 additions & 0 deletions BeatSaberPlus/CP_SDK/Chat/Interfaces/IChatService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine;

namespace CP_SDK.Chat.Interfaces
{
Expand All @@ -13,12 +14,22 @@ public interface IChatService
/// The display name of the service(s)
/// </summary>
string DisplayName { get; }
/// <summary>
/// Side handle of each message color
/// </summary>
Color AccentColor { get; }

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Channels
/// </summary>
ReadOnlyCollection<(IChatService, IChatChannel)> Channels { get; }

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

/// <summary>
/// On system message
/// </summary>
Expand All @@ -28,6 +39,9 @@ public interface IChatService
/// </summary>
event Action<IChatService> OnLogin;

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Callback that occurs when the user joins a chat channel
/// </summary>
Expand Down Expand Up @@ -69,6 +83,9 @@ public interface IChatService
/// </summary>
event Action<IChatService, IChatChannel, IChatUser, int> OnChannelRaid;

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Callback that occurs when a text message is received
/// </summary>
Expand Down
Loading

0 comments on commit 362e29e

Please sign in to comment.