ActionParams.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <actions/ActionParams.h>
00022 #include <lua/LUAUtil.h>
00023 #include <XML/XMLNode.h>
00024 
00025 void FixedActionParam::copy(ActionParam *other)
00026 {
00027         value_ = ((FixedActionParam *) other)->value_;
00028 }
00029 
00030 bool FixedActionParam::parseXML(XMLNode *accessoryNode)
00031 {
00032         return accessoryNode->getNamedChild(name_.c_str(), value_);
00033 }
00034 
00035 void FixedActionParam::initLUA(lua_State *L, int position)
00036 {
00037         value_ = LUAUtil::getNumberFromTable(L, position, name_.c_str(), value_);
00038 }
00039 
00040 void FixedActionParam::initXML(ScorchedContext &context)
00041 {
00042         value_ = parser_.getValue(context);
00043 }
00044 
00045 ActionParams::ActionParams()
00046 {
00047 }
00048 
00049 bool ActionParams::parseXML(XMLNode *accessoryNode)
00050 {
00051         std::vector<ActionParam *>::iterator itor;
00052         for (itor = params_.begin();
00053                 itor != params_.end();
00054                 itor++)
00055         {
00056                 if (!(*itor)->parseXML(accessoryNode)) return false;
00057         }
00058 
00059         return true;
00060 }
00061 
00062 void ActionParams::initLUA(lua_State *L, int position)
00063 {
00064         luaL_checktype(L, position, LUA_TTABLE);
00065 
00066         std::vector<ActionParam *>::iterator itor;
00067         for (itor = params_.begin();
00068                 itor != params_.end();
00069                 itor++)
00070         {
00071                 (*itor)->initLUA(L, position);
00072         }
00073 }
00074 
00075 void ActionParams::initXML(ScorchedContext &context)
00076 {
00077         std::vector<ActionParam *>::iterator itor;
00078         for (itor = params_.begin();
00079                 itor != params_.end();
00080                 itor++)
00081         {
00082                 (*itor)->initXML(context);
00083         }
00084 }
00085 
00086 void ActionParams::copy(ActionParams &other)
00087 {
00088         for (unsigned int i=0; i<params_.size(); i++)
00089         {
00090                 params_[i]->copy(other.params_[i]);
00091         }
00092 }
00093 
00094 TestActionParams::TestActionParams()
00095 {
00096         FIXED_ACTION_PARAM_DEFN(testName, "testname", fixed(true, 10));
00097 }

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3