private int[][] PopulateGUIControls()
{
//int[][] objrefptrs = new int[game.GUIs.Count][];
List<int[]> objrefptrs = new List<int[]>();
foreach (GUI gui in game.GUIs)
{
//objrefptrs[gui.ID] = new int[Constants.MAX_OBJS_ON_GUI];
objrefptrs.Add(new int[gui.Controls.Count]);
int numobjs = 0; // number of processed controls on this GUI
foreach (GUIControl control in gui.Controls)
{
GUIButton button = control as GUIButton;
GUILabel label = control as GUILabel;
GUIInventory invWindow = control as GUIInventory;
GUISlider slider = control as GUISlider;
GUITextBox textBox = control as GUITextBox;
GUIListBox listBox = control as GUIListBox;
GUITextWindowEdge textWindowEdge = control as GUITextWindowEdge;
if ((button != null) || (textWindowEdge != null))
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_BUTTON << 16) | GUIButtonsAndTextWindowEdges.Count;
GUIButtonsAndTextWindowEdges.Add(button != null ?
(GUIButtonOrTextWindowEdge)button :
(GUIButtonOrTextWindowEdge)textWindowEdge);
}
else if (label != null)
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_LABEL << 16) | GUILabels.Count;
GUILabels.Add(label);
}
else if (invWindow != null)
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_INVENTORY << 16) | GUIInvWindows.Count;
GUIInvWindows.Add(invWindow);
}
else if (slider != null)
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_SLIDER << 16) | GUISliders.Count;
GUISliders.Add(slider);
}
else if (textBox != null)
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_TEXTBOX << 16) | GUITextBoxes.Count;
GUITextBoxes.Add(textBox);
}
else if (listBox != null)
{
objrefptrs[gui.ID][numobjs] = (NativeConstants.GOBJ_LISTBOX << 16) | GUIListBoxes.Count;
GUIListBoxes.Add(listBox);
}
++numobjs;
}
}
return objrefptrs.ToArray();
}