splash screen

This commit is contained in:
Ellpeck 2020-06-02 23:23:43 +02:00
parent df2abe5746
commit 595bcc514e
5 changed files with 36 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Coroutine;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MLEM.Cameras;
@ -42,6 +43,8 @@ namespace TouchyTickets {
MaxScale = 24,
MinScale = 2
};
CoroutineHandler.Start(this.Ui.DisplaySplash());
}
protected override void DoUpdate(GameTime gameTime) {

View file

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Coroutine" Version="1.0.4" />
<PackageReference Include="MLEM.Startup" Version="3.3.3-193" />
<PackageReference Include="MLEM.Startup" Version="3.3.3-194" />
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
<PrivateAssets>all</PrivateAssets>
</PackageReference>

View file

@ -100,7 +100,7 @@ namespace TouchyTickets {
},
OnPressed = e => {
var backUi = new Group(Anchor.BottomLeft, new Vector2(1));
backUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(1, 20), Localization.Get("Back")) {
backUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(1, 30), Localization.Get("Back")) {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
});
// we want this to render below the main ui while it fades away
@ -130,10 +130,10 @@ namespace TouchyTickets {
map.PlacingPosition = new Point(MathHelper.Clamp(posX, 0, map.Width - attraction.Value.Width), MathHelper.Clamp(posY, 0, map.Height - attraction.Value.Height));
var yesNoUi = new Group(Anchor.BottomLeft, new Vector2(1));
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 20), Localization.Get("Back")) {
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Back")) {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
});
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 20), Localization.Get("Place")) {
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Place")) {
OnPressed = e2 => {
GameImpl.Instance.Tickets -= price;
map.Place(map.PlacingPosition, map.PlacingAttraction);
@ -171,9 +171,9 @@ namespace TouchyTickets {
IsHidden = true,
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha)
};
var upgradeHeader = upgradeUi.AddChild(new Group(Anchor.AutoLeft, new Vector2(1, 0.25F), false));
var upgradeHeader = upgradeUi.AddChild(new Group(Anchor.AutoLeft, new Vector2(1, 0.27F), false));
upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.Stars + "<i star>", true) {TextScale = 0.3F});
upgradeHeader.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.8F, 20), Localization.Get("EarnStar")) {
upgradeHeader.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.8F, 30), Localization.Get("EarnStar")) {
PositionOffset = new Vector2(0, 4),
OnUpdated = (e, time) => ((Button) e).IsDisabled = GameImpl.Instance.Tickets < GameImpl.Instance.GetStarPrice(),
OnPressed = e => {
@ -182,10 +182,10 @@ namespace TouchyTickets {
};
var panel = infoBox.AddChild(new Panel(Anchor.Center, new Vector2(0.8F), Vector2.Zero, true));
panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get("ReallyEarnStar")));
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.5F, 20), Localization.Get("Back")) {
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.5F, 30), Localization.Get("Back")) {
OnPressed = e2 => this.uiSystem.Remove(e2.Root.Name)
});
panel.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 20), Localization.Get("Yes")) {
panel.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Yes")) {
OnPressed = e2 => {
this.uiSystem.Remove(e2.Root.Name);
var game = GameImpl.Instance;
@ -201,7 +201,7 @@ namespace TouchyTickets {
upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => string.Format(Localization.Get("RequiresTickets"), PrettyPrintNumber(GameImpl.Instance.GetStarPrice())), true) {
PositionOffset = new Vector2(0, 2)
});
var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 0.75F), Vector2.Zero, false, true, new Point(10, 30), false) {
var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 0.73F), Vector2.Zero, false, true, new Point(10, 30), false) {
ChildPadding = new Padding(5, 15, 5, 5)
});
foreach (var upgrade in Upgrade.Upgrades.Values) {
@ -276,6 +276,30 @@ namespace TouchyTickets {
}
}
public IEnumerator<IWait> DisplaySplash() {
var splash = new Group(Anchor.TopLeft, Vector2.One, false) {
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, Color.Black * alpha)
};
var center = splash.AddChild(new Group(Anchor.Center, new Vector2(0.5F, 0.5F), false) {DrawAlpha = 0});
center.AddChild(new Image(Anchor.AutoCenter, new Vector2(1, -1), Texture[4, 0]));
center.AddChild(new Paragraph(Anchor.AutoCenter, 10000, "A game by Ellpeck", true));
this.uiSystem.Add("Splash", splash);
while (center.DrawAlpha < 1) {
center.DrawAlpha += 0.01F;
yield return new WaitEvent(CoroutineEvents.Update);
}
yield return new WaitSeconds(1.5);
while (center.DrawAlpha > 0) {
center.DrawAlpha -= 0.01F;
yield return new WaitEvent(CoroutineEvents.Update);
}
while (splash.DrawAlpha > 0) {
splash.DrawAlpha -= 0.01F;
yield return new WaitEvent(CoroutineEvents.Update);
}
this.uiSystem.Remove(splash.Root.Name);
}
private void ResetSwipe() {
this.finishingSwipe = false;
this.swipeProgress = 0;