/// <summary>
/// Creates one control of the selected type for each chunk in the reflexive.
/// Idents will have the tag types filled in & tag names will be auto filled when
/// the tag type is selected.
/// String IDs will have the strings list populated here.
/// </summary>
private void GenerateFields(int progressBarStart, int progressBarEnd)
{
this.SuspendLayout();
this.progressBar1.Value = progressBarStart;
try
{
pnlAutoFill.Visible = false;
ToolTip t = new ToolTip();
this.pnlFieldControls.Controls.Clear();
this.Size = new Size(400, 500);
pnlFieldControls.AutoScroll = true;
//pnlFieldControls.AutoScrollMargin = new Size(20, pnlFieldControls.Height);
pnlFieldControls.AutoScrollMinSize = new Size(20, pnlFieldControls.Height);
int StartChunk = int.Parse(cbStartChunk.Text);
int EndChunk = int.Parse(cbEndChunk.Text);
StartOffset = RD.baseOffset + FieldControl.chunkOffset - (RD.chunkSelected * RD.reflexive.chunkSize);
switch (FieldControl.GetType().ToString())
{
case "entity.MetaEditor2.DataValues":
try
{
Control c = FieldControl.Controls[1];
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
TextBox TB = new TextBox();
TB.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
TB.Location = new Point(150, 5);
TB.Height = c.Height;
TB.Width = c.Width;
TB.Tag = StartOffset + x * RD.reflexive.chunkSize;
TB.Leave += new EventHandler(Field_Leave);
TB.TextChanged += new EventHandler(Field_TextChanged);
t.SetToolTip(TB, TB.Tag.ToString());
Casing.Controls.Add(TB);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
pnlAutoFill.Visible = true;
}
catch
{
MessageBox.Show("An error occured reading DataValues fields");
}
break;
case "entity.MetaEditor2.EntStrings":
try
{
Control c = FieldControl.Controls[1];
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
TextBox TB = new TextBox();
TB.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
TB.Location = new Point(150, 5);
TB.Height = c.Height;
TB.MaxLength = ((EntStrings)FieldControl).length;
TB.Width = Casing.Width - TB.Left - 30;
TB.Tag = StartOffset + x * RD.reflexive.chunkSize;
TB.Leave += new EventHandler(Field_Leave);
t.SetToolTip(TB, TB.Tag.ToString());
Casing.Controls.Add(TB);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
}
catch
{
MessageBox.Show("An error occured reading EntStrings fields");
}
break;
case "entity.MetaEditor2.Ident":
try
{
Control c = FieldControl.Controls[1];
this.Size = new Size(FieldControl.Width, 500);
System.Collections.IEnumerator i = FieldControl.map.MetaInfo.TagTypes.Keys.GetEnumerator();
List <string> TagTypes = new List <string>();
while (i.MoveNext())
{
TagTypes.Add((string)i.Current);
}
TagTypes.Sort();
TagTypes.Add((string)"null");
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
ComboBox FieldTagType = new ComboBox();
FieldTagType.Anchor = AnchorStyles.Left | AnchorStyles.Top;
FieldTagType.DropDownStyle = ComboBoxStyle.DropDownList;
FieldTagType.Location = new Point(150, 5);
FieldTagType.Height = c.Height;
FieldTagType.Items.AddRange(TagTypes.ToArray());
FieldTagType.Width = FieldControl.Controls[2].Width;
FieldTagType.Tag = StartOffset + x * RD.reflexive.chunkSize;
FieldTagType.SelectedIndexChanged += new EventHandler(FieldTagType_SelectedIndexChanged);
FieldTagType.Leave += new EventHandler(Field_Leave);
FieldTagType.TextChanged += new EventHandler(Field_TextChanged);
t.SetToolTip(FieldTagType, FieldTagType.Tag.ToString());
ComboBox FieldIdent = new ComboBox();
FieldIdent.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
FieldIdent.DropDownStyle = ComboBoxStyle.DropDownList;
FieldIdent.Location = new Point(250, 5);
FieldIdent.Height = c.Height;
FieldIdent.Width = FieldControl.Controls[1].Width;
if (((Ident)FieldControl).HasTagType)
{
FieldIdent.Tag = StartOffset + x * RD.reflexive.chunkSize + 4;
}
else
{
FieldIdent.Tag = StartOffset + x * RD.reflexive.chunkSize;
}
FieldIdent.Leave += new EventHandler(Field_Leave);
t.SetToolTip(FieldIdent, FieldIdent.Tag.ToString());
Casing.Controls.Add(FieldTagType);
Casing.Controls.Add(FieldIdent);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
}
catch
{
MessageBox.Show("An error occured reading Tag/Ident fields");
}
break;
case "entity.MetaEditor2.SID":
try
{
Control c = FieldControl.Controls[1];
this.Size = new Size(FieldControl.Width, 500);
List <SIDData> SIDs = new List <SIDData>();
SIDs.AddRange(SIDData.CreateArray(FieldControl.map.Strings.Name));
SortStringIDs(ref SIDs);
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
ComboBox SIDBox = new ComboBox();
SIDBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
SIDBox.DropDownStyle = ComboBoxStyle.DropDownList;
SIDBox.Location = new Point(150, 5);
SIDBox.Height = c.Height;
SIDBox.Items.AddRange(SIDs.ToArray());
SIDBox.DisplayMember = "Name";
SIDBox.Width = FieldControl.Controls[1].Width;
SIDBox.Tag = StartOffset + x * RD.reflexive.chunkSize;
SIDBox.Leave += new EventHandler(Field_Leave);
t.SetToolTip(SIDBox, SIDBox.Tag.ToString());
Casing.Controls.Add(SIDBox);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
}
catch
{
MessageBox.Show("An error occured reading String ID fields");
}
break;
case "entity.MetaEditor2.Enums":
try
{
ComboBox c = (ComboBox)FieldControl.Controls[1];
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
ComboBox EnumsBox = new ComboBox();
EnumsBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
EnumsBox.Location = new Point(150, 5);
EnumsBox.Height = c.Height;
object[] objs = new object[c.Items.Count];
c.Items.CopyTo(objs, 0);
EnumsBox.Items.AddRange(objs);
EnumsBox.Width = FieldControl.Controls[1].Width;
EnumsBox.Tag = StartOffset + x * RD.reflexive.chunkSize;
EnumsBox.Leave += new EventHandler(Field_Leave);
t.SetToolTip(EnumsBox, EnumsBox.Tag.ToString());
Casing.Controls.Add(EnumsBox);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
pnlAutoFill.Visible = true;
}
catch
{
MessageBox.Show("An error occured reading Enums fields");
}
break;
case "entity.MetaEditor2.Indices":
try
{
Control c = FieldControl.Controls[1];
this.Size = new Size(FieldControl.Width, 500);
Indices indices = ((Indices)FieldControl);
// Make sure all values have been added to combobox (happens on dropdown)
indices.UpdateSelectionList(true);
for (int x = StartChunk; x <= EndChunk; x++)
{
// Update progress bar
this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk));
this.progressBar1.Refresh();
Control Casing = new Control();
Casing.Dock = DockStyle.Top;
Casing.Padding = new Padding(4);
Casing.Size = new Size(this.Width, 31);
Label LBL = new Label();
LBL.Dock = DockStyle.Left;
LBL.Location = new Point(10, 4);
LBL.Size = new Size(140, 23);
LBL.Text = FieldControl.EntName + " #" + x.ToString();
LBL.TextAlign = ContentAlignment.MiddleLeft;
ComboBox Indices = new ComboBox();
Indices.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
Indices.DropDownStyle = ComboBoxStyle.DropDownList;
Indices.Location = new Point(150, 5);
Indices.Height = c.Height;
Indices.Items.AddRange(indices.IndicesList.ToArray());
Indices.DisplayMember = "Name";
Indices.Width = Casing.Width - Indices.Left - 50;
Indices.Tag = StartOffset + x * RD.reflexive.chunkSize;
Indices.Leave += new EventHandler(Field_Leave);
t.SetToolTip(Indices, Indices.Tag.ToString());
Casing.Controls.Add(Indices);
Casing.Controls.Add(LBL);
pnlFieldControls.Controls.Add(Casing);
Casing.BringToFront();
}
}
catch
{
MessageBox.Show("An error occured reading Indices/Block Index fields");
}
break;
default:
MessageBox.Show(FieldControl.GetType().ToString() + " fields are currently Unsupported.");
this.Close();
break;
}
}
finally
{
this.ResumeLayout(true);
}
}