diff --git a/Backgrounds/BlankPixel.png b/Backgrounds/BlankPixel.png new file mode 100644 index 0000000000..810ccc1e28 Binary files /dev/null and b/Backgrounds/BlankPixel.png differ diff --git a/MainMenu/CalamityMainMenu.cs b/MainMenu/CalamityMainMenu.cs new file mode 100644 index 0000000000..0383ab993e --- /dev/null +++ b/MainMenu/CalamityMainMenu.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.MainMenu +{ + public class CalamityMainMenu : ModMenu + { + public override string DisplayName => "Calamity Style"; + + public override Asset Logo => ModContent.Request("CalamityMod/MainMenu/Logo"); + public override Asset SunTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); + public override Asset MoonTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); + + public override ModSurfaceBackgroundStyle MenuBackgroundStyle => ModContent.GetInstance(); + + // Before drawing the logo, draw the entire Calamity background. This way, the typical parallax background is skipped entirely. + public override bool PreDrawLogo(SpriteBatch spriteBatch, ref Vector2 logoDrawCenter, ref float logoRotation, ref float logoScale, ref Color drawColor) + { + Texture2D texture = ModContent.Request("CalamityMod/MainMenu/MenuBackground").Value; + spriteBatch.Draw(texture, new Vector2(0f, 0f), null, Color.White, 0f, Vector2.Zero, (float)Main.screenWidth / texture.Width, SpriteEffects.None, 0f); + + // TODO -- Draw plenty of cinders! + + return true; + } + } +} diff --git a/MainMenu/Logo.png b/MainMenu/Logo.png new file mode 100644 index 0000000000..8154776cb9 Binary files /dev/null and b/MainMenu/Logo.png differ diff --git a/MainMenu/MenuBackground.png b/MainMenu/MenuBackground.png new file mode 100644 index 0000000000..6085dbc75b Binary files /dev/null and b/MainMenu/MenuBackground.png differ diff --git a/MainMenu/NullSurfaceBackground.cs b/MainMenu/NullSurfaceBackground.cs new file mode 100644 index 0000000000..8552c0dd87 --- /dev/null +++ b/MainMenu/NullSurfaceBackground.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; + +namespace CalamityMod.MainMenu +{ + // Thanks to Nycro#0001 <@!262663471189983242> for this null background which cleanly ignores vanilla's parallax mechanics + internal class NullSurfaceBackground : ModSurfaceBackgroundStyle + { + public override void ModifyFarFades(float[] fades, float transitionSpeed) + { + for (int i = 0; i < fades.Length; i++) + { + if (i == Slot) + { + fades[i] += transitionSpeed; + if (fades[i] > 1f) + { + fades[i] = 1f; + } + } + else + { + fades[i] -= transitionSpeed; + if (fades[i] < 0f) + { + fades[i] = 0f; + } + } + } + } + + private static readonly string TexPath = "CalamityMod/Backgrounds/BlankPixel"; + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot(TexPath); + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot(TexPath); + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot(TexPath); + public override bool PreDrawCloseBackground(SpriteBatch spriteBatch) => false; + } +}