Пример #1
0
 public override void Update(IUpdateVisitor visitor, float dt)
 {
     base.DecoratedElement.Update(visitor, dt);
     //A decorated button will flash into an other color when you hover the mouse over it
     if (DecoratedButton.is_intersecting(new Position(inputManager.Hover().X, inputManager.Hover().Y)))
     {
         DecoratedButton.Color = HoverColor;
         inputManager.Click().Visit(() => Do.Nothing(), (pos2) => DecoratedButton.Color = ClickColor);
     }
     else
     {
         DecoratedButton.Color = OldColor;
     }
 }
Пример #2
0
        public override void Update(IUpdateVisitor visitor, float dt)
        {
            //A decorated label is like an input field
            base.DecoratedElement.Update(visitor, dt);
            inputManager.Typing().Visit(() => Do.Nothing(), (keys) =>
            {
                switch (keys[0].ToString())
                {
                case "Back":
                    if (label.Content.Length != 0)
                    {
                        label.Content = label.Content.Remove(label.Content.Length - 1, 1);
                    }
                    break;

                case "Space":
                    if (label.Content.Length <= Max)
                    {
                        label.Content += " ";
                    }
                    break;

                case "Enter":
                    if (label.Content.Length <= Max)
                    {
                        label.Content += "\n";
                    }
                    break;

                case "Delete":
                    label.Content = "";
                    break;

                default:
                    if (label.Content.Length <= Max)
                    {
                        label.Content += keys[0];
                    }
                    break;
                }
            });
        }
Пример #3
0
 private void ExitWindow(Action exit)
 {
     this.elements = new Empty <IGuiElement>();
     this.menuFactory.Create(1, "Yes", new Position(1000, 500), Colour.Red, () => exit()).Visit(() => Do.Nothing(), (element) => this.elements            = this.elements.Add(element));
     this.menuFactory.Create(1, "No", new Position(300, 500), Colour.Green, () => StartWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
     this.menuFactory.Create(2, "Are you sure you want to quit?", new Position(700, 500), Colour.Black, () => Do.Nothing()).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
 }
Пример #4
0
        private void LabelWindow(Action exit)
        {
            this.elements = new Empty <IGuiElement>();
            this.menuFactory.Create(4, "Start typing: ", new Position(500, 30), Colour.White, () => Do.Nothing()).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(2, "Press DELETE to refresh the input field", new Position(50, 50), Colour.Black, () => Do.Nothing()).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(5, "Go Back", new Position(1400, 200), Colour.Blue, () => StartWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));

            this.menuFactory.Create(3, "C", new Position(500, 550), Colour.White, () => Music.PlayNote(new Note(Tone.C, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "D", new Position(560, 550), Colour.White, () => Music.PlayNote(new Note(Tone.D, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "E", new Position(620, 550), Colour.White, () => Music.PlayNote(new Note(Tone.E, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "F", new Position(680, 550), Colour.White, () => Music.PlayNote(new Note(Tone.F, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "G", new Position(740, 550), Colour.White, () => Music.PlayNote(new Note(Tone.G, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "A", new Position(800, 550), Colour.White, () => Music.PlayNote(new Note(Tone.A, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
            this.menuFactory.Create(3, "B", new Position(860, 550), Colour.White, () => Music.PlayNote(new Note(Tone.B, Duration.QUARTER))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
        }
Пример #5
0
 private void InputWindow(Action exit)
 {
     this.elements = new Empty <IGuiElement>();
     this.menuFactory.Create(5, "Play Music", new Position(800, 400), Colour.Yellow, () => Music.PlaySong(Music.BuildSong(2))).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
     this.menuFactory.Create(5, "Go Back", new Position(800, 600), Colour.Blue, () => StartWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
 }
Пример #6
0
 private void StartWindow(Action exit)
 {
     this.elements = new Empty <IGuiElement>();
     this.menuFactory.Create(5, "Start", new Position(700, 300), Colour.Red, () => InputWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements   = this.elements.Add(element));
     this.menuFactory.Create(5, "Input", new Position(700, 400), Colour.White, () => LabelWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
     this.menuFactory.Create(5, "Exit", new Position(700, 500), Colour.Blue, () => ExitWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements    = this.elements.Add(element));
 }
Пример #7
0
 public TextBox(string message, Position top_left_corner, Colour color, int width, int height)
 {
     this.LabelFactory       = new ConcreteGuiElementFactory();
     this.NonClickAbleButton = new Button(message, top_left_corner, color, width, height, () => Do.Nothing());
     LabelFactory.Create(6, "", top_left_corner, color, () => Do.Nothing()).Visit(() => Do.Nothing(), (element) => this.inputField = element);
 }
Пример #8
0
        public static ILinkedList <Note> BuildSong(int select)
        {
            NoteFactory        SongBuilder = new ConcreteNoteFactory();
            ILinkedList <Note> Song        = new Empty <Note>();

            switch (select)
            {
            case 1:
                SongBuilder.Create("C", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));
                SongBuilder.Create("F", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));
                SongBuilder.Create("G", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("C", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("A", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("G", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));

                SongBuilder.Create("G", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("G", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));
                SongBuilder.Create("C", Duration.WHOLE).Visit(() => Do.Nothing(), (note) => Song   = Song.Add(note));

                SongBuilder.Create("G", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));

                SongBuilder.Create("rest", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                break;

            case 2:
                //Couplet 1
                SongBuilder.Create("D", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("D", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));
                SongBuilder.Create("C", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));

                SongBuilder.Create("D", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));
                SongBuilder.Create("E", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song    = Song.Add(note));

                SongBuilder.Create("rest", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                //Couplet 2
                SongBuilder.Create("D", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("E", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("D", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("E", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("D", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("C", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                //Couplet 3
                SongBuilder.Create("D", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("D", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("D", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("C", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                //Outro
                SongBuilder.Create("D", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("C", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("E", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("F", Duration.EIGHTH).Visit(() => Do.Nothing(), (note) => Song   = Song.Add(note));
                SongBuilder.Create("G", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("G#", Duration.QUARTER).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));

                SongBuilder.Create("F#", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                SongBuilder.Create("B", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("A", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song  = Song.Add(note));
                SongBuilder.Create("A#", Duration.HALF).Visit(() => Do.Nothing(), (note) => Song = Song.Add(note));
                break;
            }

            return(Song.Reverse());//The song needs to be reversed, cause the add function adds every item to the first place
        }