using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Windows.Forms;
using AudioImportLib;
using BoneLib.BoneMenu;
using BoneSnap;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "BoneSnap", "2.0.1", "Fizzyhex", "https://bonelab.thunderstore.io/package/Fizzyhex/BoneSnap")]
[assembly: MelonColor(0, 255, 255, 255)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BoneSnap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e5d5b765ffab9861bc0f7873662cd6bf05e97051")]
[assembly: AssemblyProduct("BoneSnap")]
[assembly: AssemblyTitle("BoneSnap")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BoneSnap
{
internal static class AssetManager
{
private static readonly string UserDataPath = MelonEnvironment.UserDataDirectory;
private static readonly string ModStoragePath = UserDataPath + "/BoneSnap";
private static readonly string AudioPath = ModStoragePath + "/Audio";
public static AudioClip? CaptureTimerAudio;
public static AudioClip? CaptureCompleteAudio;
public static AudioClip? CaptureStartAudio;
private static void LoadAudio()
{
CaptureStartAudio = API.LoadAudioClip(AudioPath + "/capture_start.wav", true);
CaptureCompleteAudio = API.LoadAudioClip(AudioPath + "/capture_complete.wav", true);
CaptureTimerAudio = API.LoadAudioClip(AudioPath + "/capture_timer.wav", true);
}
private static void CreateDirectories()
{
Directory.CreateDirectory(AudioPath);
}
public static void Initialize()
{
CreateDirectories();
LoadAudio();
}
}
internal static class AudioManager
{
private static GameObject audioGameObject;
public static void Play(AudioClip clip)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
audioGameObject = (GameObject)(Object.op_Implicit((Object)(object)audioGameObject) ? ((object)audioGameObject) : ((object)new GameObject("BoneSnap AudioManager")));
AudioSource val = (Object.op_Implicit((Object)(object)audioGameObject.GetComponent<AudioSource>()) ? audioGameObject.GetComponent<AudioSource>() : audioGameObject.AddComponent<AudioSource>());
val.PlayOneShot(clip, 0.7f);
}
}
internal abstract class BoneMenu
{
public static void CreateBoneMenu(BoneSnapPreferences preferences, Page rootCategory)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
rootCategory.CreateFunction("Screenshot Window", Color.white, (Action)delegate
{
MelonCoroutines.Start(Screenshotter.CoPrepareScreenshot(preferences.CaptureDelay.Value, preferences.CaptureQuality.Value, preferences.OutputPath.Value));
});
rootCategory.CreateInt("Capture Delay", Color.white, preferences.CaptureDelay.Value, 1, 0, 60, (Action<int>)delegate(int delay)
{
preferences.CaptureDelay.Value = delay;
preferences.ManualSave();
});
rootCategory.CreateInt("Capture Quality", Color.white, preferences.CaptureQuality.Value, 5, 5, 100, (Action<int>)delegate(int quality)
{
preferences.CaptureQuality.Value = quality;
preferences.ManualSave();
});
rootCategory.CreateFunction("Outputting to clipboard & " + preferences.OutputPath.Value, Color.cyan, (Action)null);
}
}
internal class Main : MelonMod
{
internal const string Name = "BoneSnap";
internal const string Description = "A window capture tool for BONELAB";
internal const string Author = "Fizzyhex";
internal const string Company = "";
internal const string Version = "2.0.1";
internal const string DownloadLink = "https://bonelab.thunderstore.io/package/Fizzyhex/BoneSnap";
public override void OnInitializeMelon()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
MelonPreferences_Category category = MelonPreferences.CreateCategory("BoneSnap");
BoneSnapPreferences preferences = new BoneSnapPreferences(category);
Page rootCategory = Page.Root.CreatePage("BoneSnap", Color.white, 0, true);
BoneMenu.CreateBoneMenu(preferences, rootCategory);
AssetManager.Initialize();
((MelonBase)this).OnInitializeMelon();
}
}
public readonly struct BoneSnapPreferences
{
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly MelonPreferences_Category <category>P;
public readonly MelonPreferences_Entry<int> CaptureDelay;
public readonly MelonPreferences_Entry<int> CaptureQuality;
public readonly MelonPreferences_Entry<string> OutputPath;
public BoneSnapPreferences(MelonPreferences_Category category)
{
<category>P = category;
CaptureDelay = <category>P.CreateEntry<int>("CaptureDelay", 4, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
CaptureQuality = <category>P.CreateEntry<int>("CaptureQuality", 95, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
OutputPath = <category>P.CreateEntry<string>("OutputPath", "UserData/Screenshots", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public void ManualSave()
{
<category>P.SaveToFile(true);
}
}
internal static class Screenshotter
{
private static int _screenshotIndex;
private static string GenerateTimecode(DateTime time)
{
string text = time.ToString("yyyy-MM-dd");
string text2 = time.ToString("HH.mm.ss");
return text + " " + text2;
}
private static void TakeScreenshot(string outputPath, int quality = 100)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
MelonLogger.Msg("Preparing screenshot");
string text = ((quality == 100) ? "png" : "jpg");
int width = Screen.width;
int height = Screen.height;
Texture2D val = new Texture2D(width, height);
val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0);
val.Apply();
byte[] array = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)((text == "png") ? ImageConversion.EncodeToPNG(val) : ImageConversion.EncodeToJPG(val, quality)));
Object.Destroy((Object)(object)val);
_screenshotIndex++;
Directory.CreateDirectory(outputPath);
string value = GenerateTimecode(DateTime.Now);
string text2 = outputPath + $"/{value} {_screenshotIndex}.{text}";
File.WriteAllBytes(text2, array);
Clipboard.SetImage((Image)(Bitmap)((TypeConverter)new ImageConverter()).ConvertFrom((object)array));
MelonLogger.Msg("Screenshot saved as " + text2 + "!");
}
public static IEnumerator CoPrepareScreenshot(float waitTime, int quality, string outputPath)
{
if ((Object)(object)AssetManager.CaptureTimerAudio != (Object)null)
{
AudioManager.Play(AssetManager.CaptureTimerAudio);
}
yield return (object)new WaitForSeconds(waitTime);
if ((Object)(object)AssetManager.CaptureStartAudio != (Object)null)
{
AudioManager.Play(AssetManager.CaptureStartAudio);
}
TakeScreenshot(outputPath, quality);
if ((Object)(object)AssetManager.CaptureCompleteAudio != (Object)null)
{
AudioManager.Play(AssetManager.CaptureCompleteAudio);
}
}
}
}