Decompiled source of CustomComputerWallpaper v1.0.0

BepInEx/plugins/CustomComputerWallpaper/CustomComputerWallpaper.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CustomComputerWallpaper.Configuration;
using CustomComputerWallpaper.Localization;
using CustomComputerWallpaper.Runtime;
using HarmonyLib;
using IceBoxModLib.Config;
using IceBoxModLib.Localization;
using IceBoxModLib.Runtime;
using IceBoxModLib.Utilities;
using UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomComputerWallpaper")]
[assembly: AssemblyDescription("Custom Computer Wallpaper mod for Roadside Research by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("CustomComputerWallpaper")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8aa3139a-5b12-4043-1221-a5441b21a81f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomComputerWallpaper
{
	[BepInPlugin("IceBoxStudio.RoadsideResearch.CustomComputerWallpaper", "CustomComputerWallpaper", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CustomComputerWallpaper : BasePlugin
	{
		public static CustomComputerWallpaper _Instance;

		private Harmony _harmony;

		private bool patchesApplied;

		public static CustomComputerWallpaper Instance => _Instance;

		internal static ManualLogSource Log { get; private set; }

		public override void Load()
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			_Instance = this;
			Log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			try
			{
				Log.LogInfo((object)"=============================================");
				ManualLogSource log = Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomComputerWallpaper");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initializing"));
				}
				log.LogInfo(val);
				ManualLogSource log2 = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix"));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ice Box Studio(https://steamcommunity.com/id/ibox666/)");
				}
				log2.LogInfo(val);
				ConfigManager.Initialize(((BasePlugin)this).Config);
				WallpaperManager.Initialize();
				CustomComputerWallpaperBehaviour.Initialize();
				ApplyPatches();
				ManualLogSource log3 = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomComputerWallpaper");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initialized"));
				}
				log3.LogInfo(val);
				Log.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				ManualLogSource log4 = Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(9, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("CustomComputerWallpaper");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" 初始化错误: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace);
				}
				log4.LogError(val2);
			}
		}

		private void ApplyPatches()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (!patchesApplied)
			{
				try
				{
					_harmony = new Harmony("IceBoxStudio.RoadsideResearch.CustomComputerWallpaper");
					_harmony.PatchAll();
					patchesApplied = true;
					return;
				}
				catch (Exception ex)
				{
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(10, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomComputerWallpaper");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" 应用补丁错误: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.StackTrace);
					}
					log.LogError(val);
					return;
				}
			}
			Log.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped"));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.RoadsideResearch.CustomComputerWallpaper";

		public const string PLUGIN_NAME = "CustomComputerWallpaper";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CustomComputerWallpaper.Runtime
{
	public class CustomComputerWallpaperBehaviour : MonoBehaviour
	{
		private float _checkTimer;

		private bool _isReplaced;

		public CustomComputerWallpaperBehaviour(IntPtr ptr)
			: base(ptr)
		{
		}

		public static void Initialize()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Il2CppTypeRegistry.RegisterType<CustomComputerWallpaperBehaviour>();
			GameObject val = new GameObject("CustomComputerWallpaperManager");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<CustomComputerWallpaperBehaviour>();
			((Object)val).hideFlags = (HideFlags)61;
		}

		private void Update()
		{
			if (ConfigManager.Instance.EnableCustomComputerWallpaper.Value)
			{
				_checkTimer += Time.deltaTime;
				if (_checkTimer >= 2f)
				{
					_checkTimer = 0f;
					TryReplaceWallpaper();
				}
			}
		}

		private void TryReplaceWallpaper()
		{
			AlienRoomScreenInteractionDisabler val = Object.FindObjectOfType<AlienRoomScreenInteractionDisabler>();
			if ((Object)(object)val == (Object)null)
			{
				_isReplaced = false;
			}
			else if (!_isReplaced)
			{
				if ((Object)(object)WallpaperManager.GetCustomWallpaper() == (Object)null)
				{
					_isReplaced = true;
					return;
				}
				ImageLoader.ReplaceImageBySpriteName(((Component)val).transform, "PCBackground_Naked", WallpaperManager.GetCustomWallpaper(), true);
				_isReplaced = true;
			}
		}
	}
	public static class WallpaperManager
	{
		private static Sprite _customWallpaperSprite;

		public static void Initialize()
		{
			if (ConfigManager.Instance.EnableCustomComputerWallpaper.Value)
			{
				LoadCustomTexture();
			}
		}

		private static void LoadCustomTexture()
		{
			_customWallpaperSprite = ImageLoader.LoadSpriteFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ConfigManager.Instance.ImageFileName.Value), 100f, 0.5f, 0.5f, (FilterMode)1);
		}

		public static Sprite GetCustomWallpaper()
		{
			return _customWallpaperSprite;
		}
	}
}
namespace CustomComputerWallpaper.Localization
{
	public static class LocalizationHelper
	{
		public static Dictionary<string, string> GetDefaultTranslations(string language)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			switch (language)
			{
			case "简体中文":
				dictionary.Add("plugin.initializing", "开始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过...");
				dictionary.Add("config.enable_custom_com_wallpaper.desc", "启用自定义电脑壁纸功能");
				dictionary.Add("config.image_file_name.desc", "自定义壁纸的文件名(需与本模组的 dll 放在同一目录下)");
				break;
			case "繁體中文":
				dictionary.Add("plugin.initializing", "開始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "補丁已應用,跳過...");
				dictionary.Add("config.enable_custom_com_wallpaper.desc", "啟用自訂電腦桌布功能");
				dictionary.Add("config.image_file_name.desc", "自訂桌布的檔案名稱(需與本模組的 dll 放在同一目錄下)");
				break;
			case "English":
				dictionary.Add("plugin.initializing", "Initializing...");
				dictionary.Add("plugin.author_prefix", "Author: ");
				dictionary.Add("plugin.initialized", "Initialization successful!");
				dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping...");
				dictionary.Add("config.enable_custom_com_wallpaper.desc", "Enable custom computer wallpaper feature");
				dictionary.Add("config.image_file_name.desc", "The filename of the custom wallpaper (must be placed in the same directory as this mod's dll)");
				break;
			case "日本語":
				dictionary.Add("plugin.initializing", "初期化中...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初期化に成功しました!");
				dictionary.Add("plugin.patches_skipped", "パッチは既に適用されています。スキップします...");
				dictionary.Add("config.enable_custom_com_wallpaper.desc", "カスタムPC壁紙機能を有効にする");
				dictionary.Add("config.image_file_name.desc", "カスタム壁紙のファイル名(このMODのdllと同じディレクトリに配置する必要があります)");
				break;
			}
			return dictionary;
		}
	}
	public class LocalizationManager
	{
		private static LocalizationManager _instance;

