diff options
author | Vladimir Menshakov | 2009-11-08 19:11:57 +0000 |
---|---|---|
committer | Vladimir Menshakov | 2009-11-08 19:11:57 +0000 |
commit | c1b1d42b8740f31cc0dbb1a11e934d6db9de08b5 (patch) | |
tree | bd31e0aaac8a432e04a4987e350079aff948d2f4 /engines/teenagent | |
parent | 778e1830bb10256b87d1a029326c23462a69b9f7 (diff) | |
download | scummvm-rg350-c1b1d42b8740f31cc0dbb1a11e934d6db9de08b5.tar.gz scummvm-rg350-c1b1d42b8740f31cc0dbb1a11e934d6db9de08b5.tar.bz2 scummvm-rg350-c1b1d42b8740f31cc0dbb1a11e934d6db9de08b5.zip |
removed font::color, added debugger console with enable_object/disable_object commands.
svn-id: r45755
Diffstat (limited to 'engines/teenagent')
-rw-r--r-- | engines/teenagent/console.cpp | 64 | ||||
-rw-r--r-- | engines/teenagent/console.h | 46 | ||||
-rw-r--r-- | engines/teenagent/font.cpp | 10 | ||||
-rw-r--r-- | engines/teenagent/font.h | 6 | ||||
-rw-r--r-- | engines/teenagent/inventory.cpp | 4 | ||||
-rw-r--r-- | engines/teenagent/module.mk | 1 | ||||
-rw-r--r-- | engines/teenagent/scene.cpp | 43 | ||||
-rw-r--r-- | engines/teenagent/scene.h | 3 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 21 | ||||
-rw-r--r-- | engines/teenagent/teenagent.h | 3 |
10 files changed, 166 insertions, 35 deletions
diff --git a/engines/teenagent/console.cpp b/engines/teenagent/console.cpp new file mode 100644 index 0000000000..21fb834ce0 --- /dev/null +++ b/engines/teenagent/console.cpp @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#include "teenagent/console.h" +#include "teenagent/teenagent.h" + +namespace TeenAgent { + +Console::Console(TeenAgentEngine *engine) : _engine(engine) { + DCmd_Register("enable_object", WRAP_METHOD(Console, enableObject)); + DCmd_Register("disable_object", WRAP_METHOD(Console, enableObject)); +} + +bool Console::enableObject(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("usage: %s object_id [scene_id]\n", argv[0]); + return true; + } + + int id = atoi(argv[1]); + if (id < 0) { + DebugPrintf("object id %d is invalid\n", id); + return true; + } + + int scene_id = 0; + if (argc > 2) { + scene_id = atoi(argv[2]); + if (scene_id < 0) { + DebugPrintf("scene id %d is invalid\n", scene_id); + return true; + } + } + + if (strcmp(argv[0], "disable_object") == 0) + _engine->disableObject(id, scene_id); + else + _engine->enableObject(id, scene_id); + + return true; +} + +} diff --git a/engines/teenagent/console.h b/engines/teenagent/console.h new file mode 100644 index 0000000000..83a21f223f --- /dev/null +++ b/engines/teenagent/console.h @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef TEENAGENT_DIALOG_H +#define TEENAGENT_DIALOG_H + +#include "gui/debugger.h" + +namespace TeenAgent { + +class TeenAgentEngine; + +class Console : public GUI::Debugger { +public: + Console(TeenAgentEngine *engine); + +private: + bool enableObject(int argc, const char **argv); + + TeenAgentEngine *_engine; +}; + +} // End of namespace TeenAgent + +#endif diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp index da50469e62..68c6c3f0c2 100644 --- a/engines/teenagent/font.cpp +++ b/engines/teenagent/font.cpp @@ -27,7 +27,7 @@ namespace TeenAgent { -Font::Font() : grid_color(0xd0), color(0xd1), shadow_color(0), height(0), width_pack(0), data(0) { +Font::Font() : grid_color(0xd0), shadow_color(0), height(0), width_pack(0), data(0) { } void Font::load(int id) { @@ -43,7 +43,7 @@ void Font::load(int id) { debug(0, "font size: %d", s->size()); } -uint Font::render(Graphics::Surface *surface, int x, int y, char c) { +uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color) { unsigned idx = (unsigned char)c; if (idx < 0x20 || idx >= 0x81) { debug(0, "unhandled char 0x%02x", idx); @@ -85,7 +85,7 @@ static uint find_in_str(const Common::String &str, char c, uint pos = 0) { return pos; } -uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String &str, bool show_grid) { +uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool show_grid) { if (surface != NULL) { uint max_w = render(NULL, 0, 0, str, false); if (show_grid) @@ -100,7 +100,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String uint w = render(NULL, 0, 0, line, false); int xp = x + (max_w - w) / 2; for (uint k = 0; k < line.size(); ++k) { - xp += render(surface, xp, y, line[k]); + xp += render(surface, xp, y, line[k], color); } y += height; @@ -119,7 +119,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String w = 0; continue; } - w += render(NULL, 0, 0, c); + w += render(NULL, 0, 0, c, color); } if (w > max_w) max_w = w; diff --git a/engines/teenagent/font.h b/engines/teenagent/font.h index cd2287a7b7..6961c21676 100644 --- a/engines/teenagent/font.h +++ b/engines/teenagent/font.h @@ -31,13 +31,13 @@ namespace TeenAgent { class Font { public: - byte grid_color, color, shadow_color; + byte grid_color, shadow_color; byte height, width_pack; Font(); void load(int id); - uint render(Graphics::Surface *surface, int x, int y, const Common::String &str, bool grid = false); - uint render(Graphics::Surface *surface, int x, int y, char c); + uint render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool grid = false); + uint render(Graphics::Surface *surface, int x, int y, char c, byte color); static void grid(Graphics::Surface *surface, int x, int y, int w, int h, byte color); ~Font(); diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index 69478ebeca..fb3c937932 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -273,8 +273,8 @@ void Inventory::Item::render(Inventory *inventory, InventoryObject *obj, Graphic name += obj->name; if (hovered) { - int w = res->font7.render(NULL, 0, 0, name, true); - res->font7.render(dst, (320 - w) / 2, 180, name, true); + int w = res->font7.render(NULL, 0, 0, name, 0xd1, true); + res->font7.render(dst, (320 - w) / 2, 180, name, 0xd1, true); } } diff --git a/engines/teenagent/module.mk b/engines/teenagent/module.mk index a8398ec5f1..d178266372 100644 --- a/engines/teenagent/module.mk +++ b/engines/teenagent/module.mk @@ -15,6 +15,7 @@ MODULE_OBJS := \ inventory.o \ objects.o \ music.o \ + console.o \ dialog.o # This module can be built as a plugin diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index a097fd3f13..2b5d603001 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -107,7 +107,13 @@ void Scene::init(TeenAgentEngine *engine, OSystem *system) { teenagent_idle.load(s, Animation::kTypeVaria); if (teenagent_idle.empty()) error("invalid mark animation"); - + + loadObjectData(); +} + +void Scene::loadObjectData() { + Resources *res = Resources::instance(); + //loading objects & walkboxes objects.resize(42); walkboxes.resize(42); @@ -298,8 +304,7 @@ bool Scene::processEvent(const Common::Event &event) { case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: if (!message.empty()) { - message.clear(); - message_timer = 0; + clearMessage(); nextEvent(); return true; } @@ -309,13 +314,11 @@ bool Scene::processEvent(const Common::Event &event) { if (event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_SPACE) { if (intro && event.kbd.keycode == Common::KEYCODE_ESCAPE) { intro = false; - message.clear(); - message_timer = 0; + clearMessage(); events.clear(); sounds.clear(); current_event.clear(); message_color = 0xd1; - Resources::instance()->font7.color = 0xd1; for (int i = 0; i < 4; ++i) custom_animation[i].free(); _engine->playMusic(4); @@ -324,8 +327,7 @@ bool Scene::processEvent(const Common::Event &event) { } if (!message.empty()) { - message.clear(); - message_timer = 0; + clearMessage(); nextEvent(); return true; } @@ -347,7 +349,7 @@ bool Scene::render(OSystem *system) { busy = processEventQueue(); if (!message.empty() && message_timer != 0) { if (--message_timer == 0) { - message.clear(); + clearMessage(); nextEvent(); continue; } @@ -357,12 +359,10 @@ bool Scene::render(OSystem *system) { system->fillScreen(0); Graphics::Surface *surface = system->lockScreen(); if (current_event.lan == 8) { - res->font8.color = current_event.color; res->font8.shadow_color = current_event.orientation; - res->font8.render(surface, current_event.dst.x, current_event.dst.y, message); + res->font8.render(surface, current_event.dst.x, current_event.dst.y, message, current_event.color); } else { - res->font7.color = 0xd1; - res->font7.render(surface, current_event.dst.x, current_event.dst.y, message); + res->font7.render(surface, current_event.dst.x, current_event.dst.y, message, 0xd1); } system->unlockScreen(); return true; @@ -380,7 +380,6 @@ bool Scene::render(OSystem *system) { } } - bool got_any_animation = false; for (byte i = 0; i < 4; ++i) { @@ -406,7 +405,7 @@ bool Scene::render(OSystem *system) { continue; } int index = a->currentIndex(); - //debug(0, "index = %d", index); + debug(0, "current index = %d", index); if (index == current_event.animation) { debug(0, "kWaitLanAnimationFrame(%d, %d) complete", current_event.color, current_event.animation); restart |= nextEvent(); @@ -485,8 +484,7 @@ bool Scene::render(OSystem *system) { } if (!message.empty()) { - res->font7.color = message_color; - res->font7.render(surface, message_pos.x, message_pos.y, message); + res->font7.render(surface, message_pos.x, message_pos.y, message, message_color); busy = true; } @@ -699,7 +697,7 @@ Object *Scene::getObject(int id, int scene_id) { Common::Point Scene::messagePosition(const Common::String &str, Common::Point position) { Resources *res = Resources::instance(); - uint w = res->font7.render(NULL, 0, 0, str); + uint w = res->font7.render(NULL, 0, 0, str, 0); uint h = res->font7.height + 3; position.x -= w / 2; @@ -741,8 +739,7 @@ void Scene::displayMessage(const Common::String &str, byte color) { } void Scene::clear() { - message.clear(); - message_timer = 0; + clearMessage(); events.clear(); current_event.clear(); for(int i = 0; i < 4; ++i) { @@ -751,4 +748,10 @@ void Scene::clear() { } } +void Scene::clearMessage() { + message.clear(); + message_timer = 0; + message_color = 0xd1; +} + } // End of namespace TeenAgent diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h index 7fcddcc608..ac599679d4 100644 --- a/engines/teenagent/scene.h +++ b/engines/teenagent/scene.h @@ -133,6 +133,8 @@ public: Object *getObject(int id, int scene_id = 0); Object *findObject(const Common::Point &point); + void loadObjectData(); + private: void loadOns(); void loadLans(); @@ -150,6 +152,7 @@ private: current_event.clear(); return processEventQueue(); } + void clearMessage(); TeenAgentEngine *_engine; OSystem *_system; diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index c074fb6ed2..9acb318314 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -30,10 +30,11 @@ #include "common/config-manager.h" #include "engines/advancedDetector.h" #include "sound/mixer.h" +#include "graphics/thumbnail.h" #include "teenagent/scene.h" #include "teenagent/objects.h" #include "teenagent/music.h" -#include "graphics/thumbnail.h" +#include "teenagent/console.h" namespace TeenAgent { @@ -193,6 +194,7 @@ Common::Error TeenAgentEngine::loadGameState(int slot) { int id = res->dseg.get_byte(0xB4F3); uint16 x = res->dseg.get_word(0x64AF), y = res->dseg.get_word(0x64B1); + scene->loadObjectData(); scene->init(id, Common::Point(x, y)); return Common::kNoError; } @@ -230,6 +232,7 @@ Common::Error TeenAgentEngine::run() { scene = new Scene; inventory = new Inventory; + console = new Console(this); scene->init(this, _system); inventory->init(this); @@ -277,6 +280,12 @@ Common::Error TeenAgentEngine::run() { //debug(0, "event"); switch (event.type) { + case Common::EVENT_KEYDOWN: + if ((event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'd') || + event.kbd.ascii == '~' || event.kbd.ascii == '#') { + console->attach(); + } + break; case Common::EVENT_LBUTTONDOWN: examine(event.mouse, current_object); break; @@ -316,8 +325,8 @@ Common::Error TeenAgentEngine::run() { if (current_object) name += current_object->name; - uint w = res->font7.render(NULL, 0, 0, name); - res->font7.render(surface, (320 - w) / 2, 180, name, true); + uint w = res->font7.render(NULL, 0, 0, name, 0xd1); + res->font7.render(surface, (320 - w) / 2, 180, name, 0xd1, true); if (current_object) { //current_object->rect.render(surface, 0x80); //current_object->actor_rect.render(surface, 0x81); @@ -331,6 +340,10 @@ Common::Error TeenAgentEngine::run() { _system->updateScreen(); + if (console->isAttached()) { + console->onFrame(); + } + uint32 dt = _system->getMillis() - t0; if (dt < 40) _system->delayMillis(40 - dt); @@ -392,7 +405,7 @@ void TeenAgentEngine::displayCredits(uint16 addr) { break; event.message += "\n"; } - int w = Resources::instance()->font8.render(NULL, 0, 0, event.message); + int w = Resources::instance()->font8.render(NULL, 0, 0, event.message, 0xd1); event.dst.x = (320 - w) / 2; scene->push(event); } diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h index b9cec2bfc7..85cbc2418e 100644 --- a/engines/teenagent/teenagent.h +++ b/engines/teenagent/teenagent.h @@ -39,6 +39,7 @@ namespace TeenAgent { struct Object; class Scene; class MusicPlayer; +class Console; class TeenAgentEngine: public Engine { public: @@ -97,6 +98,7 @@ public: Scene *scene; Inventory *inventory; MusicPlayer *music; + Console * console; void setMusic(byte id); @@ -107,7 +109,6 @@ private: Action action; Object *dst_object; - Audio::AudioStream *_musicStream; Audio::SoundHandle _musicHandle, _soundHandle; const ADGameDescription *_gameDescription; |