Panel nativePanel = new Panel(); // Native panel is 320x200 child panel scaled to fit parent #endregion Fields #region Constructors public DaggerfallBaseWindow(IUserInterfaceManager uiManager) : base(uiManager) { // Parent panel parentPanel.Components.Add(nativePanel); parentPanel.BackgroundColor = Color.black; // Native panel nativePanel.HorizontalAlignment = HorizontalAlignment.Center; nativePanel.VerticalAlignment = VerticalAlignment.Middle; nativePanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; nativePanel.Size = new Vector2(nativeScreenWidth, nativeScreenHeight); // Set native panel scaling mode if (DaggerfallUnity.Settings.FreeScaling) nativePanel.AutoSize = AutoSizeModes.ScaleFreely; else nativePanel.AutoSize = AutoSizeModes.ScaleToFit; // Setup default tooltip if (DaggerfallUnity.Settings.EnableToolTips) { defaultToolTip = new ToolTip(); defaultToolTip.ToolTipDelay = DaggerfallUnity.Settings.ToolTipDelayInSeconds; defaultToolTip.BackgroundColor = DaggerfallUnity.Settings.ToolTipBackgroundColor; defaultToolTip.TextColor = DaggerfallUnity.Settings.ToolTipTextColor; defaultToolTip.Parent = nativePanel; // Experimental HQ tooltip if (DaggerfallUnity.Settings.HQTooltips) { defaultToolTip.Font = DaggerfallUI.Instance.GetHQPixelFont(DaggerfallUI.HQPixelFonts.Petrock_32); defaultToolTip.Parent = parentPanel; } } }
/// <summary> /// Copies key setting from another tooltip. /// </summary> /// <param name="from"></param> public void CloneSettings(ToolTip from) { Font = from.Font; ToolTipDelay = from.ToolTipDelay; MouseOffset = from.MouseOffset; TextColor = from.TextColor; BackgroundColor = from.BackgroundColor; Parent = from.Parent; }
/// <summary> /// Initializes a fully customised new instance of ItemListScroller. /// </summary> /// <param name="listRows">Number of rows of items this list will display at one time.</param> /// <param name="listCols">Number of items displayed per row.</param> /// <param name="itemListRect">Item list coordinate rect, excluding scrollbar.</param> /// <param name="itemsRects">Individual items display coordinate rects. (1 per width*height)</param> /// <param name="miscLabelTemplate">Template for misc label: relative position, font, horizontal and vertical alignment, text scale. (defaults: Vector2.zero, Font4, Left, Top, 1)</param> /// <param name="toolTip">Tool tip class to use if items should display tooltips.</param> /// <param name="itemMarginSize">Individual item display margin size.</param> /// <param name="textScale">Text scale factor for stack labels.</param> /// <param name="scroll">True for a scrollable list, false otherwise.</param> /// <param name="miscLabelOffsetDist">Vertical distance to offset the misc label, 0 to disable.</param> /// <param name="miscLabelOffsetIdx">Index of column for which to offset the misc label.</param> public ItemListScroller(int listRows, int listCols, Rect itemListRect, Rect[] itemsRects, TextLabel miscLabelTemplate, ToolTip toolTip = null, int itemMarginSize = 1, float textScale = 1f, bool scroll = true, int miscLabelOffsetDist = 0, int miscLabelOffsetIdx = 0) : base() { listDisplayTotal = listRows * listCols; if (itemsRects.Length != listDisplayTotal) { throw new ArgumentException(); } listDisplayUnits = listRows; listWidth = listCols; itemListPanelRect = itemListRect; itemButtonRects = itemsRects; itemButtonMargin = itemMarginSize; this.toolTip = toolTip; this.textScale = textScale; scroller = scroll; this.miscLabelOffsetDist = miscLabelOffsetDist; this.miscLabelOffsetIdx = miscLabelOffsetIdx; LoadTextures(false); if (scroller) { SetupScrollBar(); SetupScrollButtons(); } SetupItemsList(false, miscLabelTemplate); }