private static void MainMenuDisposeComponents() { triggerUp -= MainMenuChangeOptionUp; triggerRight -= MainMenuChangeOptionUp; triggerDown -= MainMenuChangeOptionDown; triggerLeft -= MainMenuChangeOptionDown; triggerConfirm -= MainMenuConfirmOption; triggerBackOut -= MainMenuBackOut; tick -= MainMenuTick; if (mainMenuELLogo != null) { mainMenuELLogo.Dispose(); mainMenuELLogo = null; } foreach (var confetto in mainMenuELLogoConfetti.Keys) { confetto.Dispose(); } mainMenuELLogoConfetti.Clear(); if (mainMenuPlayButtonL != null) { mainMenuPlayButtonL.Dispose(); mainMenuPlayButtonL = null; } if (mainMenuPlayButtonR != null) { mainMenuPlayButtonR.Dispose(); mainMenuPlayButtonR = null; } if (mainMenuMedalsButtonL != null) { mainMenuMedalsButtonL.Dispose(); mainMenuMedalsButtonL = null; } if (mainMenuMedalsButtonR != null) { mainMenuMedalsButtonR.Dispose(); mainMenuMedalsButtonR = null; } if (mainMenuOptionsButtonL != null) { mainMenuOptionsButtonL.Dispose(); mainMenuOptionsButtonL = null; } if (mainMenuOptionsButtonR != null) { mainMenuOptionsButtonR.Dispose(); mainMenuOptionsButtonR = null; } if (mainMenuExitButtonL != null) { mainMenuExitButtonL.Dispose(); mainMenuExitButtonL = null; } if (mainMenuExitButtonR != null) { mainMenuExitButtonR.Dispose(); mainMenuExitButtonR = null; } if (mainMenuButtonFrontL != null) { mainMenuButtonFrontL.Dispose(); mainMenuButtonFrontL = null; } if (mainMenuButtonFrontR != null) { mainMenuButtonFrontR.Dispose(); mainMenuButtonFrontR = null; } if (mainMenuButtonRingL != null) { mainMenuButtonRingL.Dispose(); mainMenuButtonRingL = null; } if (mainMenuButtonRingR != null) { mainMenuButtonRingR.Dispose(); mainMenuButtonRingR = null; } if (mainMenuButtonRingExciterL != null) { mainMenuButtonRingExciterL.Dispose(); mainMenuButtonRingExciterL = null; } if (mainMenuButtonRingExciterR != null) { mainMenuButtonRingExciterR.Dispose(); mainMenuButtonRingExciterR = null; } if (mainMenuPlayString != null) { mainMenuPlayString.Dispose(); mainMenuPlayString = null; } if (mainMenuMedalsString != null) { mainMenuMedalsString.Dispose(); mainMenuMedalsString = null; } if (mainMenuOptionsString != null) { mainMenuOptionsString.Dispose(); mainMenuOptionsString = null; } if (mainMenuExitString != null) { mainMenuExitString.Dispose(); mainMenuExitString = null; } if (mainMenuStringExciter != null) { mainMenuStringExciter.Dispose(); mainMenuStringExciter = null; } if (mainMenuExitConfirmQuestionString != null) { mainMenuExitConfirmQuestionString.Dispose(); mainMenuExitConfirmQuestionString = null; } if (mainMenuExitConfirmYesString != null) { mainMenuExitConfirmYesString.Dispose(); mainMenuExitConfirmYesString = null; } if (mainMenuExitConfirmNoString != null) { mainMenuExitConfirmNoString.Dispose(); mainMenuExitConfirmNoString = null; } }
private static void MainMenuCreateComponents() { MainMenuDisposeComponents(); triggerUp += MainMenuChangeOptionUp; triggerRight += MainMenuChangeOptionUp; triggerDown += MainMenuChangeOptionDown; triggerLeft += MainMenuChangeOptionDown; triggerConfirm += MainMenuConfirmOption; triggerBackOut += MainMenuBackOut; tick += MainMenuTick; mainMenuInExitConfirmationScreen = false; mainMenuELLogo = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopCentered, AnchorOffset = new Vector2(0f, 0.01f), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 1f), Rotation = 0f, Scale = new Vector2(0f, 0f), Texture = AssetLocator.ELLogo, ZIndex = 3 }; for (int i = 0; i < MAIN_MENU_EL_LOGO_LOW_CONFETTI_COUNT * Config.PhysicsLevel; ++i) { ITexture2D texture; switch (i % 4) { case 0: texture = AssetLocator.GoldStar; break; case 1: texture = AssetLocator.SilverStar; break; case 2: texture = AssetLocator.BronzeStar; break; default: texture = AssetLocator.CoinFrames[0]; break; } var confetto = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopLeft, AnchorOffset = new Vector2(0.5f, mainMenuELLogo.AnchorOffset.Y), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 1f), Rotation = 0f, Scale = new Vector2(0.1f, 0.1f), Texture = texture, ZIndex = mainMenuELLogo.ZIndex - 1 }; Vector2 initialVelo = new Vector2( RandomProvider.Next(-0.5f, 0.5f), RandomProvider.Next(-0.5f, 0.5f) ); float initialSpin = RandomProvider.Next(-MathUtils.PI, MathUtils.PI); mainMenuELLogoConfetti.Add(confetto, new Vector4(initialVelo, z: initialSpin, w: texture == AssetLocator.CoinFrames[0] ? 32f : 0f)); } mainMenuPlayButtonL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopRight, AnchorOffset = new Vector2(0.37f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 0), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuPlayButton, ZIndex = 3 }; mainMenuPlayButtonR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopLeft, AnchorOffset = new Vector2(0.37f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 0), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuPlayButton, ZIndex = 3 }; mainMenuMedalsButtonL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopRight, AnchorOffset = new Vector2(0.41f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 1), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuMedalsButton, ZIndex = 3 }; mainMenuMedalsButtonR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopLeft, AnchorOffset = new Vector2(0.41f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 1), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuMedalsButton, ZIndex = 3 }; mainMenuOptionsButtonL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopRight, AnchorOffset = new Vector2(0.42f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 2), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuOptionsButton, ZIndex = 3 }; mainMenuOptionsButtonR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopLeft, AnchorOffset = new Vector2(0.42f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 2), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuOptionsButton, ZIndex = 3 }; mainMenuExitButtonL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopRight, AnchorOffset = new Vector2(0.37f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 3), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuExitButton, ZIndex = 3 }; mainMenuExitButtonR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = ViewportAnchoring.TopLeft, AnchorOffset = new Vector2(0.37f + MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 3), AspectCorrectionStrategy = HUDTexture.AspectRatioCorrectionStrategy.UseBestUniformScaling, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuExitButton, ZIndex = 3 }; mainMenuButtonFrontL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = mainMenuPlayButtonL.Anchoring, AnchorOffset = mainMenuPlayButtonL.AnchorOffset, AspectCorrectionStrategy = mainMenuPlayButtonL.AspectCorrectionStrategy, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuPlayButtonFront, ZIndex = 4 }; mainMenuButtonFrontR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = mainMenuPlayButtonR.Anchoring, AnchorOffset = mainMenuPlayButtonR.AnchorOffset, AspectCorrectionStrategy = mainMenuPlayButtonR.AspectCorrectionStrategy, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuPlayButtonFront, ZIndex = 4 }; mainMenuButtonRingL = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = mainMenuPlayButtonL.Anchoring, AnchorOffset = mainMenuPlayButtonL.AnchorOffset, AspectCorrectionStrategy = mainMenuPlayButtonL.AspectCorrectionStrategy, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuButtonRing, ZIndex = 2 }; mainMenuButtonRingR = new HUDTexture(AssetLocator.HUDFragmentShader, AssetLocator.HudLayer, AssetLocator.MainWindow) { Anchoring = mainMenuPlayButtonR.Anchoring, AnchorOffset = mainMenuPlayButtonR.AnchorOffset, AspectCorrectionStrategy = mainMenuPlayButtonR.AspectCorrectionStrategy, Color = new Vector4(1f, 1f, 1f, 0f), Rotation = 0f, Scale = MAIN_MENU_BUTTON_SCALE, Texture = AssetLocator.MainMenuButtonRing, ZIndex = 2 }; mainMenuButtonRingExciterL = new HUDItemExciterEntity(mainMenuButtonRingL) { OpacityMultiplier = 0.066f, Lifetime = 0.8f, Speed = 0.06f, CountPerSec = 60 }; mainMenuButtonRingExciterR = new HUDItemExciterEntity(mainMenuButtonRingR) { OpacityMultiplier = mainMenuButtonRingExciterL.OpacityMultiplier, Lifetime = mainMenuButtonRingExciterL.Lifetime, Speed = mainMenuButtonRingExciterL.Speed, CountPerSec = mainMenuButtonRingExciterL.CountPerSec }; mainMenuPlayString = AssetLocator.TitleFontGlow.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopCentered, new Vector2(0.0f, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 0 + MAIN_MENU_TEXT_OFFSET_Y), MAIN_MENU_TEXT_SCALE ); mainMenuPlayString.Color = new Vector4(MAIN_MENU_STRING_COLOR, w: 0f); mainMenuPlayString.Text = "PLAY"; mainMenuMedalsString = AssetLocator.TitleFontGlow.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopCentered, new Vector2(0.0f, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 1 + MAIN_MENU_TEXT_OFFSET_Y), MAIN_MENU_TEXT_SCALE ); mainMenuMedalsString.Color = new Vector4(MAIN_MENU_STRING_COLOR, w: 0f); mainMenuMedalsString.Text = "MEDALS"; mainMenuOptionsString = AssetLocator.TitleFontGlow.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopCentered, new Vector2(0.0f, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 2 + MAIN_MENU_TEXT_OFFSET_Y), MAIN_MENU_TEXT_SCALE ); mainMenuOptionsString.Color = new Vector4(MAIN_MENU_STRING_COLOR, w: 0f); mainMenuOptionsString.Text = "OPTIONS"; mainMenuExitString = AssetLocator.TitleFontGlow.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopCentered, new Vector2(0.0f, MAIN_MENU_BUTTONS_START_HEIGHT + MAIN_MENU_BUTTONS_ROW_HEIGHT * 3 + MAIN_MENU_TEXT_OFFSET_Y), MAIN_MENU_TEXT_SCALE ); mainMenuExitString.Color = new Vector4(MAIN_MENU_STRING_COLOR, w: 0f); mainMenuExitString.Text = "QUIT"; mainMenuStringExciter = new HUDItemExciterEntity(null); mainMenuExitConfirmQuestionString = AssetLocator.TitleFont.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopCentered, new Vector2(0f, 0.475f), MAIN_MENU_EXIT_ANSWER_SCALE ); mainMenuExitConfirmQuestionString.Color = new Vector4(MAIN_MENU_EXIT_QUESTION_COLOR, w: 0f); mainMenuExitConfirmQuestionString.Text = "Exit Game?"; mainMenuExitConfirmYesString = AssetLocator.TitleFont.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopRight, new Vector2(0.6f, 0.6f), MAIN_MENU_EXIT_SELECTED_ANSWER_SCALE ); mainMenuExitConfirmYesString.Color = new Vector4(MAIN_MENU_EXIT_ANSWER_COLOR, w: 0f); mainMenuExitConfirmYesString.Text = "YES"; mainMenuExitConfirmNoString = AssetLocator.TitleFont.AddString( AssetLocator.HudLayer, AssetLocator.MainWindow, ViewportAnchoring.TopLeft, new Vector2(0.64f, 0.6f), MAIN_MENU_EXIT_ANSWER_SCALE ); mainMenuExitConfirmNoString.Color = new Vector4(MAIN_MENU_EXIT_ANSWER_COLOR, w: 0f); mainMenuExitConfirmNoString.Text = "NO"; }