Beispiel #1
0
        private void vdxChooser_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (game == GameID.T7G)
            {
                if (vdx != null)
                    vdx.stop();

                string file = vdxChooser.SelectedItem.ToString();

                GJD.RLData rl;
                System.IO.BinaryReader reader = gjd.getVDX(file, out rl);
                if (reader != null)
                {
                    if (midi != null)
                        midi.Close();
                    if (!gjd.Name.Contains("xmi"))
                        vdx = new VDX(reader, rl, s);
                    else
                    {
                        if (!System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            System.Diagnostics.Process p = new System.Diagnostics.Process();
                            p.StartInfo.FileName = path + "mid\\xmi2mid.exe";
                            p.StartInfo.Arguments = path + "mid\\" + file.Substring(0, file.IndexOf(".") + 4) + " " + path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid";
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.WorkingDirectory = path + "mid\\";
                            System.Threading.Thread.Sleep(500);
                            p.Start();
                            p.WaitForExit();
                            System.Console.WriteLine("Missing midi");
                        }
                        if (System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            midi = new SdlDotNet.Audio.Music(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid");
                            midi.Play(1);
                        }

                    }

                    modEnviron();

                    textBox1.Text = ((Array.IndexOf(gjd.filemap, gjd.Name) << 10) + rl.number).ToString();
                }
            }
            else
            {
                frameSeek.Enabled = false;
                // 11H
                if (gjdChooser.SelectedItem.ToString() == "Icons")
                {
                    Cursors_v2 cur = ((Cursors_v2)(this.gjdChooser.Tag));
                    frameSeek.Maximum = cur.cursors[vdxChooser.SelectedIndex == 4 ? 3 : vdxChooser.SelectedIndex].frames - 1;
                    frameSeek.Value = 0;
                    Cursors_v2.decodeCursor((byte)vdxChooser.SelectedIndex, 0, ref cur, ref s);
                    frameSeek.Enabled = true;
                }
                else
                {
                    // ROQ parser
                    if (roq != null)
                        roq.stop();
                    roq = null;

                    GJD.RLData rl = new GJD.RLData();

                    foreach (GJD.RLData subrl in V2_RL[gjdChooser.SelectedIndex])
                    {
                        if (subrl.filename == vdxChooser.SelectedItem.ToString())
                        {
                            rl = subrl;
                            break;
                        }
                    }
                    System.IO.BinaryReader r = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\media\\" + gjdChooser.SelectedItem, System.IO.FileMode.Open,  System.IO.FileAccess.Read, System.IO.FileShare.Read));
                    r.BaseStream.Seek(rl.offset, System.IO.SeekOrigin.Begin);

                    System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.MemoryStream(r.ReadBytes((int)rl.length)));
                    if (rl.filename.Contains("xmi"))
                    {
                        roq = null;
                        string file = rl.filename;
                        if (file.Contains("\0"))
                            file = file.Substring(0, file.IndexOf("\0"));

                        if (!System.IO.File.Exists(path + "mid\\" + file))
                        {
                            byte[] buffer = new byte[reader.BaseStream.Length];
                            reader.Read(buffer, 0, buffer.Length);
                            System.IO.File.WriteAllBytes(path + "mid\\" + file, buffer);
                        }

                        if (!System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            System.Diagnostics.Process p = new System.Diagnostics.Process();
                            p.StartInfo.FileName = path + "mid\\xmi2mid.exe";
                            p.StartInfo.Arguments = path + "mid\\" + file.Substring(0, file.IndexOf(".") + 4) + " " + path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid";
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.WorkingDirectory = path + "mid\\";
                           // System.Threading.Thread.Sleep(500);
                           // p.Start();
                           // p.WaitForExit();
                            System.Console.WriteLine("Missing midi");
                        }
                        if (System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            midi = new SdlDotNet.Audio.Music(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid");
                            midi.Play(1);
                        }
                    }
                    else
                    {
                        roq = new ROQ(reader, s);
                    }
                    r.Close();
                    r = null;
                    modEnviron();

                    textBox1.Text = (rl.number).ToString();
                }
            }
        }
Beispiel #2
0
        private void readGameData()
        {
            textBox2.Text = path;
            if (roq != null)
                roq.stop();
            roq = null;
            if (vdx != null)
                vdx.stop();
            vdx = null;
            switch (game)
            {
                case GameID.T7G:
                    lblGame.Text = "The 7th Guest";

                    System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo(path);
                    System.IO.FileInfo[] files = DI.GetFiles("*.rl");
                    this.gjdChooser.Items.Clear();

                    foreach (System.IO.FileInfo rl in files)
                    {
                        this.gjdChooser.Items.Add(rl.Name);
                    }

                    break;
                case GameID.T11H:
                    lblGame.Text = "The 11th Hour";
                    //ROQ roq = new ROQ(new System.IO.BinaryReader(new System.IO.FileStream(path + "\\media\\final_hr.rol", System.IO.FileMode.Open)));

                    this.gjdChooser.Items.Clear();
                    System.IO.BinaryReader idx = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\groovie\\gjd.gjd", System.IO.FileMode.Open));
                    string name = "";
                    while (idx.BaseStream.Position < idx.BaseStream.Length)
                    {
                        if (idx.PeekChar() == 0x0A)
                        {
                            idx.ReadChar();
                            if (name.Length > 0)
                                this.gjdChooser.Items.Add(name.Substring(0, name.IndexOf(" ")));

                            name = "";
                        }
                        else
                            name += "" + idx.ReadChar();
                    }
                    idx.Close();
                    V2_RL = new List<GJD.RLData>[this.gjdChooser.Items.Count];
                    for (int i = 0; i < V2_RL.Length; i++)
                        V2_RL[i] = new List<GJD.RLData>();

                    this.gjdChooser.Items.Add("Icons");

                    idx = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\groovie\\dir.rl", System.IO.FileMode.Open));
                    uint ctr = 0;
                    while (idx.BaseStream.Position < idx.BaseStream.Length)
                    {
                        // Get RL content
                        GJD.RLData rl = new GJD.RLData();
                        idx.ReadUInt32();
                        rl.offset = idx.ReadUInt32();
                        rl.length = idx.ReadUInt32();
                        rl.number = ctr;
                        ctr++;
                        ushort target = idx.ReadUInt16();
                        byte[] filename;
                        filename = idx.ReadBytes(12);
                        rl.filename = System.Text.Encoding.ASCII.GetString(filename).Trim();
                        idx.ReadBytes(6);
                        V2_RL[target].Add(rl);
                    }

                    break;
                default:
                    lblGame.Text = "None";
                    break;
            }
        }