convert line ends
[canaan.git] / prj / cam / src / editor / autovbr.cpp
blob5420499668c62d092a17029abb04230ef52e89f2
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/editor/autovbr.cpp,v 1.3 2000/02/19 12:27:40 toml Exp $
8 // COM fun
9 #include <appagg.h>
10 #include <aggmemb.h>
12 #include <mprintf.h>
13 #include <matrix.h>
15 // sdesc
16 #include <sdesc.h>
17 #include <sdesbase.h>
18 #include <propbase.h>
19 #include <propface.h>
21 #include <command.h>
22 #include <iobjsys.h>
23 #include <objdef.h>
24 #include <objnotif.h>
25 #include <objpos.h>
27 #include <wrtype.h>
28 #include <editbr_.h>
29 #include <editbr.h>
30 #include <editbrs.h>
31 #include <vbrush.h>
32 #include <autovbr.h>
33 #include <vbr_math.h>
34 #include <memall.h>
35 #include <dbmem.h> // must be last header!
37 ILabelProperty *gAutoVBrushProp;
38 EXTERN void br_update_obj(editBrush *us);
40 static void ObjSysListener(ObjID obj, eObjNotifyMsg msg, void*)
42 AutoAppIPtr_(ObjectSystem,pObjSys);
43 char cmd[255];
44 Label *vbrname;
46 if ((msg == kObjNotifyCreate) && (OBJ_IS_CONCRETE(obj)))
48 if (gAutoVBrushProp->IsRelevant(obj))
50 gAutoVBrushProp->Get(obj, &vbrname);
51 sprintf(cmd,"load_group %s",vbrname->text);
53 mprintf("loading group %s from obj %d\n",vbrname->text,obj);
55 // load up the multibrush
56 CommandExecute(cmd);
58 // move the multibrush to this location
59 ObjPos *p1;
60 editBrush *br=vBrush_GetSel();
61 p1 = ObjPosGet(obj);
62 mx_sub_vec(br_trans_vec,&p1->loc.vec,&br->pos);
63 vBrush_GroupOp(FALSE,br_translate); // zero relative them all
64 vBrush_GroupOp(FALSE,br_update_obj);
66 // delete this poor object
67 pObjSys->Destroy(obj);
73 static sPropertyDesc AutoVBrushDesc =
75 "AutoVBR", 0,
76 NULL, 0, 0, // constraints, versions
77 { "Editor", "Auto-Multibrush" },
80 void AutoVBrushInit(void)
82 gAutoVBrushProp = CreateLabelProperty(&AutoVBrushDesc, kPropertyImplDense);
84 // listen to obj sys changes
85 AutoAppIPtr_(ObjectSystem,pObjSys);
86 sObjListenerDesc listener = { ObjSysListener, NULL};
87 pObjSys->Listen(&listener);