|
My Project
|
it represents an attribute object associated with an object. More...
#include <ParaScriptingGlobal.h>
Public Member Functions | |
| ParaAttributeObject (IAttributeFields *pAttribute, CAttributeClass *pAttClass) | |
| ParaAttributeObject (IAttributeFields *pAttribute) | |
| ParaAttributeObject | GetAttributeObject () |
| get the attribute object. More... | |
| bool | equals (const ParaAttributeObject &obj) const |
| return true, if this object is the same as the given object. | |
| ParaAttributeObject | GetChild (const std::string &sName) |
| get child attribute object. More... | |
| ParaAttributeObject | GetChildAt (int nIndex) |
| ParaAttributeObject | GetChildAt2 (int nRowIndex, int nColumnIndex) |
| int | GetChildCount () |
| int | GetChildCount2 (int nColumnIndex) |
| int | GetColumnCount () |
| we support multi-dimensional child object. More... | |
| bool | AddChild (ParaAttributeObject &obj) |
| add a child object | |
| const ParaObject & | QueryObject () |
| query object | |
| const ParaUIObject & | QueryUIObject () |
| bool | IsValid () const |
| check if the object is valid | |
| int | GetClassID () const |
| class ID | |
| const char * | GetClassName () const |
| class name | |
| const char * | GetClassName1 () const |
| const char * | GetClassDescription () const |
| class description | |
| void | SetOrder (int order) |
| Set which order fields are saved. More... | |
| int | GetOrder () |
| get which order fields are saved. More... | |
| int | GetFieldNum () |
| get the total number of field. More... | |
| const char * | GetFieldName (int nIndex) |
| get field at the specified index. More... | |
| int | GetFieldIndex (const char *sFieldname) |
| get field index of a given field name. More... | |
| const char * | GetFieldType (int nIndex) |
| get the field type as string More... | |
| bool | IsFieldReadOnly (int nIndex) |
| whether the field is read only. More... | |
| const char * | GetFieldSchematics (int nIndex) |
| Get Field Schematics string. More... | |
| const char * | GetSchematicsType (int nIndex) |
| parse the schema type from the schema string. More... | |
| void | GetSchematicsMinMax (int nIndex, float fMinIn, float fMaxIn, float &fMin, float &fMax) |
| parse the schema min max value from the schema string. More... | |
| object | GetField (const char *sFieldname, const object &output) |
| get field by name. More... | |
| object | GetField2 (const char *sFieldname, lua_State *L) |
| const char * | GetStringField (const char *sFieldname) |
| similar to GetField(). More... | |
| double | GetValueField (const char *sFieldname, int nIndex=0) |
| similar to GetField(). More... | |
| void | SetField (const char *sFieldname, const object &input) |
| set field by name e.g. More... | |
| void | SetStringField (const char *sFieldname, const char *input) |
| similar to SetField(). More... | |
| void | SetValueField (const char *sFieldname, int nIndex, double value) |
| similar to SetField(). More... | |
| void | CallField (const char *sFieldname) |
| call field by name. More... | |
| void | PrintObject (const char *file) |
| print attribute to file More... | |
| bool | ResetField (int nFieldID) |
| Reset the field to its initial or default value. More... | |
| bool | InvokeEditor (int nFieldID, const char *sParameters) |
| Invoke an (external) editor for a given field. More... | |
| object | GetDynamicField (const char *sFieldname, const object &output) |
| get field by name. More... | |
| object | GetDynamicField_ (int nIndex, const object &output) |
| Get a dynamic field with a given index. | |
| object | GetDynamicFieldImp (CDynamicAttributeField *pField, const object &output) |
| const char * | GetDynamicFieldNameByIndex (int nIndex) |
| get field name by index | |
| int | GetDynamicFieldCount () |
| how many dynamic field this object currently have. More... | |
| int | SetDynamicField (const char *sFieldname, const object &input) |
| set field by name e.g. More... | |
| int | SetDynamicField_ (int nFieldIndex, const object &input) |
| int | GetFieldKeyNums (const char *sFieldname) |
| void | SetFieldKeyNums (const char *sFieldname, int nKeyNum) |
| void | SetFieldKeyTime (const char *sFieldname, int nKeyIndex, int nTime) |
| int | GetFieldKeyTime (const char *sFieldname, int nKeyIndex) |
| void | SetFieldKeyValue (const char *sFieldname, int nKeyIndex, const object &input) |
| object | GetFieldKeyValue (const char *sFieldname, int nKeyIndex, const object &output) |
| void | RemoveAllDynamicFields () |
| remove all dynamic fields | |
| int | AddDynamicField (const std::string &sName, int dwType) |
| add dynamic field and return field index More... | |
Public Attributes | |
| IAttributeFields::WeakPtr_type | m_pAttribute |
| CAttributeClass * | m_pAttClass |
it represents an attribute object associated with an object.
Call ParaObject::GetAttributeObject() or ParaObject::GetAttributeObject() to get an instance of this object. e.g. In NPL, one can write local att = player:GetAttributeObject(); local bGloble = att:GetField("global", true); local facing = att:GetField("facing", 0); att:SetField("facing", facing+3.14); local pos = att:GetField("position", {0,0,0}); pos[1] = pos[1]+100;pos[2] = 0;pos[3] = 10; att:SetField("position", pos); att:PrintObject("test.txt");
the following shows objects and their supported attributes.
| int ParaScripting::ParaAttributeObject::AddDynamicField | ( | const std::string & | sName, |
| int | dwType | ||
| ) |
add dynamic field and return field index
| dwType | type of ATTRIBUTE_FIELDTYPE |
| void ParaAttributeObject::CallField | ( | const char * | sFieldname | ) |
call field by name.
This function is only valid when The field type is void. It simply calls the function associated with the field name.
| ParaAttributeObject ParaAttributeObject::GetAttributeObject | ( | ) |
get the attribute object.
This function return a clone of this object.
| ParaScripting::ParaAttributeObject ParaScripting::ParaAttributeObject::GetChild | ( | const std::string & | sName | ) |
get child attribute object.
this can be regarded as an intrusive data model of a given object. once you get an attribute object, you can use this model class to access all data in the hierarchy.
| int ParaScripting::ParaAttributeObject::GetColumnCount | ( | ) |
we support multi-dimensional child object.
by default objects have only one column.
| object ParaScripting::ParaAttributeObject::GetDynamicField | ( | const char * | sFieldname, |
| const object & | output | ||
| ) |
get field by name.
e.g. suppose att is the attribute object. local bGloble = att:GetField("URL", nil); local facing = att:GetField("Title", "default one");
| sFieldname | field name |
| output | default value. if field type is vectorN, output is a table with N items. |
| int ParaScripting::ParaAttributeObject::GetDynamicFieldCount | ( | ) |
how many dynamic field this object currently have.
get field by name.
e.g. suppose att is the attribute object. local bGloble = att:GetField("global", true); local facing = att:GetField("facing", 0); local pos = att:GetField("position", {0,0,0}); pos[1] = pos[1]+100;pos[2] = 0;pos[3] = 10;
| sFieldname | field name |
| output | default value. if field type is vectorN, output is a table with N items. |
| int ParaAttributeObject::GetFieldIndex | ( | const char * | sFieldname | ) |
get field index of a given field name.
-1 will be returned if name not found.
| sFieldname |
| const char * ParaAttributeObject::GetFieldName | ( | int | nIndex | ) |
get field at the specified index.
"" will be returned if index is out of range.
| int ParaAttributeObject::GetFieldNum | ( | ) |
get the total number of field.
| const char * ParaAttributeObject::GetFieldSchematics | ( | int | nIndex | ) |
Get Field Schematics string.
| nIndex | index of the field |
| const char * ParaAttributeObject::GetFieldType | ( | int | nIndex | ) |
get the field type as string
| nIndex | : index of the field |
| int ParaAttributeObject::GetOrder | ( | ) |
get which order fields are saved.
| void ParaAttributeObject::GetSchematicsMinMax | ( | int | nIndex, |
| float | fMinIn, | ||
| float | fMaxIn, | ||
| float & | fMin, | ||
| float & | fMax | ||
| ) |
parse the schema min max value from the schema string.
| nIndex | index of the field |
| fMin | : [in|out] default value |
| fMax | : [in|out] default value |
| const char * ParaAttributeObject::GetSchematicsType | ( | int | nIndex | ) |
parse the schema type from the schema string.
| const char * ParaAttributeObject::GetStringField | ( | const char * | sFieldname | ) |
similar to GetField().
except that the output is a string. Used for API exporting. not thread safe.
| double ParaAttributeObject::GetValueField | ( | const char * | sFieldname, |
| int | nIndex = 0 |
||
| ) |
similar to GetField().
except that the output is a value. Used for API exporting. not thread safe.
| nIndex | if the value has multiple component, such as a vector3. this is the index of the componet. |
| bool ParaAttributeObject::InvokeEditor | ( | int | nFieldID, |
| const char * | sParameters | ||
| ) |
Invoke an (external) editor for a given field.
This is usually for NPL script field
| nFieldID | : field ID |
| sParameters | : the parameter passed to the editor |
| bool ParaAttributeObject::IsFieldReadOnly | ( | int | nIndex | ) |
whether the field is read only.
a field is ready only if and only if it has only a get method.
| nIndex | : index of the field |
| void ParaAttributeObject::PrintObject | ( | const char * | file | ) |
print attribute to file
| file | file name to save the manual to. |
| bool ParaAttributeObject::ResetField | ( | int | nFieldID | ) |
Reset the field to its initial or default value.
| nFieldID | : field ID |
| int ParaScripting::ParaAttributeObject::SetDynamicField | ( | const char * | sFieldname, |
| const object & | input | ||
| ) |
set field by name e.g.
suppose att is the attribute object. att:SetDynamicField("URL", 3.14); att:SetDynamicField("Title", {100,0,0});
| sFieldname | field name |
| input | input value. can be value or string type |
| void ParaAttributeObject::SetField | ( | const char * | sFieldname, |
| const object & | input | ||
| ) |
set field by name e.g.
suppose att is the attribute object. att:SetField("facing", 3.14); att:SetField("position", {100,0,0});
| sFieldname | field name |
| input | input value. if field type is vectorN, input is a table with N items. |
| void ParaAttributeObject::SetOrder | ( | int | order | ) |
Set which order fields are saved.
enum Field_Order { Sort_ByName, Sort_ByCategory, Sort_ByInstallOrder, };
| void ParaAttributeObject::SetStringField | ( | const char * | sFieldname, |
| const char * | input | ||
| ) |
similar to SetField().
except that the input is a string. Used for API exporting. not thread safe.
| void ParaAttributeObject::SetValueField | ( | const char * | sFieldname, |
| int | nIndex, | ||
| double | value | ||
| ) |
similar to SetField().
except that the input is a string. Used for API exporting. not thread safe.
| nIndex | if the value has multiple component, such as a vector3. this is the index of the component. |
1.8.12