added news ticker
This commit is contained in:
parent
c1ebdac51b
commit
50768791da
6 changed files with 62 additions and 22 deletions
|
@ -43,3 +43,6 @@
|
||||||
#begin Localization/Localization.json
|
#begin Localization/Localization.json
|
||||||
/copy:Localization/Localization.json
|
/copy:Localization/Localization.json
|
||||||
|
|
||||||
|
#begin Localization/News.json
|
||||||
|
/copy:Localization/News.json
|
||||||
|
|
||||||
|
|
|
@ -44,5 +44,5 @@
|
||||||
"ManualRideModifier": "Push and Shove",
|
"ManualRideModifier": "Push and Shove",
|
||||||
"ManualRideModifierDescription": "Increases the amount of people allowed on manual (walking-based) rides, tripling their ticket sales.",
|
"ManualRideModifierDescription": "Increases the amount of people allowed on manual (walking-based) rides, tripling their ticket sales.",
|
||||||
"SpiralSlideModifier": "Sightseeing",
|
"SpiralSlideModifier": "Sightseeing",
|
||||||
"SpiralSlideModifierDescription": "Spiral slide visitors are given binoculars to look at adjacent rides, doubling their ticket sales."
|
"SpiralSlideModifierDescription": "New binoculars allow spiral slide visitors to check out adjacent rides whose ticket sales are doubled as a result."
|
||||||
}
|
}
|
23
TouchyTickets/Content/Localization/News.json
Normal file
23
TouchyTickets/Content/Localization/News.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[
|
||||||
|
"Carousel 7 broke down, but there is no mechanic available",
|
||||||
|
"Popular park now features \"buy seventeen, get one free\" ticket sale",
|
||||||
|
"Speed of ferris wheel set too high, causing whiplash",
|
||||||
|
"New park constructs never-before-seen \"log flume\" ride",
|
||||||
|
"Visitors allegedly getting lost in park due to too many paths that lead nowhere",
|
||||||
|
"Performance artist locks themselves in ferris wheel pod for eight weeks",
|
||||||
|
"Newspaper declares log flume high risk ride due to \"too many splinters\"",
|
||||||
|
"Newspaper declares log flume high risk ride due to them being \"too wet\"",
|
||||||
|
"Children excited by food stalls, saying \"soda soda soda soda soda\"",
|
||||||
|
"Ride ran in reverse accidentally, making passengers younger",
|
||||||
|
"Cotton candy reported missing after log flume ride",
|
||||||
|
"Umbrellas sold at half price due to passengers throwing up onto parkgoers",
|
||||||
|
"75% of population's colds caused by log flumes, scientists say",
|
||||||
|
"Height limit lifted for wooden coaster, making children happy",
|
||||||
|
"Pants in high demand at gift shop, allegedly due to house of horrors",
|
||||||
|
"Violinist linked to coaster crash blossoms",
|
||||||
|
"Log flume photos terrible due to water on lens",
|
||||||
|
"Park visitor out of money, starts selling souvenirs to continue riding",
|
||||||
|
"Uncomortable benches at food court causing visitors to eat lunch in bumper cars",
|
||||||
|
"Carousel \"too scary\" according to four year old child",
|
||||||
|
"Tall person mistaken for park performer on stilts"
|
||||||
|
]
|
|
@ -3,35 +3,38 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
using MLEM.Startup;
|
using MLEM.Startup;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TouchyTickets {
|
namespace TouchyTickets {
|
||||||
public static class Localization {
|
public static class Localization {
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> Strings;
|
private static readonly Dictionary<string, string> Strings = LoadLocalized<Dictionary<string, string>>("Localization");
|
||||||
|
private static readonly List<string> News = LoadLocalized<List<string>>("News");
|
||||||
static Localization() {
|
private static readonly Random Random = new Random();
|
||||||
var location = GameImpl.Instance.Content.RootDirectory + "/Localization/Localization";
|
|
||||||
var culture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
|
|
||||||
foreach (var path in new[] {$"{location}.{culture}.json", $"{location}.json"}) {
|
|
||||||
try {
|
|
||||||
using (var reader = new JsonTextReader(new StreamReader(TitleContainer.OpenStream(path)))) {
|
|
||||||
var ret = SaveHandler.Serializer.Deserialize<Dictionary<string, string>>(reader);
|
|
||||||
if (ret == null)
|
|
||||||
continue;
|
|
||||||
Strings = ret;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Exception) {
|
|
||||||
// move on to the next path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string Get(string key) {
|
public static string Get(string key) {
|
||||||
return Strings.TryGetValue(key, out var ret) ? ret : $"?{key}?";
|
return Strings.TryGetValue(key, out var ret) ? ret : $"?{key}?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetRandomNews() {
|
||||||
|
return News[Random.Next(News.Count)];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static T LoadLocalized<T>(string name) {
|
||||||
|
var location = GameImpl.Instance.Content.RootDirectory + "/Localization/" + name;
|
||||||
|
var culture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
|
||||||
|
foreach (var path in new[] {$"{location}.{culture}.json", $"{location}.json"}) {
|
||||||
|
try {
|
||||||
|
using (var reader = new JsonTextReader(new StreamReader(TitleContainer.OpenStream(path))))
|
||||||
|
return SaveHandler.Serializer.Deserialize<T>(reader);
|
||||||
|
} catch (Exception) {
|
||||||
|
// move on to the next path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ContentLoadException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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-199" />
|
<PackageReference Include="MLEM.Startup" Version="3.3.3-200" />
|
||||||
<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>
|
||||||
|
|
|
@ -57,6 +57,17 @@ namespace TouchyTickets {
|
||||||
ticket.Draw(batch, e.DisplayArea.Size, e.Scale, Color.White * alpha);
|
ticket.Draw(batch, e.DisplayArea.Size, e.Scale, Color.White * alpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var currentNews = Localization.GetRandomNews();
|
||||||
|
var newsTicker = main.AddChild(new Panel(Anchor.AutoCenter, new Vector2(1, 0.05F), Vector2.Zero));
|
||||||
|
newsTicker.AddChild(new Paragraph(Anchor.CenterLeft, float.MaxValue, p => currentNews, true) {
|
||||||
|
OnUpdated = (e, time) => {
|
||||||
|
e.PositionOffset -= new Vector2(1, 0);
|
||||||
|
if (e.PositionOffset.X <= -e.DisplayArea.Width / e.Scale - 20) {
|
||||||
|
e.PositionOffset = new Vector2(e.Parent.DisplayArea.Width / e.Scale + 20, 0);
|
||||||
|
currentNews = Localization.GetRandomNews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
var ticketGroup = main.AddChild(new Group(Anchor.AutoCenter, new Vector2(1, 0.15F), false));
|
var ticketGroup = main.AddChild(new Group(Anchor.AutoCenter, new Vector2(1, 0.15F), false));
|
||||||
ticketGroup.AddChild(new Paragraph(Anchor.AutoCenter, 10000, p => PrettyPrintNumber(GameImpl.Instance.Tickets) + "<i ticket>", true) {
|
ticketGroup.AddChild(new Paragraph(Anchor.AutoCenter, 10000, p => PrettyPrintNumber(GameImpl.Instance.Tickets) + "<i ticket>", true) {
|
||||||
TextScale = 0.3F
|
TextScale = 0.3F
|
||||||
|
@ -66,7 +77,7 @@ namespace TouchyTickets {
|
||||||
});
|
});
|
||||||
BigInteger lastTickets = 0;
|
BigInteger lastTickets = 0;
|
||||||
ActiveCoroutine storeWobble = null;
|
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.45F), 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;
|
||||||
|
|
Loading…
Reference in a new issue