private void ConfigureScreen() { BackgroundColor = Color.White; Progress generalProgress = new Progress(ViewModel.TotalSteps, ViewModel.Step) { Margin = new Thickness(5, 5, 5, 0) }; Label directionText = new Label() { TextColor = Color.Black, FontSize = 18, FontAttributes = FontAttributes.Bold, Text = DirectionMainInstruction, HorizontalTextAlignment = TextAlignment.Center, }; RoundedBorderedLabel mainDirectionLabel = new RoundedBorderedLabel(directionText, Color.Transparent, 0, ColorMainInstruction, 7) { //BackgroundColor = ColorMainInstruction, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(30, 0), VerticalOptions = LayoutOptions.Start }; mainDirectionLabel.Content.HorizontalOptions = mainDirectionLabel.HorizontalOptions; Label secondDirectionLabel = new Label() { HorizontalTextAlignment = TextAlignment.Center, FontSize = 15, Text = DirectionSecondInstruction, TextColor = Color.Black, }; UI.Animation directionGIF = new UI.Animation(ViewModel.Direction); Label accelerationText = new Label() { TextColor = Color.Black, FontSize = 18, FontAttributes = FontAttributes.Bold, Text = AccelerationInstruction, HorizontalTextAlignment = TextAlignment.Center, }; RoundedBorderedLabel accelerationLabel = new RoundedBorderedLabel(accelerationText, Color.Transparent, 0, ColorPalette.ExtraLightGray, 7) { HorizontalOptions = LayoutOptions.FillAndExpand, WidthRequest = App.ScreenWidth, Margin = new Thickness(30, 0), }; accelerationLabel.Content.HorizontalOptions = accelerationLabel.HorizontalOptions; UI.Animation accelerationGIF = new UI.Animation(ViewModel.Acceleration); int ciclo = 0; if (ViewModel.Direction != SteeringWheel.CentrallyAligned) { accelerationGIF.KeepAnimating = false; accelerationGIF.Completed += () => { ciclo++; if (ciclo <= 1) { directionGIF.StartRedrawing(); } }; directionGIF.Completed += () => { if (ciclo <= 1) { accelerationGIF.StartRedrawing(); } }; } else { accelerationGIF.Completed += () => { ciclo++; if (ciclo <= 1) { accelerationGIF.StartRedrawing(); } }; } Progress = new CurvedProgressBar() { HeightRequest = App.ScreenHeight / 5 * 1.2, WidthRequest = App.ScreenWidth }; Progress.SetBinding(CurvedProgressBar.ProgressProperty, new Binding(nameof(ViewModel.Progress))); Progress.SetBinding(CurvedProgressBar.CmsLeftProperty, new Binding(nameof(ViewModel.DistanceLeft))); RoundedButton closeButton = new RoundedButton() { BackgroundColor = ColorPalette.LightBlue, TextColor = Color.White, Text = "X", FontSize = 20, FontAttributes = FontAttributes.Bold, WidthRequest = 40, HeightRequest = 40, Padding = 0, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.EndAndExpand, Margin = 10, Command = ViewModel.Cancel }; Label ParametrosTest = new Label() { BackgroundColor = ColorPalette.ExtraLightGray, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = 18, FontAttributes = FontAttributes.Bold, VerticalOptions = LayoutOptions.EndAndExpand, Margin = 10, }; RoundedButton nextRound = new RoundedButton() { BackgroundColor = ColorPalette.LightBlue, TextColor = Color.White, Text = "Proxima Etapa".ToUpper(), VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(15, 10), Padding = new Thickness(30, 13), FontSize = 16, FontAttributes = FontAttributes.Bold, Command = ViewModel.NextRound }; ColumnDefinitions.Add(new ColumnDefinition() { Width = App.ScreenWidth }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(App.ScreenHeight / 5 * 1.2, GridUnitType.Absolute) }); Children.Add(generalProgress, 0, 0); Children.Add(mainDirectionLabel, 0, 1); if (StepViewModel.TrainingMode) { Children.Add(ParametrosTest, 0, 2); Children.Add(nextRound, 0, 7); } else { Children.Add(secondDirectionLabel, 0, 2); } Children.Add(directionGIF, 0, 3); Children.Add(accelerationLabel, 0, 4); Children.Add(accelerationGIF, 0, 5); Children.Add(Progress, 0, 6); Children.Add(closeButton, 0, 6); if (App.IsAndroidSDKBelowMarshmallow) { ViewModel.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(ViewModel.DistanceLeft)) { Progress.CmsLeft = (int)ViewModel.DistanceLeft; } }; } ViewModel.PropertyChanged += (sender, e) => { Device.BeginInvokeOnMainThread(() => { //accelerationText.Text = $"V = {Math.Round(Convert.ToDecimal(DistanceManager.Instance.CurrentSpeed), 2)} KM/H \n"; //ParametrosTest.Text = $"V = {Math.Round(Convert.ToDecimal(StepViewModel.velocidade), 2)} KM/H \n" + // $"P = {Math.Round(StepViewModel.parou1, 0)} CM"; //directionText.Text = $"V = {Math.Round(Convert.ToDecimal(DistanceManager.Instance.CurrentSpeed * 0 + StepViewModel.FilteredSpeed), 2)}"; directionText.HorizontalTextAlignment = TextAlignment.Center; if ((FlowManager.CurrentStep1 == ApplicationStep.ManeuverIII) && ViewModel.curbTouch) { cabeOuNaoCabe = DistanceManager.Instance.CorrectOnCurbColisionTeste(Direction.Left, ApplicationStep.ManeuverIII); if (cabeOuNaoCabe == 1) { directionText.BackgroundColor = Color.Green; mainDirectionLabel.BackgroundColor = Color.Green; } else if (cabeOuNaoCabe == 2) { directionText.BackgroundColor = Color.Gray; mainDirectionLabel.BackgroundColor = Color.Gray; } else { directionText.BackgroundColor = Color.Red; mainDirectionLabel.BackgroundColor = Color.Red; } } else { directionText.BackgroundColor = Color.Transparent; mainDirectionLabel.BackgroundColor = Color.White; } }); }; }
public startMenuScreen(int w, int h, ContentManager content) : base(0, 0, w, h) { instance = this; int verticalSpacing, buttonStartY; UI.ImageLabel startMenu = new UI.ImageLabel(0, 0, content.Load<Texture2D> ("menuImages/menuBackgroundTransTest5 copy")); startMenu.resize(rect.Width, rect.Height); addComponent(startMenu); //add title text //UI.TextLabel title1 = new UI.TextLabel((int)(rect.Width*0.10),rect.Height - // (rect.Height-30), startMenu.getWidth()/3,(int) // (startMenu.getHeight()*0.10), "Chicken", 1.0f, Color.White); //addComponent(title1); //UI.TextLabel title2 = new UI.TextLabel((int)(rect.Width * 0.5), rect.Height - //(rect.Height - 30), startMenu.getWidth() / 3, (int) //(startMenu.getHeight() * 0.10), "Rancher", 1.0f, Color.White); //addComponent(title2); //load 2d textures for title animation titleTextFrames = new ArrayList(); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleText")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleText")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextSmall")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextBig")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleText")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleText")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextSmall")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextBig")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell0")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell1")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell2")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell3")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell4")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell5")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell6")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell7")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell8")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell9")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell10")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell11")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell12")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleSpell13")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextSmall")); titleTextFrames.Add(content.Load<Texture2D>("MenuImages/titleTextBig")); //add buttons Texture2D buttonUp = content.Load<Texture2D>("menuImages/blankbuttonGlow"); // UI.TextLabel startText = new UI.Text Texture2D buttonDown = content.Load<Texture2D>("menuImages/blankbuttonDarkGlow"); verticalSpacing = 100; buttonStartY = (h - buttonUp.Height) / 4; UI.PushButton newGameButton = new UI.PushButton((w - buttonUp.Width - 75), buttonStartY, buttonUp, buttonDown, "");//options button addComponent(newGameButton); newGameButton.setClickEventHandler(newGameClicked); //load the options font onto the button Point location = newGameButton.getPos(); UI.TextLabel newGameText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "New Game", 0.75f, Color.White); addComponent(newGameText); //load the start button and event UI.PushButton startButton = new UI.PushButton((w - buttonUp.Width - 75), buttonStartY + verticalSpacing, buttonUp, buttonDown, ""); addComponent(startButton); startButton.setClickEventHandler(onButtonClicked); //load a temp location variable location = startButton.getPos(); //load the start font onto the button UI.TextLabel startText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "Continue", 0.75f, Color.White); addComponent(startText); //load the NewGame button and event //load the options button and event UI.PushButton optionsButton = new UI.PushButton((w - buttonUp.Width - 75), buttonStartY + (verticalSpacing*2), buttonUp, buttonDown, "");//options button addComponent(optionsButton); optionsButton.setClickEventHandler(optionsClicked); //load the options font onto the button location = optionsButton.getPos(); UI.TextLabel optionsText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "Options", 0.75f, Color.White); addComponent(optionsText); //load the help button and event UI.PushButton helpButton = new UI.PushButton((w - buttonUp.Width) - 75, buttonStartY + (verticalSpacing*3), buttonUp, buttonDown, "");//help button addComponent(helpButton); helpButton.setClickEventHandler(helpClicked); //load the help font onto the button location = helpButton.getPos(); UI.TextLabel helpText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "Help", 0.75f, Color.White); addComponent(helpText); UI.PushButton exitButton = new UI.PushButton((w - buttonUp.Width) - 75, buttonStartY + (verticalSpacing * 4), buttonUp, buttonDown, "");//credits button addComponent(exitButton); exitButton.setClickEventHandler(exitClicked); //load the help font onto the button location = exitButton.getPos(); UI.TextLabel exitText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "Exit", 0.75f, Color.White); addComponent(exitText); UI.PushButton creditsButton = new UI.PushButton((w - buttonUp.Width) - 75, buttonStartY + (verticalSpacing * 5), buttonUp, buttonDown, "");//credits button addComponent(creditsButton); creditsButton.setClickEventHandler(creditsClicked); //load the help font onto the button location = creditsButton.getPos(); UI.TextLabel creditsText = new UI.TextLabel(location.X, location.Y, buttonUp.Width, buttonUp.Height, "Credits", 0.75f, Color.White); addComponent(creditsText); //--------------------------------------------------------Debug // //debug test for other menu screens //UI.PushButton debugButton = new UI.PushButton((w - buttonUp.Width - 500), (h - buttonUp.Height) / 2, // buttonUp, buttonDown, "debug"); //addComponent(debugButton); //debugButton.setClickEventHandler(debugClicked); // //--------------------------------------------------------Debug titleText = new UI.Animation(200, titleTextFrames, true); titleText.move((int)(rect.Width * 0.10), rect.Height - (rect.Height - 30)); addComponent(titleText); }