Exemplo n.º 1
0
        internal TrackEditor()
        {
            int w = 300 - 12 - 6, h = 400 - 24;
            listView = new ObjectListView
            {
                FullRowSelect = true,
                HeaderStyle = ColumnHeaderStyle.Nonclickable,
                HideSelection = false,
                Location = new Point(12, 12),
                MultiSelect = false,
                RowFormatter = RowFormatter,
                ShowGroups = false,
                Size = new Size(w, h),
                UseFiltering = true,
                UseFilterIndicator = true
            };
            OLVColumn c1, c2, c3, c4;
            c1 = new OLVColumn("Event", "Command.Name");
            c2 = new OLVColumn("Arguments", "Command.Arguments") { UseFiltering = false };
            c3 = new OLVColumn("Offset", "Offset") { AspectToStringFormat = "0x{0:X}", UseFiltering = false };
            c4 = new OLVColumn("Ticks", "AbsoluteTicks") { UseFiltering = false };
            c1.Width = c2.Width = c3.Width = 72;
            c4.Width = 45;
            c1.Hideable = c2.Hideable = c3.Hideable = c4.Hideable = false;
            c1.TextAlign = c2.TextAlign = c3.TextAlign = c4.TextAlign = HorizontalAlignment.Center;
            listView.AllColumns.AddRange(new OLVColumn[] { c1, c2, c3, c4 });
            listView.RebuildColumns();
            listView.SelectedIndexChanged += SelectedIndexChanged;
            listView.ItemActivate += ListView_ItemActivate;

            int h2 = h / 3 - 4;
            var panel1 = new ThemedPanel { Location = new Point(306, 12), Size = new Size(w, h2) };
            var panel2 = new ThemedPanel { Location = new Point(306, 140), Size = new Size(w, h2 - 1) };
            var panel3 = new ThemedPanel { Location = new Point(306, 267), Size = new Size(w, h2) };

            // Arguments Info
            for (int i = 0; i < 3; i++)
            {
                int y = 17 + (33 * i);
                argLabels[i] = new ThemedLabel
                {
                    AutoSize = true,
                    Location = new Point(52, y + 3),
                    Text = "Arg. " + (i + 1).ToString(),
                    Visible = false,
                };
                argNumerics[i] = new ThemedNumeric
                {
                    Location = new Point(w - 152, y),
                    Maximum = int.MaxValue,
                    Minimum = int.MinValue,
                    Size = new Size(100, 25),
                    Visible = false
                };
                argNumerics[i].ValueChanged += ArgumentChanged;
                panel1.Controls.AddRange(new Control[] { argLabels[i], argNumerics[i] });
            }

            // Track controls
            tracksBox = new ComboBox
            {
                Location = new Point(4, 4),
                Size = new Size(100, 21)
            };
            tracksBox.SelectedIndexChanged += TracksBox_SelectedIndexChanged;
            trackChangeVoicesButton = new ThemedButton
            {
                Location = new Point(13, 30),
                Text = "Change Voices"
            };
            trackChangeVoicesButton.Click += ChangeEvents;
            trackAddEventButton = new ThemedButton
            {
                Location = new Point(13, 30 + 25 + 5),
                Text = "Add Event"
            };
            trackAddEventButton.Click += AddEvent;
            commandsBox = new ComboBox
            {
                Location = new Point(115, 30 + 25 + 5 + 2),
                Size = new Size(100, 21)
            };
            trackRemoveEventButton = new ThemedButton
            {
                Location = new Point(13, 30 + 25 + 5 + 25 + 5),
                Text = "Remove Event"
            };
            treButton.Click += RemoveEvent;
            tracksBox.Enabled = tvButton.Enabled = taeButton.Enabled = treButton.Enabled = commandsBox.Enabled = false;
            tvButton.Size = taeButton.Size = treButton.Size = new Size(95, 25);
            var tvFrom = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            tvArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var tvTo = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            tvArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            tvArgs[0].Maximum = tvArgs[1].Maximum = 0xFF;
            tvArgs[0].Size = tvArgs[1].Size = new Size(45, 23);
            tvArgs[0].TextAlign = tvArgs[1].TextAlign = HorizontalAlignment.Center;
            tvFrom.AutoSize = tvTo.AutoSize = true;
            panel2.Controls.AddRange(new Control[] { tracksBox, tvButton, tvFrom, tvTo, tvArgs[0], tvArgs[1], taeButton, commandsBox, treButton });
            removeEventButton.Click += RemoveEvent;

            //Track controls box preparation
            tracksBox.Enabled = changeVoicesButton.Enabled = addEventButton.Enabled = removeEventButton.Enabled = commandsBox.Enabled = false;
            changeVoicesButton.Size = addEventButton.Size = removeEventButton.Size = new Size(95, 25);
            var originalVoiceLabel = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            trackVoiceDetails[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            trackVoiceDetails[0].Enabled = false;
            var newVoiceIDLabel = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            trackVoiceDetails[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            trackVoiceDetails[0].Maximum = trackVoiceDetails[1].Maximum = 0xFF;
            trackVoiceDetails[0].Size = trackVoiceDetails[1].Size = new Size(45, 23);
            trackVoiceDetails[0].TextAlign = trackVoiceDetails[1].TextAlign = HorizontalAlignment.Center;
            originalVoiceLabel.AutoSize = newVoiceIDLabel.AutoSize = true;
            trackEditPanel.Controls.AddRange(new Control[] { tracksBox, changeVoicesButton, originalVoiceLabel, newVoiceIDLabel, trackVoiceDetails[0], trackVoiceDetails[1], addEventButton, commandsBox, removeEventButton });

            trackRemoveEventButton.Click += RemoveEvent;
            tracksBox.Enabled = trackChangeVoicesButton.Enabled = trackAddEventButton.Enabled = trackRemoveEventButton.Enabled = commandsBox.Enabled = false;
            trackChangeVoicesButton.Size = trackAddEventButton.Size = trackRemoveEventButton.Size = new Size(95, 25);
            var trackFromVoiceButton = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            trackVoiceArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var trackToVoiceButton = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            trackVoiceArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            trackVoiceArgs[0].Maximum = trackVoiceArgs[1].Maximum = 0xFF;
            trackVoiceArgs[0].Size = trackVoiceArgs[1].Size = new Size(45, 23);
            trackVoiceArgs[0].TextAlign = trackVoiceArgs[1].TextAlign = HorizontalAlignment.Center;
            trackFromVoiceButton.AutoSize = trackToVoiceButton.AutoSize = true;
            panel2.Controls.AddRange(new Control[] { tracksBox, trackChangeVoicesButton, trackFromVoiceButton, trackToVoiceButton, trackVoiceArgs[0], trackVoiceArgs[1], trackAddEventButton, commandsBox, trackRemoveEventButton });

            // Global controls
            remapsBox = new ComboBox
            {
                DataSource = Config.InstrumentRemaps.Keys.ToArray(),
                Location = new Point(4, 4),
                Size = new Size(100, 21)
            };
            remapFromButton = new ThemedButton
            {
                Location = new Point(116, 3),
                Text = "From"
            };
            remapFromButton.Click += (s, e) => ApplyRemap(true);
            remapToButton = new ThemedButton
            {
                Location = new Point(203, 3),
                Text = "To"
            };
            remapToButton.Click += (s, e) => ApplyRemap(false);
            globalChangeVoicesButton = new ThemedButton
            {
                Location = new Point(13, 30),
                Size = new Size(95, 25),
                Text = "Change Voices"
            };
            globalChangeVoicesButton.Click += ChangeAllEvents;
            var globalFromVoiceButton = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            globalVoiceArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var globalToVoiceButton = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            globalVoiceArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            globalVoiceArgs[0].Maximum = globalVoiceArgs[1].Maximum = 0xFF;
            globalVoiceArgs[0].Size = globalVoiceArgs[1].Size = new Size(45, 23);
            globalVoiceArgs[0].TextAlign = globalVoiceArgs[1].TextAlign = HorizontalAlignment.Center;
            globalFromVoiceButton.AutoSize = globalToVoiceButton.AutoSize = true;
            remapsBox.Enabled = remapFromButton.Enabled = remapToButton.Enabled = globalChangeVoicesButton.Enabled = false;
            panel3.Controls.AddRange(new Control[] { remapsBox, remapFromButton, remapToButton, globalChangeVoicesButton, globalFromVoiceButton, globalToVoiceButton, globalVoiceArgs[0], globalVoiceArgs[1] });

            ClientSize = new Size(600, 400);
            Controls.AddRange(new Control[] { listView, panel1, panel2, panel3 });
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox = false;
            Text = "GBA Music Studio ― Track Editor";

            UpdateTracks();
        }
Exemplo n.º 2
0
        public MainForm()
        {
            components = new Container();

            // Main Menu
            openROMToolStripMenuItem = new ToolStripMenuItem {
                Text = "Apri ROM", ShortcutKeys = Keys.Control | Keys.O
            };
            openROMToolStripMenuItem.Click += OpenROM;

            openMIDIToolStripMenuItem = new ToolStripMenuItem {
                Text = "Apri File MIDI", Enabled = false, ShortcutKeys = Keys.Control | Keys.M
            };
            openMIDIToolStripMenuItem.Click += OpenMIDIConverter;

            openASMToolStripMenuItem = new ToolStripMenuItem {
                Text = "Apri File ASM", Enabled = false, ShortcutKeys = Keys.Control | Keys.Shift | Keys.M
            };
            openASMToolStripMenuItem.Click += OpenAssembler;

            configToolStripMenuItem = new ToolStripMenuItem {
                Text = "Ricarica Config", ShortcutKeys = Keys.Control | Keys.R
            };
            configToolStripMenuItem.Click += ReloadConfig;

            fileToolStripMenuItem = new ToolStripMenuItem {
                Text = "File"
            };
            fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openROMToolStripMenuItem, openMIDIToolStripMenuItem, openASMToolStripMenuItem, configToolStripMenuItem });


            teToolStripMenuItem = new ToolStripMenuItem {
                Text = "Editor Traccia", Enabled = false, ShortcutKeys = Keys.Control | Keys.T
            };
            teToolStripMenuItem.Click += OpenTrackEditor;

            vteToolStripMenuItem = new ToolStripMenuItem {
                Text = "Editor VoiceTable", Enabled = false, ShortcutKeys = Keys.Control | Keys.V
            };
            vteToolStripMenuItem.Click += OpenVoiceTableEditor;

            eSf2ToolStripMenuItem = new ToolStripMenuItem {
                Text = "Esporta Voicetable In SF2", Enabled = false
            };
            eSf2ToolStripMenuItem.Click += ExportSF2;

            eASMToolStripMenuItem = new ToolStripMenuItem {
                Text = "Esporta Canzone In ASM", Enabled = false
            };
            eASMToolStripMenuItem.Click += ExportASM;

            eMIDIToolStripMenuItem = new ToolStripMenuItem {
                Text = "Esporta Canzone In MIDI", Enabled = false
            };
            eMIDIToolStripMenuItem.Click += ExportMIDI;

            dataToolStripMenuItem = new ToolStripMenuItem {
                Text = "Data"
            };
            dataToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { teToolStripMenuItem, vteToolStripMenuItem, eSf2ToolStripMenuItem, eASMToolStripMenuItem, eMIDIToolStripMenuItem });


            mainMenu = new MenuStrip {
                Size = new Size(iWidth, 24)
            };
            mainMenu.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, dataToolStripMenuItem });

            // Buttons
            playButton = new ThemedButton {
                ForeColor = Color.MediumSpringGreen, Location = new Point(5, 3), Text = "Play"
            };
            playButton.Click += Play;
            pauseButton       = new ThemedButton {
                ForeColor = Color.DeepSkyBlue, Location = new Point(85, 3), Text = "Pausa"
            };
            pauseButton.Click += Pause;
            stopButton         = new ThemedButton {
                ForeColor = Color.MediumVioletRed, Location = new Point(166, 3), Text = "Stop"
            };
            stopButton.Click += Stop;

            playButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
            playButton.Size    = stopButton.Size = new Size(75, 23);
            pauseButton.Size   = new Size(76, 23);

            // Numericals
            songNumerical = new ThemedNumeric {
                Enabled = false, Location = new Point(246, 4)
            };
            tableNumerical = new ThemedNumeric {
                Location = new Point(246, 35), Maximum = 0, Visible = false
            };

            songNumerical.Size           = tableNumerical.Size = new Size(45, 23);
            songNumerical.ValueChanged  += LoadSong;
            tableNumerical.ValueChanged += TableIndexChanged;

            // Labels
            creatorLabel = new ThemedLabel {
                Location = new Point(3, 43), Size = new Size(72, 13)
            };
            gameLabel = new ThemedLabel {
                Location = new Point(3, 30), Size = new Size(66, 13)
            };
            codeLabel = new ThemedLabel {
                Location = new Point(3, 56), Size = new Size(63, 13)
            };

            creatorLabel.AutoSize  = gameLabel.AutoSize = codeLabel.AutoSize = true;
            creatorLabel.TextAlign = gameLabel.TextAlign = codeLabel.TextAlign = ContentAlignment.MiddleCenter;

            // Timer
            timer       = new Timer(components);
            timer.Tick += UpdateUI;

            // Piano
            piano = new PianoControl {
                Anchor = AnchorStyles.Bottom, Location = new Point(0, 125 - 50 - 1), Size = new Size(iWidth, 50)
            };

            // Volume bar & Position bar
            int sWidth = (int)(iWidth / sfWidth);
            int sX     = iWidth - sWidth - 4;

            positionBar = new ColorSlider()
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                Enabled  = false,
                Location = new Point(sX, 45),
                Maximum  = 0,
                Size     = new Size(sWidth, 27)
            };
            positionBar.MouseUp   += SetPosition;
            positionBar.MouseDown += (o, e) => drag = true;
            volumeBar              = new ColorSlider()
            {
                LargeChange = 20,
                Location    = new Point(83, 45),
                Maximum     = 100,
                Size        = new Size(155, 27),
                SmallChange = 5
            };
            volumeBar.ValueChanged += (o, e) => SoundMixer.Instance.MasterVolume = (volumeBar.Value / (float)volumeBar.Maximum);
            volumeBar.Value         = Config.Instance.Volume; // Update MusicPlayer volume

            // Playlist box
            ImageList il = new ImageList(components)
            {
                ColorDepth       = ColorDepth.Depth16Bit,
                ImageSize        = new Size(64, 64),
                TransparentColor = Color.Transparent
            };

            il.Images.AddRange(new Image[] { Resources.PlaylistIcon, Resources.SongIcon });
            songsComboBox = new ImageComboBox.ImageComboBox()
            {
                Anchor    = AnchorStyles.Top | AnchorStyles.Right,
                Enabled   = false,
                ImageList = il,
                Indent    = 15,
                Location  = new Point(sX, 4),
                Size      = new Size(sWidth, 23)
            };
            songsComboBox.SelectedIndexChanged += SongsComboBox_SelectedIndexChanged;

            // Track info
            trackInfo = new TrackInfoControl()
            {
                Dock = DockStyle.Fill,
                Size = new Size(iWidth, 690)
            };

            // Split container
            splitContainer = new SplitContainer()
            {
                BackColor        = Theme.TitleBar,
                Dock             = DockStyle.Fill,
                FixedPanel       = FixedPanel.Panel1,
                IsSplitterFixed  = true,
                Orientation      = Orientation.Horizontal,
                Size             = new Size(iWidth, iHeight),
                SplitterDistance = 125,
                SplitterWidth    = 1
            };
            splitContainer.Panel1.Controls.AddRange(new Control[] { playButton, creatorLabel, gameLabel, codeLabel, pauseButton, stopButton, songNumerical, tableNumerical, songsComboBox, piano, positionBar, volumeBar });
            splitContainer.Panel2.Controls.Add(trackInfo);

            // MainForm
            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode       = AutoScaleMode.Font;
            ClientSize          = new Size(iWidth, iHeight);
            Controls.AddRange(new Control[] { splitContainer, mainMenu });
            Icon          = Resources.Icon;
            MainMenuStrip = mainMenu;
            MinimumSize   = new Size(8 + iWidth + 8, 30 + iHeight + 8); // Borders
            SongPlayer.Instance.SongEnded += () => stopUI = true;
            Resize += OnResize;
            Text    = "GBA Music Studio";
        }