Beispiel #1
0
 private void stopRecordingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Recorder != null)
     {
         RecordGame.Save(Recorder);
     }
 }
Beispiel #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (r != null)
     {
         r = RecordGame.Load(r.File);
         SetForm();
     }
 }
Beispiel #3
0
        public static void Save(RecordGame g)
        {
            var serializer = new BinaryFormatter();

            using (Stream s = new FileStream(g.File, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                serializer.Serialize(s, g);
                s.Close();
            }
        }
Beispiel #4
0
        public static RecordGame Load(string pPath)
        {
            var serializer = new BinaryFormatter();

            using (Stream s = new FileStream(pPath, FileMode.Open, FileAccess.Read, FileShare.None))
            {
                RecordGame r = (RecordGame)serializer.Deserialize(s);
                s.Close();
                return(r);
            }
        }
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Filter = "rec files (*.rec)|*.rec";
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             r = RecordGame.Load(ofd.FileName);
             SetForm();
         }
     }
 }
Beispiel #6
0
        //save code
        private void button2_Click(object sender, EventArgs e)
        {
            r.PlayerInput =
                textBox1.Lines.Select(l =>

                                      new RecordGame.Input(
                                          Convert.ToInt32(l.Substring(0, l.IndexOf(",", 0)))
                                          , l.Substring(l.IndexOf(",", 0) + 1).Trim()
                                          )

                                      ).ToList();

            RecordGame.Save(r);
            SetForm();
        }
Beispiel #7
0
        private void BeginPlayback(string pPath)
        {
            if (Recorder != null)
            {
                Recorder.eKeystroke     -= Recorder_eKeystroke;
                Recorder.ReplayFinished -= Recorder_ReplayFinished;
            }

            Recorder = RecordGame.Load(pPath);

            Recorder.eKeystroke      += Recorder_eKeystroke;
            Recorder.ReplayFinished  += Recorder_ReplayFinished;
            Recorder.eCarriageReturn += Recorder_eCarriageReturn;
            Advent.RestoreGame(Recorder.Data);
            Recorder.StartReplay();
        }
Beispiel #8
0
        private void recordGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var r = sender as ToolStripMenuItem;

            if (r.Checked)
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter = "rec files (*.rec)|*.rec";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        BeginRecording(sfd.FileName);
                    }
                    else
                    {
                        Recorder  = null;
                        r.Checked = false;
                    }
                }
            }
        }
Beispiel #9
0
 private void BeginRecording(string pPath)
 {
     Recorder = new RecordGame(Advent.GameData, pPath);
 }