Skip to content

Commit

Permalink
Merge pull request #2 from megalon/v0-12-compatability
Browse files Browse the repository at this point in the history
V0 12 compatability
  • Loading branch information
megalon authored Jan 5, 2019
2 parents d48f2f1 + ef1ff1c commit d7dbd96
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 579 deletions.
29 changes: 18 additions & 11 deletions BeatSaberTweaks/BeatSaberTweaks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BeatSaberCustomUI">
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -48,35 +51,35 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TextMeshPro-1.0.55.2017.1.0b12">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.JSONSerializeModule.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.JSONSerializeModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIElementsModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<HintPath>..\..\..\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand All @@ -88,7 +91,8 @@
<Compile Include="Utilites\ConInput.cs" />
<Compile Include="Utilites\Ryder.Lightweight.cs" />
<Compile Include="Utilites\SceneEvents.cs" />
<Compile Include="Utilites\SettingsUI.cs" />
<Compile Include="Utilites\SceneLoadHandler.cs" />
<Compile Include="Utilites\SceneUtils.cs" />
<Compile Include="Utilites\TableViewHelper.cs" />
<Compile Include="ViewControllers\HiddenNotesSettingsController.cs" />
<Compile Include="Tweaks\InGameClock.cs" />
Expand All @@ -102,4 +106,7 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetPath)" "F:\SteamLibrary\steamapps\common\Beat Saber\Plugins"</PostBuildEvent>
</PropertyGroup>
</Project>
87 changes: 84 additions & 3 deletions BeatSaberTweaks/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,104 @@
using System.Collections.Generic;
using System.Linq;
using IllusionPlugin;

using UnityEngine;
namespace BeatSaberTweaks
{
public class Plugin : IPlugin
{
public string Name => "Beat Saber Tweaks";
#if NewUI
public string Version => "3.4";
public string Version => "4.0";
#else
public string Version => "3.3.2";
#endif

private bool _init = false;
private BeatmapCharacteristicSelectionViewController _characteristicViewController;
private static SoloFreePlayFlowCoordinator _soloFlowCoordinator;
private static PartyFreePlayFlowCoordinator _partyFlowCoordinator;

private static PracticeViewController _practiceViewController;
private static StandardLevelDetailViewController _soloDetailView;
private static bool debug = true;
public static bool party { get; private set; } = false;

public static string _gameplayMode { get; private set; }
public enum LogLevel
{
DebugOnly = 0,
Info = 1,
Error = 2
}

public void OnApplicationStart()
{
if (_init) return;
_init = true;

Settings.Load();
SettingsUI.OnLoad();
//SettingsUI.OnLoad();
TweakManager.OnLoad();
UnityEngine.SceneManagement.SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
}

private void SceneManager_activeSceneChanged(UnityEngine.SceneManagement.Scene arg0, UnityEngine.SceneManagement.Scene arg1)
{
if(arg1.name == "Menu")
{
if (_characteristicViewController == null)
{
_characteristicViewController = Resources.FindObjectsOfTypeAll<BeatmapCharacteristicSelectionViewController>().FirstOrDefault();
if (_characteristicViewController == null) return;

_characteristicViewController.didSelectBeatmapCharacteristicEvent += _characteristicViewController_didSelectBeatmapCharacteristicEvent;
}

if (_soloFlowCoordinator == null)
{
_soloFlowCoordinator = Resources.FindObjectsOfTypeAll<SoloFreePlayFlowCoordinator>().FirstOrDefault();
if (_soloFlowCoordinator == null) return;
_soloDetailView = _soloFlowCoordinator.GetPrivateField<StandardLevelDetailViewController>("_levelDetailViewController");
_practiceViewController = _soloFlowCoordinator.GetPrivateField<PracticeViewController>("_practiceViewController");
if (_soloDetailView != null)
_soloDetailView.didPressPlayButtonEvent += _soloDetailView_didPressPlayButtonEvent;
else
Log("Detail View Null", Plugin.LogLevel.Info);
if (_practiceViewController != null)
_practiceViewController.didPressPlayButtonEvent += _practiceViewController_didPressPlayButtonEvent;
else
Log("Practice View Null", Plugin.LogLevel.Info);

}

if (_partyFlowCoordinator == null)
{
_partyFlowCoordinator = Resources.FindObjectsOfTypeAll<PartyFreePlayFlowCoordinator>().FirstOrDefault();
}


}
}

private void _practiceViewController_didPressPlayButtonEvent()
{
Log("Play Button Press ", Plugin.LogLevel.Info);
party = _partyFlowCoordinator.isActivated;
Log(party.ToString(), Plugin.LogLevel.Info);
}

private void _soloDetailView_didPressPlayButtonEvent(StandardLevelDetailViewController obj)
{
Log("Play Button Press " , Plugin.LogLevel.Info);
party = _partyFlowCoordinator.isActivated;
Log(party.ToString(), Plugin.LogLevel.Info);
}



private void _characteristicViewController_didSelectBeatmapCharacteristicEvent(BeatmapCharacteristicSelectionViewController arg1, BeatmapCharacteristicSO arg2)
{
_gameplayMode = arg2.characteristicName;
}

public void OnApplicationQuit()
Expand All @@ -46,5 +122,10 @@ public void OnUpdate()
public void OnFixedUpdate()
{
}

public static void Log(string input, Plugin.LogLevel logLvl)
{
if (logLvl >= LogLevel.Info || debug) Console.WriteLine("[! ! ! ! Beat Saber Tweaks ! ! ! !]: " + input);
}
}
}
54 changes: 31 additions & 23 deletions BeatSaberTweaks/TweakManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
using VRUIControls;
using TMPro;
using IllusionPlugin;

