-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit of customization can be done here
- Loading branch information
Showing
119 changed files
with
71,298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
101 changes: 101 additions & 0 deletions
101
BeatSaberCustomExit/BeatSaberCustomExit/MainMenuUIOverload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using BeatSaverDownloader.Misc; | ||
using CustomUI.BeatSaber; | ||
using System; | ||
using System.Collections; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using UnityEngine.UI; | ||
|
||
namespace BeatSaberCustomExit | ||
{ | ||
class MainMenuUIOverload : MonoBehaviour | ||
{ | ||
private CustomMenu _CustomMenu; | ||
private CustomViewController _CustomViewController; | ||
|
||
public bool Initialized = false; | ||
public bool ConfirmExitDialogOpened = false; | ||
|
||
private static MainMenuUIOverload _instance = null; | ||
public static MainMenuUIOverload Instance | ||
{ | ||
get | ||
{ | ||
if (!_instance) | ||
{ | ||
_instance = new GameObject("[BeatSaverCustomExit] MainMenuUIOverload").AddComponent<MainMenuUIOverload>(); | ||
DontDestroyOnLoad(_instance.gameObject); | ||
} | ||
return _instance; | ||
} | ||
private set | ||
{ | ||
_instance = value; | ||
} | ||
} | ||
|
||
public void OnLoad() | ||
{ | ||
Initialized = false; | ||
SetupUI(); | ||
} | ||
|
||
private void _SetupConfirmQuitPanel() | ||
{ | ||
_CustomMenu = BeatSaberUI.CreateCustomMenu<CustomMenu>("Quit"); | ||
_CustomViewController = BeatSaberUI.CreateViewController<CustomViewController>(); | ||
|
||
if (_CustomMenu != null && _CustomViewController != null) | ||
{ | ||
_CustomViewController.didDeactivateEvent += (deactivationType) => { ConfirmExitDialogOpened = false; }; | ||
_CustomMenu.SetMainViewController(_CustomViewController, false, (firstActivation, type) => | ||
{ | ||
if (firstActivation && type == VRUI.VRUIViewController.ActivationType.AddedToHierarchy) | ||
{ | ||
var topText = _CustomViewController.CreateText(PluginConfig.TextContent, new Vector2(0, 10f), new Vector2(105f, 10)); | ||
if (topText != null) | ||
{ | ||
topText.alignment = TMPro.TextAlignmentOptions.Center; | ||
topText.fontSize = 6; | ||
} | ||
else | ||
Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'topText' was null."); | ||
|
||
var buttonCancel = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(-20f, -20f), new Vector2(30f, 10f), | ||
delegate () { _CustomMenu.Dismiss(); }, "Cancel"); | ||
var buttonConfirm = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(20, -20f), new Vector2(30f, 10f), | ||
delegate () { Application.Quit(); }, "Confirm"); | ||
if (buttonCancel != null) | ||
buttonCancel.ToggleWordWrapping(false); | ||
else | ||
Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'buttonCancel' was null."); | ||
|
||
if (buttonConfirm != null) | ||
buttonConfirm.ToggleWordWrapping(false); | ||
else | ||
Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'buttonConfirm' was null."); | ||
} | ||
}); | ||
} else | ||
Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: '_CustomMenu' or '_CustomViewController' was null."); | ||
} | ||
|
||
public void ShowConfirmQuitPanel() | ||
{ | ||
if (!ConfirmExitDialogOpened && _CustomMenu != null) | ||
_CustomMenu.Present(false); | ||
} | ||
|
||
private void SetupUI() | ||
{ | ||
if (Initialized) return; | ||
|
||
_SetupConfirmQuitPanel(); | ||
|
||
Initialized = true; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...SaberCustomExit/BeatSaberCustomExit/Patches/HandleMainMenuViewControllerDidFinishPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using BeatSaberCustomExit; | ||
using BeatSaverDownloader.Misc; | ||
using Harmony; | ||
using System; | ||
using UnityEngine; | ||
|
||
[HarmonyPatch(typeof(MainFlowCoordinator), "HandleMainMenuViewControllerDidFinish", | ||
new Type[] { typeof(MainMenuViewController), typeof(MainMenuViewController.MenuButton) })] | ||
class HandleMainMenuViewControllerDidFinishPatch | ||
{ | ||
public static bool Prefix(MainMenuViewController viewController, MainMenuViewController.MenuButton subMenuType) | ||
{ | ||
if (subMenuType == MainMenuViewController.MenuButton.Quit) | ||
{ | ||
if (PluginConfig.EnablePlugin) | ||
MainMenuUIOverload.Instance.ShowConfirmQuitPanel(); | ||
else | ||
Application.Quit(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using BeatSaverDownloader.Misc; | ||
using BeatSaverDownloader.UI; | ||
using Harmony; | ||
using IllusionPlugin; | ||
using System; | ||
using System.Reflection; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace BeatSaberCustomExit | ||
{ | ||
public class Plugin : IPlugin | ||
{ | ||
public string Name => "BeatSaberCustomExit"; | ||
public string Version => "1.0.0"; | ||
|
||
public void OnApplicationStart() | ||
{ | ||
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged; | ||
SceneManager.sceneLoaded += SceneManager_sceneLoaded; | ||
PluginConfig.LoadOrCreateConfig(); | ||
HarmonyInstance harmony = HarmonyInstance.Create("com.Shoko84.beatsaber.BeatSaberCustomExit"); | ||
harmony.PatchAll(Assembly.GetExecutingAssembly()); | ||
} | ||
|
||
public void OnApplicationQuit() | ||
{ | ||
SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged; | ||
SceneManager.sceneLoaded -= SceneManager_sceneLoaded; | ||
PluginConfig.SaveConfig(); | ||
} | ||
|
||
private void SceneManagerOnActiveSceneChanged(Scene from, Scene to) | ||
{ | ||
Console.WriteLine($"[BeatSaberCustomExit] Active scene changed from \"{from.name}\" to \"{to.name}\""); | ||
|
||
if (from.name == "EmptyTransition" && to.name.Contains("Menu")) | ||
{ | ||
try | ||
{ | ||
SettingsUI.Instance.OnLoad(); | ||
if (PluginConfig.EnablePlugin) | ||
MainMenuUIOverload.Instance.OnLoad(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("Exception on scene change: " + e); | ||
} | ||
} | ||
} | ||
|
||
private void SceneManager_sceneLoaded(Scene from, LoadSceneMode to) | ||
{ | ||
|
||
} | ||
|
||
public void OnLevelWasLoaded(int level) | ||
{ | ||
|
||
} | ||
|
||
public void OnLevelWasInitialized(int level) | ||
{ | ||
} | ||
|
||
public void OnUpdate() | ||
{ | ||
|
||
} | ||
|
||
public void OnFixedUpdate() | ||
{ | ||
|
||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
BeatSaberCustomExit/BeatSaberCustomExit/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("BeatSaberCustomExit")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("BeatSaberCustomExit")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("42bc6ce7-6d1c-429d-97fd-ae4fc39b5b9f")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// 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")] |
47 changes: 47 additions & 0 deletions
47
BeatSaberCustomExit/BeatSaberCustomExit/Settings/PluginConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using IllusionPlugin; | ||
using Microsoft.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Xml.Serialization; | ||
|
||
namespace BeatSaverDownloader.Misc | ||
{ | ||
public class PluginConfig | ||
{ | ||
public static bool EnablePlugin = true; | ||
public static string TextContent = "Are you really sure to quit <b><color=#FF6060>Beat <color=#00B0FF>Saber</b><color=#FFFFFF> ?"; | ||
|
||
public static void LoadOrCreateConfig() | ||
{ | ||
if (!Directory.Exists("UserData")) | ||
Directory.CreateDirectory("UserData"); | ||
|
||
//EnablePlugin property | ||
if (!ModPrefs.HasKey("BeatSaverCustomExit", "EnablePlugin")) | ||
{ | ||
ModPrefs.SetBool("BeatSaverCustomExit", "EnablePlugin", true); | ||
Console.WriteLine("Created config"); | ||
} | ||
else | ||
EnablePlugin = ModPrefs.GetBool("BeatSaverCustomExit", "EnablePlugin", true, true); | ||
|
||
//TextContent property | ||
if (!ModPrefs.HasKey("BeatSaverCustomExit", "TextContent")) | ||
{ | ||
ModPrefs.SetString("BeatSaverCustomExit", "TextContent", "Are you really sure to quit <b><color=#FF6060>Beat <color=#00B0FF>Saber</b><color=#FFFFFF> ?"); | ||
Console.WriteLine("Created config"); | ||
} | ||
else | ||
TextContent = ModPrefs.GetString("BeatSaverCustomExit", "TextContent", "Are you really sure to quit <b><color=#FF6060>Beat <color=#00B0FF>Saber</b><color=#FFFFFF> ?", true); | ||
} | ||
|
||
public static void SaveConfig() | ||
{ | ||
ModPrefs.SetBool("BeatSaverCustomExit", "EnablePlugin", EnablePlugin); | ||
ModPrefs.SetString("BeatSaverCustomExit", "TextContent", TextContent); | ||
} | ||
} | ||
} |
Oops, something went wrong.