using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.gingerphoenix10.videopath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+9b0ee3ae84d75c582e14e6fc3851b039fe593b22")]
[assembly: AssemblyProduct("DontSaveToDesktop")]
[assembly: AssemblyTitle("com.gingerphoenix10.videopath")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DontSaveToDesktop
{
[ContentWarningPlugin("com.gingerphoenix10.videopath", "DontSaveToDesktop", true)]
[BepInPlugin("com.gingerphoenix10.videopath", "DontSaveToDesktop", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
private static readonly Harmony Patcher = new Harmony("com.gingerphoenix10.videopath");
private void Awake()
{
Patcher.PatchAll();
}
}
[ContentWarningSetting]
public class FileName : StringSetting, IExposedSetting
{
public override void ApplyValue()
{
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
public string GetDisplayName()
{
return "[DontSaveToDesktop] Video Filename";
}
protected override string GetDefaultValue()
{
return "content_warning_%HANDLE";
}
}
[ContentWarningSetting]
public class FilePath : StringSetting, IExposedSetting
{
public override void ApplyValue()
{
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
public string GetDisplayName()
{
return "[DontSaveToDesktop] Video Path";
}
protected override string GetDefaultValue()
{
return "%USER\\Desktop";
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.gingerphoenix10.videopath";
public const string PLUGIN_NAME = "DontSaveToDesktop";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace DontSaveToDesktop.Patches
{
[HarmonyPatch(typeof(SaveVideoToDesktopInteractable))]
internal static class SaveVideoToDesktopInteractablePatch
{
[HarmonyPatch("Interact")]
[HarmonyPrefix]
internal static bool Interact(SaveVideoToDesktopInteractable __instance)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Expected O, but got Unknown
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Expected O, but got Unknown
//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Expected O, but got Unknown
//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
//IL_05b7: Expected O, but got Unknown
//IL_0537: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Expected O, but got Unknown
//IL_0563: Unknown result type (might be due to invalid IL or missing references)
//IL_0569: Expected O, but got Unknown
CameraRecording val = (CameraRecording)typeof(SaveVideoToDesktopInteractable).GetField("m_recording", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
Debug.Log((object)"Saving video to folder...");
string localizedString1 = LocalizationKeys.GetLocalizedString((Keys)122);
string localizedString2 = LocalizationKeys.GetLocalizedString((Keys)123);
string localizedString4 = LocalizationKeys.GetLocalizedString((Keys)124);
string localizedString3 = LocalizationKeys.GetLocalizedString((Keys)121);
string path = default(string);
string videoFileName;
if (!RecordingsHandler.TryGetRecordingPath(val.videoHandle, ref path))
{
videoFileName = string.Empty;
Modal.Show(localizedString4, "", (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
return false;
}
string fileName = ((StringSetting)GameHandler.Instance.SettingsHandler.GetSetting<FileName>()).Value.Replace("%HANDLE", ((object)(VideoHandle)(ref val.videoHandle)).ToString()).Replace("%USER", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)).Replace("%YY", DateTime.Now.Year.ToString("yy"))
.Replace("%CCYY", DateTime.Now.Year.ToString())
.Replace("%MM", DateTime.Now.Month.ToString("00"))
.Replace("%DD", DateTime.Now.Day.ToString("00"))
.Replace("%hh", DateTime.Now.Hour.ToString("00"))
.Replace("%mm", DateTime.Now.Minute.ToString("00"))
.Replace("%ss", DateTime.Now.Second.ToString("00"))
.Replace("%DAY", SurfaceNetworkHandler.RoomStats.CurrentDay.ToString())
.Replace("%QDAY", SurfaceNetworkHandler.RoomStats.CurrentQuotaDay.ToString())
.Replace("%RUN", SurfaceNetworkHandler.RoomStats.CurrentRun.ToString());
videoFileName = fileName + ".webm";
string filePath = ((StringSetting)GameHandler.Instance.SettingsHandler.GetSetting<FilePath>()).Value.Replace("%HANDLE", ((object)(VideoHandle)(ref val.videoHandle)).ToString()).Replace("%USER", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)).Replace("%YY", DateTime.Now.Year.ToString("yy"))
.Replace("%CCYY", DateTime.Now.Year.ToString())
.Replace("%MM", DateTime.Now.Month.ToString("00"))
.Replace("%DD", DateTime.Now.Day.ToString("00"))
.Replace("%hh", DateTime.Now.Hour.ToString("00"))
.Replace("%mm", DateTime.Now.Minute.ToString("00"))
.Replace("%ss", DateTime.Now.Second.ToString("00"))
.Replace("%DAY", SurfaceNetworkHandler.RoomStats.CurrentDay.ToString())
.Replace("%QDAY", SurfaceNetworkHandler.RoomStats.CurrentQuotaDay.ToString())
.Replace("%RUN", SurfaceNetworkHandler.RoomStats.CurrentRun.ToString());
if (!File.Exists(path))
{
Debug.LogError((object)("Video: " + path + " Does Not Exist!"));
Modal.Show(localizedString4, "", (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
return false;
}
if (!Directory.Exists(filePath))
{
Modal.Show("Directory not found", "The directory \"" + filePath + "\" does not exist. Would you like to create it? (Selecting No will save video to Desktop)", (ModalOption[])(object)new ModalOption[2]
{
new ModalOption("Yes", (Action)delegate
{
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
Directory.CreateDirectory(filePath);
string destFileName3 = Path.Combine(filePath, videoFileName);
if (File.Exists(destFileName3))
{
Modal.Show("File already exists", "The file \"" + fileName + ".webm\" already exists. Check the DontSaveToDesktop workshop description to fix this. Would you like to overwrite it?", (ModalOption[])(object)new ModalOption[2]
{
new ModalOption("Yes", (Action)delegate
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
File.Copy(path, destFileName3, overwrite: true);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}),
new ModalOption("No", (Action)delegate
{
})
}, (Action)null);
}
else
{
File.Copy(path, destFileName3);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}
}),
new ModalOption("No", (Action)delegate
{
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
string destFileName2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), videoFileName);
if (File.Exists(destFileName2))
{
Modal.Show("File already exists", "The file \"" + fileName + ".webm\" already exists. Check the DontSaveToDesktop workshop description to fix this. Would you like to overwrite it?", (ModalOption[])(object)new ModalOption[2]
{
new ModalOption("Yes", (Action)delegate
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
File.Copy(path, destFileName2, overwrite: true);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}),
new ModalOption("No", (Action)delegate
{
})
}, (Action)null);
}
else
{
File.Copy(path, destFileName2);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}
})
}, (Action)null);
return false;
}
string destFileName = Path.Combine(filePath, videoFileName);
if (File.Exists(destFileName))
{
Modal.Show("File already exists", "The file \"" + fileName + ".webm\" already exists. Check the DontSaveToDesktop workshop description to fix this. Would you like to overwrite it?", (ModalOption[])(object)new ModalOption[2]
{
new ModalOption("Yes", (Action)delegate
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
File.Copy(path, destFileName, overwrite: true);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}),
new ModalOption("No", (Action)delegate
{
})
}, (Action)null);
}
else
{
File.Copy(path, destFileName);
Modal.Show(localizedString1, localizedString2 + " " + videoFileName, (ModalOption[])(object)new ModalOption[1]
{
new ModalOption(localizedString3, (Action)null)
}, (Action)null);
}
return false;
}
}
}