Beispiel #1
0
        public override async Task LoadContent()
        {
            await base.LoadContent();

            //add a label with directions
            AddItem(new Label("Click anywhere to pop up a context menu", Content, FontSize.Small)
            {
                Horizontal    = HorizontalAlignment.Center,
                Vertical      = VerticalAlignment.Center,
                Position      = Resolution.TitleSafeArea.Center,
                Highlightable = false
            });

            var clicker = new RelativeLayoutButton()
            {
                Size       = Resolution.ScreenArea.Size.ToVector2(),
                Horizontal = HorizontalAlignment.Left,
                Vertical   = VerticalAlignment.Top,
                Position   = Point.Zero
            };

            clicker.OnClick += PopupMenu;
            AddItem(clicker);

            var cancel = AddCancelButton();

            cancel.OnClick += (obj, e) =>
            {
                var game1 = ScreenManager.Game as Game1;
                ScreenManager.ClearScreens();
                LoadingScreen.Load(ScreenManager, null, string.Empty, game1.GetMainMenuScreenStack());
            };
        }
Beispiel #2
0
        public void RelButtonClone2()
        {
            var button = new RelativeLayoutButton()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                Layer            = 1000,
                IsHighlighted    = true,
                DrawWhenInactive = true,
                Description      = "catpants!"
            };

            var original = new Shim()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                DrawWhenInactive = false,
                Layer            = 1000,
            };

            button.AddItem(original);

            var clone = button.DeepCopy() as RelativeLayoutButton;

            original.Size             = new Vector2(60, 70);
            original.Position         = new Point(80, 90);
            original.Horizontal       = HorizontalAlignment.Left;
            original.Vertical         = VerticalAlignment.Bottom;
            original.Scale            = 2.5f;
            original.DrawWhenInactive = true;
            original.Layer            = 2000;

            var copiedShim = clone.Layout.Items[0] as Shim;

            Assert.AreEqual(20, copiedShim.Size.X);
            Assert.AreEqual(30, copiedShim.Size.Y);
            Assert.AreEqual(40, copiedShim.Position.X);
            Assert.AreEqual(49, copiedShim.Position.Y);
            Assert.AreEqual(HorizontalAlignment.Center, copiedShim.Horizontal);
            Assert.AreEqual(VerticalAlignment.Center, copiedShim.Vertical);
            Assert.AreEqual(.5f, copiedShim.Scale);
            Assert.AreEqual(false, copiedShim.DrawWhenInactive);
            Assert.AreEqual(1000, copiedShim.Layer);
        }
        private RelativeLayoutButton AddButton(string text)
        {
            var hitButton = new RelativeLayoutButton()
            {
                Size          = new Vector2(256, 64),
                HasOutline    = true,
                HasBackground = true,
                Horizontal    = HorizontalAlignment.Left,
                Vertical      = VerticalAlignment.Top
            };

            hitButton.AddItem(new Label(text, Content, FontSize.Small)
            {
                Horizontal = HorizontalAlignment.Center,
                Vertical   = VerticalAlignment.Center
            });
            return(hitButton);
        }
Beispiel #4
0
        public void RelButtonClone_move()
        {
            var button = new RelativeLayoutButton()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                Layer            = 1000,
                IsHighlighted    = true,
                DrawWhenInactive = true,
                Description      = "catpants!"
            };

            var original = new Shim()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                DrawWhenInactive = false,
                Layer            = 1000,
            };

            button.AddItem(original);

            var buttonClone = button.DeepCopy() as RelativeLayoutButton;

            buttonClone.Position = new Point(50, 60);

            Assert.AreEqual(20, original.Size.X);
            Assert.AreEqual(30, original.Size.Y);
            Assert.AreEqual(40, original.Position.X);
            Assert.AreEqual(49, original.Position.Y);
            Assert.AreEqual(HorizontalAlignment.Center, original.Horizontal);
            Assert.AreEqual(VerticalAlignment.Center, original.Vertical);
            Assert.AreEqual(.5f, original.Scale);
            Assert.AreEqual(false, original.DrawWhenInactive);
            Assert.AreEqual(1000, original.Layer);
        }
