Beispiel #1
0
        private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
                // Load VDX
                //System.Console.WriteLine("Load VDX");
                ushort offset;
                try
                {
                    offset = System.Convert.ToUInt16(textBox1.Text);
                }
                catch { textBox1.Text = "";  return; }

                ushort gjdIndex = (ushort)(offset >> 10);
                ushort file = (ushort)(offset & 0x3FF);
                GJD.RLData rl;
                gjd = new GJD(gjdIndex);
                System.IO.BinaryReader reader = gjd.getVDX(file, out rl);
                if (reader != null)
                {
                    gjdChooser.SelectedItem = gjd.Name.ToUpper() + ".RL";
                    gjdChooser_SelectedIndexChanged(null,null);
                    if (!gjd.Name.ToLower().Contains("xmi"))
                    {
                        vdx = new VDX(gjd.getVDX(file, out rl), rl, s);
                        modEnviron();
                        vdxChooser.SelectedItem = rl.filename;
                    }
                    else
                    {
                        gjd.getVDX(file, out rl);
                        vdx = null;
                        modEnviron();
                        vdxChooser.SelectedItem = rl.filename;
                    }

                }

            }
            else if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
            {
            }
            else if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9 || e.Modifiers != 0)
            {
                e.SuppressKeyPress = true;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Parse the VDX to locate individual chunks
        /// </summary>
        private void parseVDX(GJD.RLData? rlData)
        {
            long stop;
            // Final stream position
            if (rlData.HasValue)
            {
                stop = rlData.Value.offset + rlData.Value.length;
            }
            else
            {
                stop = file.BaseStream.Length;
            }
            VDXHeader header = new VDXHeader();
            VDXChunkHeader chunk = new VDXChunkHeader();

            // Initialise queue's
            audioOffsets = new Queue<long>();
            videoOffsets = new Queue<long>();

            // Read VDX header
            header.ID = file.ReadUInt16();
            if (header.ID != 0x9267)
                throw new Exception("Invalid VDX header");

            header.Unknown1 = file.ReadByte();
            header.Unknown2 = file.ReadByte();
            header.Unknown3 = file.ReadByte();
            header.Unknown4 = file.ReadByte();
            header.FPS = file.ReadUInt16();

            //fps = (byte)header.FPS;
            try
            {
                while (file.BaseStream.Position < stop)
                {
                    // Read VDX chunk header
                    chunk = readChunkHeader();

                    // Add offsets where appropriate
                    switch (chunk.BlockType)
                    {
                        case VDXBlockType.Video:
                            videoFrames++;
                            goto case VDXBlockType.Zero;
                        case VDXBlockType.Zero:
                            videoMaster.Enqueue(file.BaseStream.Position - VDXChunkHeader.size);
                            break;
                        case VDXBlockType.Sound:
                            audioOffsets.Enqueue(file.BaseStream.Position - VDXChunkHeader.size);
                            break;
                        case VDXBlockType.Image:
                            imageOffset = file.BaseStream.Position - VDXChunkHeader.size;
                            break;
                    }

                    // Seek to next chunk
                    file.BaseStream.Seek(chunk.DataSize, System.IO.SeekOrigin.Current);
                }
            } catch {
                audio = null;
                videoFrames = 1;

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

                vdx = null;

                gjd = new GJD(this.gjdChooser.SelectedItem.ToString());
                System.Collections.Generic.Dictionary<ushort, GJD.RLData> rlMap = gjd.rlMap;
                this.vdxChooser.Items.Clear();
                foreach (GJD.RLData rl in rlMap.Values)
                {
                    this.vdxChooser.Items.Add(rl.filename);
                }
            }
            else
            {
                if (this.gjdChooser.SelectedItem.ToString() == "Icons")
                {
                    if (this.gjdChooser.Tag == null)
                        this.gjdChooser.Tag = new Cursors_v2(path);

                    Cursors_v2 cursor = (Cursors_v2)this.gjdChooser.Tag;

                    this.vdxChooser.Items.Clear();
                    for (int i = 0; i < cursor.numCursors; i++)
                        this.vdxChooser.Items.Add(i);
                }
                else
                {
                    // V2 GJD
                    this.vdxChooser.Items.Clear();
                    foreach (GJD.RLData rl in V2_RL[this.gjdChooser.SelectedIndex])
                    {
                        this.vdxChooser.Items.Add(rl.filename);
                    }
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Open a vdx based on filestream and rl data
 /// </summary>
 /// <param name="stream">Stream pointing to the VDX location</param>
 /// <param name="rl">RL information including offset and length of the VDX</param>
 /// <param name="flags">VDX flags relating to playback</param>
 /// <param name="baseSurface">Base surface to build from</param>
 public VDX(BinaryReader stream, GJD.RLData rl, Surface baseSurface)
 {
     this.file = stream;
     status = VDXStatus.Loading;
     surface = baseSurface;
     parseVDX(rl);
     parseAudio();
     parseImage();
 }