//*******************************************************
//Includes all the GUI elements
//*******************************************************
public void OnGUI()
{
if (atWall6 && Input.GetKeyDown("e"))
{
GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
//If at wall terminal show default cursor instead
}
/*
if (!atWall6)
{ //If not at wall terminal jack in - "show crosshair"
}
else if (Input.GetKeyDown("e"))
{
GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
//If at wall terminal show default cursor instead
}
*/
if (guiEnabled)
{
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Arrays Puzzle");
if (showError)
{
GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
{
showError = false;
}
}
GUI.SetNextControlName("textarea");
GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);
if (showError)
{
GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
{
showError = false;
}
}
editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
editor.SelectNone();
GUI.skin.label.fontSize = 12;
GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("index")); //print statement title
ind = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), ind);
GUI.Label(new Rect(Screen.width * 0.16f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("value")); //print statement title
val = GUI.TextField(new Rect(Screen.width * 0.16f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), val);
if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.1f, Screen.height * 0.05f), "Assign index"))
{
GUI.FocusControl("Textarea");
if (!isNumber(ind))
{
errorString = invalid;
showError = true;
}
else
{
int.TryParse(ind, out index);
int.TryParse(val, out value);
if (index > 4 || index < 0)
{
errorString = outOfRange;
showError = true;
}
else
{
string s = "steps[" + index + "] = " + value + ";\n\t\t";
boxes[index] = value;
editor = goToNextLine(editor, code);
code = addToCode(code, editor, s);
}
}
}
// Button that activates the user's code
if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
{
//assign the actual turret index to whatever is in the ind field
GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock1(boxes[0]);
GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock2(boxes[1]);
GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock3(boxes[2]);
GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock4(boxes[3]);
GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock5(boxes[4]);
resume();
}
// Button that closes the UI and disregards changes
if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
{
resume();
code = restoreCode();
converted = false;
showError = false;
}
// Button that restores the code in the indArea to its original state
if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset") || reset)
{
code = restoreCode();
converted = false;
showError = false;
int i = 0;
while(i<5)
{
boxes[i]=1;
i++;
}
}
}
}