Esempio n. 1
0
    /// <summary>
    /// Runs every frame to update the GUI elements.
    /// </summary>
    void OnGUI()
    {
        switch (currentTab)
        {
        case Tab.FieldDir:
            if (customfieldon && !fieldBrowser.Active)
            {
                currentTab = Tab.Sim;

                homeTab.SetActive(false);
                optionsTab.SetActive(false);
                simTab.SetActive(true);
                customfieldon = false;
            }
            break;

        case Tab.RobotDir:
            if (customroboton && !robotBrowser.Active)
            {
                currentTab = Tab.Sim;

                homeTab.SetActive(false);
                optionsTab.SetActive(false);
                simTab.SetActive(true);
                customroboton = false;
            }
            break;
        }
        InitFieldBrowser();
        InitRobotBrowser();

        UserMessageManager.Render();
        UserMessageManager.scale = canvas.scaleFactor;
    }
Esempio n. 2
0
    private Canvas canvas;                   //canvas component of this object--used for scaling user message manager to size


    /// <summary>
    /// Runs every frame to update the GUI elements.
    /// </summary>
    void OnGUI()
    {
        switch (currentTab)
        {
        //Switches back to sim tab UI elements if field browser is closed
        case Tab.FieldDir:
            if (customfieldon && !fieldBrowser.Active)
            {
                currentTab = Tab.Sim;

                homeTab.SetActive(false);
                optionsTab.SetActive(false);
                simTab.SetActive(true);
                customfieldon = false;
            }
            break;

        //Switches back to sim tab UI elements if robot directory is closed
        case Tab.RobotDir:
            if (customroboton && !robotBrowser.Active)
            {
                currentTab = Tab.Sim;

                homeTab.SetActive(false);
                optionsTab.SetActive(false);
                simTab.SetActive(true);
                customroboton = false;
            }
            break;
        }

        //Initializes and renders the Field Browser
        if (fieldDirectory != null)
        {
            InitFieldBrowser();
        }
        if (robotDirectory != null)
        {
            InitRobotBrowser();
        }


        //Renders the message manager which displays error messages
        UserMessageManager.Render();
        UserMessageManager.scale = canvas.scaleFactor;
    }
Esempio n. 3
0
    void OnGUI()
    {
        if (editingNode)
        {
            editingNodePanel.SetActive(true);
        }
        else
        {
            editingNodePanel.SetActive(false);
        }
        if (editingVector)
        {
            editingVectorPanel.SetActive(true);
        }
        else
        {
            editingVectorPanel.SetActive(false);
        }

        UserMessageManager.Render();
    }
Esempio n. 4
0
    /// <summary>
    /// Runs every frame to update the GUI elements.
    /// </summary>
    void OnGUI()
    {
        switch (currentMenu)
        {
        case Menu.LoadField:
            //Updates the preview thumbnail and text
            if (fields.Count > 0)
            {
                fieldText.GetComponent <Text>().text     = currenttext;
                fieldImage.GetComponent <Image>().sprite = currentimage;
            }
            break;

        case Menu.LoadRobot:
            //Updates the preview thumbnail and text
            if (robots.Count > 0)
            {
                robotText.GetComponent <Text>().text     = currenttext;
                robotImage.GetComponent <Image>().sprite = currentimage;
            }
            break;

        case Menu.Custom:
            //Switches back to the Load Field or Load Robot menu if the custom directory browser has been turned off
            if (customfieldon && !fieldBrowser.Active)
            {
                customfieldon = false;
                SwitchState(Menu.LoadField);
            }
            else if (customroboton && !robotBrowser.Active)
            {
                customroboton = false;
                SwitchState(Menu.LoadRobot);
            }
            break;
        }
        InitFieldBrowser();
        InitRobotBrowser();
        UserMessageManager.Render();
    }
Esempio n. 5
0
 private void OnGUI()
 {
     UserMessageManager.Render();
 }
Esempio n. 6
0
 /// <summary>
 /// Renders the UserMessageManager.
 /// </summary>
 public void OnGUI()
 {
     UserMessageManager.Render();
 }
