// Some variables we need to remember across different funtions. int _targetWidth, _targetHeight, _targetX, _targetY; // Some constant values. readonly int kFontSize = 9; readonly int kLineLength = 30; readonly int kPadding = 9; // Tweens the display GUI so we don't have to copy and paste the code. function _tweenDisplay(int transparency, int toX, int toY, int toWidth, int toHeight, TweenEasingType easing) { float delay = 0.0; if(transparency > 50) { delay = 0.4; } gDisplay.StopAllTweens(); WaitForLongest( gDisplay.TweenTransparency(0.1, transparency, eEaseLinearTween, eNoBlockTween, delay), gDisplay.TweenPosition(0.5, toX, toY, easing, eNoBlockTween), gDisplay.TweenSize(0.5, toWidth, toHeight, easing, eNoBlockTween) ); } // Uses the message length to resize the GUI and Label properly. function _reflow(int length) { _targetWidth = 1; _targetHeight = (kFontSize - 1); if (length < kLineLength) { _targetWidth = length * kFontSize; } else { _targetWidth = kLineLength * kFontSize; while (length > kLineLength) { _targetHeight += (kFontSize - 2); length -= kLineLength; } } lblDisplay.X = kPadding; lblDisplay.Width = _targetWidth; lblDisplay.Height = _targetHeight; _targetWidth += (kPadding * 2); _targetHeight += (kPadding * 2); lblDisplay.Y = _targetHeight; _targetX = GetScreenWidth() / 2 - _targetWidth / 2; _targetY = GetScreenHeight() / 2 - _targetHeight / 2; } function noloopcheck Display2(String message) { // Init _reflow(message.Length); gDisplay.Width = 1; gDisplay.Height = 1; gDisplay.X = GetScreenWidth() / 2; gDisplay.Y = GetScreenHeight() - 1; gDisplay.Transparency = 100; lblDisplay.Text = message; gDisplay.Visible = true; lblDisplay.Visible = false; // Tween In bool wasButtonDown = Mouse.IsButtonDown(eMouseLeft); lblDisplay.StopAllTweens(); Tween.IncreaseGameSpeed(); _tweenDisplay(0, _targetX, _targetY, _targetWidth, _targetHeight, eEaseOutBackTween); lblDisplay.Visible = true; lblDisplay.TweenY(0.3, kPadding, eEaseOutSineTween, eBlockTween); // Remember mouse mode, change it, and wait for input if (game.skip_display == eSkipTime) { WaitSeconds(IntToFloat(message.Length)/IntToFloat(Game.TextReadingSpeed)); } else { CursorMode previousMode = mouse.Mode; mouse.Mode = eModeWait; mouse.ChangeModeGraphic(eModeWait, mouse.GetModeGraphic(eModePointer)); while(!Mouse.IsButtonDown(eMouseLeft) || wasButtonDown) { if(!Mouse.IsButtonDown(eMouseLeft)) { wasButtonDown = false; } Wait(1); } mouse.UseDefaultGraphic(); mouse.Mode = previousMode; } // Tween Out lblDisplay.TweenY(0.3, -lblDisplay.Height, eEaseInSineTween, eBlockTween); lblDisplay.Visible = false; _tweenDisplay(100, GetScreenWidth() / 2, -1, 1, 1, eEaseInBackTween); gDisplay.Visible = false; Tween.RestoreGameSpeed(); }