aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-07 09:40:11 +0000
committerVladimir Menshakov2009-11-07 09:40:11 +0000
commit5a22a255926b1d50975cbc65b3e4533dcb3b35f2 (patch)
tree7a006af0fc9510cb0e16cbd8c578ea9533a8a067 /engines/teenagent
parent71eae24902d18d1cd45eab7dce4a4f4612bfd780 (diff)
downloadscummvm-rg350-5a22a255926b1d50975cbc65b3e4533dcb3b35f2.tar.gz
scummvm-rg350-5a22a255926b1d50975cbc65b3e4533dcb3b35f2.tar.bz2
scummvm-rg350-5a22a255926b1d50975cbc65b3e4533dcb3b35f2.zip
added default delays for the messages
svn-id: r45719
Diffstat (limited to 'engines/teenagent')
-rw-r--r--engines/teenagent/scene.cpp27
-rw-r--r--engines/teenagent/scene.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 5d8ba85ea1..df0c3d6c2a 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -299,6 +299,7 @@ bool Scene::processEvent(const Common::Event &event) {
case Common::EVENT_RBUTTONDOWN:
if (!message.empty()) {
message.clear();
+ message_timer = 0;
nextEvent();
return true;
}
@@ -309,6 +310,7 @@ bool Scene::processEvent(const Common::Event &event) {
if (intro) {
intro = false;
message.clear();
+ message_timer = 0;
events.clear();
sounds.clear();
current_event.clear();
@@ -323,6 +325,7 @@ bool Scene::processEvent(const Common::Event &event) {
if (!message.empty()) {
message.clear();
+ message_timer = 0;
nextEvent();
return true;
}
@@ -342,6 +345,13 @@ bool Scene::render(OSystem *system) {
do {
restart = false;
busy = processEventQueue();
+ if (!message.empty() && message_timer != 0) {
+ if (--message_timer == 0) {
+ message.clear();
+ nextEvent();
+ continue;
+ }
+ }
if (current_event.type == SceneEvent::kCreditsMessage) {
system->fillScreen(0);
@@ -549,6 +559,7 @@ bool Scene::processEventQueue() {
case SceneEvent::kCreditsMessage:
case SceneEvent::kMessage: {
message = current_event.message;
+ message_timer = messageDuration(message);
Common::Point p(
(actor_animation_position.left + actor_animation_position.right) / 2,
actor_animation_position.top
@@ -677,16 +688,32 @@ Common::Point Scene::messagePosition(const Common::String &str, Common::Point po
return position;
}
+uint Scene::messageDuration(const Common::String &str) {
+ uint words = 1;
+ for(uint i = 0; i < str.size(); ++i) {
+ if (str[i] == ' ' || str[i] == '\n')
+ ++words;
+ }
+ words *= 7; //add text speed here
+ if (words < 15)
+ words = 15;
+
+ return words;
+}
+
+
void Scene::displayMessage(const Common::String &str, byte color) {
//assert(!str.empty());
//debug(0, "displayMessage: %s", str.c_str());
message = str;
message_pos = messagePosition(str, position);
message_color = color;
+ message_timer = messageDuration(message);
}
void Scene::clear() {
message.clear();
+ message_timer = 0;
events.clear();
current_event.clear();
for(int i = 0; i < 4; ++i) {
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index 6e115e63f7..b6e0b64d30 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -142,6 +142,7 @@ private:
byte palette[768];
void setPalette(OSystem *system, const byte *palette, unsigned mul = 1);
static Common::Point messagePosition(const Common::String &str, Common::Point position);
+ static uint messageDuration(const Common::String &str);
bool processEventQueue();
inline bool nextEvent() {
@@ -170,6 +171,7 @@ private:
Common::String message;
Common::Point message_pos;
byte message_color;
+ uint message_timer;
typedef Common::List<SceneEvent> EventList;
EventList events;