aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/util.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-04-18 23:34:29 +0200
committerWillem Jan Palenstijn2013-05-08 20:39:44 +0200
commit01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6 (patch)
tree544b07f3aa41abe7907bcd2040cdad11ebc324bb /engines/gob/util.cpp
parent9cf2c83e5e5a35816ab153bf8443dac691829ea8 (diff)
parenta41d72a44a660c72fdadbc3a8ef580e5e03cb890 (diff)
downloadscummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.gz
scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.bz2
scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.zip
Merge branch 'master'
Diffstat (limited to 'engines/gob/util.cpp')
-rw-r--r--engines/gob/util.cpp45
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;