Esempio n. 1
0
        public static Page Create(Route route)
        {
            Page result = new Page();

            #region Init
            if (route == null)
            {
                route = new Route()
                {
                    Name = "<enter name>",
                }
            }
            ;
            result.Daytime = Application.DefaultDaytime;
            result.Weather = Application.DefaultWeather;

            result.CameraPosition  = route.PreviewCameraPosition;
            result.CameraDirection = route.PreviewCameraDirection;

            previewPosition  = route.PreviewCameraPosition;
            previewDirection = route.PreviewCameraDirection;
            spawnPosition    = route.SpawnPosition;
            spawnRotation    = route.SpawnRotation;
            barriers         = new List <Barrier>();
            barriers.AddRange(route.Barriers);

            tempBarriers = new List <Barrier>();
            tempBarriers.AddRange(barriers);

            MarkerScript         = Application.GetScript <DrawMarkerScript>();
            MarkerScript.Markers = tempBarriers;
            MarkerScript.Start();

            barrierIndex = 0;
            #endregion

            #region EditRoute Elements
            editRouteLabel = new Label()
            {
                ScaledX     = 950,
                ScaledY     = 100,
                ScaledWidth = 1500,
                Name        = "editRouteLabel",
                Content     = "Edit Route",
                TextColor   = Application.ColorText,
                Shadow      = true,
                Outline     = true,
                FontSize    = 56,
            };
            result.AddElement(editRouteLabel);

            #region Name
            routeNameLabel = new Label()
            {
                Name         = "routeNameLabel",
                Content      = "Name:",
                TextColor    = Application.ColorText,
                Shadow       = true,
                Outline      = true,
                FontSize     = 34,
                ScaledWidth  = 150,
                ScaledHeight = 75,
                ScaledX      = 100,
                ScaledY      = 250,
            };
            routeNameInputField = new InputField()
            {
                Name         = "routeNameInputField",
                ScaledWidth  = 700,
                ScaledHeight = 50,
                ScaledX      = 200,
                ScaledY      = 250,
                Content      = route != null ? route.Name : "<enter name>",
            };
            result.AddElement(routeNameLabel);
            result.AddElement(routeNameInputField);
            #endregion

            #region Barriers
            availableBarriersLabel = new Label()
            {
                ScaledX     = 550,
                ScaledY     = 340,
                ScaledWidth = 1500,
                Name        = "availableBarriersLabel",
                Content     = "Barriers:",
                TextColor   = Application.ColorText,
                Shadow      = false,
                Outline     = true,
                FontSize    = 40,
            };
            availableBarriersList = new ItemList()
            {
                Name = "availableBarriersList",

                ScaledX      = 200,
                ScaledY      = 400,
                ScaledWidth  = 700,
                ScaledHeight = 7 * ItemList.C_ItemHeight + 10,
            };
            barriers.ForEach(x => availableBarriersList.AddItem("Barrier" + barrierIndex++));
            availableBarriersList.AddItem("<create new>");
            availableBarriersList.Selected += EditBarrier;

            result.AddElement(availableBarriersLabel);
            result.AddElement(availableBarriersList);
            #endregion

            #region Settings
            selectSpawnButton = new Button()
            {
                Name    = "selectSpawnButton",
                Content = "Select spawnpoint",

                ScaledWidth  = 700,
                ScaledHeight = 50,
                ScaledX      = Tools.ScreenWidth - 900,
                ScaledY      = 400
            };
            selectSpawnButton.Selected += SelectSpawn;


            selectPreviewButton = new Button()
            {
                Name    = "selectPreviewButton",
                Content = "Select camera preview",

                ScaledWidth  = 700,
                ScaledHeight = 50,
                ScaledX      = Tools.ScreenWidth - 900,
                ScaledY      = 500
            };
            selectPreviewButton.Selected += SelectPreview;

            result.AddElement(selectSpawnButton);
            result.AddElement(selectPreviewButton);
            #endregion

            #region Control buttons
            abortButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "abortButton",
                Content = "Abort",
            };
            abortButton.Selected += (a, b) => Application.GUI.SetPage(ManageRoutesMenu.Create());

            deleteButton = new Button()
            {
                ScaledX = Tools.ScreenWidth / 2 - 175,
                ScaledY = 950,

                ScaledWidth  = 350,
                ScaledHeight = 50,

                Name    = "deleteButton",
                Content = "Delete route",

                TextColor = System.Drawing.Color.Red
            };
            deleteButton.Selected += (a, b) =>
            {
                route.Delete();
                Application.GUI.SetPage(ManageRoutesMenu.Create());
            };

            applyButton = new Button()
            {
                ScaledX = Tools.ScreenWidth - 250,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "applyButton",
                Content = "OK",
            };
            applyButton.Selected += (a, b) =>
            {
                ApplyChanges(route);
                Application.GUI.SetPage(ManageRoutesMenu.Create());
            };


            result.AddElement(abortButton);
            result.AddElement(deleteButton);
            result.AddElement(applyButton);
            #endregion
            #endregion

            #region SelectSpwan Elements
            abortSpawnButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "abortSpawnButton",
                Content = "Abort",
            };
            abortSpawnButton.Selected += AbortSpawnSelection;
            applySpawnButton           = new Button()
            {
                ScaledX = Tools.ScreenWidth - 250,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "applySpawnButton",
                Content = "Select",
            };
            applySpawnButton.Selected += ApplySpawnSelection;

            abortSpawnButton.Hide();
            applySpawnButton.Hide();
            result.AddElement(abortSpawnButton);
            result.AddElement(applySpawnButton);
            #endregion


            #region SelectPreview Elements
            abortPreviewButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "abortPreviewButton",
                Content = "Abort",
            };
            abortPreviewButton.Selected += AbortPreviewSelection;

            applyPreviewButton = new Button()
            {
                ScaledX = Tools.ScreenWidth - 250,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "applyPreviewButton",
                Content = "Select",
            };
            applyPreviewButton.Selected += ApplyPreviewSelection;

            abortPreviewButton.Hide();
            applyPreviewButton.Hide();
            result.AddElement(abortPreviewButton);
            result.AddElement(applyPreviewButton);
            #endregion

            #region EditBarrier Elements
            barrierNameLabel = new Label()
            {
                ScaledX     = 950,
                ScaledY     = 100,
                ScaledWidth = 1500,
                Name        = "barrierNameLabel",
                TextColor   = Application.ColorText,
                Shadow      = true,
                Outline     = true,
                FontSize    = 56,
            };

            startRecordingButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 850,

                ScaledWidth  = 350,
                ScaledHeight = 50,

                Name    = "startRecordingButton",
                Content = "Start recording",
            };
            startRecordingButton.Selected += StartRecording;

            stopRecordingButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 850,

                ScaledWidth  = 350,
                ScaledHeight = 50,

                Name    = "stopRecordingButton",
                Content = "Stop recording",
            };
            stopRecordingButton.Selected += StopRecording;

            abortBarrierButton = new Button()
            {
                ScaledX = 50,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "abortBarrierButton",
                Content = "Abort",
            };
            abortBarrierButton.Selected += AbortBarrierEditing;

            deleteBarrierButton = new Button()
            {
                ScaledX = Tools.ScreenWidth / 2 - 175,
                ScaledY = 950,

                ScaledWidth  = 350,
                ScaledHeight = 50,

                Name    = "deleteBarrierButton",
                Content = "Delete barrier",

                TextColor = System.Drawing.Color.Red
            };
            deleteBarrierButton.Selected += DeleteBarrier;

            applyBarrierButton = new Button()
            {
                ScaledX = Tools.ScreenWidth - 250,
                ScaledY = 950,

                ScaledWidth  = 200,
                ScaledHeight = 50,

                Name    = "applyBarrierButton",
                Content = "Save",
            };
            applyBarrierButton.Selected += SaveBarrier;

            barrierNameLabel.Hide();
            startRecordingButton.Hide();
            stopRecordingButton.Hide();
            abortBarrierButton.Hide();
            deleteBarrierButton.Hide();
            applyBarrierButton.Hide();

            result.AddElement(barrierNameLabel);
            result.AddElement(startRecordingButton);
            result.AddElement(stopRecordingButton);
            result.AddElement(abortBarrierButton);
            result.AddElement(deleteBarrierButton);
            result.AddElement(applyBarrierButton);
            #endregion

            return(result);
        }
