From 76ea1fbb6493cdefcb7bdc2bf1112fc7cff6f108 Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Tue, 15 Sep 2009 20:08:28 +0000 Subject: implemented proper dialog positioning svn-id: r44108 --- engines/teenagent/dialog.cpp | 4 ++++ engines/teenagent/scene.cpp | 50 ++++++++++++++++++++++++++--------------- engines/teenagent/scene.h | 2 +- engines/teenagent/surface.cpp | 4 ++-- engines/teenagent/teenagent.cpp | 1 + 5 files changed, 40 insertions(+), 21 deletions(-) (limited to 'engines/teenagent') diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp index 302080fb48..14729d8b60 100644 --- a/engines/teenagent/dialog.cpp +++ b/engines/teenagent/dialog.cpp @@ -98,6 +98,10 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation SceneEvent e(SceneEvent::Message); e.message = message; e.color = color; + if (animation1 != 0 && color == color1) + e.lan = slot1; + if (animation2 != 0 && color == color2) + e.lan = slot2; scene->push(e); message.clear(); } diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index f2d7709336..4d0963f48d 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -382,7 +382,7 @@ bool Scene::render(OSystem *system) { } else busy = true; } else - teenagent.render(surface, position, orientation, 0); + actor_animation_position = teenagent.render(surface, position, orientation, 0); } else { actor_animation_position = mark->render(surface); busy = true; @@ -480,21 +480,36 @@ bool Scene::processEventQueue() { break; case SceneEvent::CreditsMessage: - case SceneEvent::Message: - //debug(0, "pop(%04x)", current_event.message); - message = current_event.message; - message_pos = messagePosition(message, position); - message_color = current_event.color; + case SceneEvent::Message: { + message = current_event.message; + Common::Point p( + (actor_animation_position.left + actor_animation_position.right) / 2, + actor_animation_position.top + ); + //FIXME: rewrite it: + if (current_event.lan < 4) { + const Surface * s = custom_animation[current_event.lan].currentFrame(0); + if (s == NULL) + s = animation[current_event.lan].currentFrame(0); + if (s != NULL) { + p.x = s->x + s->w / 2; + p.y = s->y; + } else + warning("no animation in slot %u", current_event.lan); + } + message_pos = messagePosition(message, p); + message_color = current_event.color; + } break; case SceneEvent::PlayAnimation: - debug(0, "playing animation %u", current_event.animation); + debug(0, "playing animation %u in slot %u", current_event.animation, current_event.lan & 3); playAnimation(current_event.lan & 0x3, current_event.animation, (current_event.lan & 0x80) != 0, (current_event.lan & 0x40) != 0); current_event.clear(); break; case SceneEvent::PauseAnimation: - debug(0, "pause animation in slot %u", current_event.color & 3); + debug(0, "pause animation in slot %u", current_event.lan & 3); custom_animation[current_event.lan & 3].paused = (current_event.lan & 0x80) != 0; current_event.clear(); break; @@ -582,18 +597,17 @@ Object *Scene::getObject(int id, int scene_id) { return obj; } -Common::Point Scene::messagePosition(const Common::String &str, const Common::Point &position) { +Common::Point Scene::messagePosition(const Common::String &str, Common::Point position) { Resources *res = Resources::instance(); uint w = res->font7.render(NULL, 0, 0, str); - Common::Point message_pos = position; - message_pos.x -= w / 2; - message_pos.y -= 62; - if (message_pos.x + w > 320) - message_pos.x = 320 - w; - if (message_pos.x < 0) - message_pos.x = 0; - - return message_pos; + position.x -= w / 2; + position.y -= res->font7.height + 3; + if (position.x + w > 320) + position.x = 320 - w; + if (position.x < 0) + position.x = 0; + + return position; } void Scene::displayMessage(const Common::String &str, byte color) { diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h index 36934019c5..3bff7cac1a 100644 --- a/engines/teenagent/scene.h +++ b/engines/teenagent/scene.h @@ -130,7 +130,7 @@ private: byte palette[768]; void setPalette(OSystem *system, const byte *palette, unsigned mul = 1); - static Common::Point messagePosition(const Common::String &str, const Common::Point &position); + static Common::Point messagePosition(const Common::String &str, Common::Point position); bool processEventQueue(); inline bool nextEvent() { diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 9bde604b8f..62bc033a20 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -76,8 +76,8 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) { } Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror) { - assert(x + w <= surface->w); - assert(y + h <= surface->h); + assert(x + dx + w <= surface->w); + assert(y + dy + h <= surface->h); byte *src = (byte *)pixels; byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y); diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index 87c172d95a..a1b0be0d80 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -338,6 +338,7 @@ void TeenAgentEngine::displayMessage(const Common::String &str, byte color) { SceneEvent event(SceneEvent::Message); event.message = str; event.color = color; + event.lan = 4; scene->push(event); } -- cgit v1.2.3