Esempio n. 7
0
    void OnGUI()
    {
        //Custom style for windows
        menuWindow = new GUIStyle(GUI.skin.window);
        menuWindow.normal.background   = transparentWindowTexture;
        menuWindow.onNormal.background = transparentWindowTexture;
        menuWindow.font = russoOne;

        //Custom style for buttons
        menuButton      = new GUIStyle(GUI.skin.button);
        menuButton.font = russoOne;
        menuButton.normal.background   = buttonTexture;
        menuButton.hover.background    = buttonSelected;
        menuButton.active.background   = buttonSelected;
        menuButton.onNormal.background = buttonSelected;
        menuButton.onHover.background  = buttonSelected;
        menuButton.onActive.background = buttonSelected;

        // Draws stats window on to GUI
        if (showStatWindow)
        {
            GUI.Window(0, statsWindowRect, StatsWindow, "Stats", statsWindow);
        }

        if (gui == null)
        {
            gui = new GUIController();
            gui.hideGuiCallback = HideGuiSidebar;
            gui.showGuiCallback = ShowGuiSidebar;

            gui.AddWindow("Load Robot", new FileBrowser("Load Robot"), (object o) =>
            {
                string fileLocation = (string)o;
                // If dir was selected...
                if (File.Exists(fileLocation + "\\skeleton.bxdj"))
                {
                    fileLocation += "\\skeleton.bxdj";
                }
                DirectoryInfo parent = Directory.GetParent(fileLocation);
                if (parent != null && parent.Exists && File.Exists(parent.FullName + "\\skeleton.bxdj"))
                {
                    this.filePath       = parent.FullName + "\\";
                    reloadRobotInFrames = 2;
                }
                else
                {
                    UserMessageManager.Dispatch("Invalid selection!", 10f);
                }

                dynamicCamera.EnableMoving();
            });

            gui.AddAction("Reset Robot", () =>
            {
                resetRobot();
            });
            //shows button to manually orient the robot
            ShowOrient();

            if (!File.Exists(filePath + "\\skeleton.bxdj"))
            {
                gui.DoAction("Load Model");
            }

            gui.AddWindow("Switch View", new DialogWindow("Switch View",
                                                          "Driver Station", "Orbit Robot", "Freeroam"), (object o) =>
            {
                HideGuiSidebar();

                switch ((int)o)
                {
                case 0:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.DriverStationState(dynamicCamera));
                    break;

                case 1:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.OrbitState(dynamicCamera));
                    dynamicCamera.EnableMoving();
                    break;

                case 2:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.FreeroamState(dynamicCamera));
                    break;

                default:
                    Debug.Log("Camera state not found: " + (string)o);
                    break;
                }
            });

            gui.AddWindow("Quit to Main Menu", new DialogWindow("Quit to Main Menu?", "Yes", "No"), (object o) =>
            {
                if ((int)o == 0)
                {
                    Application.LoadLevel("MainMenu");
                }
            });

            gui.AddWindow("Quit to Desktop", new DialogWindow("Quit to Desktop?", "Yes", "No"), (object o) =>
            {
                if ((int)o == 0)
                {
                    Application.Quit();
                }
            });
        }

        if (Input.GetMouseButtonUp(0) && !gui.ClickedInsideWindow())
        {
            HideGuiSidebar();
            gui.HideAllWindows();
        }

        if (fieldBrowser == null)
        {
            fieldBrowser             = new FileBrowser("Load Field", false);
            fieldBrowser.Active      = false;
            fieldBrowser.OnComplete += (object obj) =>
            {
                fieldBrowser.Active = false;
                string fileLocation = (string)obj;
                // If dir was selected...
                if (File.Exists(fileLocation + "\\definition.bxdf"))
                {
                    fileLocation += "\\definition.bxdf";
                }
                DirectoryInfo parent = Directory.GetParent(fileLocation);
                if (parent != null && parent.Exists && File.Exists(parent.FullName + "\\definition.bxdf"))
                {
                    this.filePath       = parent.FullName + "\\";
                    fieldBrowser.Active = false;
                    reloadFieldInFrames = 2;
                }
                else
                {
                    UserMessageManager.Dispatch("Invalid selection!", 10f);
                }
            };
        }

        if (!fieldLoaded)
        {
            fieldBrowser.Render();
        }

        else
        {
            // The Menu button on the top left corner
            GUI.Window(1, new Rect(0, 0, gui.GetSidebarWidth(), 25),
                       (int windowID) =>
            {
                if (GUI.Button(new Rect(0, 0, gui.GetSidebarWidth(), 25), "Menu", menuButton))
                {
                    gui.EscPressed();
                }
            },
                       "",
                       menuWindow
                       );

            gui.Render();
        }

        UserMessageManager.Render();

        if (reloadRobotInFrames >= 0 || reloadFieldInFrames >= 0)
        {
            GUI.backgroundColor = new Color(1, 1, 1, 0.5f);
            GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 25, 200, 25), "Loading... Please Wait", gui.BlackBoxStyle);
        }
    }
Esempio n. 8
0
 /// <summary>
 /// Renders the UserMessageManager.
 /// </summary>
 public override void OnGUI()
 {
     UserMessageManager.Render();
 }