Esempio n. 2
0
        public static Page Create()
        {
            Page result = new Page();

            result.AddElement(new Label()
            {
                ScaledX     = 950,
                ScaledY     = 100,
                ScaledWidth = 1500,
                Name        = "MainMenuTitle",
                Content     = "Welcome to the OpenDrive Simulator!",
                Shadow      = true,
                Outline     = true,
                FontSize    = 66,
            });

            var ListItems = new List <string>()
            {
                "Start simulation",
                "Manage scenarios",
                "Manage routes",
                "Settings"
            };

            ItemList list = new ItemList()
            {
                Name         = "MainMenuList",
                ScaledX      = (Tools.ScreenWidth - 400) / 2,
                ScaledY      = 760,
                ScaledWidth  = 400,
                ScaledHeight = ListItems.Count * ItemList.C_ItemHeight,
            };

            ListItems.ForEach(x => list.AddItem(x));

            list.Selected += (s, e) =>
            {
                switch ((s as Button).Content)
                {
                case "Start simulation":
                    Application.GUI.SetPage(SelectScenariosMenu.Create());
                    break;

                case "Manage scenarios":
                    Application.GUI.SetPage(ManageScenariosMenu.Create());
                    break;

                case "Manage routes":
                    Application.Console.WriteLine("Selected Manage routes");
                    Application.GUI.SetPage(ManageRoutesMenu.Create());
                    break;

                case "Settings":
                    Application.GUI.SetPage(SettingsMenu.Create());
                    break;
                }
            };

            result.AddElement(list);
            return(result);
        }