1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // CustomPropertyModel.cpp
- // cocos2d
- //
- // Created by ZhengSong on 2022/7/21.
- //
- #include "CustomPropertyModel.h"
- NS_CC_BEGIN
- CustomPropertyModel::CustomPropertyModel()
- :_isUseDefault(true)
- ,_type(0)
- {
-
- }
- bool CustomPropertyModel::init()
- {
- return true;
- }
- Value CustomPropertyModel::code()
- {
- ValueMap dict;
- dict["name"] = Value(_name);
- dict["type"] = Value(_type);
- dict["value"] = Value(_value);
- dict["override"] = Value(_isUseDefault);
- return Value(dict);
- }
- void CustomPropertyModel::decode(const Value& value)
- {
- const ValueMap& customProp = value.asValueMap();
- for(auto iter : customProp) {
- auto key = iter.first;
- if(key == "name")
- {
- _name = iter.second.asString();
- }
- else if (key == "type")
- {
- _type = iter.second.asInt();
- }
- else if (key == "value")
- {
- _value = iter.second;
- }
- else if (key == "override")
- {
- _isUseDefault = iter.second.asBool();
- }
- }
- }
- //获取属性
- bool CustomPropertyModel::isUseDefault()
- {
- return _isUseDefault;
- }
- void CustomPropertyModel::setIsUseDefault(bool isUse)
- {
- _isUseDefault = isUse;
- }
- int CustomPropertyModel::getType()
- {
- return _type;
- }
- void CustomPropertyModel::setType(int type)
- {
- _type = type;
- }
- const Value& CustomPropertyModel::getValue()
- {
- return _value;
- }
- void CustomPropertyModel::setValue(const Value& value)
- {
- _value = value;
- }
- const std::string& CustomPropertyModel::getName()
- {
- return _name;
- }
- void CustomPropertyModel::setName(const std::string &name)
- {
- _name = name;
- }
- NS_CC_END
|