diff options
Diffstat (limited to 'engines/wage/entities.cpp')
-rw-r--r-- | engines/wage/entities.cpp | 99 |
1 files changed, 38 insertions, 61 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index d9e4b60591..90247a5b21 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -8,12 +8,12 @@ * 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. @@ -48,10 +48,13 @@ #include "wage/wage.h" #include "wage/entities.h" #include "wage/design.h" +#include "wage/gui.h" #include "wage/script.h" #include "wage/world.h" #include "common/memstream.h" +#include "graphics/managed_surface.h" +#include "graphics/macgui/macfontmanager.h" namespace Wage { @@ -79,11 +82,12 @@ Context::Context() { } Scene::Scene() { + _resourceId = 0; + _script = NULL; _design = NULL; _textBounds = NULL; - _fontSize = 0; - _fontType = 0; + _font = NULL; for (int i = 0; i < 4; i++) _blocked[i] = false; @@ -97,14 +101,17 @@ Scene::Scene() { } Scene::Scene(Common::String name, Common::SeekableReadStream *data) { + debug(9, "Creating scene: %s", name.c_str()); + _name = name; _classType = SCENE; _design = new Design(data); + _resourceId = 0; + _script = NULL; _textBounds = NULL; - _fontSize = 0; - _fontType = 0; + _font = NULL; setDesignBounds(readRect(data)); _worldY = data->readSint16BE(); @@ -130,78 +137,45 @@ Scene::Scene(Common::String name, Common::SeekableReadStream *data) { Scene::~Scene() { delete _script; delete _textBounds; + delete _font; } -void Scene::paint(Graphics::Surface *surface, int x, int y) { +void Scene::paint(Graphics::ManagedSurface *surface, int x, int y) { Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10); surface->fillRect(r, kColorWhite); - _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y); + _design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y); for (ObjList::const_iterator it = _objs.begin(); it != _objs.end(); ++it) { - debug(2, "paining Obj: %s", (*it)->_name.c_str()); - (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y); + debug(2, "painting Obj: %s, index: %d, type: %d", (*it)->_name.c_str(), (*it)->_index, (*it)->_type); + (*it)->_design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y); } for (ChrList::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) { - debug(2, "paining Chr: %s", (*it)->_name.c_str()); - (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y); + debug(2, "painting Chr: %s", (*it)->_name.c_str()); + (*it)->_design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y); } } -// Source: Apple IIGS Technical Note #41, "Font Family Numbers" -// http://apple2.boldt.ca/?page=til/tn.iigs.041 -static const char *const fontNames[] = { - "Chicago", // system font - "Geneva", // application font - "New York", - "Geneva", - - "Monaco", - "Venice", - "London", - "Athens", - - "San Francisco", - "Toronto", - NULL, - "Cairo", - "Los Angeles", // 12 - - "Zapf Dingbats", - "Bookman", - "Helvetica Narrow", - "Palatino", - NULL, - "Zapf Chancery", - NULL, - - "Times", // 20 - "Helvetica", - "Courier", - "Symbol", - "Taliesin", // mobile? - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, // 30 - NULL, - NULL, - "Avant Garde", - "New Century Schoolbook" -}; - -const char *Scene::getFontName() { - if (_fontType >= 0 && _fontType < ARRAYSIZE(fontNames) && fontNames[_fontType] != NULL) { - return fontNames[_fontType]; +Designed *Scene::lookUpEntity(int x, int y) { + for (ObjList::const_iterator it = _objs.end(); it != _objs.begin(); ) { + it--; + if ((*it)->_design->isPointOpaque(x, y)) + return *it; + } + + for (ChrList::const_iterator it = _chrs.end(); it != _chrs.begin(); ) { + it--; + if ((*it)->_design->isPointOpaque(x, y)) + return *it; } - return "Unknown"; + + return nullptr; } Obj::Obj() : _currentOwner(NULL), _currentScene(NULL) { _index = 0; + _resourceId = 0; _namePlural = false; _value = 0; _attackType = 0; @@ -212,7 +186,9 @@ Obj::Obj() : _currentOwner(NULL), _currentScene(NULL) { _damage = 0; } -Obj::Obj(Common::String name, Common::SeekableReadStream *data) { +Obj::Obj(Common::String name, Common::SeekableReadStream *data, int resourceId) { + _resourceId = resourceId; + _name = name; _classType = OBJ; _currentOwner = NULL; @@ -303,6 +279,7 @@ Chr::Chr(Common::String name, Common::SeekableReadStream *data) { _design = new Design(data); _index = 0; + _resourceId = 0; _currentScene = NULL; setDesignBounds(readRect(data)); |