using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using Nebula.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyCompany("Nebula.UI")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Nebula.UI")] [assembly: AssemblyTitle("Nebula.UI")] [assembly: AssemblyVersion("1.0.0.0")] namespace Nebula.UI; public class MOTDDatum { public string motdPath; public string motd; public MOTDDatum(string motd, string motdPath = "WIDGET_MOTD/PANEL_ScrollWindow/010_LABEL_BlockText") { this.motd = motd; this.motdPath = motdPath; } } public class ButtonDatum { public UIButton button; public string menuPath; public int priority; public MOTDDatum motdDatum; public ButtonDatum(UIButton button, string menuPath, int priority, MOTDDatum motdDatum = null) { this.button = button; this.menuPath = menuPath; this.priority = priority; this.motdDatum = motdDatum; } } [Obsolete("Use UIFactory.CreateButton")] public static class ButtonFactory { public static UIButton Create(ButtonFactoryDatum datum) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)((Component)GameObjectUtils.GetMenu(datum.menuPath ?? "")).transform.FindChild(datum.buttonsPath)).gameObject; return gameObject.CreateButton(datum.name, new UIFactory.ButtonSettings { OnClick = datum.onClick, Size = datum.buttonSize }, new UIFactory.LabelSettings { Text = datum.text, Font = datum.detail.font, FontSize = datum.fontSize, Color = datum.detail.color }, (Pivot)5); } public static List CreateMultiple(List data) { return new List(LinqSubstitute.Remap((IEnumerable)data, (Func)Create)); } } [Obsolete("Use UIFactory.CreateButton")] public class ButtonDetailDatum { public Color color; public Font font; public ButtonDetailDatum(Color color, Font font = null) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) this.color = color; this.font = font ?? StockFonts.microgramma["BoldDynamic"]; } } [Obsolete("Use UIFactory.CreateButton")] public class ButtonFactoryDatum { public string name; public string text; public List onClick; public int fontSize; public Vector3 buttonSize; public string menuPath; public string buttonsPath; public ButtonDetailDatum detail; public ButtonFactoryDatum(string name, string text, List onClick, int fontSize, Vector3 buttonSize, string menuPath, string buttonsPath, ButtonDetailDatum detail = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) this.name = name; this.text = text; this.onClick = onClick; this.fontSize = fontSize; this.buttonSize = buttonSize; this.menuPath = menuPath; this.buttonsPath = buttonsPath; this.detail = detail ?? new ButtonDetailDatum(Color.white); } } public class ButtonSpawner { private const string type = "ButtonSpawner"; public static Queue buttonQueue = new Queue(); public static void InitQueue() { GameObject rootObject = GameObjectUtils.GetRootObject("# CUI_2D"); Transform val = rootObject.transform.FindChild("Camera/ROOT_Menus"); Debug.Log((object)string.Format("{0}: Resolving {1} buttons in queue...", "ButtonSpawner", buttonQueue.Count)); foreach (ButtonDatum item in buttonQueue) { Transform val2 = val.FindChild(item.menuPath); string text = item.priority.ToString().PadLeft(3, '0'); ((Object)item.button).name = text + "_" + ((Object)item.button).name; if (item.motdDatum != null) { UILabel component = ((Component)val2.FindChild(item.motdDatum.motdPath)).GetComponent(); ((CUIMenu)(object)((Component)val2).GetComponent()).AddTooltip(component, ((Component)item.button).gameObject, item.motdDatum.motd); } } Debug.Log((object)"ButtonSpawner: Button creation complete."); buttonQueue.Clear(); } } public class CUIInputField : MonoBehaviour { public UIInput input; public UITexture background; private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) if (((UIWidget)background).pivot != ((UIWidget)input.label).pivot) { ((UIWidget)background).pivot = ((UIWidget)input.label).pivot; ((Component)background).transform.localPosition = Vector3.zero; } } } public static class StockFonts { public static Dictionary serifGothic = new Dictionary { { "Normal", LoadFont("SerifGothicStd") }, { "Black", LoadFont("SerifGothicStd-Black") }, { "Bold", LoadFont("SerifGothicStd-Bold") }, { "ExtraBold", LoadFont("SerifGothicStd-ExtraBold") }, { "Heavy", LoadFont("SerifGothicStd-Heavy") }, { "Light", LoadFont("SerifGothicStd-Light") } }; public static Dictionary microgramma = new Dictionary { { "Bold", LoadFont("MicrogrammaExtDBold") }, { "BoldDynamic", LoadFont("MicrogrammaExtDBold_Dynamic") }, { "BoldStatic", LoadFont("MicrogrammaExtDBoldStatic_CockpitHUD") }, { "Med", LoadFont("MicrogrammaExtDMed") }, { "MedDynamic", LoadFont("MicrogrammaExtDMed_Dynamic") }, { "MedStatic", LoadFont("MicrogrammaExtDMedStatic_CockpitHUD") } }; public static Dictionary blender = new Dictionary { { "Bold", LoadFont("Blender-Bold") }, { "Book", LoadFont("Blender-Book") } }; private static Font LoadFont(string fontName) { return Resources.Load("ui/fonts/" + fontName); } } public static class UIFactory { public class LabelSettings { public string Text { get; set; } = ""; public Color Color { get; set; } = Color.white; public int FontSize { get; set; } public int Width { get; set; } public Font Font { get; set; } = StockFonts.microgramma["BoldDynamic"]; public Effect Effect { get; set; } = (Effect)1; public int MaxLineCount { get; set; } = 1; public Overflow Overflow { get; set; } = (Overflow)2; } public class TextureSettings { public Vector3 Size { get; set; } public Color Color { get; set; } = Color.clear; } public class ButtonSettings : TextureSettings { public float TweenDuration { get; set; } = 0.01f; public Color HoverColor { get; set; } = new Color(0.7686f, 0.1804f, 0f); public Color PressedColor { get; set; } = new Color(0.7725f, 0.1808f, 0f); public Color DisabledColor { get; set; } = Color.gray; public List OnClick { get; set; } = new List(); public bool UseSpriteAtlas { get; set; } = false; public bool StartsSelected { get; set; } = false; } public class InputFieldSettings : LabelSettings { public KeyboardType KeyboardType { get; set; } = (KeyboardType)0; public Color BackgroundColor { get; set; } = new Color(0.0392f, 0.0392f, 0.0392f); public Color SelectColor { get; set; } = new Color(0.7686f, 0.1804f, 0f, 0.2f); public bool StartsSelected { get; set; } = false; } public static UILabel CreateLabel(this GameObject root, string name, LabelSettings settings, Pivot pivot) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) UILabel val = NGUITools.AddWidget(root); ((Object)val).name = name; val.text = settings.Text; val.effectStyle = settings.Effect; ((UIWidget)val).color = settings.Color; ((UIWidget)val).height = settings.FontSize * settings.MaxLineCount; val.maxLineCount = settings.MaxLineCount; ((UIWidget)val).width = settings.Width; val.overflowMethod = settings.Overflow; ((UIWidget)val).pivot = pivot; ((Component)val).transform.localPosition = Vector3.zero; val.trueTypeFont = settings.Font; val.fontSize = settings.FontSize; return val; } public static UITexture CreateTextureBackground(this GameObject root, TextureSettings settings, Pivot pivot) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0067: 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) Texture2D mainTexture = Resources.Load("ui/ngui/textures/fill_64x"); UITexture val = NGUITools.AddWidget(root); ((Object)val).name = "TEXTURE_Background"; ((UIWidget)val).mainTexture = (Texture)(object)mainTexture; ((UIWidget)val).color = settings.Color; ((UIWidget)val).pivot = pivot; ((Component)val).transform.localPosition = MathUtils.GetOffset(settings.Size, pivot); ((UIWidget)val).shader = Shader.Find("Unlit/Transparent Colored"); ((UIWidget)val).width = (int)settings.Size.x; ((UIWidget)val).height = (int)settings.Size.y; ((UIWidget)val).depth = -1; return val; } public static UISprite AddSpriteComponent(this GameObject root, TextureSettings settings, Pivot pivot) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_004f: 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_0075: Unknown result type (might be due to invalid IL or missing references) UISprite val = root.AddComponent(); ((UIWidget)val).pivot = pivot; ((Component)val).transform.localPosition = MathUtils.GetOffset(settings.Size, pivot); val.atlas = Resources.Load("ui/ngui/StarfighterAtlas"); val.spriteName = "fill_64x"; val.type = (Type)1; ((UIWidget)val).width = (int)settings.Size.x; ((UIWidget)val).height = (int)settings.Size.y; ((UIWidget)val).color = settings.Color; val.tilingScaleX = 1f; return val; } public static UISprite CreateSprite(this GameObject root, string name, TextureSettings settings, Pivot pivot) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) GameObject val = NGUITools.AddChild(root); GameObjectUtils.CopyParentLayer(val); ((Object)val).name = name; return val.AddSpriteComponent(settings, pivot); } private static BoxCollider CreateInteractionArea(this GameObject root, Vector3 size, Pivot pivot) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = root.AddComponent(); val.size = size; val.center = MathUtils.GetOffset(size, pivot); ((Collider)val).isTrigger = true; return val; } public static UIButton CreateButton(this GameObject root, string name, ButtonSettings settings, LabelSettings labelSettings, Pivot pivot) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) bool flag = labelSettings != null; GameObject val = NGUITools.AddChild(root); ((Object)val).name = name; GameObjectUtils.CopyParentLayer(val); UIButton val2 = val.AddComponent(); val2.onClick = settings.OnClick; ((UIButtonColor)val2).hover = settings.HoverColor; ((UIButtonColor)val2).pressed = settings.PressedColor; ((UIButtonColor)val2).disabledColor = settings.DisabledColor; ((UIButtonColor)val2).duration = 0.01f; val.CreateInteractionArea(settings.Size, pivot); CUIButtonInput val3 = val.AddComponent(); val3.inputType = (InputType)0; val3.sendsOnClickOnConfirm = true; val3.startsSelected = settings.StartsSelected; CUIMenuAudioTrigger val4 = val.AddComponent(); val4.clipType = (AudioClipType)0; val4.trigger = (Trigger)1; GameObject val6; if (!settings.UseSpriteAtlas) { UITexture val5 = val.CreateTextureBackground(settings, pivot); val6 = ((Component)val5).gameObject; } else if (flag) { UISprite val7 = val.CreateSprite("SPRITE_Background", settings, pivot); ((UIWidget)val7).depth = -1; val6 = ((Component)val7).gameObject; } else { val.AddSpriteComponent(settings, pivot); val6 = val; } TweenColor val8 = val6.gameObject.AddComponent(); val8.from = settings.HoverColor; val8.to = settings.Color; ((UITweener)val8).duration = settings.TweenDuration; ((UIButtonColor)val2).tweenTarget = val6; if (flag) { val.CreateLabel("LABEL_Button", labelSettings, pivot); } return val2; } public static CUIButtonTooltip AddTooltip(this CUIMenu menu, UILabel label, GameObject target, string text) { CUIButtonTooltip val = ((Component)menu).gameObject.AddComponent(); val.label = label; val.target = target; val.text = text; return val; } public static UIScrollBar CreateVerticalScrollBar(this GameObject root, string name, float barSize, UIScrollView scrollView) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) UIPanel val = NGUITools.AddChild(root); val.showInPanelTool = false; val.renderQueue = (RenderQueue)1; Rigidbody val2 = ((Component)val).gameObject.AddComponent(); val2.useGravity = false; val2.isKinematic = true; UIScrollBar val3 = ((Component)val).gameObject.AddComponent(); val3.barSize = barSize; ((UIProgressBar)val3).fillDirection = (FillDirection)3; ((Object)val3).name = name; GameObjectUtils.CopyParentLayer(((Component)val3).gameObject); ((Behaviour)val3).enabled = true; scrollView.verticalScrollBar = (UIProgressBar)(object)val3; UISprite val4 = ((Component)val3).gameObject.CreateSprite("Background", new TextureSettings { Color = Color.black, Size = new Vector3(2f, 288f, 0f) }, (Pivot)1); ((UIWidget)val4).depth = -1; ((Component)val4).transform.localPosition = Vector3.zero; ((UIProgressBar)val3).backgroundWidget = (UIWidget)(object)val4; ((Component)val4).gameObject.CreateInteractionArea(new Vector3(16f, 288f, 0f), (Pivot)1); UIButton val5 = ((Component)val3).gameObject.CreateButton("Foreground", new ButtonSettings { Size = new Vector3(14f, 288f, 0f), Color = Color.gray, HoverColor = Color.white, PressedColor = new Color(1f, 0.67f, 0f), TweenDuration = 0.05f, UseSpriteAtlas = true }, null, (Pivot)1); ((Component)val5).transform.localPosition = Vector3.zero; ((UIProgressBar)val3).foregroundWidget = (UIWidget)(object)((Component)val5).GetComponent(); return val3; } public static UIInput CreateInput(this GameObject root, string name, InputFieldSettings settings, Pivot pivot) { //IL_0004: 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_004c: 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) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) UILabel val = root.CreateLabel(name, settings, pivot); BoxCollider val2 = ((Component)val).gameObject.AddComponent(); ((Collider)val2).isTrigger = true; val2.size = new Vector3((float)((UIWidget)val).width, (float)((UIWidget)val).height, 0f); CUIButtonInput val3 = ((Component)val).gameObject.AddComponent(); val3.inputType = (InputType)0; val3.sendsOnClickOnConfirm = true; val3.startsSelected = settings.StartsSelected; ((Behaviour)val3).enabled = false; CUIMenuAudioTrigger val4 = ((Component)val).gameObject.AddComponent(); val4.clipType = (AudioClipType)2; val4.trigger = (Trigger)1; UIInput val5 = ((Component)val).gameObject.AddComponent(); val5.keyboardType = settings.KeyboardType; val5.label = val; val5.selectionColor = settings.SelectColor; val5.caretColor = settings.Color; UITexture background = ((Component)val).gameObject.CreateTextureBackground(new TextureSettings { Size = new Vector3((float)((UIWidget)val).width, (float)((UIWidget)val).height), Color = settings.BackgroundColor }, pivot); CUIInputField cUIInputField = ((Component)val5).gameObject.AddComponent(); cUIInputField.input = val5; cUIInputField.background = background; return val5; } } public static class PluginInfo { public const string PLUGIN_GUID = "Nebula.UI"; public const string PLUGIN_NAME = "Nebula.UI"; public const string PLUGIN_VERSION = "1.0.0"; }