using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Halo3Map.IO;

namespace Cartographer.Scripts
{
    public class ScriptList
    {
        Scripts parent;
        ScriptHolder scripts;

        public int ScriptCount
        {
            get { return scripts.list.Count; }
        }

        public Script this[int i]
        {
            get { return scripts[i]; }
            set { scripts[i] = value; }
        }

        public ScriptList(Scripts that)
        {
            parent = that;
            parent.scripts = this;
            scripts = new ScriptHolder();
            scripts.list = new List<BaseClass>();
            EndianReader br = parent.br;

            for (int i = 0; i < parent.scriptCount; i++)
            {
                br.BaseStream.Position = parent.scriptsPos + i * 52;
                ScriptHeader sh = new ScriptHeader( br);
                Script s = new Script(sh, br);
                s.syntaxStartPos = parent.syntaxPos;
                scripts.list.Add(s);
            }

            scripts.Sort(SortType.Order);
            //parent.DisplayScripts();
        }
    }
}
