Exemple #1
0
        internal static void InitializeModule()
        {
            _debugUIController = new Controller();
            CornerAnchor       = new CornerAnchor();
            _debugUIController.Add(CornerAnchor);

            Context.ScriptingEngine.Expose("highlight", (Action <string>)(source =>
            {
                bool parsed = Enum.TryParse(source, true, out MessageSource parsedSource);
                if (!parsed)
                {
                    return;
                }
                _highlighted = parsedSource;
            }), "Highlights the specified message source.");
        }
Exemple #2
0
        public override void Load()
        {
            // Create the corner anchor.
            _anchor = new CornerAnchor {
                Padding = new Rectangle(10, 10, 10, 10)
            };

            // Create the UI controller.
            _uiController = new Controller();
            _uiController.Add(_anchor);

            // Generate 10 random components in each corner.
            Random randomizer = new Random();

            for (int i = 0; i < 10; i++)
            {
                BasicButton test = new BasicButton(new Vector3(0, 0, 0), new Vector2(randomizer.Next(10, 101), randomizer.Next(10, 101)));
                _anchor.AddChild(test, AnchorLocation.TopLeft, new Rectangle(randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16)));
            }

            for (int i = 0; i < 10; i++)
            {
                BasicButton test = new BasicButton(new Vector3(0, 0, 0), new Vector2(randomizer.Next(10, 101), randomizer.Next(10, 101)));
                _anchor.AddChild(test, AnchorLocation.BottomLeft, new Rectangle(randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16)));
            }

            for (int i = 0; i < 10; i++)
            {
                BasicButton test = new BasicButton(new Vector3(0, 0, 0), new Vector2(randomizer.Next(10, 101), randomizer.Next(10, 101)));
                _anchor.AddChild(test, AnchorLocation.TopRight, new Rectangle(randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16)));
            }

            for (int i = 0; i < 10; i++)
            {
                BasicButton test = new BasicButton(new Vector3(0, 0, 0), new Vector2(randomizer.Next(10, 101), randomizer.Next(10, 101)));
                _anchor.AddChild(test, AnchorLocation.BottomRight, new Rectangle(randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16), randomizer.Next(5, 16)));
            }
        }
        public override void Load()
        {
            _uiController = new Controller();
            CornerAnchor cornerAnchor = new CornerAnchor();

            _uiController.Add(cornerAnchor);

            // Create labels for each scene.
            for (int i = 0; i < _scenes.Length; i++)
            {
                int iCopy = i;

                ClickableLabel addSceneLabel = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _scenes[i].ToString(), Color.White, Vector3.Zero)
                {
                    OnClick = () =>
                    {
                        Context.LayerManager.Remove(this);
                        Context.LayerManager.Add((Layer)Activator.CreateInstance(_scenes[iCopy]), _scenes[iCopy].ToString(), 1);
                    }
                };
                cornerAnchor.AddChild(addSceneLabel, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0));
            }
        }
Exemple #4
0
        public override void Load()
        {
            _sounds = Directory.GetFiles("Assets/SoundPlayer").Where(x => x.Contains(".wav")).Select(x => x.Replace("Assets/", "")).ToArray();

            _uiController = new Controller();
            CenterAnchor centerAnchor = new CenterAnchor();

            _uiController.Add(centerAnchor);

            _controlButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_playButton),
                OnClick = () =>
                {
                    SoundLayer layer = Context.SoundManager.GetLayer("main");
                    if (layer == null)
                    {
                        return;
                    }

                    if (layer.Status == SoundStatus.Playing)
                    {
                        layer.Pause();
                    }
                    else
                    {
                        layer.Resume();
                    }
                }
            };
            centerAnchor.AddChild(_controlButton, new Rectangle(0, Context.Settings.RenderHeight / 2 - 36, 0, 0));

            BasicButton loopButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_loopButton)
            };

            loopButton.OnClick = () =>
            {
                SoundLayer layer = Context.SoundManager.GetLayer("main");
                if (layer == null)
                {
                    return;
                }

                layer.Looping   = !layer.Looping;
                loopButton.Tint = layer.Looping ? Color.Green : Color.White;
            };
            centerAnchor.AddChild(loopButton, new Rectangle(-40, Context.Settings.RenderHeight / 2 - 36, 0, 0));

            _soundBar = new ScrollInput(Vector3.Zero, new Vector2(Context.Settings.RenderWidth - 40, 10))
            {
                KeepSelectorInside = true,
                SelectorRatio      = 3
            };
            centerAnchor.AddChild(_soundBar, new Rectangle(0, Context.Settings.RenderHeight / 2 - 10, 0, 0));

            _soundBarInfo = new BasicText(Context.AssetLoader.Get <Font>(_defaultFont), 13, "N/A", Color.White, Vector3.Zero);
            centerAnchor.AddChild(_soundBarInfo, new Rectangle(100, Context.Settings.RenderHeight / 2 - 30, 0, 0));

            CornerAnchor cornerAnchor = new CornerAnchor();

            _uiController.Add(cornerAnchor);

            for (int i = 0; i < _sounds.Length; i++)
            {
                int iCopy = i;

                ClickableLabel addSoundText = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _sounds[i], Color.White, Vector3.Zero)
                {
                    OnClick = () =>
                    {
                        if (_append)
                        {
                            Context.SoundManager.PlayQueue(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main");
                        }
                        else
                        {
                            Context.SoundManager.Play(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main");
                        }
                    }
                };
                cornerAnchor.AddChild(addSoundText, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0));
            }

            BasicButton appendButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_addButton)
            };

            appendButton.OnClick = () =>
            {
                _append           = !_append;
                appendButton.Tint = _append ? Color.Green : Color.White;
            };
            cornerAnchor.AddChild(appendButton, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0));

            PlayerVolumeControl volumeControl = new PlayerVolumeControl(Vector3.Zero, new Vector2(100, 20));

            cornerAnchor.AddChild(volumeControl, AnchorLocation.TopRight, new Rectangle(0, 20, 20, 0));
        }