#if NewUI
using BeatSaberUI;
#endif
using CustomUI.BeatSaber;
using CustomUI.Settings;

namespace BeatSaberTweaks
{
Expand All @@ -23,8 +21,6 @@ public class TweakManager : MonoBehaviour
MainMenuViewController _mainMenuViewController = null;
SimpleDialogPromptViewController prompt = null;

static MainGameSceneSetupData _mainGameSceneSetupData = null;

float carTime = 0;

public static void OnLoad()
Expand All @@ -42,7 +38,7 @@ public void Awake()
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
DontDestroyOnLoad(gameObject);

Console.WriteLine("Tweak Manager started.");
Plugin.Log("Tweak Manager started.", Plugin.LogLevel.DebugOnly);

MoveEnergyBar.OnLoad(transform);
ScoreMover.OnLoad(transform);
Expand All @@ -60,11 +56,16 @@ public void Awake()

private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
//Console.WriteLine("Loaded: " + arg0.name);
if(arg0.name == "Menu")
CreateUI();
}

public void Update()
{
/*
* TODO
* This is to enable the flying cars easteregg.
* Is this even still in the game?
if (SettingsUI.isMenuScene(SceneManager.GetActiveScene()))
{
if (_mainMenuViewController.childViewController == null &&
Expand All @@ -85,8 +86,12 @@ public void Update()
carTime = 0;
}
}
*/
}

/*
* TODO
* More flyingcars stuff
private void CarEvent(SimpleDialogPromptViewController viewController, bool ok)
{
viewController.didFinishEvent -= CarEvent;
Expand All @@ -97,43 +102,44 @@ private void CarEvent(SimpleDialogPromptViewController viewController, bool ok)
FlyingCar.startflyingCars = ok;
viewController.DismissModalViewController(null, false);
}
*/

public static bool IsPartyMode()
{
if (_mainGameSceneSetupData == null)
{
_mainGameSceneSetupData = Resources.FindObjectsOfTypeAll<MainGameSceneSetupData>().FirstOrDefault();
}

if (_mainGameSceneSetupData == null)
{
Plugin.Log(Plugin.party.ToString(), Plugin.LogLevel.Info);
if (Plugin.party)
return true;
else
return false;
}

return _mainGameSceneSetupData.gameplayMode == GameplayMode.PartyStandard;

}

