added an option to keep the screen on when the app is open

This commit is contained in:
Ellpeck 2020-06-29 13:47:45 +02:00
parent fff6724b00
commit e7df449d82
5 changed files with 28 additions and 0 deletions

View file

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Android.App; using Android.App;
using Android.Gms.Ads; using Android.Gms.Ads;
using Android.Views;
using Android.Widget; using Android.Widget;
using GameAnalyticsSDK; using GameAnalyticsSDK;
using GameAnalyticsSDK.Utilities; using GameAnalyticsSDK.Utilities;
@ -38,5 +39,13 @@ namespace Android {
GameAnalytics.NewResourceEvent(sink ? GAResourceFlowType.Sink : GAResourceFlowType.Source, currency, amount, itemType, itemId); GameAnalytics.NewResourceEvent(sink ? GAResourceFlowType.Sink : GAResourceFlowType.Source, currency, amount, itemType, itemId);
} }
public override void SetKeepScreenOn(bool keep) {
if (keep) {
this.activity.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
} else {
this.activity.Window.ClearFlags(WindowManagerFlags.KeepScreenOn);
}
}
} }
} }

View file

@ -16,6 +16,7 @@
"AGameByEllpeck": "A game by Ellpeck", "AGameByEllpeck": "A game by Ellpeck",
"WhileYouWereAway": "While you were away, you sold <i ticket> at half the regular speed. You were away for <c Yellow>{0} minutes</c> and sold <c Yellow>{1} <i ticket></c> during that time. Nice!", "WhileYouWereAway": "While you were away, you sold <i ticket> at half the regular speed. You were away for <c Yellow>{0} minutes</c> and sold <c Yellow>{1} <i ticket></c> during that time. Nice!",
"WhileYouWereAwayMessage": "Display Offline Summary", "WhileYouWereAwayMessage": "Display Offline Summary",
"KeepScreenOn": "Keep Screen On",
"----- Tutorial -----": "", "----- Tutorial -----": "",
"Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!", "Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!",
"Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.", "Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.",

View file

@ -22,6 +22,15 @@ namespace TouchyTickets {
private float soundVolume = 1; private float soundVolume = 1;
[DataMember] [DataMember]
public bool WhileYouWereAwayMessage = true; public bool WhileYouWereAwayMessage = true;
[DataMember]
public bool KeepScreenOn {
get => this.keepScreenOn;
set {
this.keepScreenOn = value;
GameImpl.Instance.Platform.SetKeepScreenOn(value);
}
}
private bool keepScreenOn;
public static void Save() { public static void Save() {
var file = GetOptionsFile(true); var file = GetOptionsFile(true);

View file

@ -9,5 +9,7 @@ namespace TouchyTickets {
public abstract void AddResourceEvent(bool sink, string currency, float amount, string itemType, string itemId); public abstract void AddResourceEvent(bool sink, string currency, float amount, string itemType, string itemId);
public abstract void SetKeepScreenOn(bool keep);
} }
} }

View file

@ -391,6 +391,13 @@ namespace TouchyTickets {
Options.Save(); Options.Save();
} }
}); });
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 20), Localization.Get("KeepScreenOn"), Options.Instance.KeepScreenOn) {
PositionOffset = new Vector2(0, 1),
OnCheckStateChange = (b, value) => {
Options.Instance.KeepScreenOn = value;
Options.Save();
}
});
this.uiSystem.Add("Options", optionsUi); this.uiSystem.Add("Options", optionsUi);
this.swipeRelations = new Element[] {optionsUi, upgradeUi, main, buyUi, modifierUi}; this.swipeRelations = new Element[] {optionsUi, upgradeUi, main, buyUi, modifierUi};