示例#1
0
        private void RefreshContent(IUserInterfaceRenderContext renderContext, int maxWidth)
        {
            if (!dirty && content != null)
            {
                if (maxWidth > content.Size.Width)
                {
                    return;
                }

                dirty = true;
            }

            if (dirty || lastContentMaxWidth != maxWidth)
            {
                if (Props.Text == null)
                {
                    content = null;
                }
                else
                {
                    layoutOptions.Font     = Style.Font;
                    layoutOptions.MaxWidth = maxWidth;

                    content = renderContext.CreateContentLayout(Props.Text, layoutOptions, Props.PerformLocalization);
                    content.Options.ReadSlowly = Props.ReadSlowly;

                    content.AnimationComplete += () => Props.AnimationComplete?.Invoke(evt.Reset(this));
                }

                lastContentMaxWidth = maxWidth;
                dirty = false;
            }
        }
示例#2
0
        public SplashScene(GraphicsDevice graphicsDevice, IContentProvider content, CImage img, CSound snd)
        {
            this.graphicsDevice = graphicsDevice;
            this.content        = content;
            this.img            = img;
            this.snd            = snd;
            this.spriteBatch    = new SpriteBatch(graphicsDevice);

            img.preload(content);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                delay = 500;
            }

            StringBuilder text = new StringBuilder();

            text.AppendLine("Ball: Buster eXtreme");
            text.AppendLine("Copyright 2004-18 Patrick Avella, Erik Ylvisaker");
            text.AppendLine("Game Programming: Patrick Avella (patrickavella.com)");
            text.AppendLine("eXtreme Version Programming: Erik Ylvisaker (vermiliontower.com)");
            text.AppendLine("Game Art: Patrick Avella (patrickavella.com)");
            text.AppendLine("Background Music: Partners in Rhyme (musicloops.com)");
            text.AppendLine("Sound Effects: A1 Free Sound Effects (a1freesoundeffects.com)");

            ContentLayoutEngine layout = new ContentLayoutEngine(img.Fonts);

            textLayout = layout.LayoutContent(text.ToString(), font: new FontStyleProperties {
                Color = Color.Black
            });

            initialDelay = delay;
        }
 /// <summary>
 /// Creates a scrollable window.<br/>
 /// The scrolling content will be the same width as the parent.
 /// </summary>
 /// <param name="content">The <c>ContentArea</c> to put the scrollable window in.</param>
 /// <param name="config">The configuration options for the scrollbar.</param>
 /// <param name="contentHeight">The height of the scroll window.</param>
 /// <param name="layout">The layout to apply to the added content.</param>
 /// <param name="action">The action that will get called to add the content.</param>
 /// <returns></returns>
 public static ContentArea AddScrollPaneContent(
     this ContentArea content,
     ScrollbarConfig config,
     RelLength contentHeight,
     IContentLayout layout,
     Action <ContentArea> action
     ) => content.AddScrollPaneContent(config, contentHeight, layout, action, out _, out _);
示例#4
0
        private static void DrawContent(IUserInterfaceRenderContext renderContext, IContentLayout content, ref int x)
        {
            content.Draw(
                new Vector2(x, renderContext.Area.Height - content.Size.Height),
                renderContext.SpriteBatch);

            x += content.Size.Width;
        }
示例#5
0
 /// <summary>
 /// Adds "content" to the menu in a certain layout. <br/>
 /// If <c>CreateContentPane</c> has not been called yet, this method will immeddiately return.
 /// </summary>
 /// <param name="layout">The layout of the added content</param>
 /// <param name="navgraph">The navigation graph to place the selectables in.</param>
 /// <param name="action">The action that will get called to add the content</param>
 /// <returns></returns>
 public MenuBuilder AddContent(IContentLayout layout, INavigationGraph navgraph, Action <ContentArea> action)
 {
     if (this.Screen.content == null)
     {
         return(this);
     }
     action(new ContentArea(this.Screen.content.gameObject, layout, navgraph));
     return(this);
 }
        public IContentLayout LayoutContent(string text, ContentLayoutOptions layoutOptions, bool localize = true)
        {
            IContentLayout result = engine.LayoutContent(text, layoutOptions, localize);

            calls.Add(new ContentLayoutEngineCalls
            {
                Result        = result,
                Text          = text,
                LayoutOptions = layoutOptions,
                Localize      = localize
            });

            return(result);
        }
示例#7
0
        public ContentMenuItem()
        {
            Display.IndicatorType              = IndicatorType.Standard;
            Display.Styles.ActiveStyleChanged += (sender, e) =>
            {
                content = null;
            };

            buttonPress.Press += button =>
            {
                if (button == MenuInputButton.Accept)
                {
                    PressAccept?.Invoke(this, EventArgs.Empty);
                }
            };
        }