public void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
{
try
{
//Console.WriteLine("Active: " + scene.name);
if (SettingsUI.isMenuScene(scene))
if (SceneUtils.isMenuScene(scene))
{
Plugin.Log("TweakManager isMenuScene", Plugin.LogLevel.DebugOnly);
_mainMenuViewController = Resources.FindObjectsOfTypeAll<MainMenuViewController>().First();
var _menuMasterViewController = Resources.FindObjectsOfTypeAll<StandardLevelSelectionFlowCoordinator>().First();
prompt = ReflectionUtil.GetPrivateField<SimpleDialogPromptViewController>(_menuMasterViewController, "_simpleDialogPromptViewController");

CreateUI();
//var _menuMasterViewController = Resources.FindObjectsOfTypeAll<StandardLevelSelectionFlowCoordinator>().First();
//prompt = ReflectionUtil.GetPrivateField<SimpleDialogPromptViewController>(_menuMasterViewController, "_simpleDialogPromptViewController");
}
else
{
Plugin.Log("TweakManager not in menu scene", Plugin.LogLevel.DebugOnly);
}
}catch (Exception e)
{
Console.WriteLine("Tweaks (Manager) done fucked up: " + e);
Plugin.Log("TweakManager scene changed error: " + e, Plugin.LogLevel.Error);
}
}

private void CreateUI()
{
Plugin.Log("TweakManager creating the BSTweaks UI", Plugin.LogLevel.DebugOnly);
var subMenu2 = SettingsUI.CreateSubMenu("Interface Tweaks");

var energyBar = subMenu2.AddBool("Move Energy Bar");
Expand Down Expand Up @@ -290,6 +296,7 @@ private void Warning_didFinishEvent(SimpleDialogPromptViewController viewControl
}
*/

/*
private void Prompt_didFinishEvent(SimpleDialogPromptViewController viewController, bool ok)
{
viewController.didFinishEvent -= Prompt_didFinishEvent;
Expand All @@ -307,5 +314,6 @@ private void Prompt_didFinishEvent(SimpleDialogPromptViewController viewControll
}
viewController.DismissModalViewController(null, false);
}
*/
}
}
9 changes: 7 additions & 2 deletions BeatSaberTweaks/Tweaks/InGameClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public class InGameClock : MonoBehaviour
public static void OnLoad(Transform parent)
{
if (Instance != null) return;
Plugin.Log("Creating InGameClock.", Plugin.LogLevel.DebugOnly);
new GameObject("In Game Time").AddComponent<InGameClock>().transform.parent = parent;
}

public void Awake()
{
if (Instance == null)
{
Plugin.Log("InGameClock awake.", Plugin.LogLevel.DebugOnly);
Instance = this;
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
DontDestroyOnLoad(gameObject);
Expand All @@ -49,10 +51,12 @@ public void Awake()

public void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
{
Plugin.Log("InGameClock SceneManagerOnActiveSceneChanged: " + arg0.name + " " + scene.name, Plugin.LogLevel.DebugOnly);
try
{
if (SettingsUI.isMenuScene(scene) && ClockCanvas == null)
if (SceneUtils.isMenuScene(scene) && ClockCanvas == null)
{
Plugin.Log("Creating the clock object... ", Plugin.LogLevel.DebugOnly);
ClockCanvas = new GameObject();
DontDestroyOnLoad(ClockCanvas);
ClockCanvas.AddComponent<Canvas>();
Expand Down Expand Up @@ -81,7 +85,7 @@ public void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
}
catch (Exception e)
{
Console.WriteLine("Tweaks (Clock) done fucked up: " + e);
Plugin.Log("InGameClock error: " + e, Plugin.LogLevel.DebugOnly);
}
}

Expand All @@ -102,6 +106,7 @@ public void Update()

public static void UpdateClock()
{
Plugin.Log("InGameClock UpdateClock function called.", Plugin.LogLevel.DebugOnly);
string time;
if (Settings.Use24hrClock)
{
Expand Down
Loading

0 comments on commit d7dbd96

Please sign in to comment.