2024-05-28 20:04:22 +10:00
|
|
|
|
using BepInEx;
|
2024-05-29 08:18:35 +10:00
|
|
|
|
using BepInEx.Configuration;
|
2024-05-28 20:04:22 +10:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using TMPro;
|
2024-06-01 22:14:28 +10:00
|
|
|
|
using Photon.Pun;
|
2024-06-08 21:18:25 +10:00
|
|
|
|
using BepInEx.Logging;
|
2024-05-28 20:04:22 +10:00
|
|
|
|
|
2024-06-04 19:53:14 +10:00
|
|
|
|
namespace SpookTubeEX;
|
2024-05-28 20:04:22 +10:00
|
|
|
|
|
|
|
|
|
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
|
2024-06-04 19:47:28 +10:00
|
|
|
|
[BepInIncompatibility("me.loaforc.Flashcard")] // No flashcard support
|
2024-05-28 20:04:22 +10:00
|
|
|
|
[ContentWarningPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, true)]
|
|
|
|
|
public class Plugin : BaseUnityPlugin
|
|
|
|
|
{
|
|
|
|
|
Harmony harmony;
|
|
|
|
|
|
2024-05-29 08:18:35 +10:00
|
|
|
|
public static ConfigEntry<string> URL;
|
|
|
|
|
|
2024-06-04 17:11:41 +10:00
|
|
|
|
// public static void ModalProxy(string title, string message) => Modal.ShowError(title, message);
|
|
|
|
|
|
2024-06-08 21:18:25 +10:00
|
|
|
|
internal new static ManualLogSource Logger;
|
|
|
|
|
|
2024-05-28 20:04:22 +10:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2024-06-08 21:18:25 +10:00
|
|
|
|
Logger = base.Logger;
|
2024-05-29 08:18:35 +10:00
|
|
|
|
// Config
|
2024-06-09 17:43:02 +10:00
|
|
|
|
URL = Config.Bind("Networking", "WebsocketURL", "wss://spook.redbigz.com/api/upload", "The ws[s]:// URL.");
|
2024-05-29 08:18:35 +10:00
|
|
|
|
|
2024-05-28 20:04:22 +10:00
|
|
|
|
// Plugin startup logic
|
2024-06-10 16:19:11 +10:00
|
|
|
|
Logger.LogInfo($"SpookTubeEX has loaded.");
|
2024-05-28 20:04:22 +10:00
|
|
|
|
|
|
|
|
|
// Create patches
|
2024-06-10 16:19:11 +10:00
|
|
|
|
harmony = new("com.redbigz.SpookTubeEXPatch");
|
2024-05-28 20:04:22 +10:00
|
|
|
|
harmony.PatchAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
harmony.UnpatchSelf();
|
|
|
|
|
|
2024-06-10 16:19:11 +10:00
|
|
|
|
Logger.LogInfo($"SpookTubeEX has unloaded."); // Unpatch everything
|
2024-05-28 20:04:22 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(UploadCompleteUI), nameof(UploadCompleteUI.Replay))]
|
|
|
|
|
class ReplayPatch
|
|
|
|
|
{
|
|
|
|
|
[HarmonyPrefix]
|
2024-05-29 08:18:35 +10:00
|
|
|
|
static bool Prefix(UploadCompleteUI __instance)
|
2024-05-28 20:04:22 +10:00
|
|
|
|
{
|
2024-06-01 22:14:28 +10:00
|
|
|
|
if (!PhotonNetwork.IsMasterClient)
|
|
|
|
|
{
|
2024-06-04 17:11:41 +10:00
|
|
|
|
// Modal.ShowError("Upload Error", "Only the host can upload videos to SpookedTube.");
|
2024-06-01 22:14:28 +10:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-05-29 08:18:35 +10:00
|
|
|
|
|
2024-06-01 22:14:28 +10:00
|
|
|
|
IPlayableVideo video = new Traverse(__instance).Field("m_replayVideo").GetValue() as IPlayableVideo;
|
|
|
|
|
GameObject States = __instance.m_videoPlayer.transform.parent.parent.parent.gameObject;
|
2024-05-29 08:18:35 +10:00
|
|
|
|
|
2024-06-01 22:14:28 +10:00
|
|
|
|
GameObject ShowVideoState = Util.FindObject(States, "ShowVideoState");
|
|
|
|
|
GameObject UploadingState = Util.FindObject(States, "UploadingState");
|
|
|
|
|
|
|
|
|
|
// Show Uploading Screen
|
|
|
|
|
UploadingState.SetActive(true);
|
|
|
|
|
ShowVideoState.SetActive(false);
|
|
|
|
|
|
|
|
|
|
SpookedUploader uploader = new();
|
|
|
|
|
|
2024-06-11 16:03:02 +10:00
|
|
|
|
uploader.Upload(video, () =>
|
2024-06-01 22:14:28 +10:00
|
|
|
|
{
|
|
|
|
|
UploadingState.SetActive(false);
|
2024-06-08 21:58:37 +10:00
|
|
|
|
|
|
|
|
|
// Util.FindObject(Util.FindObject(__instance.m_videoPlayer.transform.parent.parent.parent.parent.parent.gameObject, "SaveVideoToDesktopInteractable"), "CloseInt").GetComponent<CloseVideoInteractable>().Interact(null);
|
|
|
|
|
UploadVideoStationStateMachine stateMachine = new Traverse(GameObject.Find("/Tools/UploadMachine2").GetComponent<UploadVideoStation>()).Field("m_stateMachine").GetValue() as UploadVideoStationStateMachine;
|
|
|
|
|
stateMachine.SwitchState<UploadVideoState>();
|
2024-06-01 22:14:28 +10:00
|
|
|
|
});
|
2024-05-28 20:04:22 +10:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(UploadCompleteUI), nameof(UploadCompleteUI.PlayVideo))]
|
|
|
|
|
class VideoEndedUIInjection
|
|
|
|
|
{
|
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
static void Postfix(UploadCompleteUI __instance)
|
|
|
|
|
{
|
|
|
|
|
// Edit Text
|
|
|
|
|
GameObject text = GameObject.Find("VideoDone/Replay/Text (TMP)");
|
|
|
|
|
|
|
|
|
|
text.GetComponent<UnityEngine.Localization.PropertyVariants.GameObjectLocalizer>()
|
|
|
|
|
.enabled = false; // Disable Localiser
|
|
|
|
|
|
|
|
|
|
TextMeshProUGUI comp = text.GetComponent<TextMeshProUGUI>();
|
|
|
|
|
|
2024-06-04 19:41:02 +10:00
|
|
|
|
comp.SetText("UPLOAD TO THE DEEP DARK WEB");
|
2024-05-28 20:04:22 +10:00
|
|
|
|
|
|
|
|
|
// Edit Icon (there's no finds here because I forgot that postfixes existed and I'm too lazy to change it back)
|
|
|
|
|
GameObject VideoDone = Util.FindObject(__instance.m_videoPlayer.transform.parent.gameObject, "VideoDone");
|
|
|
|
|
GameObject Replay = Util.FindObject(VideoDone, "Replay");
|
|
|
|
|
GameObject SaveImageElement = Util.FindObject(Util.FindObject(VideoDone, "SaveVideo"), "Image");
|
|
|
|
|
GameObject ImageElement = Util.FindObject(Replay, "Image");
|
|
|
|
|
ImageElement.GetComponent<Image>().sprite = SaveImageElement.GetComponent<Image>().sprite;
|
|
|
|
|
}
|
|
|
|
|
}
|