Пример #1
0
        public void Start(TFXFile tfx, byte[] sampledata, int subsong)
        {
            if (!File.Exists(playerPath))
            {
                throw new Exception($"tfmx player '{playerPath}' not found");
            }

            if (started)
            {
                throw new Exception("already started");
            }
            started = true;

            var tmp     = Path.GetTempFileName();
            var tfxpath = Path.ChangeExtension(tmp, ".tfx");
            var sampath = Path.ChangeExtension(tmp, ".sam");

            tfx.Save(tfxpath);
            File.WriteAllBytes(sampath, sampledata);
            var sui = new ProcessStartInfo
            {
                FileName    = playerPath,
                Arguments   = (subsong != 0 ? "-p " + subsong : "") + " -b 1 " + tfxpath,
                WindowStyle = ProcessWindowStyle.Minimized
            };

            process = Process.Start(sui);
        }
Пример #2
0
        void UpdateTrackstepView(TFXFile tfx)
        {
            var listview = listViewTrackstep;

            listview.BeginUpdate();
            for (int i = 0; i < tfx.NumTracksteps; ++i)
            {
                var item = new ListViewItem(i.ToString());

                if (tfx.Tracksteps[i][0] == 0xEFFE)
                {
                    item.BackColor = Color.Azure;
                }

                for (int j = 0; j < 8; ++j)
                {
                    int v = tfx.Tracksteps[i][j];
                    item.SubItems.Add((v >> 8).ToString("X2") + "  " + (v & 0xFF).ToString("X2"));
                }
                if (i < listview.Items.Count)
                {
                    listview.Items[i] = item;
                }
                else
                {
                    listview.Items.Add(item);
                }
            }
            while (listview.Items.Count > tfx.NumTracksteps)
            {
                listview.Items.RemoveAt(listview.Items.Count - 1);
            }
            listview.EndUpdate();
        }
Пример #3
0
        void Open(string path)
        {
            this.path = path;
            Text      = "TFMX Editor (experimental) - " + Path.GetFileName(path);

            sampledata = File.ReadAllBytes(Path.ChangeExtension(path, ".sam"));

            tfx = new TFXFile(path);

            /*txfm = new TFMXFile(@"..\..\assets\WORLD1.TFX");
            *  txfm = new TFMXFile(@"..\..\assets\WORLD2.TFX");
            *  txfm = new TFMXFile(@"..\..\assets\WORLD3.TFX");
            *  txfm = new TFMXFile(@"..\..\assets\WORLD4.TFX");
            *  txfm = new TFMXFile(@"..\..\assets\WORLD5.TFX");*/
            UpdateTrackstepView(tfx);
            UpdateSongView(tfx);

            numericUpDownPattern.Maximum = tfx.Patterns.Count - 1;
            numericUpDownMacro.Maximum   = tfx.Macros.Count - 1;

            UpdatePatternView(tfx.Patterns[(int)numericUpDownPattern.Value]);
            UpdateMacroView(tfx.Macros[(int)numericUpDownMacro.Value]);

            textBoxMessage.Lines = new string[] { tfx.TextLines[0].TrimEnd(), tfx.TextLines[1].TrimEnd(), tfx.TextLines[2].TrimEnd(), tfx.TextLines[3].TrimEnd() };

            comboBoxPreviewNote.Items.Clear();
            for (int i = 0; i < 64; ++i)
            {
                comboBoxPreviewNote.Items.Add(Note.Format(i));
            }
            comboBoxPreviewNote.SelectedIndex = 42;

            var namesFile = Path.ChangeExtension(path, ".txt");

            if (File.Exists(namesFile))
            {
                using (var f = new StreamReader(namesFile))
                {
                    while (f.EndOfStream)
                    {
                        var ss = f.ReadLine().Split(' ');
                        switch (ss[0])
                        {
                        case "pattern":
                            tfx.Patterns[int.Parse(ss[1])].Name = ss[2];
                            break;

                        case "macro":
                            tfx.Macros[int.Parse(ss[1])].Name = ss[2];
                            break;
                        }
                    }
                }
            }
        }
Пример #4
0
 void UpdateSongView(TFXFile tfx)
 {
     listViewSongs.BeginUpdate();
     listViewSongs.Items.Clear();
     for (int i = 0; i < 32; ++i)
     {
         var item = new ListViewItem(i.ToString());
         item.SubItems.Add(tfx.SongStartPositions[i].ToString());
         item.SubItems.Add(tfx.SongEndPositions[i].ToString());
         item.SubItems.Add(tfx.TempoNumbers[i].ToString());
         listViewSongs.Items.Add(item);
     }
     listViewSongs.EndUpdate();
 }
Пример #5
0
        private void MusicTest_Load(object sender, EventArgs e)
        {
            actx = new AudioContext();

            tfx = new TFXFile();
            var m = new TFXMacro {
                Steps = new List <TFXMacroCommand>()
            };

            m.Steps.Add(new TFXMacroCommand(0x07000000));
            tfx.Macros.Add(m);
            var p = new TFXPattern {
                Steps = new List <TFXPatternCommand>()
            };

            p.Steps.Add(new TFXPatternCommand(0xF0000000));
            tfx.Patterns.Add(p);

            UpdateTrackstepView(tfx);
            UpdateSongView(tfx);
            numericUpDownPattern.Maximum = tfx.Patterns.Count - 1;
            numericUpDownMacro.Maximum   = tfx.Macros.Count - 1;
            UpdateMacroView(tfx.Macros[(int)numericUpDownMacro.Value]);
            UpdatePatternView(tfx.Patterns[(int)numericUpDownPattern.Value]);
            textBoxMessage.Lines = new string[] { tfx.TextLines[0].TrimEnd(), tfx.TextLines[1].TrimEnd(), tfx.TextLines[2].TrimEnd(), tfx.TextLines[3].TrimEnd() };
            comboBoxPreviewNote.Items.Clear();
            for (int i = 0; i < 64; ++i)
            {
                comboBoxPreviewNote.Items.Add(Note.Format(i));
            }
            comboBoxPreviewNote.SelectedIndex = 42;
            sampledata = new byte[1];


            var def = @"..\..\..\game\unpacked\WORLD1.TFX";

            //def = "last.tfx";
            if (File.Exists(def))
            {
                Open(def);
            }

            var animationTimer = new Timer {
                Interval = 1000 / 60
            };

            animationTimer.Tick += AnimationTimer_Tick;
            animationTimer.Start();
        }
Пример #6
0
        public PlayerForm(string name, byte[] tfmxData, byte[] samData)
        {
            InitializeComponent();

            Text = "TFMX Player / " + name;

            audio      = new AudioContext();
            tfx        = new TFXFile(tfmxData);
            sampleData = samData;

            updateSongList();
            if (songList.Items.Count > 0)
            {
                songList.Focus();
                songList.Items[0].Selected = true;
            }

            var animationTimer = new Timer {
                Interval = 1000 / 60
            };

            animationTimer.Tick += AnimationTimer_Tick;
            animationTimer.Start();
        }