made ui look nice

This commit is contained in:
Ellpeck 2020-06-02 16:46:44 +02:00
parent bef7885124
commit 2aefd7fc4f
6 changed files with 42 additions and 18 deletions

View file

@ -2,21 +2,23 @@
"Back": "Back", "Back": "Back",
"Place": "Place", "Place": "Place",
"EarnStar": "Earn <i star>", "EarnStar": "Earn <i star>",
"ReallyEarnStar": "Are you sure that you want to earn a <i star>? This will remove all placed attractions and reset your <i ticket>!",
"Yes": "Yes",
"RequiresTickets": "Requires {0}<i ticket>", "RequiresTickets": "Requires {0}<i ticket>",
"Carousel": "Carousel", "Carousel": "Carousel",
"FoodCourt": "Food Court", "FoodCourt": "Food Court",
"FerrisWheel": "Ferris Wheel", "FerrisWheel": "Ferris Wheel",
"WildMouse": "Wild Mouse", "WildMouse": "Wild Mouse",
"MapSize1": "Big Park", "MapSize1": "Big Park",
"MapSize1Description": "Increases your park's buildable area.", "MapSize1Description": "Increases your park's buildable area. Existing attractions are not removed.",
"MapSize2": "Bigger Park", "MapSize2": "Bigger Park",
"MapSize2Description": "Increases your park's buildable area more.", "MapSize2Description": "Increases your park's buildable area more. Existing attractions are not removed.",
"MapSize3": "Biggest Park", "MapSize3": "Biggest Park",
"MapSize3Description": "Increases your park's buildable area even more.", "MapSize3Description": "Increases your park's buildable area even more. Existing attractions are not removed.",
"MapSize4": "Biggester Park", "MapSize4": "Biggester Park",
"MapSize4Description": "Increases your park's buildable area even more.", "MapSize4Description": "Increases your park's buildable area even more. Existing attractions are not removed.",
"MapSize5": "Biggestest Park", "MapSize5": "Biggestest Park",
"MapSize5Description": "Increases your park's buildable area to the maximum.", "MapSize5Description": "Increases your park's buildable area to the maximum. Existing attractions are not removed.",
"FoodCourtModifier": "Tasty Treats", "FoodCourtModifier": "Tasty Treats",
"FoodCourtModifierDescription": "Doubles ticket sales for all attractions adjacent to food courts.", "FoodCourtModifierDescription": "Doubles ticket sales for all attractions adjacent to food courts.",
"FerrisWheelModifier": "Crowded Pods", "FerrisWheelModifier": "Crowded Pods",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -74,7 +74,7 @@ namespace TouchyTickets {
this.TicketsPerSecond = tickets; this.TicketsPerSecond = tickets;
// map movement // map movement
if (GameImpl.Instance.DrawMap) { if (GameImpl.Instance.DrawMap && GameImpl.Instance.UiSystem.Controls.HandleTouch) {
var camera = GameImpl.Instance.Camera; var camera = GameImpl.Instance.Camera;
if (MlemGame.Input.GetGesture(GestureType.Pinch, out var pinch)) { if (MlemGame.Input.GetGesture(GestureType.Pinch, out var pinch)) {
var startDiff = pinch.Position2 - pinch.Position; var startDiff = pinch.Position2 - pinch.Position;

View file

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

View file

@ -34,6 +34,8 @@ namespace TouchyTickets {
this.uiSystem.AutoScaleWithScreen = true; this.uiSystem.AutoScaleWithScreen = true;
this.uiSystem.AutoScaleReferenceSize = new Point(720, 1280); this.uiSystem.AutoScaleReferenceSize = new Point(720, 1280);
this.uiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/Regular")); this.uiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/Regular"));
this.uiSystem.Style.PanelTexture = this.uiSystem.Style.ScrollBarBackground = new NinePatch(Texture[2, 1], 4);
this.uiSystem.Style.ButtonTexture = this.uiSystem.Style.ScrollBarScrollerTexture = new NinePatch(Texture[3, 1], 4);
this.uiSystem.Style.TextScale = 0.1F; this.uiSystem.Style.TextScale = 0.1F;
this.uiSystem.TextFormatter.AddImage("ticket", Texture[2, 0]); this.uiSystem.TextFormatter.AddImage("ticket", Texture[2, 0]);
this.uiSystem.TextFormatter.AddImage("star", Texture[3, 0]); this.uiSystem.TextFormatter.AddImage("star", Texture[3, 0]);
@ -50,7 +52,7 @@ namespace TouchyTickets {
rainingTickets.Add(new RainingTicket()); rainingTickets.Add(new RainingTicket());
}, },
OnDrawn = (e, time, batch, alpha) => { OnDrawn = (e, time, batch, alpha) => {
batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86cfcb) * alpha); batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha);
foreach (var ticket in rainingTickets) foreach (var ticket in rainingTickets)
ticket.Draw(batch, e.DisplayArea.Size, e.Scale, Color.White * alpha); ticket.Draw(batch, e.DisplayArea.Size, e.Scale, Color.White * alpha);
} }
@ -63,11 +65,14 @@ namespace TouchyTickets {
PositionOffset = new Vector2(0, -8) PositionOffset = new Vector2(0, -8)
}); });
BigInteger lastTickets = 0; BigInteger lastTickets = 0;
ActiveCoroutine storeWobble = null;
var storeGroup = main.AddChild(new CustomDrawGroup(Anchor.AutoCenter, new Vector2(1, 0.5F), null, null, false) { var storeGroup = main.AddChild(new CustomDrawGroup(Anchor.AutoCenter, new Vector2(1, 0.5F), null, null, false) {
OnUpdated = (e, time) => { OnUpdated = (e, time) => {
if (lastTickets != GameImpl.Instance.Tickets) { if (lastTickets != GameImpl.Instance.Tickets) {
lastTickets = GameImpl.Instance.Tickets; lastTickets = GameImpl.Instance.Tickets;
CoroutineHandler.Start(WobbleElement((CustomDrawGroup) e)); // only wobble if we're not already wobbling
if (storeWobble == null || storeWobble.IsFinished)
storeWobble = CoroutineHandler.Start(WobbleElement((CustomDrawGroup) e));
} }
} }
}); });
@ -90,11 +95,12 @@ namespace TouchyTickets {
var (scaleX, scaleY) = e.DisplayArea.Size / mapSize; var (scaleX, scaleY) = e.DisplayArea.Size / mapSize;
var scale = Math.Min(scaleX, scaleY); var scale = Math.Min(scaleX, scaleY);
var pos = e.DisplayArea.Location + (e.DisplayArea.Size - mapSize * scale) / 2; var pos = e.DisplayArea.Location + (e.DisplayArea.Size - mapSize * scale) / 2;
batch.Draw(this.uiSystem.Style.PanelTexture, new RectangleF(pos - new Vector2(2) * e.Scale, mapSize * scale + new Vector2(4) * e.Scale), Color.White * alpha, e.Scale);
map.Draw(time, batch, pos, scale, alpha, false, new RectangleF(Vector2.Zero, mapSize * scale)); map.Draw(time, batch, pos, scale, alpha, false, new RectangleF(Vector2.Zero, mapSize * scale));
}, },
OnPressed = e => { OnPressed = e => {
var backUi = new Group(Anchor.BottomLeft, new Vector2(1)); var backUi = new Group(Anchor.BottomLeft, new Vector2(1));
backUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(1, 40), Localization.Get("Back")) { backUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(1, 20), Localization.Get("Back")) {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)) OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
}); });
// we want this to render below the main ui while it fades away // we want this to render below the main ui while it fades away
@ -115,6 +121,7 @@ namespace TouchyTickets {
BigInteger price = 0; BigInteger price = 0;
var button = buyUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) { var button = buyUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) {
ChildPadding = new Vector2(4), ChildPadding = new Vector2(4),
PositionOffset = new Vector2(0, 1),
OnPressed = e => { OnPressed = e => {
var map = GameImpl.Instance.Map; var map = GameImpl.Instance.Map;
map.PlacingAttraction = attraction.Value.Create(); map.PlacingAttraction = attraction.Value.Create();
@ -123,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)); 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)); var yesNoUi = new Group(Anchor.BottomLeft, new Vector2(1));
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 40), Localization.Get("Back")) { yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 20), Localization.Get("Back")) {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)) OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
}); });
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 40), Localization.Get("Place")) { yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 20), Localization.Get("Place")) {
OnPressed = e2 => { OnPressed = e2 => {
GameImpl.Instance.Tickets -= price; GameImpl.Instance.Tickets -= price;
map.Place(map.PlacingPosition, map.PlacingAttraction); map.Place(map.PlacingPosition, map.PlacingAttraction);
@ -170,11 +177,25 @@ namespace TouchyTickets {
PositionOffset = new Vector2(0, 4), PositionOffset = new Vector2(0, 4),
OnUpdated = (e, time) => ((Button) e).IsDisabled = GameImpl.Instance.Tickets < GameImpl.Instance.GetStarPrice(), OnUpdated = (e, time) => ((Button) e).IsDisabled = GameImpl.Instance.Tickets < GameImpl.Instance.GetStarPrice(),
OnPressed = e => { OnPressed = e => {
var game = GameImpl.Instance; var infoBox = new Group(Anchor.TopLeft, Vector2.One, false) {
game.TimesRestarted++; OnDrawn = (e2, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e2.DisplayArea, Color.Black * 0.35F)
game.Stars++; };
game.Map = new ParkMap(game.Map.Width, game.Map.Height); var panel = infoBox.AddChild(new Panel(Anchor.Center, new Vector2(0.8F), Vector2.Zero, true));
game.Tickets = 0; panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get("ReallyEarnStar")));
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.5F, 20), 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")) {
OnPressed = e2 => {
this.uiSystem.Remove(e2.Root.Name);
var game = GameImpl.Instance;
game.TimesRestarted++;
game.Stars++;
game.Map = new ParkMap(game.Map.Width, game.Map.Height);
game.Tickets = 0;
}
});
this.uiSystem.Add("ReallyEarnStarBox", infoBox);
} }
}); });
upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => string.Format(Localization.Get("RequiresTickets"), PrettyPrintNumber(GameImpl.Instance.GetStarPrice())), true) { upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => string.Format(Localization.Get("RequiresTickets"), PrettyPrintNumber(GameImpl.Instance.GetStarPrice())), true) {
@ -186,6 +207,7 @@ namespace TouchyTickets {
foreach (var upgrade in Upgrade.Upgrades.Values) { foreach (var upgrade in Upgrade.Upgrades.Values) {
var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) { var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
SetHeightBasedOnChildren = true, SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4), ChildPadding = new Vector2(4),
OnPressed = e => { OnPressed = e => {
GameImpl.Instance.Stars--; GameImpl.Instance.Stars--;
@ -213,7 +235,7 @@ namespace TouchyTickets {
public void Update(GameTime time) { public void Update(GameTime time) {
// swiping between tabs // swiping between tabs
if (!this.currentUi.IsHidden) { if (!this.currentUi.IsHidden && this.uiSystem.Controls.HandleTouch) {
if (MlemGame.Input.GetGesture(GestureType.HorizontalDrag, out var gesture)) { if (MlemGame.Input.GetGesture(GestureType.HorizontalDrag, out var gesture)) {
this.swipeProgress -= gesture.Delta.X / this.currentUi.DisplayArea.Width; this.swipeProgress -= gesture.Delta.X / this.currentUi.DisplayArea.Width;
} else if (!this.finishingSwipe && this.swipeProgress != 0 && !MlemGame.Input.TouchState.Any()) { } else if (!this.finishingSwipe && this.swipeProgress != 0 && !MlemGame.Input.TouchState.Any()) {