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 AssetBundleTools;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Celestial Corp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+975850fa19ef914f6d787051d3b2cca49cace6c3")]
[assembly: AssemblyProduct("RealTimeDisplayPlugin")]
[assembly: AssemblyTitle("RealTimeDisplayPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class LongTimePanel : MonoBehaviour, IPointerExitHandler, IEventSystemHandler, IPointerEnterHandler
{
private TMP_Text longTime;
private TMP_Text meridiem;
private TMP_Text longDate;
private Image background;
private string longTimeFormat;
private string longDateFormat;
private bool hasFocus;
private void Awake()
{
longTime = (TMP_Text)(object)((Component)((Component)this).gameObject.transform.Find("LongTime")).GetComponent<TextMeshProUGUI>();
meridiem = (TMP_Text)(object)((Component)((Component)this).gameObject.transform.Find("Meridiem")).GetComponent<TextMeshProUGUI>();
longDate = (TMP_Text)(object)((Component)((Component)this).gameObject.transform.Find("LongDate")).GetComponent<TextMeshProUGUI>();
background = ((Component)this).gameObject.GetComponent<Image>();
longTimeFormat = longTime.text;
longDateFormat = longDate.text;
TMP_FontAsset font = ((TMP_Text)((Component)Object.FindObjectOfType<FechaHora>()).GetComponentInChildren<TextMeshProUGUI>()).font;
longTime.font = font;
meridiem.font = font;
longDate.font = font;
}
private void Update()
{
if (((Component)this).gameObject.activeSelf)
{
DateTime now = DateTime.Now;
longTime.text = now.ToString(longTimeFormat);
meridiem.text = now.ToString("tt");
longDate.text = now.ToString(longDateFormat);
}
if (!hasFocus && Input.GetMouseButtonUp(0))
{
OnHidePanel();
}
}
public void OnShowPanel()
{
((Component)this).gameObject.SetActive(true);
((Component)this).gameObject.transform.SetAsLastSibling();
}
public void OnHidePanel()
{
((Component)this).gameObject.SetActive(false);
}
public void OnPointerEnter(PointerEventData eventData)
{
hasFocus = true;
}
public void OnPointerExit(PointerEventData eventData)
{
hasFocus = false;
}
public void SetTheme(UI_Theme theme)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
((Graphic)longTime).color = Color32.op_Implicit(theme.clockText);
((Graphic)meridiem).color = Color32.op_Implicit(theme.clockText);
((Graphic)longDate).color = Color32.op_Implicit(theme.clockText);
((Graphic)background).color = Color32.op_Implicit(theme.window_background);
}
}
[HarmonyPatch]
public class DesktopFinderPatch
{
[HarmonyPatch(typeof(DesktopFinder), "Start")]
private class StartPatch
{
private static void Postfix()
{
Transform transform = GameObject.Find("ComputerCanvas/Desktop/BarraSupDesktop").transform;
GameObject prefab = BundleTool.GetPrefab("Assets/RealTimeDisplayPlugin/RealTimeClock.prefab");
if (!((Object)(object)prefab == (Object)null))
{
GameObject obj = Object.Instantiate<GameObject>(prefab, transform);
((Object)obj).name = "RealTimeClock";
rtc = obj.gameObject.AddComponent<RealTimeClock>();
obj.SetActive(true);
Transform transform2 = GameObject.Find("ComputerCanvas/Desktop").transform;
GameObject prefab2 = BundleTool.GetPrefab("Assets/RealTimeDisplayPlugin/LongTimePanel.prefab");
if (!((Object)(object)prefab2 == (Object)null))
{
GameObject obj2 = Object.Instantiate<GameObject>(prefab2, transform2);
((Object)obj2).name = "LongTimePanel";
ltp = obj2.gameObject.AddComponent<LongTimePanel>();
obj2.SetActive(true);
}
}
}
}
[HarmonyPatch(typeof(DesktopFinder), "SetColors")]
private class SetColorsPlugin
{
private static void Postfix(ref UI_Theme theme)
{
rtc.SetTheme(theme);
ltp.SetTheme(theme);
ltp.OnHidePanel();
}
}
private static RealTimeClock rtc;
private static LongTimePanel ltp;
}
public class RealTimeClock : MonoBehaviour
{
private TMP_Text time;
private string timeFormat;
private Button button;
private void Awake()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
button = ((Component)((Component)this).gameObject.transform).GetComponent<Button>();
time = (TMP_Text)(object)((Component)((Component)this).gameObject.transform.Find("Time")).GetComponent<TextMeshProUGUI>();
timeFormat = time.text;
TMP_FontAsset font = ((TMP_Text)((Component)Object.FindObjectOfType<FechaHora>()).GetComponentInChildren<TextMeshProUGUI>()).font;
time.font = font;
((UnityEvent)button.onClick).AddListener((UnityAction)delegate
{
ShowPanel();
});
}
private void Update()
{
DateTime now = DateTime.Now;
time.text = now.ToString(timeFormat);
}
private void ShowPanel()
{
Object.FindObjectOfType<LongTimePanel>(true).OnShowPanel();
}
public void SetTheme(UI_Theme theme)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
Button obj = button;
ColorBlock colors = default(ColorBlock);
((ColorBlock)(ref colors)).fadeDuration = 0.1f;
((ColorBlock)(ref colors)).colorMultiplier = 1f;
((ColorBlock)(ref colors)).normalColor = Color32.op_Implicit(theme.clockText);
((ColorBlock)(ref colors)).pressedColor = Color32.op_Implicit(theme.clockText);
((ColorBlock)(ref colors)).highlightedColor = Color32.op_Implicit(theme.clockTextHighlight);
((ColorBlock)(ref colors)).selectedColor = Color32.op_Implicit(theme.clockTextHighlight);
((ColorBlock)(ref colors)).disabledColor = Color.white;
((Selectable)obj).colors = colors;
}
}
namespace RealTimeDisplayPlugin
{
[BepInPlugin("com.machaceleste.realtimedisplayplugin", "RealTimeDisplayPlugin", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin RealTimeDisplayPlugin is loaded!");
BundleTool.LoadBundle();
new Harmony("com.machaceleste.realtimedisplayplugin").PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RealTimeDisplayPlugin";
public const string PLUGIN_NAME = "RealTimeDisplayPlugin";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace AssetBundleTools
{
public class BundleTool
{
public static AssetBundle bundle;
public static void LoadBundle()
{
string text = Path.Combine(Paths.PluginPath, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RealTimeDisplayPlugin.bundle");
if (!File.Exists(text))
{
Debug.LogError((object)"[Info :RealTimeDisplayPlugin] Bundle not found!");
return;
}
bundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)bundle == (Object)null)
{
Debug.LogError((object)"[Info :RealTimeDisplayPlugin] Failed to load bundle!");
}
else
{
Debug.Log((object)"[Info :RealTimeDisplayPlugin] Loaded bundle");
}
}
public static GameObject GetPrefab(string path)
{
GameObject val = bundle.LoadAsset<GameObject>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :RealTimeDisplayPlugin] Failed to load prefab " + path));
return null;
}
return val;
}
public static AudioClip GetClip(string path)
{
AudioClip val = bundle.LoadAsset<AudioClip>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :RealTimeDisplayPlugin] Failed to load audio clip " + path));
return null;
}
return val;
}
public static Sprite GetSprite(string path)
{
Sprite val = bundle.LoadAsset<Sprite>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :RealTimeDisplayPlugin] Failed to load sprite " + path));
return null;
}
return val;
}
}
}