/* Loto client graphic interface - june 2000 - by Julien ZORKO */ /* Bitmaps required by the interface */ var fBgGrid="Dms/Games/Loto/gridbg.jpg";; var fBoxes="Dms/Games/Loto/boxes.png";; var fTokens="Dms/Games/Loto/tokens.png";; var fNewGame="Dms/Games/Loto/newgame.bmp";; var fNewGrid="Dms/Games/Loto/newgrid.bmp";; var fAdmin="Dms/Games/Loto/admin.bmp";; var fBackGround="Dms/Games/Loto/bgcontrol.jpg";; var fQuitBut="Dms/Games/Loto/quitbut.bmp";; var fScrolPl="Dms/Games/Loto/scrolpl.jpg";; var fScrolGa="Dms/Games/Loto/scrolga.jpg";; /* here are the constants for drawing the interface */ /* grid position */ var gridX=5;; var gridY=30;; var tokenX=310;; var tokenY=30;; /* game list position and size */ var gamesX=5;; var gamesY=160;; var gamesW=145;; var gamesH=135;; /* players list position and size */ var playersX=155;; var playersY=160;; var playersW=140;; var playersH=135;; /* info window position and size */ var infoX=300;; var infoY=70;; var infoW=95;; var infoH=180;; /* new grid button position */ var newgridX=345;; var newgridY=55;; /* administration button position */ var adminX=350;; var adminY=280;; /* logout button position */ var logoutX=300;; var logoutY=280;; /* transparency color */ var transColor=0x008000;; /* Variables */ typeof myGame=S;; typeof mySelGame=S;; /*------------ Graphic Objects ----------- */ typeof serWin=ObjWin;; /* main window */ typeof SerCon=ObjContainer;; /* container in the window where the interface will be drawn */ typeof scGameList=CompList;; typeof scPlayerList=CompList;; typeof txtNewGame=CompText;; typeof txtPlayList=CompText;; typeof txtInfo=CompText;; typeof zoneInfo=CompText;; /**************************************************************************************** * La grille et les jetons sont dessinés sur deux compBitmaps de même taille superposés * Derrière la bitmap de jetons on voit la grille par transparence, et derrière la grille * on voit le plateau de jeu (qui contient entre autre les cadres des différentes parties ) ****************************************************************************************/ typeof bmpGrid=CompBitmap;; typeof bmpToks=CompBitmap;; typeof butNewGrid=CompRollOver;; typeof butLogoutGame=CompRollOver;; typeof butCreateGame=CompRollOver;; typeof butToken=CompBitmap;; typeof bmpTokens=AlphaBitmap;; typeof bmpBoxes=AlphaBitmap;; typeof bmpBgTokens=ObjBitmap;; typeof bmpBgBoxes=ObjBitmap;; /**************************************************************************************** * in order to optimize the display, references to the alphabitmaps of the compBitmaps * are kept in order to directly redraw in them ****************************************************************************************/ typeof scrBoxes=AlphaBitmap;; typeof scrTokens=AlphaBitmap;; typeof scrToken=AlphaBitmap;; typeof stText=ObjFont;; typeof stTextHead=ObjFont;; typeof stVscrollBmp=AlphaBitmap;; typeof stHscrollBmp=AlphaBitmap;; /* -------------Other functions------------- */ fun _end(a)=_DMSdelete this;; fun _destroyevent(a,b)=_DMSdelete this;; fun _quit_control(a,b,c,d,e,f)=_DScontainer SerCon;; /* Grid Content */ fun _TransSatList(l,m)= let l -> [a next] in if a==nil then nil else let m -> [t inf sup] in let a+t -> a in if asup then sup::_TransSatList next m else a::_TransSatList next m;; /*-----------------Grid creation----------------- */ fun _IniAlphaBitmaps()= set bmpBoxes = _LDalphaBitmap _channel _checkpack fBoxes; set bmpTokens = _LDalphaBitmap _channel _checkpack fTokens; set bmpBgBoxes = _LDjpeg _channel _checkpack fBgGrid; let _GETbitmapSize bmpBgBoxes -> [w h] in let _GETalphaBitmapSize bmpTokens -> [tw th] in ( set bmpBgTokens = _CRbitmap _channel w h; _FILLbitmap bmpBgTokens transColor; set scrTokens = _CRalphaBitmap _channel (_CRbitmap _channel w h) nil transColor transColor; set scrBoxes = _CRalphaBitmap _channel (_CRbitmap _channel w h) nil transColor transColor; set scrToken = _CRalphaBitmap _channel (_CRbitmap _channel tw/91 th) nil transColor transColor; set bmpGrid = _CRcompBitmap _channel SerCon nil [gridX gridY] OBJ_VISIBLE 0 scrBoxes 0 0 w h; set bmpToks = _CRcompBitmap _channel SerCon nil [gridX gridY] OBJ_VISIBLE 0 scrTokens 0 0 w h; set butToken = _CRcompBitmap _channel SerCon nil [tokenX tokenY] OBJ_VISIBLE|OBJ_ENABLE OBJ_CONTAINER_DBLCLICK scrToken 0 0 tw th );; /**************************************************************************************** * Fonction récursive qui dessine les cases de la grille en fonction d'une * chaine de caractères qui représente son contenu ****************************************************************************************/ fun _PaintBoxes(icontent,i,rows,gridbg,gridboxes,posx,posy,sizex,sizey)= let icontent -> [first next] in if first==nil then gridbg else ( _CPalphaBitmap gridbg posx+sizex*(i/rows) posy+sizey*(mod i rows) gridboxes sizex*first 0 sizex sizey; _PaintBoxes next i+1 rows gridbg gridboxes posx posy sizex sizey );; fun _GetGridBitmap(content,bitmaps,dest)= let content -> [rows cols icontent] in let bitmaps -> [gridbg gridboxes] in let _GETbitmapSize dest -> [w h] in let _SCPbitmap dest 0 0 w h gridbg 0 0 w h nil -> bg in let _GETalphaBitmapSize gridboxes -> [sizex sizey] in let sizex/91 -> sizex in let _GETbitmapSize bg -> [posx posy] in let [(posx-(cols*sizex))/2 (posy-(rows*sizey))/2]->[posx posy] in _PaintBoxes icontent 0 rows bg gridboxes posx posy sizex sizey;; /************************************************************************************** * redessine la grille quand le serveur le demande **************************************************************************************/ fun __DrawGrid(rows,cols,content)= let [rows cols (_TransSatList (strtolist content) [0 0 90])] -> content in let _GETalphaBitmaps scrBoxes -> [bmp _] in _GetGridBitmap content [bmpBgBoxes bmpBoxes] bmp; _PAINTcontainer SerCon;; fun __DrawTokens(rows,cols,content)= let [rows cols (_TransSatList (strtolist content) [-100 0 90])] -> content in let _GETalphaBitmaps scrTokens -> [bmp _] in _GetGridBitmap content [bmpBgTokens bmpTokens] bmp; _PAINTcontainer SerCon;; /*-------------- window creation----------------- */ fun _CreateControl()= /* si on veut créer le container dans une fenêtre ou un zone d'affichage */ let _DMSgetZone this "Board" @_end nil @_end ->[wn x y w h] in (set stText= _CRfont _channel 12 0 0 "Verdana"; set stTextHead= _CRfont _channel 12 0 FF_WEIGHT "Verdana"; set serWin = ( if wn==nil then ( set w=400; set h=300; _CRwindow _channel DMSwin nil nil w h WN_MENU|WN_MINBOX _DMSgetName this ) else ( _CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this ) ); /* ---- */ set SerCon=_CRcontainerFromObjWin _channel serWin 0 0 400 300 CO_CHILDINSIDE 0xffffaa "Loto"; /* dessin du fond */ let _LDjpeg _channel _checkpack fBackGround -> fond in let _GETbitmapSize fond -> [w h] in let _CRalphaBitmap _channel fond nil nil nil -> bg in _CRcompBitmap _channel SerCon nil [0 0] OBJ_VISIBLE 0 bg 0 0 w h; /* création des deux compBitmap (grille et jetons) */ _IniAlphaBitmaps; /* titre de la liste des parties */ _CRcompText _channel SerCon nil [gamesX gamesY] OBJ_VISIBLE nil 100 15 "Games list" stTextHead [0 0 0 0] [0 50] nil nil; /* liste des parties */ let _LDjpeg _channel _checkpack fScrolGa -> bmp in let _CRalphaBitmap _channel bmp nil nil nil -> abmp in set scGameList= _CRcompList _channel SerCon nil [gamesX+10 gamesY+15] OBJ_ENABLE|OBJ_VISIBLE|LST_LEFT|LST_HIGHLIGHT_SELECTED|LST_HIGHLIGHT_CLICKED OBJ_CONTAINER_CLICK gamesW-10 gamesH-30 10 LST_VERTICAL stText 1 [0 0 0 0] [0 50] [[-10 0] SLB_MASK|SLB_ROLLOVER abmp [10 94 104]]; /* champ de saisie d'un nom de partie */ set txtNewGame= _CRcompText _channel SerCon nil [gamesX+58 gamesY+gamesH-15] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_EDITLINE 0 gamesW-58 15 "Game" _CRfont _channel 12 2000 FF_WEIGHT "Verdana" [0 0 0 0] [0 50] nil nil; /* titre de al liste des joueurs */ set txtPlayList= _CRcompText _channel SerCon nil [playersX playersY] OBJ_VISIBLE 0 playersW 15 "Joueurs:" _CRfont _channel 12 2000 FF_WEIGHT "Verdana" [0 0 0 0] [0 50] nil nil; /* liste des joueurs */ let _LDjpeg _channel _checkpack fScrolPl -> bmp in let _CRalphaBitmap _channel bmp nil nil nil -> abmp in set scPlayerList= _CRcompList _channel SerCon nil [playersX+10 playersY+15] OBJ_ENABLE|OBJ_VISIBLE|LST_LEFT|LST_HIGHLIGHT_CLICKED OBJ_CONTAINER_CLICK playersW-10 playersH-15 10 LST_VERTICAL stText 1 [0 0 0 0] [0 50] [[-10 0] SLB_MASK|SLB_ROLLOVER abmp [10 106 116]]; /* bouton de creation d'une nouvelle partie */ let _LDbitmap _channel _checkpack fNewGame -> bmp in let _CRalphaBitmap _channel bmp nil nil 0xffffff -> abmp in set butCreateGame= _CRcompRollOver _channel SerCon nil [gamesX gamesY+gamesH-15] OBJ_VISIBLE|OBJ_ENABLE OBJ_CONTAINER_CLICK abmp; /* bouton de génération d'une nouvelle grille */ let _LDbitmap _channel _checkpack fNewGrid -> bmp in let _CRalphaBitmap _channel bmp nil nil 0xffffff -> abmp in set butNewGrid= _CRcompRollOver _channel SerCon nil [newgridX newgridY] OBJ_VISIBLE|OBJ_ENABLE OBJ_CONTAINER_CLICK abmp; /* bouton pour quitter la partie (s'affiche à la place du bouton de création de partie) */ let _LDbitmap _channel _checkpack fQuitBut-> bmp in let _CRalphaBitmap _channel bmp nil nil 0xffffff -> abmp in set butLogoutGame= _CRcompRollOver _channel SerCon nil [gamesX gamesY+gamesH-15] OBJ_HIDE|OBJ_ENABLE OBJ_CONTAINER_CLICK abmp; /* titre de la zone d'infos */ set txtInfo= _CRcompText _channel SerCon nil [infoX infoY] OBJ_VISIBLE 0 infoW 15 "Infos" _CRfont _channel 12 2000 FF_WEIGHT "Verdana" [0 0 0 0] [0 50] nil nil; /* zone de texte où défilent les infos sur la partie */ set zoneInfo= _CRcompText _channel SerCon nil [infoX infoY+15] OBJ_VISIBLE|CT_WORDWRAP|CT_LABEL|CT_LEFT 0 infoW infoH-15 "" stText [0x207020 10 0 0] [0 50] nil nil; 0);; /* chaine de caractères du titre de la liste des joueurs */ fun _NewPlayListText(game)= _SETcompText txtPlayList strcat "in->" game stText [0 0 0 0] CT_NOCHANGE;;