Ejemplo n.º 1
0
        /// <summary>
        /// Called at initialization of the MainMenu scene. Initializes all variables and loads pre-existing settings if they exist.
        /// </summary>
        void Start()
        {
            FindAllGameObjects();
            splashScreen.SetActive(true); //Turns on the loading screen while initializing
            LinkTabs();
            ButtonCallbackManager.RegisterButtonCallbacks(StateMachine.SceneGlobal, gameObject);
            ButtonCallbackManager.RegisterDropdownCallbacks(StateMachine.SceneGlobal, gameObject);

            //Creates the replay directory
            FileInfo file = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Autodesk\Synthesis\Replays\");

            file.Directory.Create();

            //Assigns the currently store registry values or default file path to the proper variables if they exist.
            string robotDirectory = PlayerPrefs.GetString("RobotDirectory", (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Autodesk\synthesis\Robots"));
            string fieldDirectory = PlayerPrefs.GetString("FieldDirectory", (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Autodesk\synthesis\Fields"));

            //If the directory doesn't exist, create it.
            if (!Directory.Exists(robotDirectory))
            {
                file = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Autodesk\synthesis\Robots\");
                file.Directory.Create();
                robotDirectory = file.Directory.FullName;
            }
            if (!Directory.Exists(fieldDirectory))
            {
                file = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Autodesk\synthesis\Fields\");
                file.Directory.Create();
                fieldDirectory = file.Directory.FullName;
            }
            //Saves the current directory information to the registry
            PlayerPrefs.SetString("RobotDirectory", robotDirectory);
            PlayerPrefs.SetString("FieldDirectory", fieldDirectory);

            canvas = GetComponent <Canvas>();

            if (DirectSimulatorLaunch())
            {
                return;
            }

            splashScreen.SetActive(false);

            //This makes it so that if the user exits from the simulator,
            //they are put into the panel where they can select a robot/field
            //In all other cases, users are welcomed with the main menu screen.
            if (!string.IsNullOrEmpty(AppModel.ErrorMessage))
            {
                SwitchErrorScreen();
            }
            else
            {
                StateMachine.SceneGlobal.PushState(new HomeTabState());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds all the necessary UI elements that need to be updated/modified
        /// </summary>
        private void FindElements()
        {
            canvas  = GameObject.Find("Canvas");
            resetUI = Auxiliary.FindGameObject("ResetRobotSpawnpointUI");

            freeroamCameraWindow = Auxiliary.FindObject(canvas, "FreeroamPanel");
            overviewCameraWindow = Auxiliary.FindObject(canvas, "OverviewPanel");
            spawnpointPanel      = Auxiliary.FindObject(canvas, "SpawnpointPanel");
            //multiplayerPanel = Auxiliary.FindObject(canvas, "MultiplayerPanel");
            driverStationPanel   = Auxiliary.FindObject(canvas, "DriverStationPanel");
            changeRobotPanel     = Auxiliary.FindObject(canvas, "ChangeRobotPanel");
            robotListPanel       = Auxiliary.FindObject(changeRobotPanel, "RobotListPanel");
            changeFieldPanel     = Auxiliary.FindObject(canvas, "ChangeFieldPanel");
            inputManagerPanel    = Auxiliary.FindObject(canvas, "InputManagerPanel");
            bindedKeyPanel       = Auxiliary.FindObject(canvas, "BindedKeyPanel");
            checkSavePanel       = Auxiliary.FindObject(canvas, "CheckSavePanel");
            unitConversionSwitch = Auxiliary.FindObject(canvas, "UnitConversionSwitch");

            hotKeyPanel  = Auxiliary.FindObject(canvas, "HotKeyPanel");
            hotKeyButton = Auxiliary.FindObject(canvas, "DisplayHotKeyButton");

            orientWindow  = Auxiliary.FindObject(resetUI, "OrientWindow");
            resetDropdown = GameObject.Find("Reset Robot Dropdown");

            exitPanel          = Auxiliary.FindObject(canvas, "ExitPanel");
            loadingPanel       = Auxiliary.FindObject(canvas, "LoadingPanel");
            analyticsPanel     = Auxiliary.FindObject(canvas, "AnalyticsPanel");
            sensorManager      = GameObject.Find("SensorManager").GetComponent <SensorManager>();
            robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>();
            robotCameraGUI     = GetComponent <RobotCameraGUI>();
            mixAndMatchPanel   = Auxiliary.FindObject(canvas, "MixAndMatchPanel");

            changePanel = Auxiliary.FindObject(canvas, "ChangePanel");
            addPanel    = Auxiliary.FindObject(canvas, "AddPanel");

            // tab and toolbar system components
            tabs            = Auxiliary.FindGameObject("Tabs");
            emulationTab    = Auxiliary.FindObject(tabs, "EmulationTab");
            tabStateMachine = tabs.GetComponent <StateMachine>();

            CheckControlPanel();

            LinkToolbars();
            tabStateMachine.ChangeState(new MainToolbarState());
            currentTab = "HomeTab";

            ButtonCallbackManager.RegisterButtonCallbacks(tabStateMachine, canvas);
            ButtonCallbackManager.RegisterDropdownCallbacks(tabStateMachine, canvas);

            helpMenu = Auxiliary.FindObject(canvas, "Help");
            overlay  = Auxiliary.FindObject(canvas, "Overlay");
        }