/* Site Map Client - DMS - june 98 - by Marc BARILLEY */ /* Rev. 1.1 - Sep. '98 - by Marc BARILLEY */ /* Mod. 2.4 - Sep. 99 - by Sebastien DENEUX (update users list on rfl over) */ /* Mod. 2.5 - June 00 - by Sebastien DENEUX (info bubble)*/ /* Rev. - Sep. '01 - by Jérôme ICARD (Païkan) */ /*MODIF 2.5*/ typeof bubbleWindow=ObjWin;; typeof winpMAP=ObjWin;; typeof bubbleFont=ObjFont;; typeof bubbleTimer=Timer;; typeof bubbleTimer2=Timer;; /*FIN MODIF 2.5*/ defcom Cstarted = started;; defcom Ccontact = contact S S;; struct Rect = [ aliasRect : S, xRect : I, yRect : I, wRect : I, hRect : I, outlnRect : I, outlnColorRect : I, avatarRect : I, meDotRect : I, meSizeRect : I, meColorRect : I, meBitmapRect : I, meFileRect : S, otherDotRect : I, otherSizeRect : I, otherColorRect : I, otherBitmapRect : I, otherFileRect : S, numberRect : I, userRect : [S r1], meIconeRect : ObjBitmap, otherIconeRect : ObjBitmap ] mkRect;; typeof rects = [Rect r1];; typeof activeRect = Rect;; typeof whereIam = [Rect r1];; typeof mainButton = ObjButton;; typeof mapFile = S;; typeof map = ObjBitmap;; typeof altmapFile = S;; typeof altmap = ObjBitmap;; typeof mapWindow = ObjWin;; typeof workmap = ObjBitmap;; typeof userList = ObjList;; typeof rectCombo = ObjBox;; typeof xscale = F;; typeof yscale = F;; var wmap = 0;; var hmap = 0;; /* internal */ fun userByNickname (x, nickname)= !strcmp x nickname;; fun rectByName (r, name)= !strcmp r.aliasRect name;; fun rectByPoint (r, point)= let point -> [x y] in { (x > ftoi ((itof r.xRect)*.xscale)) && (x < ftoi ((itof (r.xRect+r.wRect))*.xscale)) && (y > ftoi ((itof r.yRect)*.yscale)) && (y < ftoi ((itof (r.yRect+r.hRect))*.yscale)) };; fun fillUserList (l)= if l==nil then userList else { _ADDlist userList (_GETlistCount userList) hd l; fillUserList tl l };; fun fillRectCombo (l)= if l==nil then rectCombo else { let hd l -> r in _ADDcombo rectCombo (_GETcomboCount rectCombo) r.aliasRect; fillRectCombo tl l };; fun resetMap ()= if map==nil then _FILLbitmap workmap 0xffffff else let _GETbitmapSize map -> [wmap hmap] in _CPbitmap16 workmap 0 0 map 0 0 wmap hmap nil;; /* comm */ fun endloadMap (file)= if file == nil then _DLGMessageBox _channel nil "" "nil" 0 else nil; set mapFile = file; _DSbitmap map; set map= let _checkpack file -> pack in let _LDbitmap _channel pack -> b in if b==nil then let _LDjpeg _channel pack -> b in if b==nil then _FILLbitmap _CRbitmap _channel wmap hmap 0xffffff else b else b; if mapWindow==nil then nil else let _GETbitmapSize map -> [bw bh] in { _DSbitmap workmap; set workmap = _CRbitmap _channel bw bh; let _GETwindowSizePosition mapWindow -> [mw mh mx my] in { set xscale = (itof mw) /. (itof bw); set yscale = (itof mh) /. (itof bh); _fooS "endloadMap"; _fooS strcat " xscale == " if xscale==nil then "nil" else ftoa xscale; _fooS strcat " yscale == " if yscale==nil then "nil" else ftoa yscale; }; resetMap; _PAINTwindow mapWindow }; 0;; fun __map (file, w, h)= _RSCdownload this file file @endloadMap 1;; fun endloadAltmap (file)= set altmapFile = file; _DSbitmap altmap; if file==nil then { set altmap=nil; nil } else let _checkpack file -> pack in { set altmap= let _LDbitmap _channel pack -> b in if b==nil then _LDjpeg _channel pack else b; if altmap == nil then set altmapFile = nil else nil; }; 0;; fun __alt (file)= _RSCdownload this file file @endloadAltmap 1;; fun endloadMeFile (file, r)= if file==nil then { set r.meBitmapRect = 0; set r.meIconeRect = nil; } else let _checkpack file -> pack in let _LDbitmap _channel pack -> b in let if b==nil then _LDjpeg _channel pack else b -> b in { set r.meBitmapRect = (b != nil); set r.meIconeRect = b }; 0;; fun endloadOtherFile (file, r)= if file==nil then { set r.otherBitmapRect = 0; set r.otherIconeRect = nil; } else let _checkpack file -> pack in let _LDbitmap _channel pack -> b in let if b==nil then _LDjpeg _channel pack else b -> b in { set r.otherBitmapRect = (b != nil); set r.otherIconeRect = b }; 0;; fun __alias (error, alias, x, y, w, h, l, lc, av, md, ms, mc, mb, mf, od, os, oc, ob, of, n)= if error==0 then let mkRect [alias x y w h l lc av md ms mc mb mf od os oc ob of n nil nil nil] -> r in { set rects = r::rects; if r.meBitmapRect then { set r.meBitmapRect = 0; _RSCdownload this r.meFileRect r.meFileRect mkfun2 @endloadMeFile r 1; } else nil; if r.otherBitmapRect then { set r.otherBitmapRect = 0; _RSCdownload this r.otherFileRect r.otherFileRect mkfun2 @endloadOtherFile r 1 } else nil; _ADDcombo rectCombo 0 alias } else if error==1 then { set rects = nil; rectCombo } else if error==2 then { _DMSevent this "in" nil nil; set activeRect = hd rects; _SELcombo rectCombo 0; } else rectCombo;; fun __youAreIn (alias)= let search_in_list whereIam @rectByName alias -> r in if r==nil then { set whereIam = (search_in_list rects @rectByName alias)::whereIam; resetMap; _PAINTwindow mapWindow } else nil;; fun __youAreOut (alias)= let search_in_list whereIam @rectByName alias -> r in if r==nil then nil else { set whereIam = remove_from_list whereIam r; resetMap; _PAINTwindow mapWindow };; fun __addUser (nickname, alias)= let search_in_list rects @rectByName alias -> r in if r==nil then nil else { set r.userRect = listcat r.userRect nickname::nil; if (activeRect == r) && (userList != nil) then _ADDlist userList (_GETlistCount userList) nickname else nil; if mapWindow == nil then nil else { resetMap; _PAINTwindow mapWindow } };; fun __delUser (nickname, alias)= let search_in_list rects @rectByName alias -> r in { set r.userRect = removef_from_list r.userRect @userByNickname nickname; if (activeRect == r) && (userList != nil) then { _RSTlist userList; fillUserList r.userRect } else nil; if mapWindow == nil then nil else { resetMap; _PAINTwindow mapWindow } };; fun __chglogin (old, new)= let rects -> l in while l != nil do { let hd l -> r in let search_in_list r.userRect @userByNickname old -> user in if user==nil then nil else set r.userRect = replace_in_list r.userRect user new; set l = tl l }; if userList != nil then { _RSTlist userList; fillUserList activeRect.userRect } else nil; if mapWindow == nil then nil else { resetMap; _PAINTwindow mapWindow };; fun __destroy ()= _DMSdelete this;; fun __hide ()= _SHOWwindow mapWindow WINDOW_HIDDEN; _SHOWcombo rectCombo WINDOW_HIDDEN; _SHOWlist userList WINDOW_HIDDEN; _DMSevent this "hidden" nil nil;; /* reflexes combo */ fun rflDMSEndCombo (zone)= _DScombo rectCombo; set rectCombo = nil; 0;; fun rflDMSResizeCombo (coord, s)= let coord->[wn x y w h] in _SIZEcombo rectCombo w 100 x y; 0;; fun rflSelCombo (c, blurp, index, string)= set activeRect = nth_list rects index; if userList != nil then { _RSTlist userList; fillUserList activeRect.userRect } else nil;; /* reflexes mapWindow */ fun rflDestroyMapWindow (w, blurp)= set mapWindow=nil;; fun fillzone (r, n, xOffset, yOffset)= if n<=0 then 0 else let if r.otherBitmapRect then if r.otherIconeRect==nil then nil else _GETbitmapSize r.otherIconeRect else if r.otherDotRect then [r.otherSizeRect r.otherSizeRect] else nil -> [wOther hOther] in if wOther==nil then /* ya rien à tracer */ /* arrêter tout */ nil else if (yOffset+hOther) > r.hRect then /* ya plus de place en hauteur */ /* arrêter le massacre */ nil else if (xOffset+wOther) > r.wRect then /* ya plus de place en largeur */ /* passer à la ligne suivante */ let if (search_in_list whereIam @rectByName r.aliasRect)==nil then /*c'est pas un rect où je suis */ nil else if r.meBitmapRect then if r.meIconeRect==nil then /* je ne suis pas affiché */ nil else _GETbitmapSize r.meIconeRect else if r.meDotRect then [r.meSizeRect r.meSizeRect] else nil -> [wMe hMe] in if wMe==nil then /* je ne suis pas affiché : l'offset en x est 0 */ fillzone r n 0 yOffset+hOther else if (yOffset+hMe) < hMe then /* on est à coté de Me : l'offset en x n'est pas 0 */ fillzone r n ((mod wMe wOther)+1)*wOther (yOffset+hMe) else /* on est en dessous de Me : l'offset en x est 0 */ fillzone r n 0 yOffset+hMe else /* rester sur cette ligne */ if r.otherBitmapRect then { _CPbitmap16 workmap r.xRect+xOffset r.yRect+yOffset r.otherIconeRect 0 0 wOther-1 hOther-1 _GETpixel16 r.otherIconeRect 0 0; /* passer à la suite */ fillzone r n-1 xOffset+wOther yOffset } else if r.otherDotRect then { _DRAWcircle workmap r.xRect+xOffset+wOther/2 r.yRect+yOffset+hOther/2 hOther/2 DRAW_SOLID 1 r.otherColorRect DRAW_SOLID r.otherColorRect; /* passer à la suite */ fillzone r n-1 xOffset+wOther yOffset } else nil;; fun showAvatars (r)= let 0 -> myW in { if (search_in_list whereIam @rectByName r.aliasRect)==nil then nil else if r.meBitmapRect then if r.meIconeRect==nil then nil else let _GETbitmapSize r.meIconeRect -> [wMe hMe] in ( if (wMe > r.wRect) || (hMe > r.hRect) then /* ya pas assez de place soit en largeur, soit en hauteur */ nil else { _CPbitmap16 workmap r.xRect r.yRect r.meIconeRect 0 0 wMe-1 hMe-1 _GETpixel16 r.meIconeRect 0 0; set myW = wMe; } ) else if r.meDotRect then if (r.meSizeRect > r.wRect) || (r.meSizeRect > r.hRect) then /* ya pas assez de place soit en largeur, soit en hauteur */ nil else { _DRAWcircle workmap /*modif 2.5*/ r.xRect/*+r.meSizeRect/2*/+r.wRect/2 r.yRect/*+r.meSizeRect/2*/+r.hRect/2 r.meSizeRect/2 /*fin modif 2.5*/ DRAW_SOLID 1 r.meColorRect DRAW_SOLID r.meColorRect; set myW = r.meSizeRect; } else nil; let if r.otherBitmapRect then _GETbitmapSize r.otherIconeRect else if r.otherDotRect then [r.otherSizeRect r.otherSizeRect] else nil -> [wOther hOther] in if wOther==nil then /* ya rien à afficher pour les autres */ nil else fillzone r (sizelist r.userRect) if myW==0 then 0 else ((myW/wOther)+1)*wOther 0; };; fun addusers (l)= if l==nil then 0 else let hd l -> r in { if r.outlnRect then _DRAWrectangle workmap r.xRect r.yRect r.wRect r.hRect DRAW_SOLID 1 r.outlnColorRect DRAW_INVISIBLE r.outlnColorRect else nil; if r.avatarRect then showAvatars r else nil; if r.numberRect then let _CRfont _channel 15 0 FF_WEIGHT "Arial" -> font in { _DRAWtext workmap font r.xRect+r.wRect/2 r.yRect+r.hRect/2 TD_CENTER|TD_BASELINE r.outlnColorRect itoa sizelist r.userRect; _DSfont font; } else nil; addusers tl l; };; fun rflPaintMapWindow (wn, blurp)= addusers rects; let _GETbitmapSize workmap -> [ww hw] in let _GETwindowPositionSize wn -> [_ _ wwn hwn] in _STBLTbitmap wn 0 0 wwn hwn workmap 0 0 ww hw;; fun rflDMSEndMap (zone)= _fooS "rflDMSEndMap"; _DSwindow mapWindow; _DSwindow bubbleWindow; set bubbleWindow=nil; set mapWindow = nil; 0;; fun rflDMSResizeMap (coord, s)= _fooS "rflDMSResizeMap"; let coord->[wn x y w h] in let _GETbitmapSize map -> [bw bh] in { _fooS strcat " bw == " itoa bw; _fooS strcat " bh == " itoa bh; set xscale = (itof w) /. (itof bw); set yscale = (itof h) /. (itof bh); _fooS strcat " xscale == " if xscale==nil then "nil" else ftoa xscale; _fooS strcat " yscale == " if yscale==nil then "nil" else ftoa yscale; _fooS strcat "@@@@@@@ x = " itoa x; _fooS strcat "@@@@@@@ y = " itoa y; _SIZEwindow mapWindow w h x y }; 0;; fun rflSizeMapWindow (wn, blurp, w, h)= _fooS "rflSizeMapWindow"; let _GETwindowSizePosition wn -> [_ _ x y] in { _fooS strcat " x == " if x==nil then "nil" else itoa x; _fooS strcat " y == " if y==nil then "nil" else itoa y; _fooS strcat " w == " if w==nil then "nil" else itoa w; _fooS strcat " h == " if h==nil then "nil" else itoa h; rflDMSResizeMap [wn x y w h] "map" };; fun rflClickMapWindow (w, blurp, x, y, button)= let search_in_list rects @rectByPoint [x y] -> r in if r==nil then nil else if button==1 then { set activeRect = r; if userList != nil then { _RSTlist userList; fillUserList activeRect.userRect } else nil; if rectCombo != nil then let pos_in_list rects r 0 -> index in _SELcombo rectCombo index else nil; _DMSevent this strcat "click_" r.aliasRect nil nil } else if button==2 then _DMSevent this strcat "rclick_" r.aliasRect nil nil else nil;; var inside = 0;; typeof insideRec = Rect;; /*modif 2.5*/ fun _hideBubble(t,b)= _deltimer t; _DSwindow bubbleWindow; set bubbleWindow=nil; 0;; fun _showBubble(t,b)= let _GETscreenPos->[xx yy] in let b-> [sx sy name] in ( _MVwindow bubbleWindow xx+5 yy+5; _SHOWwindow bubbleWindow WINDOW_UNHIDDEN; _SETfocus mapWindow; _PAINTrectangle bubbleWindow 0 0 sx+10 sy+4 DRAW_SOLID 1 make_rgb 0 0 0 DRAW_SOLID make_rgb 251 255 204; _TXTout bubbleWindow bubbleFont 5 2 TD_LEFT+TD_TOP make_rgb 0 0 0 name; _deltimer t; 0 );; /*fin modif 2.5*/ fun rflCursorMapWindow (wn, blurp, x, y, b)= if b!=0 then nil else let search_in_list rects @rectByPoint [x y] -> r in if r==nil then { if inside then { /*modif sd*/ _RSTlist userList; /*modif sd*/ resetMap; _PAINTwindow mapWindow } else nil; set inside = 0; /*modif 2.5*/ _DSwindow bubbleWindow; nil /*fin modif 2.5*/ } else if inside && (r==insideRec) then nil else { set insideRec = r; set inside = 1; /*modif 2.4*/ if userList != nil then { _RSTlist userList; fillUserList insideRec.userRect } else nil; /*modif 2.4*/ if altmap == nil then nil else { resetMap; _CPbitmap16 workmap r.xRect r.yRect altmap r.xRect r.yRect r.wRect r.hRect nil; _PAINTwindow mapWindow; }; /*MODIF 2.5*/ _DSwindow bubbleWindow; let r.aliasRect -> name in let _GETstringSize bubbleFont name -> [sx sy] in ( set bubbleWindow=_CRwindow _channel mapWindow nil nil sx+10 sy+4 WN_NOBORDER+WN_NOCAPTION+WN_HIDDEN "bubble"; _deltimer bubbleTimer; set bubbleTimer=_rfltimer _starttimer _channel 300 @_showBubble [sx sy name]; _deltimer bubbleTimer2; set bubbleTimer2=_rfltimer _starttimer _channel 2000 @_hideBubble nil; ); /*FIN MODIF 2.5*/ _DMSevent this strcat "over_" r.aliasRect nil nil; };; /* reflexes users */ fun rflDMSEndUser (zone)= _DSlist userList; set userList = nil; 0;; fun rflDMSResizeUser (coord, s)= let coord->[wn x y w h] in _SIZElist userList w h x y; 0;; fun rflDclickUserList (ul, blurp, index, string)= let nth_list activeRect.userRect index -> nickname in _DMSsend this Ccontact [activeRect.aliasRect nickname];; /* reflexes mainButton */ fun rflDMSResizeMainButton (coord, zone)= let coord -> [wn x y w h] in _SIZEbutton mainButton w h x y; 0;; fun rflMainButton (b, blurp)= if mapWindow==nil then let _DMSgetZone this "map" @rflDMSEndMap @rflDMSResizeMap @rflDMSEndMap -> [wn x y w h] in let if wn==nil then [nil 5 5 wmap hmap WN_NORMAL] else [wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER] -> [win mx my mw mh f] in { set winpMAP=wn; set mapWindow = _CRwindow _channel win mx my mw mh f _DMSgetName this; _CBwinPaint mapWindow @rflPaintMapWindow 0; _CBwinClick mapWindow @rflClickMapWindow 0; _CBcursorMove mapWindow @rflCursorMapWindow 0; if win==nil then { _CBwinDestroy mapWindow @rflDestroyMapWindow 0; _CBwinSize mapWindow @rflSizeMapWindow 0; } else nil; if map==nil then if mapFile==nil then { _DSbitmap workmap; set workmap = _FILLbitmap _CRbitmap _channel wmap hmap 0xffffff; } else nil else { endloadMap mapFile; _CPbitmap16 workmap 0 0 map 0 0 wmap-1 hmap-1 nil; }; set xscale = (itof mw)/.(itof wmap); set yscale = (itof mh)/.(itof hmap); _fooS "rflMainButton"; _fooS strcat " xscale == " if xscale==nil then "nil" else ftoa xscale; _fooS strcat " yscale == " if yscale==nil then "nil" else ftoa yscale; _fooS strcat " wmap == " if wmap==nil then "nil" else itoa wmap; _fooS strcat " hmap == " if hmap==nil then "nil" else itoa hmap; _PAINTwindow mapWindow } else { _SHOWwindow mapWindow WINDOW_UNHIDDEN; _PAINTwindow mapWindow }; if rectCombo==nil then let _DMSgetZone this "combo" @rflDMSEndCombo @rflDMSResizeCombo @rflDMSEndCombo -> [wn x y w h] in if wn==nil then set rectCombo = nil else { set rectCombo = _CRcombo _channel wn x y w 100 CB_NOEDIT|CB_AHSCROLL|CB_DOWN ""; _CBcombo rectCombo @rflSelCombo 0; fillRectCombo rects; if activeRect == nil then nil else let pos_in_list rects activeRect 0 -> pos in _SELcombo rectCombo pos; } else nil; if userList==nil then let _DMSgetZone this "list" @rflDMSEndUser @rflDMSResizeUser @rflDMSEndUser -> [wn x y w h] in if wn==nil then set userList = nil else { set userList = _CRlist _channel wn x y w h LB_VSCROLL|LB_DOWN; _CBlistDclick userList @rflDclickUserList 0; fillUserList activeRect.userRect } else nil;; fun __show ()= _fooS "__show"; _fooS strcat " xscale == " if xscale==nil then "nil" else ftoa xscale; _fooS strcat " yscale == " if yscale==nil then "nil" else ftoa yscale; rflMainButton nil 0; _SHOWcombo rectCombo WINDOW_UNHIDDEN; _SHOWlist userList WINDOW_UNHIDDEN; _DMSevent this "shown" nil nil;; /* DMS */ fun IniDMI (map_w_h)= set bubbleFont=_CRfont _channel 16 1 0 "Arial"; _DMSregisterDMI this nil nil; let hd hd strextr map_w_h -> mf in let if !strcmp mf "*" then nil else mf -> mapfile in { set xscale = itof 1; set yscale = itof 1; set wmap = atoi hd hd tl strextr map_w_h; set hmap = atoi hd hd tl tl strextr map_w_h; _fooS "IniDMI"; _fooS strcat " xscale == " if xscale==nil then "nil" else ftoa xscale; _fooS strcat " yscale == " if yscale==nil then "nil" else ftoa yscale; _fooS strcat " wmap == " if wmap==nil then "nil" else itoa wmap; _fooS strcat " hmap == " if hmap==nil then "nil" else itoa hmap; _RSCdownload this mapfile mapfile @endloadMap 1; set workmap = _FILLbitmap _CRbitmap _channel wmap hmap 0xffffff; let _DMSgetZone this "button" nil @rflDMSResizeMainButton nil -> [wn x y w h] in if wn==nil then { /* rflMainButton nil [wmap hmap]; */ set mainButton = nil } else set mainButton = _CBbutton _CRbutton _channel wn x y w h 0 _DMSgetName this @rflMainButton [wmap hmap]; }; _DMSsend this Cstarted [];; /* _DMSevent this "started" nil nil;; */