diff --git a/Demos/UiDemo.cs b/Demos/UiDemo.cs index 152e72b..c1fb57a 100644 --- a/Demos/UiDemo.cs +++ b/Demos/UiDemo.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text.RegularExpressions; using Coroutine; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -96,17 +95,18 @@ namespace Demos { // adding some custom image formatting codes // note that all added formatting codes need to be lowercase, while their casing doesn't matter when used - TextFormatting.FormattingCodes[new Regex("grass")] = (m, i) => new FormattingCode(i, image.Texture); - TextFormatting.FormattingCodes[new Regex("tree")] = (m, i) => new FormattingCode(i, tree); + TextFormatting.FormattingCodes["grass"] = new FormattingCode(image.Texture); + TextFormatting.FormattingCodes["tree"] = new FormattingCode(tree); // formatting codes can also be sprite animations! var atlas = new UniformTextureAtlas(LoadContent("Textures/Anim"), 4, 4); - TextFormatting.FormattingCodes[new Regex("walk")] = (m, i) => new FormattingCode(i, new SpriteAnimation(0.2F, atlas[0, 0], atlas[0, 1], atlas[0, 2], atlas[0, 3])); + TextFormatting.FormattingCodes["walk"] = new FormattingCode(new SpriteAnimation(0.2F, atlas[0, 0], atlas[0, 1], atlas[0, 2], atlas[0, 3])); root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Additionally, you can create custom formatting codes that contain [Grass] images or [Walk] sprite animations! Note that these images have to be square, or [Tree] bad things happen.")); var animatedPar = root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Defining text animations as formatting codes is also possible, including [Wobbly]wobbly text[Unanimated] as well as a [Typing]dialogue-esc typing effect by default. Of course, more animations can be added though.")); root.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), "Reset Typing Animation") { - OnPressed = e => animatedPar.FormattingCodes.Reset() + // to reset any animation, simply change the paragraph's TimeIntoAnimation + OnPressed = e => animatedPar.TimeIntoAnimation = TimeSpan.Zero }); root.AddChild(new VerticalSpace(3));