/* * **/ // Our window list static private var windowList : Array = new Array(); // Static variables defining the properties of a window static private var windowName : int = 0; static private var windowID : int = 1; static private var windowWidth : int = 2; static private var windowHeight : int = 3; static private var windowDragable : int = 4; static private var windowPositionX : int = 5; static private var windowPositionY : int = 6; // The last used ID for windows. ID's are assigned by the script and not the user. static private var lastID : int = 0; // Create a new window with the given paramaters. // @returns The window ID for this new window. static function NewWindow(newWindowTitle : String, dragable : boolean){ var newWindow = new Array(); newWindow.Push(newWindowTitle); newWindow.Push(lastID++); newWindow.Push(100); newWindow.Push(100); newWindow.Push(dragable); newWindow.Push(0); newWindow.Push(0); windowList.Push(newWindow); return lastID - 1; } // Draw all objects in the UI. This function should be called // from the parent script's OnGUI function. static function DrawAllGUI(){ for (var thisWindow in windowList){ var thisRect = Rect(thisWindow[windowPositionX],thisWindow[windowPositionY],thisWindow[windowWidth],thisWindow[windowHeight]); var thisName : String = thisWindow[windowName]; thisRect = GUI.Window(thisWindow[windowID], thisRect, ImbueWindow, thisName); } } // Imbue a window with all the controls it has assigned to it. static private function ImbueWindow (thisWindowID : int) { var thisWindow = GetWindowByID(thisWindowID); if (thisWindow[windowDragable]) GUI.DragWindow(); } static private function GetWindowByID(thisWindowID : int){ for (var thisWindow in windowList){ if(thisWindow[windowID] == thisWindowID) return thisWindow; } return null; } /* * Window Functions * * These functions are for modifying and editing windows in real time * by editing their table entries. **/ // Set the width and height of this window. static function SetWindowSize(thisWindowID : int, width : int, height : int){ var thisWindow = GetWindowByID(thisWindowID); thisWindow[windowWidth] = width; thisWindow[windowHeight] = height; } // Set the x and y position of this window. static function SetWindowPosition(thisWindowID : int, x : int, y : int){ var thisWindow = GetWindowByID(thisWindowID); thisWindow[windowPositionX] = x; thisWindow[windowPositionY] = y; }