public static UIScrollablePanel CreateScrollBox(UIComponent parent, UITextureAtlas atlas_a) { //code from tmpe UIScrollablePanel scrollablePanel = parent.AddUIComponent <UIScrollablePanel>(); scrollablePanel.backgroundSprite = string.Empty; scrollablePanel.size = new Vector2(130, 240); scrollablePanel.relativePosition = new Vector3(0, 0); scrollablePanel.clipChildren = true; scrollablePanel.FitTo(parent); scrollablePanel.scrollWheelDirection = UIOrientation.Vertical; scrollablePanel.builtinKeyNavigation = true; UIScrollbar verticalScroll = parent.AddUIComponent <UIScrollbar>(); verticalScroll.stepSize = 1; verticalScroll.relativePosition = new Vector2(parent.width - 15, 0); verticalScroll.orientation = UIOrientation.Vertical; verticalScroll.size = new Vector2(20, parent.size.y); verticalScroll.incrementAmount = 25; verticalScroll.scrollEasingType = EasingType.BackEaseOut; scrollablePanel.verticalScrollbar = verticalScroll; UISlicedSprite track = verticalScroll.AddUIComponent <UISlicedSprite>(); track.spriteName = "ScrollbarTrack"; track.relativePosition = Vector3.zero; track.size = new Vector2(16, parent.size.y); verticalScroll.trackObject = track; UISlicedSprite thumb = track.AddUIComponent <UISlicedSprite>(); thumb.spriteName = "ScrollbarThumb"; thumb.autoSize = true; thumb.relativePosition = Vector3.zero; verticalScroll.thumbObject = thumb; return(scrollablePanel); }
/// <summary> /// Initialises the dialog, populates it with list of incompatible mods, and adds it to the modal stack. /// If the modal stack was previously empty, a blur effect is added over the screen background. /// </summary> public void Initialize() { Log._Debug("IncompatibleModsPanel initialize"); if (mainPanel_ != null) { mainPanel_.OnDestroy(); } modListChanged_ = false; isVisible = true; mainPanel_ = AddUIComponent <UIPanel>(); mainPanel_.backgroundSprite = "UnlockingPanel2"; mainPanel_.color = new Color32(75, 75, 135, 255); width = 600; height = 440; mainPanel_.width = 600; mainPanel_.height = 440; Vector2 resolution = UIView.GetAView().GetScreenResolution(); relativePosition = new Vector3((resolution.x / 2) - 300, resolution.y / 3); mainPanel_.relativePosition = Vector3.zero; warningIcon_ = mainPanel_.AddUIComponent <UISprite>(); warningIcon_.size = new Vector2(40f, 40f); warningIcon_.spriteName = "IconWarning"; warningIcon_.relativePosition = new Vector3(15, 15); warningIcon_.zOrder = 0; title_ = mainPanel_.AddUIComponent <UILabel>(); title_.autoSize = true; title_.padding = new RectOffset(10, 10, 15, 15); title_.relativePosition = new Vector2(60, 12); title_.text = TrafficManagerMod.ModName + " " + Translation.ModConflicts.Get("Window.Title:Detected incompatible mods"); closeButton_ = mainPanel_.AddUIComponent <UIButton>(); closeButton_.eventClick += CloseButtonClick; closeButton_.relativePosition = new Vector3(width - closeButton_.width - 45, 15f); closeButton_.normalBgSprite = "buttonclose"; closeButton_.hoveredBgSprite = "buttonclosehover"; closeButton_.pressedBgSprite = "buttonclosepressed"; UIPanel panel = mainPanel_.AddUIComponent <UIPanel>(); panel.relativePosition = new Vector2(20, 70); panel.size = new Vector2(565, 320); UIHelper helper = new UIHelper(mainPanel_); string checkboxLabel = Translation.ModConflicts.Get("Checkbox:Scan for known incompatible mods on startup"); runModsCheckerOnStartup_ = helper.AddCheckbox( checkboxLabel, GlobalConfig.Instance.Main.ScanForKnownIncompatibleModsAtStartup, RunModsCheckerOnStartup_eventCheckChanged) as UICheckBox; runModsCheckerOnStartup_.relativePosition = new Vector3(20, height - 30f); UIScrollablePanel scrollablePanel = panel.AddUIComponent <UIScrollablePanel>(); scrollablePanel.backgroundSprite = string.Empty; scrollablePanel.size = new Vector2(550, 340); scrollablePanel.relativePosition = new Vector3(0, 0); scrollablePanel.clipChildren = true; scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; scrollablePanel.autoLayout = true; // Populate list of incompatible mods if (IncompatibleMods.Count != 0) { IncompatibleMods.ForEach( pair => { CreateEntry(ref scrollablePanel, pair.Value, pair.Key); }); } scrollablePanel.FitTo(panel); scrollablePanel.scrollWheelDirection = UIOrientation.Vertical; scrollablePanel.builtinKeyNavigation = true; UIScrollbar verticalScroll = panel.AddUIComponent <UIScrollbar>(); verticalScroll.stepSize = 1; verticalScroll.relativePosition = new Vector2(panel.width - 15, 0); verticalScroll.orientation = UIOrientation.Vertical; verticalScroll.size = new Vector2(20, 320); verticalScroll.incrementAmount = 25; verticalScroll.scrollEasingType = EasingType.BackEaseOut; scrollablePanel.verticalScrollbar = verticalScroll; UISlicedSprite track = verticalScroll.AddUIComponent <UISlicedSprite>(); track.spriteName = "ScrollbarTrack"; track.relativePosition = Vector3.zero; track.size = new Vector2(16, 320); verticalScroll.trackObject = track; UISlicedSprite thumb = track.AddUIComponent <UISlicedSprite>(); thumb.spriteName = "ScrollbarThumb"; thumb.autoSize = true; thumb.relativePosition = Vector3.zero; verticalScroll.thumbObject = thumb; // Add blur effect if applicable blurEffect_ = GameObject.Find("ModalEffect").GetComponent <UIComponent>(); AttachUIComponent(blurEffect_.gameObject); blurEffect_.size = new Vector2(resolution.x, resolution.y); blurEffect_.absolutePosition = new Vector3(0, 0); blurEffect_.SendToBack(); blurEffect_.eventPositionChanged += OnBlurEffectPositionChange; blurEffect_.eventZOrderChanged += OnBlurEffectZOrderChange; blurEffect_.opacity = 0; blurEffect_.isVisible = true; ValueAnimator.Animate( "ModalEffect", val => blurEffect_.opacity = val, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut)); // Make sure modal dialog is in front of all other UI BringToFront(); }
public void Initialize() { DebugLog.LogToFileOnly("IncompatibleModsPanel initialize"); isVisible = true; backgroundSprite = "MenuPanel3"; color = new Color32(75, 75, 135, 255); width = 600; height = 440; Vector2 resolution = UIView.GetAView().GetScreenResolution(); relativePosition = new Vector3(resolution.x / 2 - 300, resolution.y / 3); warningIcon = AddUIComponent <UISprite>(); warningIcon.size = new Vector2(40f, 40f); warningIcon.spriteName = "IconWarning"; warningIcon.relativePosition = new Vector3(15, 15); warningIcon.zOrder = 0; title = AddUIComponent <UILabel>(); title.autoSize = true; title.padding = new RectOffset(10, 10, 15, 15); title.relativePosition = new Vector2(60, 12); title.text = Localization.Get("INCOMPATIBILITY_CHECK_TIP"); UIPanel panel = AddUIComponent <UIPanel>(); panel.relativePosition = new Vector2(20, 70); panel.size = new Vector2(565, 320); UIScrollablePanel scrollablePanel = panel.AddUIComponent <UIScrollablePanel>(); scrollablePanel.backgroundSprite = ""; scrollablePanel.size = new Vector2(550, 340); scrollablePanel.relativePosition = new Vector3(0, 0); scrollablePanel.clipChildren = true; if (IncompatibleMods.Count != 0) { int acc = 0; UIPanel item; IncompatibleMods.ForEach((pair) => { item = CreateEntry(ref scrollablePanel, pair.Value, pair.Key); item.relativePosition = new Vector2(0, acc); item.size = new Vector2(560, 50); acc += 50; }); item = null; } scrollablePanel.FitTo(panel); scrollablePanel.scrollWheelDirection = UIOrientation.Vertical; scrollablePanel.builtinKeyNavigation = true; UIScrollbar verticalScroll = panel.AddUIComponent <UIScrollbar>(); verticalScroll.stepSize = 1; verticalScroll.relativePosition = new Vector2(panel.width - 15, 0); verticalScroll.orientation = UIOrientation.Vertical; verticalScroll.size = new Vector2(20, 320); verticalScroll.incrementAmount = 25; verticalScroll.scrollEasingType = EasingType.BackEaseOut; scrollablePanel.verticalScrollbar = verticalScroll; UISlicedSprite track = verticalScroll.AddUIComponent <UISlicedSprite>(); track.spriteName = "ScrollbarTrack"; track.relativePosition = Vector3.zero; track.size = new Vector2(16, 320); verticalScroll.trackObject = track; UISlicedSprite thumb = track.AddUIComponent <UISlicedSprite>(); thumb.spriteName = "ScrollbarThumb"; thumb.autoSize = true; thumb.relativePosition = Vector3.zero; verticalScroll.thumbObject = thumb; closeButton = AddUIComponent <UIButton>(); closeButton.eventClick += CloseButtonClick; closeButton.relativePosition = new Vector3(width - closeButton.width - 45, 15f); closeButton.normalBgSprite = "buttonclose"; closeButton.hoveredBgSprite = "buttonclosehover"; closeButton.pressedBgSprite = "buttonclosepressed"; BringToFront(); }
public void Initialize() { Log._Debug("IncompatibleModsPanel initialize"); if (mainPanel != null) { mainPanel.OnDestroy(); } isVisible = true; mainPanel = AddUIComponent <UIPanel>(); mainPanel.backgroundSprite = "UnlockingPanel2"; mainPanel.color = new Color32(75, 75, 135, 255); width = 600; height = 440; mainPanel.width = 600; mainPanel.height = 440; Vector2 resolution = UIView.GetAView().GetScreenResolution(); relativePosition = new Vector3(resolution.x / 2 - 300, resolution.y / 3); mainPanel.relativePosition = Vector3.zero; warningIcon = mainPanel.AddUIComponent <UISprite>(); warningIcon.size = new Vector2(40f, 40f); warningIcon.spriteName = "IconWarning"; warningIcon.relativePosition = new Vector3(15, 15); warningIcon.zOrder = 0; title = mainPanel.AddUIComponent <UILabel>(); title.autoSize = true; title.padding = new RectOffset(10, 10, 15, 15); title.relativePosition = new Vector2(60, 12); title.text = Translation.GetString("Traffic_Manager_detected_incompatible_mods"); closeButton = mainPanel.AddUIComponent <UIButton>(); closeButton.eventClick += CloseButtonClick; closeButton.relativePosition = new Vector3(width - closeButton.width - 45, 15f); closeButton.normalBgSprite = "buttonclose"; closeButton.hoveredBgSprite = "buttonclosehover"; closeButton.pressedBgSprite = "buttonclosepressed"; UIPanel panel = mainPanel.AddUIComponent <UIPanel>(); panel.relativePosition = new Vector2(20, 70); panel.size = new Vector2(565, 320); UIHelper helper = new UIHelper(mainPanel); runModsCheckerOnStartup = helper.AddCheckbox(Translation.GetString("Scan_for_known_incompatible_mods_on_startup"), State.GlobalConfig.Instance.Main.ScanForKnownIncompatibleModsAtStartup, RunModsCheckerOnStartup_eventCheckChanged) as UICheckBox; runModsCheckerOnStartup.relativePosition = new Vector3(20, height - 30f); UIScrollablePanel scrollablePanel = panel.AddUIComponent <UIScrollablePanel>(); scrollablePanel.backgroundSprite = ""; scrollablePanel.size = new Vector2(550, 340); scrollablePanel.relativePosition = new Vector3(0, 0); scrollablePanel.clipChildren = true; if (IncompatibleMods.Count != 0) { int acc = 0; UIPanel item; IncompatibleMods.ForEach((pair) => { item = CreateEntry(ref scrollablePanel, pair.Value, pair.Key); item.relativePosition = new Vector2(0, acc); item.size = new Vector2(560, 50); acc += 50; }); item = null; } scrollablePanel.FitTo(panel); scrollablePanel.scrollWheelDirection = UIOrientation.Vertical; scrollablePanel.builtinKeyNavigation = true; UIScrollbar verticalScroll = panel.AddUIComponent <UIScrollbar>(); verticalScroll.stepSize = 1; verticalScroll.relativePosition = new Vector2(panel.width - 15, 0); verticalScroll.orientation = UIOrientation.Vertical; verticalScroll.size = new Vector2(20, 320); verticalScroll.incrementAmount = 25; verticalScroll.scrollEasingType = EasingType.BackEaseOut; scrollablePanel.verticalScrollbar = verticalScroll; UISlicedSprite track = verticalScroll.AddUIComponent <UISlicedSprite>(); track.spriteName = "ScrollbarTrack"; track.relativePosition = Vector3.zero; track.size = new Vector2(16, 320); verticalScroll.trackObject = track; UISlicedSprite thumb = track.AddUIComponent <UISlicedSprite>(); thumb.spriteName = "ScrollbarThumb"; thumb.autoSize = true; thumb.relativePosition = Vector3.zero; verticalScroll.thumbObject = thumb; blurEffect = GameObject.Find("ModalEffect").GetComponent <UIComponent>(); AttachUIComponent(blurEffect.gameObject); blurEffect.size = new Vector2(resolution.x, resolution.y); blurEffect.absolutePosition = new Vector3(0, 0); blurEffect.SendToBack(); if (blurEffect != null) { blurEffect.isVisible = true; ValueAnimator.Animate("ModalEffect", delegate(float val) { blurEffect.opacity = val; }, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut)); } BringToFront(); }