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 GlobalList
    {
        Scripts parent;
        GlobalHolder globals;

        public int GlobalCount
        {
            get { return globals.list.Count; }
        }

        public Global this[int i]
        {
            get { return globals[i]; }
            set { globals[i] = value; }
        }

        public GlobalList(Scripts that)
        {
            parent = that;
            parent.globals = this;
            globals = new GlobalHolder();
            globals.list = new List<BaseClass>();
            EndianReader br = parent.br;

            for (int i = 0; i < parent.globalCount; i++)
            {
                br.BaseStream.Position = parent.globalsPos + i * 40;
                GlobalHeader gh = new GlobalHeader(br);
                Global g = new Global(gh, br);
                g.syntaxStartPos = parent.syntaxPos;
                g.Decompile();
                globals.list.Add(g);
            }

            globals.Sort(SortType.Order);

            //parent.DisplayGlobals();
        }
    }
}
