// c'tor /// <summary> /// Simple c'tor using a blob to hold the common data. /// </summary> /// <param name="blob"></param> /// <param name="label"></param> public ModularMenu(UIGridElement.ParamBlob blob, string title) { this.title = TextHelper.FilterInvalidCharacters(title); if (this.title == "") { this.title = null; } // blob this.width = blob.width; this.height = blob.height; this.edgeSize = blob.edgeSize; this.normalMapName = blob.normalMapName; this.justify = blob.justify; itemList = new List <MenuItem>(); }
/// <summary> /// Activates scrollable text display. /// </summary> /// <param name="text">Text to display.</param> /// <param name="useBackgroundThumbnail">Should the game thumbnail be used as a backdrop when rendering?</param> /// <param name="useRtCoords">Should hit testing be adjusted for rendering to an RT?</param> /// <param name="scrubText">Should text be scrubbed through bad word filter?</param> public void Activate(GameActor thinker, string text, UIGridElement.Justification justification, bool useBackgroundThumbnail, bool useRtCoords, bool scrubText) { if (text == null) { return; } if (state != States.Active) { this.useBackgroundThumbnail = useBackgroundThumbnail; this.useRtCoords = useRtCoords; // Do stack handling here. If we do it in the update object we have no // clue which order things get pushed and popped and madness ensues. CommandStack.Push(commandMap); state = States.Active; // Get the current scene thumbnail. If we're using this from the main menu (options) // then use the title screen image instead. if (InGame.inGame.State == InGame.States.Inactive) { thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture; } else { thumbnail = InGame.inGame.SmallThumbNail; } // Tell InGame we're using the thumbnail so no need to do full render. prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail; if (!prevRenderWorldAsThumbnail) { InGame.inGame.RenderWorldAsThumbnail = true; } Time.Paused = true; HelpOverlay.Push(@"ScrollableTextDisplay"); // Get text string. if (thinker != null) { text = TextHelper.ApplyStringSubstitutions(text, thinker as GameActor); } rawText = text; text = TextHelper.RemoveTags(text); blob = new TextBlob(UI2D.Shared.GetGameFont20, text, textWidth); blob.Justification = justification; // By default TextBlob scrubs the text. If the scrubText is false // then set the text again via a path that doesn't do any scrub. if (!scrubText) { blob.RawTextNoScrub = text; } this.thinker = thinker; topLine = 0; textOffset = 0; // If a second button is needed, the text for it should be set after activation. textB = null; userHitA = true; PreRender(); // Set up text rendering for first frame. } } // end of Activate
/// <summary> /// Activates scrollable text display. /// </summary> /// <param name="text">Text to display.</param> /// <param name="useBackgroundThumbnail">Should the game thumbnail be used as a backdrop when rendering?</param> /// <param name="useRtCoords">Should hit testing be adjusted for rendering to an RT?</param> public void Activate(GameActor thinker, string text, UIGridElement.Justification justification, bool useBackgroundThumbnail, bool useRtCoords) { Activate(thinker, text, justification, useBackgroundThumbnail, useRtCoords, true); }
public void Activate(GameActor thinker, string text, UIGridElement.Justification justification, bool useBackgroundThumbnail, bool useRtCoords) { if (text == null) { return; } if (state != States.Active) { this.useBackgroundThumbnail = useBackgroundThumbnail; this.useRtCoords = useRtCoords; // Do stack handling here. If we do it in the update object we have no // clue which order things get pushed and popped and madness ensues. CommandStack.Push(commandMap); state = States.Active; // Get the current scene thumbnail. If we're using this from the main menu (options) // then use the title screen image instead. if (InGame.inGame.State == InGame.States.Inactive) { thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture; } else { thumbnail = InGame.inGame.SmallThumbNail; } // Tell InGame we're using the thumbnail so no need to do full render. prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail; if (!prevRenderWorldAsThumbnail) { InGame.inGame.RenderWorldAsThumbnail = true; } Time.Paused = true; HelpOverlay.Push(@"TextDisplay"); // Get text string. if (thinker != null) { text = TextHelper.ApplyStringSubstitutions(text, thinker as GameActor); } rawText = text; text = TextHelper.RemoveTags(text); blob = new TextBlob(Font, text, textWidth); blob.Justification = justification; this.thinker = thinker; // Render text into RT. RenderTarget2D rt = UI2D.Shared.RenderTarget512_512; InGame.SetRenderTarget(rt); InGame.Clear(Color.Transparent); Color greyTextColor = new Color(127, 127, 127); blob.RenderWithButtons(textPosition, greyTextColor); InGame.RestoreRenderTarget(); activationTime = Time.WallClockTotalSeconds; } } // end of Activate