Beispiel #5
0
        public void RelButtonClone_baselinemove()
        {
            var button = new RelativeLayoutButton()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                Layer            = 1000,
                IsHighlighted    = true,
                DrawWhenInactive = true,
                Description      = "catpants!"
            };

            var original = new Shim()
            {
                Size             = new Vector2(20, 30),
                Position         = new Point(40, 50),
                Horizontal       = HorizontalAlignment.Center,
                Vertical         = VerticalAlignment.Center,
                Scale            = 0.5f,
                DrawWhenInactive = false,
                Layer            = 1000,
            };

            button.AddItem(original);

            button.Position = new Point(50, 60);

            var copiedShim = button.Layout.Items[0] as Shim;

            Assert.AreEqual(20, copiedShim.Size.X);
            Assert.AreEqual(30, copiedShim.Size.Y);
            Assert.AreEqual(50, copiedShim.Position.X);
            Assert.AreEqual(59, copiedShim.Position.Y);
            Assert.AreEqual(HorizontalAlignment.Center, copiedShim.Horizontal);
            Assert.AreEqual(VerticalAlignment.Center, copiedShim.Vertical);
            Assert.AreEqual(.5f, copiedShim.Scale);
            Assert.AreEqual(false, copiedShim.DrawWhenInactive);
            Assert.AreEqual(1000, copiedShim.Layer);
        }
        private StackLayout GetStack()
        {
            //create the stack layout and add some labels
            var stack = new StackLayout()
            {
                Alignment  = StackAlignment.Top,
                Horizontal = HorizontalAlignment.Left,
                Vertical   = VerticalAlignment.Center
            };

            for (int i = 100; i < 150; i++)
            {
                var text  = i.ToString();
                var label = new Label(text, Content, FontSize.Small)
                {
                    Horizontal = HorizontalAlignment.Center,
                    Vertical   = VerticalAlignment.Center,
                };

                var button = new RelativeLayoutButton()
                {
                    Horizontal    = HorizontalAlignment.Center,
                    Vertical      = VerticalAlignment.Center,
                    HasOutline    = true,
                    HasBackground = false,
                    Layer         = i,
                    //Size = new Vector2(label.Rect.Width, label.Rect.Height)
                };
                button.Size = new Vector2(label.Rect.Width, label.Rect.Height);
                button.AddItem(label);
                button.OnClick += ((object obj, ClickEventArgs e) =>
                {
                    ScreenManager.AddScreen(new OkScreen(text));
                });

                stack.AddItem(button);
            }

            return(stack);
        }
        private void AddButton(HorizontalAlignment horiz, VerticalAlignment vert, string text)
        {
            //Add some buttons
            var button1 = new RelativeLayoutButton()
            {
                TransitionObject = new WipeTransitionObject(TransitionWipeType.PopLeft),
                Horizontal       = horiz,
                Vertical         = vert,
                Position         = new Point(horiz == HorizontalAlignment.Left ? Resolution.TitleSafeArea.Left : Resolution.TitleSafeArea.Right,
                                             vert == VerticalAlignment.Top ? Resolution.TitleSafeArea.Top : Resolution.TitleSafeArea.Bottom),
            };
            var label = new Label(text, Content)
            {
                Horizontal = HorizontalAlignment.Center,
                Vertical   = VerticalAlignment.Center,
            };

            button1.Size = label.Rect.Size.ToVector2();
            button1.AddItem(label);
            AddMenuItem(button1);
            AddItem(button1);
        }
Beispiel #8
0
        private void AddListenButton(QuestionLabel label, SoundEffect soundEffect)
        {
            //create the button
            var button = new RelativeLayoutButton()
            {
                TransitionObject = new WipeTransitionObject(TransitionWipeType.PopRight, Transition),
                Size             = new Vector2(48f),
                Vertical         = VerticalAlignment.Center,
                Horizontal       = HorizontalAlignment.Right,
                Position         = new Point(Resolution.TitleSafeArea.Right, label.Rect.Center.Y),
                IsQuiet          = true
            };

            //create the image for the button
            var image = new Image(Content.Load <Texture2D>("volume-high"))
            {
                TransitionObject = new WipeTransitionObject(TransitionWipeType.PopRight, Transition),
                Size             = new Vector2(48f),
                Vertical         = VerticalAlignment.Center,
                Horizontal       = HorizontalAlignment.Right,
                Highlightable    = false,
                FillRect         = true
            };

            button.AddItem(image);

            button.OnClick += (obj, e) =>
            {
                //send the listen again message
                QuestionScreen.QuestionStateMachine.SendStateMessage((int)QuestionStateMachine.QuestionMessage.Listen);
                //set the override of the label
                QuestionScreen.SetLabelOverride(label);

                //play the sound
                QuestionScreen.PlaySoundEffect(soundEffect);
            };
            AddItem(button);
        }
