updated to new monogame and mlem versions partly

This commit is contained in:
Ell 2022-02-06 22:53:44 +01:00
parent d184731134
commit d4bd862b04
7 changed files with 454 additions and 5294 deletions

View file

@ -2,7 +2,6 @@ using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Gms.Ads;
using Android.Gms.Common;
using Android.Gms.Games;
using Android.OS;
@ -10,6 +9,7 @@ using Android.Views;
using Android.Widget;
using GameAnalyticsSDK;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using MLEM.Extensions;
using MLEM.Misc;
using TouchyTickets;
@ -41,15 +41,12 @@ namespace Android {
adLayout.SetGravity(GravityFlags.Bottom);
// set up the game
TextInputWrapper.Current = new TextInputWrapper.Mobile();
MlemPlatform.Current = new MlemPlatform.Mobile(KeyboardInput.Show, l => this.StartActivity(new Intent(Intent.ActionView, Uri.Parse(l))));
this.platform = new AndroidPlatform(this, adLayout);
this.game = new GameImpl(this.platform);
this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window);
this.game.GraphicsDeviceManager.IsFullScreen = true;
this.game.OnLoadContent += game => {
game.InputHandler.HandleMouse = false;
game.UiSystem.LinkBehavior = l => this.StartActivity(new Intent(Intent.ActionView, Uri.Parse(l.Match.Groups[1].Value)));
};
this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false;
var gameView = this.game.Services.GetService(typeof(View)) as View;
gameView.LayoutChange += (o, args) => {

View file

@ -78,11 +78,11 @@
</MonoGameContentReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Contentless" Version="3.0.0" />
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.1" />
<PackageReference Include="Contentless" Version="3.0.6" />
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="5.2.3" />
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189" />
<PackageReference Include="Xamarin.GooglePlayServices.Games" Version="29.0.0.2" />
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.0.1641" />
<PackageReference Include="Xamarin.GooglePlayServices.Games" Version="121.0.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TouchyTickets\TouchyTickets.csproj">

View file

@ -3,7 +3,6 @@ using System.Collections;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.Gms.Ads;
using Android.Gms.Common;
using Android.Gms.Common.Apis;
using Android.Gms.Extensions;
@ -62,11 +61,12 @@ namespace Android {
public override void SetupOnlineInteractions(Dictionary<string, object> analyticsJson) {
// Analytics
GameAnalytics.SetAutoDetectAppVersion(true);
GameAnalytics.Initialize(this.activity, GA_MiniJSON.JsonEncode(new Hashtable(analyticsJson)));
GameAnalytics.Initialize(this.activity, GA_MiniJSON.Serialize(new Hashtable(analyticsJson)));
AndroidEnvironment.UnhandledExceptionRaiser += (o, args) => GameAnalytics.NewErrorEvent(GAErrorSeverity.Critical, args.Exception.ToString());
// TODO fix ads
// Ads
try {
/*try {
var ad = new AdView(this.activity) {
AdUnitId = "ca-app-pub-5754829579653773/7841535920",
AdSize = AdSize.SmartBanner
@ -77,9 +77,10 @@ namespace Android {
this.adLayout.AddView(ad);
} catch (Exception e) {
GameAnalytics.NewErrorEvent(GAErrorSeverity.Error, "Ads " + e);
}
}*/
// Google Play game services
// TODO fix google play game services
/*// Google Play game services
try {
this.GoogleApi = new GoogleApiClient.Builder(this.activity)
.AddApi(GamesClass.API)
@ -95,7 +96,7 @@ namespace Android {
this.GoogleApi.Connect();
} catch (Exception e) {
GameAnalytics.NewErrorEvent(GAErrorSeverity.Error, "GoogleApiClient " + e);
}
}*/
#if DEBUG
// Sanity check to ensure that all achievements are mapped

File diff suppressed because it is too large Load diff

View file

@ -5,12 +5,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Coroutine" Version="2.0.0" />
<PackageReference Include="MLEM.Startup" Version="4.1.0-228" />
<PackageReference Include="Coroutine" Version="2.1.3" />
<PackageReference Include="MLEM.Startup" Version="5.3.0-365" />
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

View file

@ -13,6 +13,7 @@ using MLEM.Font;
using MLEM.Formatting.Codes;
using MLEM.Input;
using MLEM.Misc;
using MLEM.Sound;
using MLEM.Startup;
using MLEM.Textures;
using MLEM.Ui;
@ -51,7 +52,7 @@ namespace TouchyTickets {
rainingTickets.Add(new RainingTicket());
},
OnDrawn = (e, time, batch, alpha) => {
batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha);
batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorHelper.FromHexRgb(0x86bccf) * alpha);
foreach (var ticket in rainingTickets)
ticket.Draw(batch, e.DisplayArea.Size, e.Scale, Color.White * alpha);
}
@ -75,13 +76,13 @@ namespace TouchyTickets {
ticketGroup.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.Map.TicketsPerSecond.ToString("#,0.##") + "<i ticket>/s", true));
BigInteger lastTickets = 0;
ActiveCoroutine storeWobble = null;
var storeGroup = main.AddChild(new CustomDrawGroup(Anchor.AutoCenter, new Vector2(1, 0.425F), null, null, false) {
var storeGroup = main.AddChild(new Group(Anchor.AutoCenter, new Vector2(1, 0.425F), false) {
OnUpdated = (e, time) => {
if (lastTickets != GameImpl.Instance.Tickets) {
lastTickets = GameImpl.Instance.Tickets;
// only wobble if we're not already wobbling
if (storeWobble == null || storeWobble.IsFinished)
storeWobble = CoroutineHandler.Start(WobbleElement((CustomDrawGroup) e));
storeWobble = CoroutineHandler.Start(WobbleElement(e));
}
}
});
@ -145,10 +146,10 @@ namespace TouchyTickets {
// buy ui
var buyUi = new Group(Anchor.TopLeft, Vector2.One, false) {
IsHidden = true,
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha)
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorHelper.FromHexRgb(0x86bccf) * alpha)
};
buyUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Attractions"), true) {TextScale = 0.15F});
var buyList = buyUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) {
var buyList = buyUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
@ -156,7 +157,7 @@ namespace TouchyTickets {
BigInteger price = 0;
var attractionAmount = 0;
var button = buyList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) {
ChildPadding = new Vector2(4),
ChildPadding = new Padding(4),
PositionOffset = new Vector2(0, 1),
OnPressed = e => {
if (this.swipeProgress != 0)
@ -196,7 +197,7 @@ namespace TouchyTickets {
}
});
var image = button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), Assets.AttractionTexture[attraction.Value.TextureRegion]) {
Padding = new Vector2(4)
Padding = new Padding(4)
});
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1), false) {CanBeMoused = false});
var name = right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(attraction.Key), true));
@ -218,10 +219,10 @@ namespace TouchyTickets {
// modifier ui
var modifierUi = new Group(Anchor.TopLeft, Vector2.One, false) {
IsHidden = true,
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha)
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorHelper.FromHexRgb(0x86bccf) * alpha)
};
modifierUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Modifiers"), true) {TextScale = 0.15F});
var modifierList = modifierUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) {
var modifierList = modifierUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
@ -229,7 +230,7 @@ namespace TouchyTickets {
var button = modifierList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4),
ChildPadding = new Padding(4),
OnPressed = e => {
if (this.swipeProgress != 0)
return;
@ -287,7 +288,7 @@ namespace TouchyTickets {
}
});
var image = button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), Assets.UiTexture[modifier.Texture]) {
Padding = new Vector2(4)
Padding = new Padding(4)
});
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1)) {CanBeMoused = false});
var name = right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(modifier.Name), true));
@ -320,7 +321,7 @@ namespace TouchyTickets {
// upgrade ui
var upgradeUi = new Group(Anchor.TopLeft, Vector2.One, false) {
IsHidden = true,
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha)
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorHelper.FromHexRgb(0x86bccf) * alpha)
};
var upgradeHeader = upgradeUi.AddChild(new Group(Anchor.AutoLeft, new Vector2(1)));
upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.Stars + "<i star>", true) {TextScale = 0.3F});
@ -357,7 +358,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), Vector2.Zero, false, true, new Point(10, 30), false) {
var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5)
});
upgradeHeader.OnAreaUpdated += e => upgradeList.Size = new Vector2(1, (upgradeUi.DisplayArea.Height - upgradeHeader.DisplayArea.Height) / e.Scale);
@ -367,10 +368,10 @@ namespace TouchyTickets {
// options ui
var optionsUi = new Group(Anchor.TopLeft, Vector2.One, false) {
IsHidden = true,
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha)
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorHelper.FromHexRgba(0x86bccf) * alpha)
};
optionsUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Options"), true) {TextScale = 0.15F});
var optionList = optionsUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, new Point(10, 30), false) {
var optionList = optionsUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
@ -461,7 +462,7 @@ namespace TouchyTickets {
var tex = new TextureRegion(GameImpl.Instance.SpriteBatch.GetBlankTexture());
swipeInfo.AddChild(new Image(Anchor.AutoInlineIgnoreOverflow, new Vector2(12, 6), tex) {
MaintainImageAspect = false,
Padding = new Vector2(1),
Padding = new Padding(1),
OnUpdated = (e, time) => ((Image) e).DrawAlpha = this.currentUi == ui ? 1 : 0.35F
});
}
@ -561,8 +562,7 @@ namespace TouchyTickets {
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 30), Localization.Get("Okay")) {
OnPressed = e2 => {
// create the (empty) flag file
using (analyticsFlag.Create()) {
}
using (analyticsFlag.Create()) {}
splash.RemoveChild(panel);
CoroutineHandler.RaiseEvent(evt);
}
@ -696,7 +696,7 @@ namespace TouchyTickets {
var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4),
ChildPadding = new Padding(4),
ActionSound = new SoundEffectInfo(Assets.BuySound),
OnPressed = e => {
GameImpl.Instance.Stars -= upgrade.Price;
@ -717,7 +717,7 @@ namespace TouchyTickets {
HideAndDisable();
button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), Assets.UiTexture[upgrade.Texture]) {
Padding = new Vector2(4)
Padding = new Padding(4)
});
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1)) {CanBeMoused = false});
right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(upgrade.Name), true));
@ -727,10 +727,10 @@ namespace TouchyTickets {
}
}
private static IEnumerator<Wait> WobbleElement(CustomDrawGroup element, float intensity = 0.02F) {
private static IEnumerator<Wait> WobbleElement(Element element, float intensity = 0.02F) {
var sin = 0F;
while (sin < MathHelper.Pi) {
element.ScaleOrigin(1 + (float) Math.Sin(sin) * intensity);
element.ScaleTransform(1 + (float) Math.Sin(sin) * intensity);
sin += 0.2F;
yield return new Wait(CoroutineEvents.Update);
}

View file

@ -131,10 +131,10 @@
<InterfaceDefinition Include="LaunchScreen.storyboard" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Contentless" Version="3.0.0" />
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.1" />
<PackageReference Include="Contentless" Version="3.0.6" />
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="5.2.3" />
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
<PackageReference Include="MonoGame.Framework.iOS" Version="3.8.0.1375-develop" />
<PackageReference Include="MonoGame.Framework.iOS" Version="3.8.0.1641" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TouchyTickets\TouchyTickets.csproj">