Esempio n. 1
0
 protected override void OnTick()
 {
     if (m_Sheet == null)
     {
         Stop();
     }
     else if (m_Mobile == null || m_Mobile.Backpack == null || m_Mobile.NetState == null || !m_Mobile.Alive)
     {
         Stop();
     }
     else if (!m_Mobile.Backpack.Items.Contains(m_Sheet) || (m_Mus > -1 && !m_Mobile.Backpack.Items.Contains(m_Sheet.m_Instrument)))
     {
         Stop();
     }
     else
     {
         MusicSheet.SheetPage sheet = m_Sheet.Pages[m_Page];
         uint tocheck = sheet.GetColumn(m_Column);
         foreach (uint val in m_Values)
         {
             if ((tocheck & val) != 0)
             {
                 string name = ((NoteFlag)val).ToString();
                 if (m_Mus > -1)
                 {
                     m_Mobile.PlaySound(m_Mus + ((int)Enum.Parse(typeof(Notes), name)));
                 }
             }
         }
         m_Column++;
         if (m_Column >= sheet.Count)
         {
             m_Page++;
             m_Column = 0;
         }
         if (m_Page >= m_Sheet.Pages.Count)
         {
             if (!m_Sheet.Repeat)
             {
                 m_Mobile.CloseGump(typeof(MusicComposer));
                 Stop();
                 m_Mobile.SendGump(new MusicComposer(m_Mobile, m_Sheet, 1));
             }
             else
             {
                 m_Page = 0;
             }
         }
     }
 }
Esempio n. 2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (sender == null || info == null)
            {
                return;
            }
            Mobile m = sender.Mobile;

            if (m == null || m.Backpack == null || m_MusicSheet == null || !m.Backpack.Items.Contains(m_MusicSheet))
            {
                return;
            }
            if (info.ButtonID == 0)
            {
                m.CloseGump(typeof(MusicComposer));
                return;
            }
            bool abort = false;

            if (m_MusicSheet.Instrument == null || !m.Backpack.Items.Contains(m_MusicSheet.Instrument))
            {
                m_MusicSheet.Instrument = null;
                abort = true;
                m.SendMessage("The instrument is not in your backpack!");
            }
            //save the state
            int cols = m_SheetPage.Count;
            int rows = 32;          //everything

            if (info.Switches != null)
            {
                for (int col = 0; col < cols; col++)
                {
                    uint rowcont = 0;
                    for (int row = 0; row < rows; row++)
                    {
                        if (info.IsSwitched(col * rows + row))
                        {
                            rowcont |= (uint)1 << row;
                        }
                        else
                        {
                            rowcont &= ~((uint)1 << row);
                        }
                    }
                    m_SheetPage.SetColumn(col, rowcont);
                }
            }
            rows = info.ButtonID;
            if (abort)
            {
                m.CloseGump(typeof(MusicComposer));
                return;
            }
            if (rows == 2 || rows == 4)
            {
                if (m_MusicSheet.Playing(m))
                {
                    m_MusicSheet.StopPlayback(m);
                }
                else
                {
                    m_MusicSheet.StartPlayback(m, (rows == 4 ? m_Page - 1 : 0));
                }
            }
            else if (rows == 3)
            {
                m_MusicSheet.Repeat = !m_MusicSheet.Repeat;
            }
            else if (rows == 5)
            {
                m_SheetPage.Reduce();
            }
            else if (rows == 6)
            {
                m_SheetPage.Enlarge();
            }
            else if (rows == 7)
            {
                if (m_MusicSheet.Pages.Count < 60)
                {
                    m_MusicSheet.Pages.Add(new MusicSheet.SheetPage(DefaultPageSize));
                }
            }
            else if (rows == 8)
            {
                if (m_MusicSheet.Pages.Count < 60)
                {
                    MusicSheet.SheetPage sheet = new MusicSheet.SheetPage(cols);
                    sheet.SetButtons(new List <uint>(m_SheetPage.GetButtons));
                    m_MusicSheet.Pages.Add(sheet);
                }
            }
            else if (rows == 9)
            {
                if (m_MusicSheet.Pages.Count > 1)
                {
                    m_MusicSheet.Pages.Remove(m_SheetPage);
                }
            }
            else if (rows >= 1000 && rows < 2000)
            {
                int note = -1;
                if (m_MusicSheet.Instrument is Harp)
                {
                    note = 0x497;
                }
                else if (m_MusicSheet.Instrument is LapHarp)
                {
                    note = 0x3CA;
                }
                m.PlaySound(note + rows - 1001);
            }
            else if (rows >= 3000 && rows < 4000)
            {
                if (rows > 3000 && (rows - 3000) <= m_MusicSheet.Pages.Count)
                {
                    m_Page = rows - 3000;
                }
            }
            else if (rows >= 4000 && rows < 5000)
            {
                m_MusicSheet.BeatPerMinute = rows - 4000;
            }
            else if (rows >= 5000 && rows < 6000)
            {
                m_MusicSheet.Guida = rows - 5000;
            }
            else if (rows >= 6000 && rows < 7000)
            {
                if (m_SheetPage.Count < 36)
                {
                    m_SheetPage.Insert(rows - 6000);
                }
            }
            else if (rows >= 7000)
            {
                if (m_SheetPage.Count > 1)
                {
                    m_SheetPage.Remove(rows - 7000);
                }
            }
            m.CloseGump(typeof(MusicComposer));
            m.SendGump(new MusicComposer(m, m_MusicSheet, m_Page));
        }