Beispiel #9
0
        public override async Task LoadContent()
        {
            await base.LoadContent();

            AddCancelButton();

            //add the scroll options
            var scroll = new MenuEntry("Scroll Up", Content);

            scroll.OnClick += ((object obj, ClickEventArgs e) =>
            {
                var scrollPos = _layout.ScrollPosition;
                scrollPos.Y -= _scrollDelta;
                _layout.ScrollPosition = scrollPos;
            });
            AddMenuEntry(scroll);

            scroll          = new MenuEntry("Scroll Down", Content);
            scroll.OnClick += ((object obj, ClickEventArgs e) =>
            {
                var scrollPos = _layout.ScrollPosition;
                scrollPos.Y += _scrollDelta;
                _layout.ScrollPosition = scrollPos;
            });
            AddMenuEntry(scroll);

            scroll          = new MenuEntry("Scroll Left", Content);
            scroll.OnClick += ((object obj, ClickEventArgs e) =>
            {
                var scrollPos = _layout.ScrollPosition;
                scrollPos.X -= _scrollDelta;
                _layout.ScrollPosition = scrollPos;
            });
            AddMenuEntry(scroll);

            scroll          = new MenuEntry("Scroll Right", Content);
            scroll.OnClick += ((object obj, ClickEventArgs e) =>
            {
                var scrollPos = _layout.ScrollPosition;
                scrollPos.X += _scrollDelta;
                _layout.ScrollPosition = scrollPos;
            });
            AddMenuEntry(scroll);

            //create the stack layout and add some labels
            var stack = new StackLayout()
            {
                Alignment  = StackAlignment.Top,
                Horizontal = HorizontalAlignment.Left,
                Vertical   = VerticalAlignment.Top
            };

            var label  = new Label("buttnuts", Content, FontSize.Small);
            var button = new RelativeLayoutButton()
            {
                HasOutline    = true,
                HasBackground = false
            };

            button.Size = new Vector2(label.Rect.Width, label.Rect.Height);
            button.AddItem(label);
            button.OnClick += ((object obj, ClickEventArgs e) =>
            {
                ExitScreen();
            });
            stack.AddItem(button);

            label  = new Label("catpants", Content, FontSize.Small);
            button = new RelativeLayoutButton()
            {
                HasOutline    = true,
                HasBackground = false
            };
            button.Size = new Vector2(label.Rect.Width, label.Rect.Height);
            button.AddItem(label);
            button.OnClick += ((object obj, ClickEventArgs e) =>
            {
                ExitScreen();
            });
            stack.AddItem(button);

            label  = new Label("foo", Content, FontSize.Small);
            button = new RelativeLayoutButton()
            {
                HasOutline    = true,
                HasBackground = false
            };
            button.Size = new Vector2(label.Rect.Width, label.Rect.Height);
            button.AddItem(label);
            button.OnClick += ((object obj, ClickEventArgs e) =>
            {
                ExitScreen();
            });
            stack.AddItem(button);

            label  = new Label("bleh", Content, FontSize.Small);
            button = new RelativeLayoutButton()
            {
                HasOutline    = true,
                HasBackground = false
            };
            button.Size = new Vector2(label.Rect.Width, label.Rect.Height);
            button.AddItem(label);
            button.OnClick += ((object obj, ClickEventArgs e) =>
            {
                ExitScreen();
            });
            stack.AddItem(button);

            //create the scroll layout and add the stack
            _layout = new ScrollLayout()
            {
                Horizontal = HorizontalAlignment.Right,
                Vertical   = VerticalAlignment.Bottom,
                Size       = new Vector2(label.Rect.Width, label.Rect.Height)
            };
            _layout.Position = new Point(ResolutionBuddy.Resolution.ScreenArea.Right, ResolutionBuddy.Resolution.ScreenArea.Bottom);

            _layout.AddItem(stack);
            AddItem(_layout);
        }
Beispiel #10
0
 public void Setup()
 {
     _button = new RelativeLayoutButton();
 }