Go to
the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008 #pragma once
00009
00010
00011
00012 #include <map>
00013
00014 #include "..\..\custattrib.h"
00015 #include "..\..\ICustAttribContainer.h"
00016 #include "mxsplugin.h"
00017
00018 #define I_SCRIPTEDCUSTATTRIB 0x000010C1
00019
00020 #define MSCUSTATTRIB_CHUNK 0x0110
00021 #define MSCUSTATTRIB_NAME_CHUNK 0x0010
00022
00023
00024
00025
00026
00027 visible_class (MSCustAttribDef)
00028
00029 class MSCustAttribDef;
00030 typedef std::map<Class_ID, MSCustAttribDef*> MSCustAttribDefMap;
00031 typedef MSCustAttribDefMap::iterator MSCustAttribDefMapIter;
00032 typedef MSCustAttribDefMap::const_iterator MSCustAttribDefMapConstIter;
00033 typedef MSCustAttribDefMap::value_type MSCustAttribDefMapValue;
00034
00035
00036 class MSCustAttribDef : public MSPluginClass
00037 {
00038 public:
00039
00040 ScripterExport static MSCustAttribDefMap ms_attrib_defs;
00041
00042 Value* defData;
00043 MSTR source;
00044
00045
00046 ScripterExport MSCustAttribDef(Class_ID& attrib_id);
00047 ScripterExport ~MSCustAttribDef();
00048
00049
00050 static MSCustAttribDef* intern(Class_ID& attrib_id);
00051 ScripterExport void init(int local_count, Value** inits, HashTable* local_scope, HashTable* handlers, Array* pblock_defs, Array* iremap_param_names, Array* rollouts, CharStream* source);
00052
00053
00054
00055 BOOL is_kind_of(ValueMetaClass* c) { return (c == class_tag(MSCustAttribDef)) ? 1 : MSPluginClass::is_kind_of(c); }
00056 # define is_attribute_def(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MSCustAttribDef))
00057 void collect() { delete this; }
00058 void gc_trace();
00059 void sprin1(CharStream* s);
00060
00061 bool is_custAttribDef() { return true; }
00062 ScripterExport MSCustAttribDef* unique_clone();
00063
00064
00065 Value* apply(Value** arg_list, int count, CallContext* cc=NULL) { return Value::apply(arg_list, count, cc); }
00066
00067
00068 static IOResult save_custattrib_defs(ISave* isave);
00069 static IOResult load_custattrib_defs(ILoad* iload);
00070
00071
00072 RefTargetHandle Create(BOOL loading);
00073
00074 Value* get_property(Value** arg_list, int count);
00075 Value* set_property(Value** arg_list, int count);
00076
00077 def_property ( name );
00078 };
00079
00080
00081 #pragma warning(push)
00082 #pragma warning(disable:4239)
00083
00084
00085
00086 class MSCustAttrib : public MSPlugin, public CustAttrib, public ISubMap
00087 {
00088 public:
00089 IObjParam* cip;
00090 static MSAutoMParamDlg* masterMDlg;
00091 IMtlParams* mip;
00092 MSTR name;
00093
00094 ScripterExport MSCustAttrib() : cip(NULL), mip(NULL) { }
00095 ScripterExport MSCustAttrib(MSCustAttribDef* pc, BOOL loading);
00096 ScripterExport ~MSCustAttrib() { DeleteAllRefsFromMe(); }
00097
00098
00099 using Collectable::operator new;
00100 using Collectable::operator delete;
00101
00102 ScripterExport void sprin1(CharStream* s);
00103
00104
00105 ScripterExport HWND AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_CUSTATTRIB - 1);
00106 ScripterExport void DeleteRollupPage(HWND hRollup);
00107 ScripterExport IRollupWindow* GetRollupWindow();
00108 ReferenceTarget* get_delegate() { return NULL; }
00109
00110
00111 const MCHAR* GetName() { return name; }
00112 ScripterExport ParamDlg* CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp);
00113
00114 void SetName(const MCHAR* newName) { name = newName ; }
00115
00116
00117
00118 using CustAttrib::GetInterface;
00119
00120 void GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }
00121 Class_ID ClassID() { return pc->class_id; }
00122 SClass_ID SuperClassID() { return pc->sclass_id; }
00123 void FreeCaches() { }
00124 int NumSubs() { return pblocks.Count(); }
00125 Animatable* SubAnim(int i) { return pblocks[i]; }
00126 MSTR SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
00127 int NumParamBlocks() { return pblocks.Count(); }
00128 IParamBlock2* GetParamBlock(int i) { return pblocks[i]; }
00129 IParamBlock2* GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
00130 BOOL CanCopyAnim() { return FALSE; }
00131
00132 ScripterExport void* GetInterface(ULONG id);
00133 ScripterExport void DeleteThis();
00134 ScripterExport void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
00135 ScripterExport void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00136
00137
00138 RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message)
00139 {
00140 if (!(pc->mpc_flags & MPC_REDEFINITION))
00141 return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message);
00142 else
00143 return REF_SUCCEED;
00144 }
00145
00146
00147 int NumRefs() { return pblocks.Count(); }
00148 RefTargetHandle GetReference(int i) { return pblocks[i]; }
00149 protected:
00150 virtual void SetReference(int i, RefTargetHandle rtarg)
00151 {
00152 if (i >= pblocks.Count())
00153 pblocks.SetCount(i+1);
00154 pblocks[i] = (IParamBlock2*)rtarg;
00155 }
00156 public:
00157 void RefDeleted() { MSPlugin::RefDeleted(); }
00158 RefTargetHandle Clone(RemapDir& remap);
00159
00160 ScripterExport IOResult Save(ISave *isave);
00161 ScripterExport IOResult Load(ILoad *iload);
00162
00163
00164 ScripterExport int NumSubTexmaps();
00165 ScripterExport Texmap* GetSubTexmap(int i);
00166 ScripterExport void SetSubTexmap(int i, Texmap *m);
00167 ScripterExport MSTR GetSubTexmapSlotName(int i);
00168 int MapSlotType(int i) { UNUSED_PARAM(i); return MAPSLOT_TEXTURE; }
00169 MSTR GetSubTexmapTVName(int i) { return GetSubTexmapSlotName(i); }
00170 ReferenceTarget *GetRefTarget() { return this; }
00171 };
00172
00173 #pragma warning(pop)
00174
00175
00176 class FindCustAttribOwnerDEP : public DependentEnumProc
00177 {
00178 public:
00179 ReferenceMaker* rm;
00180 CustAttrib* targ_ca;
00181 FindCustAttribOwnerDEP(CustAttrib* ca) { rm = NULL; targ_ca = ca; }
00182 int proc(ReferenceMaker* rmaker)
00183 {
00184 if (rmaker == targ_ca)
00185 return DEP_ENUM_CONTINUE;
00186
00187
00188
00189
00190
00191 if( !rmaker->IsRealDependency(targ_ca) )
00192 return DEP_ENUM_SKIP;
00193
00194 if (rmaker->ClassID() == CUSTATTRIB_CONTAINER_CLASS_ID )
00195 {
00196 ICustAttribContainer* cac = (ICustAttribContainer*)rmaker;
00197 Animatable* owner = cac->GetOwner();
00198 if (owner)
00199 {
00200 SClass_ID sid = owner->SuperClassID();
00201 if (sid != MAKEREF_REST_CLASS_ID && sid != MAXSCRIPT_WRAPPER_CLASS_ID && sid != DELREF_REST_CLASS_ID)
00202 {
00203 for (int j = 0; j < cac->GetNumCustAttribs(); j++)
00204 {
00205 CustAttrib* ca = cac->GetCustAttrib(j);
00206 if (ca == targ_ca)
00207 {
00208 rm = (ReferenceMaker*)owner;
00209 return DEP_ENUM_HALT;
00210 }
00211 }
00212 }
00213 }
00214 }
00215 return DEP_ENUM_SKIP;
00216 }
00217
00218 };
00219