public override void HandleInput(Scene scene) { TextParameters parameters = new TextParameters().SetColor(Color.White, Color.Black).SetConstraints(Width - 16 - 16, int.MaxValue); int textHeight = FontUtil.GetStringHeight(Text(), parameters); if (scene.InputState.IsKeyPressed(Keys.Enter)) { Close(); } if (scene.InputState.IsKeyPressed(Keys.Escape)) { Close(); } if (scene.InputState.IsKeyPressed(Keys.W, 10, 1)) { Scroll -= 3; } if (scene.InputState.IsKeyPressed(Keys.S, 10, 1)) { Scroll += 3; } if (scene.InputState.IsMouseWheelUp()) { Scroll -= 6; } if (scene.InputState.IsMouseWheelDown()) { Scroll += 6; } Scroll = MathHelper.Clamp(Scroll, 0, textHeight - Height + 8); base.HandleInput(scene); }
public override void Draw(SceneGame scene, DrawPass pass) { var calcParams = new TextParameters().SetColor(FontColor, BorderColor).SetConstraints(128, 64); string fit = FontUtil.FitString(Game.ConvertToSmallPixelText(Text), calcParams); var width = FontUtil.GetStringWidth(fit, calcParams); var height = FontUtil.GetStringHeight(fit); scene.DrawText(fit, Position + Offset - new Vector2(128, height) / 2, Alignment.Center, new TextParameters().SetColor(FontColor, BorderColor).SetConstraints(128, height + 64)); }