Esempio n. 9
0
    void OnGUI()
    {
        // Draws stats window on to GUI
        if (showStatWindow)
        {
            GUI.Window(0, statsWindowRect, StatsWindow, "Stats");
        }

        // Draws help window on to GUI
        if (showHelpWindow)
        {
            int   windowWidth  = 900;
            int   windowHeight = 450;
            float paddingX     = (Screen.width - windowWidth) / 2.0f;
            float paddingY     = (Screen.height - windowHeight) / 2.0f;
            helpWindowRect = new Rect(paddingX, paddingY, windowWidth, windowHeight);
            GUI.Window(0, helpWindowRect, HelpWindow, "Help");
        }

        if (gui == null)
        {
            gui = new GUIController();
            gui.hideGuiCallback = HideGuiSidebar;
            gui.showGuiCallback = ShowGuiSidebar;

            gui.AddWindow("Load Robot", new FileBrowser("Load Robot"), (object o) =>
            {
                string fileLocation = (string)o;
                // If dir was selected...
                if (File.Exists(fileLocation + "\\skeleton.bxdj"))
                {
                    fileLocation += "\\skeleton.bxdj";
                }
                DirectoryInfo parent = Directory.GetParent(fileLocation);
                if (parent != null && parent.Exists && File.Exists(parent.FullName + "\\skeleton.bxdj"))
                {
                    this.filePath       = parent.FullName + "\\";
                    reloadRobotInFrames = 2;
                }
                else
                {
                    UserMessageManager.Dispatch("Invalid selection!", 10f);
                }

                dynamicCamera.EnableMoving();
            });

            gui.AddAction("Reset Robot", () =>
            {
                resetRobot();
            });
            //shows button to manually orient the robot
            ShowOrient();

            if (!File.Exists(filePath + "\\skeleton.bxdj"))
            {
                gui.DoAction("Load Model");
            }

            gui.AddWindow("Switch View", new DialogWindow("Switch View",
                                                          "Driver Station [D]", "Orbit Robot [R]", "Freeroam [F]"), (object o) =>
            {
                HideGuiSidebar();

                switch ((int)o)
                {
                case 0:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.DriverStationState(dynamicCamera));
                    break;

                case 1:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.OrbitState(dynamicCamera));
                    dynamicCamera.EnableMoving();
                    break;

                case 2:
                    dynamicCamera.SwitchCameraState(new DynamicCamera.FreeroamState(dynamicCamera));
                    break;

                default:
                    Debug.Log("Camera state not found: " + (string)o);
                    break;
                }
            });


            gui.AddWindow("Quit Simulation", new DialogWindow("Exit?", "Yes", "No"), (object o) =>
            {
                if ((int)o == 0)
                {
                    Application.Quit();
                }
            });
        }

        if (Input.GetMouseButtonUp(0) && !gui.ClickedInsideWindow())
        {
            HideGuiSidebar();
            gui.HideAllWindows();
        }

        if (fieldBrowser == null)
        {
            fieldBrowser             = new FileBrowser("Load Field", false);
            fieldBrowser.Active      = true;
            fieldBrowser.OnComplete += (object obj) =>
            {
                fieldBrowser.Active = true;
                string fileLocation = (string)obj;
                // If dir was selected...
                if (File.Exists(fileLocation + "\\definition.bxdf"))
                {
                    fileLocation += "\\definition.bxdf";
                }
                DirectoryInfo parent = Directory.GetParent(fileLocation);
                if (parent != null && parent.Exists && File.Exists(parent.FullName + "\\definition.bxdf"))
                {
                    this.filePath       = parent.FullName + "\\";
                    fieldBrowser.Active = false;
                    reloadFieldInFrames = 2;
                }
                else
                {
                    UserMessageManager.Dispatch("Invalid selection!", 10f);
                }
            };
        }

        if (showHelpWindow && Input.GetMouseButtonUp(0) && !auxFunctions.MouseInWindow(helpWindowRect) && !auxFunctions.MouseInWindow(helpButtonRect))
        {
            showHelpWindow = false;
        }

        gui.guiBackgroundVisible = showHelpWindow;

        if (!fieldLoaded)
        {
            fieldBrowser.Render();
        }

        else
        {
            // The Menu button on the top left corner
            GUI.Window(1, new Rect(0, 0, gui.GetSidebarWidth(), 25),
                       (int windowID) =>
            {
                if (GUI.Button(new Rect(0, 0, gui.GetSidebarWidth(), 25), "Menu"))
                {
                    gui.EscPressed();
                }
            },
                       ""
                       );

            helpButtonRect = new Rect(Screen.width - 25, 0, 25, 25);

            // The Help button on top right corner
            GUI.Window(2, helpButtonRect,
                       (int windowID) =>
            {
                if (GUI.Button(new Rect(0, 0, 25, 25), helpButtonContent))
                {
                    showHelpWindow = !showHelpWindow;
                }
            },
                       ""
                       );

            gui.Render();
        }

        UserMessageManager.Render();

        if (reloadRobotInFrames >= 0 || reloadFieldInFrames >= 0)
        {
            GUI.backgroundColor = new Color(1, 1, 1, 0.5f);
            GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 25, 200, 50), "Loading... Please Wait", gui.BlackBoxStyle);
        }
    }