/* Plugin C3D : Msg3d - part Client */ /* author : iri - http://www.irizone.net - april 2004 */ /* rev. iri - http://www.irizone.net - august 2004 */ /* TO DO : faire la césure selon les mots et non selon les lettres */ typeof class = S;; struct Tdata = [ D_posX : I, /* X position of the term3d */ D_posY : I, /* Y position of the term3d */ D_width : I, /* width of the term3d */ D_heigth : I, /* heigth of the term3d */ D_color : I, /* fontColor (default value) */ D_font : ObjFont, /* font des messages services */ D_fond : ObjBitmap, /* background bitmap (fixed) */ D_Timer : Timer /* Timer d'affichage (10 sec) */ ] mkData;; /* t -> Timer z -> Tdata (user param) I <- */ /* callback timer */ fun _endTimer(t, z)= _DSbitmap z.D_fond; set z.D_fond = nil; _deltimer z.D_Timer; set z.D_Timer = nil; 0;; /* s -> S z -> Tdata I <- */ /* détermine si la chaîne 'dessinée' est plus longue que la largeur du bitmap */ fun long(s, z)= let _GETstringSize z.D_font s -> [w h] in w <= (z.D_width - z.D_posX);; /* s -> S z -> Tdata l -> [S r1] tmp -> S [S r1] <- l */ /* découpe le message en autant de lignes que nécessaire */ fun cutMsg(s, z, l, tmp)= if s != "" then if (long s z) then if (long tmp z) then set l = tmp::s::l else (set l = s::l; cutMsg tmp z l "") else let substr s 0 (strlen s)-1 -> string in let strcat substr s strlen s 1 tmp -> tmp in cutMsg string z l tmp else l;; /* msg -> S (message à afficher) z -> Tdata ObjSurface <- */ /* affiche le message service */ fun displayMsg(msg, z)= _deltimer z.D_Timer; set z.D_Timer = _starttimer _channel 10000; _rfltimer z.D_Timer @_endTimer z; set z.D_fond = _CRbitmap _channel z.D_width z.D_heigth; set z.D_fond = _FILLbitmap z.D_fond w3d.V3dfond; let cutMsg msg z nil "" -> ll in let _GETstringSize z.D_font msg -> [_ h] in let 0 -> i in while i < (sizelist ll) do (set z.D_fond = _DRAWtext z.D_fond z.D_font z.D_posX (z.D_posY + (((sizelist ll)-i-1)*(h+2))) 0 z.D_color nth_list ll i; set i = i+1);; /* callback post render */ fun cbBlitTerm(o, b, p) = let p -> [z] in _Bitmap2Surface w3d.V3dbuf 0 0 z.D_fond 0 0 z.D_width z.D_heigth w3d.V3dfond; 0;; /* ui -> UserI action -> S param -> S p -> not used I <- not used */ /* communications intramodules (server / client) */ fun cbcomm(ui, action, param, p)= let p -> [z] in if !strcmp action "display" then (displayMsg param z; 0) else 0;; fun newOb(o) = let getView3dSize w3d -> [w h] in let atoi hd UgetParam ObUi o "x" -> x in let atoi hd UgetParam ObUi o "y" -> y in let atoi hd UgetParam ObUi o "color" -> fontColor in let _CRfont _channel 18 FF_WEIGHT 0 "Arial" -> font in let mkData[x y w h fontColor font nil nil] -> z in ( UcbComm this ObUi o mkfun4 @cbcomm [z]; ObCbPostRender o mkfun3 @cbBlitTerm [z]; 0 );; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;