Changeset 832


Ignore:
Timestamp:
11/26/18 01:40:31 (2 weeks ago)
Author:
Maciej Komosinski
Message:

Renamed MutableParam? property manipulation functions to avoid potential name clash in scripts; added warning for docs to discourage their use; automatically calculated the correct static member count from the paramtab array

Location:
cpp/frams/param
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/mutableparam.cpp

    r824 r832  
    66#include <frams/util/extvalue.h>
    77
     8#define PROPERTY_WARNING "Using most _property functions is restricted for internal purposes. Use \"property:\" or \"state:\" definitions in your script files to change object properties."
     9
    810#define FIELDSTRUCT MutableParam
    911ParamEntry MutableParam::pe_tab[] =
    10 { //TODO: these names are visible for scripts in ExpProperties, ShowProperties, etc. add some reserved prefix to avoid conflicts with script-defined properties!
    11         { "clear", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove all properties", "p", PROCEDURE(p_clear), },
    12         { "add", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "add property (id,type,name,help)", "p", PROCEDURE(p_addprop), },
    13         { "remove", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove property (index)", "p", PROCEDURE(p_remprop), },
    14         { "change", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "change property (id,type,name,flags,help)", "p", PROCEDURE(p_changeprop), },
    15         { "addGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "add group (name)", "p", PROCEDURE(p_addgroup), },
    16         { "removeGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove group (index)", "p", PROCEDURE(p_remgroup), },
    17         { "changedProperty", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "last changed property #", "d", FIELD(changed), },
    18         { "changedPropertyId", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "last changed property id", "s", GETONLY(changedname), },
     12{
     13        { "_propertyClear", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Remove all properties", "p()", PROCEDURE(p_clear), PROPERTY_WARNING },
     14        { "_propertyAdd", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Add property (id,type,name,help)", "p(s id,s type description,s name,d flags,s help text)", PROCEDURE(p_addprop), PROPERTY_WARNING },
     15        { "_propertyRemove", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Remove property", "p(d index)", PROCEDURE(p_remprop), PROPERTY_WARNING },
     16        { "_propertyChange", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Change property", "p(s id,s type description,s name,d flags,s help text)", PROCEDURE(p_changeprop),  PROPERTY_WARNING },
     17        { "_propertyAddGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Add property group", "p(s name)", PROCEDURE(p_addgroup), PROPERTY_WARNING },
     18        { "_propertyRemoveGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Remove property group", "p(d index)", PROCEDURE(p_remgroup), PROPERTY_WARNING },
     19        { "_property_changed_index", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "Last changed property index", "d", FIELD(changed), },
     20        { "_property_changed_id", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "Last changed property id", "s", GETONLY(changedname), },
    1921};
    2022#undef FIELDSTRUCT
     23const int MutableParam::staticprops = ARRAY_LENGTH(pe_tab);
    2124
    2225MutableParam::MutableParam(const char*n, const char*g, int gr0)
     
    211214void MutableParam::p_addprop(ExtValue *args, ExtValue *ret)
    212215{
    213         int i = addProperty(0, args[2].getString().c_str(), args[1].getString().c_str(), args[0].getString().c_str());
     216        int i = addProperty(0, args[4].getString().c_str(), args[3].getString().c_str(), args[2].getString().c_str(), args[0].getString().c_str(), args[1].getInt());
    214217        ret->setInt(i);
    215218}
  • cpp/frams/param/mutableparam.h

    r824 r832  
    1616class MutableParam : public SimpleAbstractParam, public MutableParamInterface
    1717{
    18         static const int staticprops = 8;
     18        static const int staticprops;
    1919        static ParamEntry pe_tab[];
    2020        /** group #0 cannot be removed by scripting  */
Note: See TracChangeset for help on using the changeset viewer.