diff options
author | Torbjörn Andersson | 2015-02-08 13:56:01 +0100 |
---|---|---|
committer | Torbjörn Andersson | 2015-02-08 13:56:01 +0100 |
commit | 8725f2cff2357049a3759f24e3fa530c25644e25 (patch) | |
tree | 7be1430462462ddee7c424386d4cfa8538f2b984 /engines/zvision/scripting/controls/input_control.cpp | |
parent | b7b4e9cc5899eff0810d97a848ace0fa2ede5548 (diff) | |
download | scummvm-rg350-8725f2cff2357049a3759f24e3fa530c25644e25.tar.gz scummvm-rg350-8725f2cff2357049a3759f24e3fa530c25644e25.tar.bz2 scummvm-rg350-8725f2cff2357049a3759f24e3fa530c25644e25.zip |
ZVISION: Limit input text to the width of the input control
This is to prevent the player from entering ridiculously long
savegame descriptions.
Diffstat (limited to 'engines/zvision/scripting/controls/input_control.cpp')
-rw-r--r-- | engines/zvision/scripting/controls/input_control.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index b25aa13543..20c8e7ccbc 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -110,6 +110,10 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } + + _maxTxtWidth = _textRectangle.width(); + if (_animation) + _maxTxtWidth -= _animation->getWidth(); } InputControl::~InputControl() { @@ -208,12 +212,20 @@ bool InputControl::process(uint32 deltaTimeInMillis) { Graphics::Surface txt; txt.copyFrom(*_background); + int32 oldTxtWidth = _txtWidth; + if (!_readOnly || !_focused) _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); else _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt); - _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); + if (_readOnly || _txtWidth <= _maxTxtWidth) + _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); + else { + // Assume the last character caused the overflow. + _currentInputText.deleteLastChar(); + _txtWidth = oldTxtWidth; + } txt.free(); } |