[Scummvm-cvs-logs] SF.net SVN: scummvm:[45755] scummvm/trunk/engines/teenagent

megath at users.sourceforge.net megath at users.sourceforge.net
Sun Nov 8 20:11:58 CET 2009


Revision: 45755
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45755&view=rev
Author:   megath
Date:     2009-11-08 19:11:57 +0000 (Sun, 08 Nov 2009)

Log Message:
-----------
removed font::color, added debugger console with enable_object/disable_object commands. 

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/font.cpp
    scummvm/trunk/engines/teenagent/font.h
    scummvm/trunk/engines/teenagent/inventory.cpp
    scummvm/trunk/engines/teenagent/module.mk
    scummvm/trunk/engines/teenagent/scene.cpp
    scummvm/trunk/engines/teenagent/scene.h
    scummvm/trunk/engines/teenagent/teenagent.cpp
    scummvm/trunk/engines/teenagent/teenagent.h

Added Paths:
-----------
    scummvm/trunk/engines/teenagent/console.cpp
    scummvm/trunk/engines/teenagent/console.h

Added: scummvm/trunk/engines/teenagent/console.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/console.cpp	                        (rev 0)
+++ scummvm/trunk/engines/teenagent/console.cpp	2009-11-08 19:11:57 UTC (rev 45755)
@@ -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;
+}
+
+}


Property changes on: scummvm/trunk/engines/teenagent/console.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/teenagent/console.h
===================================================================
--- scummvm/trunk/engines/teenagent/console.h	                        (rev 0)
+++ scummvm/trunk/engines/teenagent/console.h	2009-11-08 19:11:57 UTC (rev 45755)
@@ -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


Property changes on: scummvm/trunk/engines/teenagent/console.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/engines/teenagent/font.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/font.cpp	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/font.cpp	2009-11-08 19:11:57 UTC (rev 45755)
@@ -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 @@
 	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 @@
 	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 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 @@
 				w = 0;
 				continue;
 			}
-			w += render(NULL, 0, 0, c);
+			w += render(NULL, 0, 0, c, color);
 		}
 		if (w > max_w)
 			max_w = w;

Modified: scummvm/trunk/engines/teenagent/font.h
===================================================================
--- scummvm/trunk/engines/teenagent/font.h	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/font.h	2009-11-08 19:11:57 UTC (rev 45755)
@@ -31,13 +31,13 @@
 
 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();

Modified: scummvm/trunk/engines/teenagent/inventory.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/inventory.cpp	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/inventory.cpp	2009-11-08 19:11:57 UTC (rev 45755)
@@ -273,8 +273,8 @@
 	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);
 	}
 }
 

Modified: scummvm/trunk/engines/teenagent/module.mk
===================================================================
--- scummvm/trunk/engines/teenagent/module.mk	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/module.mk	2009-11-08 19:11:57 UTC (rev 45755)
@@ -15,6 +15,7 @@
 	inventory.o \
 	objects.o \
 	music.o \
+	console.o \
 	dialog.o 
 
 # This module can be built as a plugin

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-08 19:11:57 UTC (rev 45755)
@@ -107,7 +107,13 @@
 	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 @@
 	case Common::EVENT_LBUTTONDOWN:
 	case Common::EVENT_RBUTTONDOWN:
 		if (!message.empty()) {
-			message.clear();
-			message_timer = 0;
+			clearMessage();
 			nextEvent();
 			return true;
 		}
@@ -309,13 +314,11 @@
 		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 @@
 			}
 		
 			if (!message.empty()) {
-				message.clear();
-				message_timer = 0;
+				clearMessage();
 				nextEvent();
 				return true;
 			}
@@ -347,7 +349,7 @@
 		busy = processEventQueue();
 		if (!message.empty() && message_timer != 0) {
 			if (--message_timer == 0) {
-				message.clear();
+				clearMessage();
 				nextEvent();
 				continue;
 			}
@@ -357,12 +359,10 @@
 			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 got_any_animation = false;
 
 		for (byte i = 0; i < 4; ++i) {
@@ -406,7 +405,7 @@
 					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 @@
 		}
 
 		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 @@
 
 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::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::clearMessage() {
+	message.clear();
+	message_timer = 0;
+	message_color = 0xd1;
+}
+
 } // End of namespace TeenAgent

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/scene.h	2009-11-08 19:11:57 UTC (rev 45755)
@@ -133,6 +133,8 @@
 	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 @@
 		current_event.clear();
 		return processEventQueue();
 	}
+	void clearMessage();
 
 	TeenAgentEngine *_engine;
 	OSystem *_system;

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-08 19:11:57 UTC (rev 45755)
@@ -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 @@
 
 	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 @@
 
 	scene = new Scene;
 	inventory = new Inventory;
+	console = new Console(this);
 
 	scene->init(this, _system);
 	inventory->init(this);
@@ -277,6 +280,12 @@
 
 			//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 @@
 				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 @@
 
 		_system->updateScreen();
 
+		if (console->isAttached()) {
+			console->onFrame();
+		}
+
 		uint32 dt = _system->getMillis() - t0;
 		if (dt < 40)
 			_system->delayMillis(40 - dt);
@@ -392,7 +405,7 @@
 			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);
 }

Modified: scummvm/trunk/engines/teenagent/teenagent.h
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.h	2009-11-08 19:10:24 UTC (rev 45754)
+++ scummvm/trunk/engines/teenagent/teenagent.h	2009-11-08 19:11:57 UTC (rev 45755)
@@ -39,6 +39,7 @@
 struct Object;
 class Scene;
 class MusicPlayer;
+class Console;
 
 class TeenAgentEngine: public Engine {
 public:
@@ -97,6 +98,7 @@
 	Scene *scene;
 	Inventory *inventory;
 	MusicPlayer *music;
+	Console * console;
 
 	void setMusic(byte id);
 
@@ -107,7 +109,6 @@
 	Action action;
 	Object *dst_object;
 
-
 	Audio::AudioStream *_musicStream;
 	Audio::SoundHandle _musicHandle, _soundHandle;
 	const ADGameDescription *_gameDescription;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list