Exemplo n.º 1
0
 protected override void Unload()
 {
     this.StopButton.Dispose();
     this.StopButton = null;
     this.Conveyor.Dispose();
     this.Conveyor = null;
     this.StopPlayback();
     GameService.Overlay.BlishHudWindow.RemoveTab(MusicianTab);
     ModuleInstance = null;
 }
Exemplo n.º 2
0
 private void StopPlayback()
 {
     if (StopButton != null)
     {
         StopButton.Dispose();
         StopButton = null;
     }
     if (MusicPlayer != null)
     {
         MusicPlayer.Worker.Abort();
         MusicPlayer = null;
     }
 }
Exemplo n.º 3
0
 protected override void Initialize()
 {
     ICON     = ICON ?? ContentsManager.GetTexture("musician_icon.png");
     Conveyor = new Conveyor()
     {
         Parent = ContentService.Graphics.SpriteScreen, Visible = false
     };
     xmlParser       = new XmlMusicSheetReader();
     displayedSheets = new List <SheetButton>();
     StopButton      = new HealthPoolButton()
     {
         Parent  = GameService.Graphics.SpriteScreen,
         Text    = "Stop Playback",
         ZIndex  = -1,
         Visible = false
     };
     StopButton.LeftMouseButtonReleased += delegate
     {
         this.StopPlayback();
     };
     GameService.GameIntegration.Gw2LostFocus += GameIntegrationOnGw2LostFocus;
 }
Exemplo n.º 4
0
        private Panel BuildLibraryPanel(WindowBase wndw)
        {
            var lPanel = new Panel()
            {
                CanScroll = false,
                Size      = wndw.ContentRegion.Size
            };
            var backButton = new BackButton(wndw)
            {
                Text     = "Musician",
                NavTitle = "Library",
                Parent   = lPanel,
                Location = new Point(20, 20),
            };
            var melodyPanel = new Panel()
            {
                Location  = new Point(Panel.LEFT_MARGIN + 20, Panel.BOTTOM_MARGIN + backButton.Bottom),
                Size      = new Point(lPanel.Size.X - 50 - Panel.LEFT_MARGIN, lPanel.Size.Y - 50 - Panel.BOTTOM_MARGIN),
                Parent    = lPanel,
                CanScroll = true
            };

            // Load local sheet music (*.xml) files.
            Task loader = Task.Run(() => Sheets = xmlParser.LoadDirectory(GameService.FileSrv.BasePath + @"\musician"));

            loader.Wait();

            // TODO: Load a list from online database.
            foreach (RawMusicSheet sheet in Sheets)
            {
                var melody = new SheetButton
                {
                    Parent = melodyPanel,
                    Icon   = GameService.Content.GetTexture(@"instruments\" + sheet.Instrument.ToLower()),
                    Artist = sheet.Artist,
                    Title  = sheet.Title,
                    // TODO: Use ApiService to get fixed, non-editable account name for User.
                    User       = sheet.User,
                    MusicSheet = sheet
                };
                displayedSheets.Add(melody);
                melody.LeftMouseButtonPressed += delegate
                {
                    if (melody.MouseOverPlay)
                    {
                        GameService.Director.BlishHudWindow.Hide();
                        MusicPlayer = MusicPlayerFactory.Create(
                            melody.MusicSheet,
                            KeyboardType.Practice
                            );
                        MusicPlayer.Worker.Start();
                    }
                    if (melody.MouseOverEmulate)
                    {
                        GameService.Director.BlishHudWindow.Hide();
                        MusicPlayer = MusicPlayerFactory.Create(
                            melody.MusicSheet,
                            KeyboardType.Emulated
                            );
                        MusicPlayer.Worker.Start();
                        StopButton = new HealthPoolButton()
                        {
                            Parent = GameService.Graphics.SpriteScreen,
                            Text   = "Stop Playback"
                        };
                        StopButton.LeftMouseButtonReleased += delegate
                        {
                            this.StopPlayback();
                        };
                    }
                    if (melody.MouseOverPreview)
                    {
                        if (melody.IsPreviewing)
                        {
                            this.StopPlayback();
                            melody.IsPreviewing = false;
                        }
                        else
                        {
                            foreach (SheetButton other in displayedSheets)
                            {
                                other.IsPreviewing = other == melody ? true : false;
                            }
                            if (MusicPlayer != null)
                            {
                                this.StopPlayback();
                            }
                            MusicPlayer = MusicPlayerFactory.Create(
                                melody.MusicSheet,
                                KeyboardType.Preview
                                );
                            MusicPlayer.Worker.Start();
                        }
                    }
                };
            }
            var ddSortMethod = new Dropdown()
            {
                Parent   = lPanel,
                Visible  = melodyPanel.Visible,
                Location = new Point(lPanel.Right - 150 - 10, 5),
                Width    = 150
            };

            ddSortMethod.Items.Add(DD_TITLE);
            ddSortMethod.Items.Add(DD_ARTIST);
            ddSortMethod.Items.Add(DD_USER);
            ddSortMethod.Items.Add("------------------");
            ddSortMethod.Items.Add(DD_HARP);
            ddSortMethod.Items.Add(DD_FLUTE);
            ddSortMethod.Items.Add(DD_LUTE);
            ddSortMethod.Items.Add(DD_HORN);
            ddSortMethod.Items.Add(DD_BASS);
            ddSortMethod.Items.Add(DD_BELL);
            ddSortMethod.Items.Add(DD_BELL2);
            ddSortMethod.ValueChanged += UpdateSort;
            ddSortMethod.SelectedItem  = DD_TITLE;

            UpdateSort(ddSortMethod, EventArgs.Empty);
            backButton.LeftMouseButtonReleased += (object sender, MouseEventArgs e) => { wndw.NavigateHome(); };

            return(lPanel);
        }