/// <summary>
/// Load blocks, update if needed.
/// </summary>
public static void Init()
{
if (!File.Exists("blocks.txt"))
{
frmUpdate up = new frmUpdate();
up.Start();
up.ShowDialog();
return;
}
MapGenerators.Init();
foreach (string line in File.ReadAllLines("blocks.txt"))
{
if (string.IsNullOrEmpty(line))
{
continue;
}
if (line.StartsWith("#"))
{
continue;
}
//Console.WriteLine(line);
// dec file color name
string[] chunks = line.Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
Block b = new Block();
short id = short.Parse(chunks[0]);
b.ID = id;
b.Name = chunks[2];
string bf = Path.Combine("blocks", string.Format("{0}.png", (short)id));
string if_ = Path.Combine("items", chunks[1]);
string af = Path.Combine("blocks", "0.png");
if (id < 255 && File.Exists(bf))
{
b.Image = (Bitmap)Bitmap.FromFile(bf);
}
else if (File.Exists(if_))
{
b.Image = (Bitmap)Bitmap.FromFile(if_);
}
else
{
b.Image = new Bitmap(16, 16);
}
b.Color = GetColorFor(b);
BlockList.Add(id, b);
#if DEBUG
Console.WriteLine(b);
#endif
}
SetupLighting();
}