Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit

Permalink
Fixed for Beat Saber 0.11.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeturDarri committed Aug 20, 2018
1 parent 526ef59 commit eb202f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
14 changes: 3 additions & 11 deletions BeatSaberDiscordPresence/BeatSaberDiscordPresence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="discord-rpc">
<HintPath>libs\discord-rpc.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
Expand All @@ -65,11 +61,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Target Name="AfterBuild">
<Copy SourceFiles="$(OutputPath)BeatSaberDiscordPresence.dll" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\" ContinueOnError="true" />
</Target>
</Project>
16 changes: 9 additions & 7 deletions BeatSaberDiscordPresence/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ namespace BeatSaberDiscordPresence
{
public class Plugin : IPlugin
{
public static readonly DiscordRpc.RichPresence Presence = new DiscordRpc.RichPresence();
private const string MenuSceneName = "Menu";
private const string GameSceneName = "StandardLevel";
private const string DiscordAppID = "445053620698742804";
public static readonly DiscordRpc.RichPresence Presence = new DiscordRpc.RichPresence();
private MainGameSceneSetupData _mainSetupData;
private bool _init;

Expand All @@ -20,28 +22,28 @@ public string Name

public string Version
{
get { return "v2.0"; }
get { return "v2.0.1"; }
}

public void OnApplicationStart()
{
if (_init) return;
_init = true;
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
SceneManager.sceneLoaded += SceneManagerOnSceneLoaded;

var handlers = new DiscordRpc.EventHandlers();
DiscordRpc.Initialize(DiscordAppID, ref handlers, false, string.Empty);
}

public void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged;
SceneManager.sceneLoaded -= SceneManagerOnSceneLoaded;
DiscordRpc.Shutdown();
}

private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene)
private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode)
{
if (newScene.buildIndex == 1)
if (newScene.name == MenuSceneName)
{
//Menu scene loaded
Presence.details = "In Menu";
Expand All @@ -53,7 +55,7 @@ private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene)
Presence.smallImageText = "Solo Standard";
DiscordRpc.UpdatePresence(Presence);
}
else if (newScene.buildIndex == 5)
else if (newScene.name == GameSceneName)
{
_mainSetupData = Resources.FindObjectsOfTypeAll<MainGameSceneSetupData>().FirstOrDefault();
if (_mainSetupData == null)
Expand Down
6 changes: 3 additions & 3 deletions BeatSaberDiscordPresence/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeatSaberDiscordPresence")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © xyonico 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]

0 comments on commit eb202f6

Please sign in to comment.