ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

anim_component.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/grim/objectstate.h"
00024 #include "engines/grim/grim.h"
00025 #include "engines/grim/debug.h"
00026 #include "engines/grim/set.h"
00027 
00028 #include "engines/grim/costume/anim_component.h"
00029 
00030 namespace Grim {
00031 
00032 
00033 AnimComponent::AnimComponent(Component *p, int parentID, const char *filename, tag32 t) :
00034         Component(p, parentID, filename, t) {
00035     _overlay = false;
00036     _created = false;
00037     const char *comma = strchr(filename, ',');
00038     if (comma) {
00039         _name = Common::String(filename, comma);
00040         _overlay = atoi(comma + 1) == 1;
00041     }
00042 }
00043 
00044 void AnimComponent::setKey(int val) {
00045     ObjectState *state = g_grim->getCurrSet()->findState(_name);
00046 
00047     if (!state) {
00048         Set *set = g_grim->getCurrSet();
00049         state = set->addObjectState(set->getSetup(), (_overlay ? ObjectState::OBJSTATE_OVERLAY : ObjectState::OBJSTATE_UNDERLAY),
00050                                     _name.c_str(), nullptr, false);
00051     }
00052     _created = true;
00053 
00054     if (state) {
00055         state->setActiveImage(val);
00056         return;
00057     }
00058     // Complain that we couldn't find the bitmap.  This means we probably
00059     // didn't handle something correctly.  Example: Before the tube-switcher
00060     // bitmaps were not loading with the scene. This was because they were requested
00061     // as a different case then they were stored (tu_0_dorcu_door_open versus
00062     // TU_0_DORCU_door_open), which was causing problems in the string comparison.
00063     Debug::warning(Debug::Bitmaps | Debug::Costumes, "Missing scene bitmap: %s", _name.c_str());
00064 
00065 /* In case you feel like drawing the missing bitmap anyway...
00066     // Assume that all objects the scene file forgot about are OBJSTATE_STATE class
00067     state = new ObjectState(0, ObjectState::OBJSTATE_STATE, bitmap, NULL, true);
00068     if (!state) {
00069         if (gDebugLevel == DEBUG_BITMAPS || gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
00070             warning("Couldn't find bitmap %s in current scene", _filename.c_str());
00071         return;
00072     }
00073     g_grim->getCurrSet()->addObjectState(state);
00074     state->setNumber(val);
00075 */
00076 }
00077 
00078 void AnimComponent::reset() {
00079     if (_created) {
00080         setKey(0);
00081     }
00082 }
00083 
00084 } // end of namespace Grim


Generated on Sat Nov 9 2019 05:00:27 for ResidualVM by doxygen 1.7.1
curved edge   curved edge