示例#8
0
 /// <summary>
 /// Creates a new <c>ContentArea</c> with no navigation graph.
 /// </summary>
 /// <param name="obj">The object to place the added content in.</param>
 /// <param name="layout">The layout to apply to the content being added.</param>
 public ContentArea(GameObject obj, IContentLayout layout) : this(obj, layout, new NullNavigationGraph())
 {
 }
示例#9
0
 /// <summary>
 /// Creates a new <c>ContentArea</c>.
 /// </summary>
 /// <param name="obj">The object to place the added content in.</param>
 /// <param name="layout">The layout to apply to the content being added.</param>
 /// <param name="navGraph">The navigation graph to place the selectables in.</param>
 public ContentArea(GameObject obj, IContentLayout layout, INavigationGraph navGraph)
 {
     this.ContentObject = obj;
     this.Layout        = layout;
     this.NavGraph      = navGraph;
 }
示例#10
0
 /// <summary>
 /// Adds "content" to the control pane in a certain layout with the default navigation graph.<br/>
 /// If <c>CreateControlPane</c> has not been called yet, this method will immeddiately return.
 /// </summary>
 /// <param name="layout">The layout to apply to the added content.</param>
 /// <param name="action">The action that will get called to add the content.</param>
 /// <returns></returns>
 public MenuBuilder AddControls(
     IContentLayout layout,
     Action <ContentArea> action
     ) => this.AddControls(layout, this.DefaultNavGraph, action);
        /// <summary>
        /// Creates a scrollable window.<br/>
        /// The scrolling content will be the same width as the parent.
        /// </summary>
        /// <param name="content">The <c>ContentArea</c> to put the scrollable window in.</param>
        /// <param name="config">The configuration options for the scrollbar.</param>
        /// <param name="contentHeight">The height of the scroll window.</param>
        /// <param name="layout">The layout to apply to the added content.</param>
        /// <param name="action">The action that will get called to add the content.</param>
        /// <param name="scrollContent">The created scrollable window game object.</param>
        /// <param name="scroll">The <c>Scrollbar</c> component on the created scrollbar.</param>
        /// <returns></returns>
        public static ContentArea AddScrollPaneContent(
            this ContentArea content,
            ScrollbarConfig config,
            RelLength contentHeight,
            IContentLayout layout,
            Action <ContentArea> action,
            out GameObject scrollContent,
            out Scrollbar scroll
            )
        {
            // Scrollbar
            content.AddScrollbar(config, out scroll);

            // ScrollMask
            var scrollMask = new GameObject("ScrollMask");

            GameObject.DontDestroyOnLoad(scrollMask);
            scrollMask.transform.SetParent(content.ContentObject.transform, false);
            // RectTransform
            var scrollMaskRt = scrollMask.AddComponent <RectTransform>();

            scrollMaskRt.sizeDelta        = new Vector2(0f, 0f);
            scrollMaskRt.pivot            = new Vector2(0.5f, 0.5f);
            scrollMaskRt.anchorMin        = new Vector2(0f, 0f);
            scrollMaskRt.anchorMax        = new Vector2(1f, 1f);
            scrollMaskRt.anchoredPosition = new Vector2(0f, 0f);
            // CanvasRenderer
            scrollMask.AddComponent <CanvasRenderer>();
            // Mask
            var mask = scrollMask.AddComponent <Mask>();

            mask.showMaskGraphic = false;
            // Image
            var maskImage = scrollMask.AddComponent <Image>();

            maskImage.raycastTarget = false;

            // Scrolling Pane
            var scrollPane = new GameObject("ScrollingPane");

            GameObject.DontDestroyOnLoad(scrollPane);
            scrollPane.transform.SetParent(scrollMask.transform, false);
            // RectTransform
            var scrollPaneRt = scrollPane.AddComponent <RectTransform>();

            RectTransformData.FromSizeAndPos(
                new RelVector2(new RelLength(0f, 1f), contentHeight),
                new AnchoredPosition(new Vector2(0.5f, 1f), new Vector2(0.5f, 1f))
                ).Apply(scrollPaneRt);
            // CanvasRenderer
            scrollPane.AddComponent <CanvasRenderer>();

            action(new ContentArea(
                       scrollPane,
                       layout,
                       new ScrollMovingNavGraph
            {
                Inner               = content.NavGraph,
                Scrollbar           = scroll,
                ScrollPaneTransform = scrollPaneRt,
                SelectionPadding    = config.SelectionPadding ?? (_ => (0, 0))
            }