Esempio n. 3
0
        private void PreGump()
        {
            m_SheetPage = m_MusicSheet.Pages[m_Page - 1];
            AddPage(0);
            int multiuse = 25;
            int cols     = m_SheetPage.Count;

            AddBackground(0, 0, 472 + (12 * Math.Max(0, cols - DefaultPageSize)), 132 + 14 * multiuse, 9300);
            //row 1
            AddHtml(5, 4, 452, 18, m_MusicSheet.SongName, false, false);
            //salvataggio manuale
            AddButton(325, 6, 11410, 11412, 1, GumpButtonType.Reply, 0);
            AddHtml(343, 5, 123, 18, "Save Everything", false, false);
            //row 2
            AddButton(6, 28, 2224, 2224, 2, GumpButtonType.Reply, 0);
            AddHtml(26, 25, 53, 18, (m_MusicSheet.Playing(m_Mobile) ? "Stop" : "Start"), false, false);
            multiuse = (m_MusicSheet.Repeat ? 0 : 10);
            AddButton(79, 27, 11400 + multiuse, 11402 + multiuse, 3, GumpButtonType.Reply, 0);
            AddHtml(96, 25, 91, 18, "Repeat: " + (m_MusicSheet.Repeat ? "<BASEFONT COLOR=GREEN>ON</BASEFONT>" : "<BASEFONT COLOR=RED>OFF</BASEFONT>"), false, false);
            //page switching start
            AddButton(192, 26, 5002, 5002, 3000 + m_Page - 1, GumpButtonType.Reply, 0);
            AddLabel(196, 23, DefHue, "<");
            AddButton(330, 26, 5002, 5002, 3000 + m_Page + 1, GumpButtonType.Reply, 0);
            AddLabel(335, 23, DefHue, ">");
            //page swtiching end
            AddButton(361, 28, 2224, 2224, 4, GumpButtonType.Reply, 0);
            AddHtml(381, 25, 76, 18, (m_MusicSheet.Playing(m_Mobile) ? "Stop" : "Start from Here"), false, false);
            //row 3
            //BPM BEGIN
            multiuse = m_MusicSheet.BeatPerMinute;
            AddHtml(46, 47, 105, 18, "<CENTER>" + multiuse + " BPM</CENTER>", false, false);
            multiuse += 4000;
            AddButton(6, 48, 5002, 5002, multiuse - 10, GumpButtonType.Reply, 0);          //-10
            AddLabel(6, 46, DefHue, "<<");
            AddButton(26, 48, 5002, 5002, multiuse - 1, GumpButtonType.Reply, 0);          //-1
            AddLabel(30, 46, DefHue, "<");
            AddButton(154, 48, 5002, 5002, multiuse + 1, GumpButtonType.Reply, 0);         //+1
            AddLabel(159, 46, DefHue, ">");
            AddButton(174, 48, 5002, 5002, multiuse + 10, GumpButtonType.Reply, 0);        //+10
            AddLabel(175, 46, DefHue, ">>");
            //BPM END
            //PAGE SIZE
            AddButton(223, 48, 5002, 5002, 5, GumpButtonType.Reply, 0);            //-1
            AddLabel(227, 46, DefHue, "<");
            AddHtml(237, 47, 183, 18, "<CENTER>Page Size: " + cols + "</CENTER>", false, false);
            AddButton(416, 48, 5002, 5002, 6, GumpButtonType.Reply, 0);            //+1
            AddLabel(422, 46, DefHue, ">");
            //PAGE SIZE END
            //row 4
            AddButton(7, 71, 2362, 2361, 7, GumpButtonType.Reply, 0);
            AddHtml(20, 68, 87, 18, "New Page", false, false);
            AddButton(111, 71, 2362, 2361, 8, GumpButtonType.Reply, 0);
            AddHtml(124, 68, 87, 18, "Copy Page", false, false);
            AddButton(216, 71, 2362, 2361, 9, GumpButtonType.Reply, 0);
            AddHtml(229, 68, 87, 18, "Remove Page", false, false);
            //GUIDA
            multiuse = m_MusicSheet.Guida;
            AddButton(321, 69, 5002, 5002, 5000 + multiuse - 1, GumpButtonType.Reply, 0);        //-1
            AddLabel(326, 67, DefHue, "<");
            AddHtml(341, 68, 90, 18, "<CENTER>Guide: " + multiuse + "</CENTER>", false, false);
            AddButton(433, 69, 5002, 5002, 5000 + multiuse + 1, GumpButtonType.Reply, 0);        //+1
            AddLabel(439, 67, DefHue, @">");
            //GUIDA
            EvalGump(m_Page);
        }