using System;
using System.Collections.Generic;
using System.IO;

namespace SceneEditWindow
{
	public class CustomViewItemData
	{
		public static List<CustomViewItemData.ItemData> itemList { get; private set; }

		public static void Create()
		{
			if (CustomViewItemData.itemList != null)
			{
				return;
			}
			CustomViewItemData.itemList = new List<CustomViewItemData.ItemData>();
			using (AFileBase afileBase = GameUty.FileSystem.FileOpen("edit_custom_view.nei"))
			{
				using (CsvParser csvParser = new CsvParser())
				{
					bool condition = csvParser.Open(afileBase);
					NDebug.Assert(condition, "edit_custom_view.nei\nopen failed.");
					for (int i = 1; i < csvParser.max_cell_y; i++)
					{
						if (csvParser.IsCellToExistData(0, i))
						{
							int num = 0;
							CustomViewItemData.ItemData item = default(CustomViewItemData.ItemData);
							item.page = csvParser.GetCellAsInteger(num++, i) - 1;
							try
							{
								item.mpn = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i));
							}
							catch (Exception e)
							{
								NDebug.AssertParseError("MPN", e);
							}
							item.iconTexName = Path.ChangeExtension(csvParser.GetCellAsString(num++, i).ToString(), "tex");
							CustomViewItemData.itemList.Add(item);
						}
					}
				}
			}
		}

		public struct ItemData
		{
			public int page;

			public MPN mpn;

			public string iconTexName;
		}
	}
}
