public void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } Text.Draw(spriteBatch, new Loc()); //when text is paused and waiting for input, flash a tick at the end TextPause textPause = getCurrentTextPause(); if (textPause != null && textPause.Time == 0) { //text needs a "GetTextProgress" method, which returns the end loc of the string as its currently shown. //the coordinates are relative to the string's position Loc loc = Text.GetTextProgress() + Text.Start; if ((GraphicsManager.TotalFrameTick / (ulong)FrameTick.FrameToTick(CURSOR_FLASH_TIME / 2)) % 2 == 0) { GraphicsManager.Cursor.DrawTile(spriteBatch, new Vector2(loc.X + 2, loc.Y), 0, 0); } } //draw down-tick if (HoldTime == -1 && CurrentFadeTime >= FADE_TIME && Text.Finished && (GraphicsManager.TotalFrameTick / (ulong)FrameTick.FrameToTick(CURSOR_FLASH_TIME / 2)) % 2 == 0) { Loc end = Text.GetTextProgress(); GraphicsManager.Cursor.DrawTile(spriteBatch, new Vector2(GraphicsManager.ScreenWidth / 2 - 5, GraphicsManager.ScreenHeight / 2 + end.Y + 16), 1, 0); } }
public override void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } base.Draw(spriteBatch); //when text is paused and waiting for input, flash a tick at the end TextPause textPause = getCurrentTextPause(); if (textPause != null && textPause.Time == 0) { //text needs a "GetTextProgress" method, which returns the end loc of the string as its currently shown. //the coordinates are relative to the string's position Loc loc = Text.GetTextProgress() + Text.Start; if ((GraphicsManager.TotalFrameTick / (ulong)FrameTick.FrameToTick(CURSOR_FLASH_TIME / 2)) % 2 == 0) { GraphicsManager.Cursor.DrawTile(spriteBatch, new Vector2(loc.X + 2, loc.Y), 0, 0); } } if (speakerPic != null) { speakerPic.Draw(spriteBatch, new Loc()); } }
public void Update(InputManager input) { if (!Text.Finished) { //if (input[FrameInput.InputType.Cancel] && (input.JustPressed(FrameInput.InputType.Confirm) || input.JustPressed(FrameInput.InputType.Start))) //{ // Text.CurrentCharIndex = Text.Text.Length; // CurrentTextTime = new FrameTick(); // Pauses.Clear(); //} //else //{ TextPause textPause = getCurrentTextPause(); bool continueText = false; if (textPause != null) { if (textPause.Time > 0) { continueText = CurrentTextTime >= textPause.Time; } else { continueText = (input.JustPressed(FrameInput.InputType.Confirm) || input[FrameInput.InputType.Cancel]); } } else { continueText = CurrentTextTime >= FrameTick.FromFrames(TEXT_TIME); } if (continueText) { CurrentTextTime = new FrameTick(); Text.CurrentCharIndex++; if (Sound && Text.CurrentCharIndex % 3 == 0) { GameManager.Instance.SE("Menu/Speak"); } if (textPause != null) //remove last text pause { Pauses.RemoveAt(0); } } //} } else { ProcessTextDone(input); } }
public TitleDialog(string message, bool fadeIn, int holdTime, Action action) { Visible = true; this.action = action; FadeIn = fadeIn; showing = true; if (!FadeIn) { CurrentFadeTime = FrameTick.FromFrames(FADE_TIME); } HoldTime = holdTime; //message will contain pauses, which get parsed here. //and colors, which will get parsed by the text renderer Pauses = new List <TextPause>(); int startIndex = 0; int tabIndex = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase); while (tabIndex > -1) { int endIndex = message.IndexOf("]", tabIndex); if (endIndex == -1) { break; } int param; if (Int32.TryParse(message.Substring(tabIndex + "[pause=".Length, endIndex - (tabIndex + "[pause=".Length)), out param)) { TextPause pause = new TextPause(); pause.LetterIndex = tabIndex; pause.Time = param; message = message.Remove(tabIndex, endIndex - tabIndex + "]".Length); Pauses.Add(pause); tabIndex = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase); } else { break; } } string newMessage = message; Text = new DialogueText(newMessage, new Loc(GraphicsManager.ScreenWidth / 2, GraphicsManager.ScreenHeight / 2), GraphicsManager.ScreenWidth, TEXT_SPACE, true, FadeIn ? -1 : 0); }
public DialogueBox(string message, bool sound) { Bounds = Rect.FromPoints(new Loc(SIDE_BUFFER, GraphicsManager.ScreenHeight - (16 + PER_LINE_SPACE * MAX_LINES)), new Loc(GraphicsManager.ScreenWidth - SIDE_BUFFER, GraphicsManager.ScreenHeight - 8)); Sound = sound; //message will contain pauses, which get parsed here. //and colors, which will get parsed by the text renderer Pauses = new List <TextPause>(); int startIndex = 0; int tabIndex = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase); while (tabIndex > -1) { int endIndex = message.IndexOf("]", tabIndex); if (endIndex == -1) { break; } int param; if (Int32.TryParse(message.Substring(tabIndex + "[pause=".Length, endIndex - (tabIndex + "[pause=".Length)), out param)) { TextPause pause = new TextPause(); pause.LetterIndex = tabIndex; pause.Time = param; message = message.Remove(tabIndex, endIndex - tabIndex + "]".Length); Pauses.Add(pause); tabIndex = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase); } else { break; } } string newMessage = message; Text = new DialogueText(newMessage, Bounds.Start + new Loc(GraphicsManager.MenuBG.TileWidth * 2, GraphicsManager.MenuBG.TileHeight), Bounds.End.X - GraphicsManager.MenuBG.TileWidth * 4 - Bounds.X, TEXT_SPACE, false, true); }
public void Update(InputManager input) { if (!showing || CurrentFadeTime < FADE_TIME) { if (!showing && CurrentFadeTime <= 0) { //close this MenuManager.Instance.RemoveMenu(); //do what it wants action(); } } else if (!Text.Finished) { TextPause textPause = getCurrentTextPause(); bool continueText = false; if (textPause != null) { if (textPause.Time > 0) { continueText = CurrentTextTime >= textPause.Time; } else { continueText = (input.JustPressed(FrameInput.InputType.Confirm)); } } else { continueText = CurrentTextTime >= FrameTick.FromFrames(TEXT_TIME); } if (continueText) { CurrentTextTime = new FrameTick(); Text.CurrentCharIndex++; if (textPause != null)//remove last text pause { Pauses.RemoveAt(0); } } } else { bool exit = false; if (HoldTime > -1) { if (CurrentTextTime >= HoldTime) { exit = true; } } else { if (input.JustPressed(FrameInput.InputType.Confirm) || input[FrameInput.InputType.Cancel]) { exit = true; } } if (exit) { if (FadeIn) { showing = false; } else { //close this MenuManager.Instance.RemoveMenu(); //do what it wants action(); } } } }