00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }