diff options
Diffstat (limited to 'engines/gob/util.cpp')
-rw-r--r-- | engines/gob/util.cpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 6d83745602..7f9c6131fd 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -20,6 +20,10 @@ * */ +#include "common/stream.h" +#include "common/events.h" + +#include "graphics/palette.h" #include "gob/gob.h" #include "gob/util.h" @@ -31,10 +35,6 @@ #include "gob/videoplayer.h" #include "gob/sound/sound.h" -#include "common/events.h" - -#include "graphics/palette.h" - namespace Gob { Util::Util(GobEngine *vm) : _vm(vm) { @@ -257,6 +257,18 @@ bool Util::checkKey(int16 &key) { return true; } +bool Util::keyPressed() { + int16 key = checkKey(); + if (key) + return true; + + int16 x, y; + MouseButtons buttons; + + getMouseState(&x, &y, &buttons); + return buttons != kMouseButtonsNone; +} + void Util::getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons) { Common::Point mouse = g_system->getEventManager()->getMousePos(); *pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX; @@ -518,6 +530,11 @@ void Util::deleteList(List *list) { } char *Util::setExtension(char *str, const char *ext) { + assert(str && ext); + + if (str[0] == '\0') + return str; + char *dot = strrchr(str, '.'); if (dot) *dot = '\0'; @@ -527,6 +544,9 @@ char *Util::setExtension(char *str, const char *ext) { } Common::String Util::setExtension(const Common::String &str, const Common::String &ext) { + if (str.empty()) + return str; + const char *dot = strrchr(str.c_str(), '.'); if (dot) return Common::String(str.c_str(), dot - str.c_str()) + ext; @@ -534,6 +554,23 @@ Common::String Util::setExtension(const Common::String &str, const Common::Strin return str + ext; } +Common::String Util::readString(Common::SeekableReadStream &stream, int n) { + Common::String str; + + char c; + while (n-- > 0) { + if ((c = stream.readByte()) == '\0') + break; + + str += c; + } + + if (n > 0) + stream.skip(n); + + return str; +} + /* NOT IMPLEMENTED */ void Util::checkJoystick() { _vm->_global->_useJoystick = 0; |