		private readonly ModLocalizationService _service;

		public static readonly string[] SupportedLanguages = new string[4] { "简体中文", "繁體中文", "English", "日本語" };

		public static LocalizationManager Instance => _instance ?? (_instance = new LocalizationManager());

		private LocalizationManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			_service = new ModLocalizationService((IEnumerable<string>)SupportedLanguages, "English");
			Initialize();
		}

		public void Initialize()
		{
			string[] supportedLanguages = SupportedLanguages;
			foreach (string text in supportedLanguages)
			{
				Dictionary<string, string> defaultTranslations = LocalizationHelper.GetDefaultTranslations(text);
				if (defaultTranslations != null && defaultTranslations.Count > 0)
				{
					_service.AddTranslations(text, defaultTranslations);
				}
			}
		}

		public string GetLocalizedText(string key, params object[] args)
		{
			return _service.GetText(key, args);
		}
	}
}
namespace CustomComputerWallpaper.Configuration
{
	public class ConfigManager : ModConfigBase
	{
		private static ConfigManager _instance;

		public ConfigEntry<bool> EnableCustomComputerWallpaper { get; private set; }

		public ConfigEntry<string> ImageFileName { get; private set; }

		public static ConfigManager Instance => _instance;

		private ConfigManager(ConfigFile configFile)
			: base(configFile)
		{
			InitializeDefaultConfigs();
		}

		public static void Initialize(ConfigFile configFile)
		{
			if (_instance == null)
			{
				_instance = new ConfigManager(configFile);
			}
		}

		private void InitializeDefaultConfigs()
		{
			EnableCustomComputerWallpaper = ((ModConfigBase)this).RegisterBool("General", "EnableCustomComputerWallpaper", GetLocalizedDescription("config.enable_custom_com_wallpaper.desc"), true);
			ImageFileName = ((ModConfigBase)this).RegisterString("Advanced", "ImageFileName", GetLocalizedDescription("config.image_file_name.desc"), "wallpaper.png");
		}

		private string GetLocalizedDescription(string key)
		{
			return LocalizationManager.Instance.GetLocalizedText(key);
		}
	}
}