/* digiClock plugin - February 00 - Sebastien Deneux */ var avfile="Dms/3d/Plugins/digiClock/x.m3d";; typeof class=S;; var fontSize=20;; var fontSize2=10;; var fontType="Arial";; typeof textColor=I;; typeof backColor=I;; var vw=128;; var vh=128;; typeof font=ObjFont;; typeof font2=ObjFont;; var TYPE_NORMAL=0;; var TYPE_SWATCH=1;; fun applytx(x,t)= match x with (objAnchor [_ m _ _] -> (M3chgMaterialTexture session m t; M3setType session m (M3getType session m)|1)) |(_->nil);; fun addZero(s)=if (strlen s)&1 then strcat "0" s else s;; fun getSwatch(s,m,h)=(s+m*60+(if h==23 then 0 else h+1)*3600)*999/86400;; fun _clock(t,b)= let b -> [o tx zone1 zone2 name1 name2 type1 type2] in let _CRbitmap _channel vw vh -> image in let gmtime zone1 -> [s1 m1 h1 _ _ _ _ _] in let gmtime zone2 -> [s2 m2 h2 _ _ _ _ _] in ( _FILLbitmap image backColor; if zone2!=nil then ( if type1==TYPE_SWATCH then let getSwatch s1 m1 h1 -> swatch1 in (_DRAWtext image font vw/2 vh/4 (TD_BASELINE|TD_CENTER) textColor strcatn "@"::(itoa swatch1)::nil; _DRAWtext image font2 vw vh/2-10 (TD_BASELINE|TD_RIGHT) textColor name1) else (_DRAWtext image font vw/2 vh/4 (TD_BASELINE|TD_CENTER) textColor strcatn (addZero itoa h1)::":"::(addZero itoa m1)::":"::(addZero itoa s1)::nil; _DRAWtext image font2 vw vh/2-10 (TD_BASELINE|TD_RIGHT) textColor name1); if type2==TYPE_SWATCH then let getSwatch s1 m1 h1 -> swatch2 in (_DRAWtext image font vw/2 3*vh/4 (TD_BASELINE|TD_CENTER) textColor strcatn "@"::(itoa swatch2)::nil; _DRAWtext image font2 vw vh-10 (TD_BASELINE|TD_RIGHT) textColor name2) else (_DRAWtext image font vw/2 3*vh/4 (TD_BASELINE|TD_CENTER) textColor strcatn (addZero itoa h2)::":"::(addZero itoa m2)::":"::(addZero itoa s2)::nil; _DRAWtext image font2 vw vh-10 (TD_BASELINE|TD_RIGHT) textColor name2); ) else if type1==TYPE_SWATCH then let getSwatch s1 m1 h1 -> swatch1 in (_DRAWtext image font vw/2 vh/2 (TD_BASELINE|TD_CENTER) textColor strcatn "@"::(itoa swatch1)::nil; _DRAWtext image font2 vw vh-10 (TD_BASELINE|TD_RIGHT) textColor name1) else (_DRAWtext image font vw/2 vh/2 (TD_BASELINE|TD_CENTER) textColor strcatn (addZero itoa h1)::":"::(addZero itoa m1)::":"::(addZero itoa s1)::nil; _DRAWtext image font2 vw vh-10 (TD_BASELINE|TD_RIGHT) textColor name1); M3blitTexture16 session tx image; apply_on_list ObAnchor o @applytx tx; _DSbitmap image; mutate b<-[_ _ zone1+1 zone2+1 _ _ _ _]; 0 );; fun newOb(o)= M3load session avfile nil; let M3copyMaterialTexture session M3getMat session "snapmater" -> txt in let hd UgetParam ObUi o "name1" -> n1 in let hd UgetParam ObUi o "name2" -> n2 in let hd UgetParam ObUi o "zone1" -> z1 in let hd UgetParam ObUi o "zone2" -> z2 in let hd UgetParam ObUi o "dst1" -> d1 in let hd UgetParam ObUi o "dst2" -> d2 in let if !strcmpi d1 "ON" then 3600 else 0 -> dst1 in let if !strcmpi d2 "ON" then 3600 else 0 -> dst2 in let hd UgetParam ObUi o "type1" -> t1 in let hd UgetParam ObUi o "type2" -> t2 in let if z1==nil||n1==nil then nil else (atoi z1)*3600 -> zone1 in let if z2==nil||n2==nil then nil else (atoi z2)*3600 -> zone2 in let if !strcmpi t1 "SWATCH" then TYPE_SWATCH else TYPE_NORMAL -> type1 in let if !strcmpi t2 "SWATCH" then TYPE_SWATCH else TYPE_NORMAL -> type2 in if zone1==nil then nil else _rfltimer _starttimer _channel 1000 @_clock [o txt _DMStime+zone1+dst1 _DMStime+zone2+dst2 n1 n2 type1 type2]; 0;; fun IniPlug(file)= set textColor=make_rgb 255 0 0; set backColor=make_rgb 0 0 0; set class=getInfo strextr _getpack _checkpack file "name"; set font = _CRfont _channel fontSize 0 FF_PIXEL+FF_WEIGHT fontType; set font2 = _CRfont _channel fontSize2 0 FF_PIXEL+FF_WEIGHT fontType; PlugRegister class @newOb nil; 0;;