/* CLOUVION - part Client - 03/2004 */ /* by iri - http://www.irizone.net */ typeof win = ObjWin;; /* fenetre du module */ typeof background = S;; /* path du bmp de fond */ typeof BGbmp = ObjBitmap;; /* bmp de fond */ typeof colorTexte = I;; /* couleur du texte */ typeof saisie = ObjText;; /* champ de saisie */ typeof cpteur = ObjText;; /* compte à rebours */ typeof defWord = S;; /* mot à taper */ typeof loginTop = S;; /* login du meilleur score */ typeof usersList = [S r1];; /* liste des pseudos */ typeof wordmax = S;; /* nombre max de mots */ var premier = 1;; /* avant lancement = 1 */ var rebours = 5;; /* décompte temps */ var score = 0;; /* score courant */ var delai = 1000;; /* delai initial par lettre */ var scoreTop = 0;; /* meileur score */ var palierScore = [0 0];; /* sauvegarde palier précédent */ defcom Cregister = register;; defcom CgetWord = getWord;; defcom CnewScore = newScore I;; /* TO DO : mettre des commentaires ... */ /* fun [I ObjFont I] I */ fun _pseudo(i, font, w)= if i > ((sizelist usersList)*2) then 0 else let nth_list usersList i -> name in let nth_list usersList i+1 -> points in (_DRAWtext BGbmp font w-110 11+i*5 TD_TOP|TD_LEFT colorTexte name; _DRAWtext BGbmp font w-10 11+i*5 TD_TOP|TD_RIGHT colorTexte points; _pseudo i+3 font w);; /* fun [] ObjBitmap */ fun loadABMP()= let _LDbitmap _channel _checkpack background -> tmp in if tmp == nil then let _LDjpeg _channel _checkpack background -> tmp in if tmp == nil then _LDbitmap _channel _checkpack "logo.bmp" else tmp else tmp;; /* fun [] ObjWin */ fun draw()= set BGbmp = loadABMP; let _GETwindowPositionSize win -> [_ _ w h] in let _GETbitmapSize BGbmp -> [wbmp hbmp] in let _CRfont _channel 18 0 FF_WEIGHT "Arial" -> font in let _CRfont _channel 16 0 FF_WEIGHT "Arial" -> font2 in ( _DRAWtext BGbmp font (w/2)-60 5 TD_TOP|TD_CENTER colorTexte (_loc this "title" nil); _DRAWtext BGbmp font2 w-100 3 TD_TOP|TD_LEFT colorTexte (_loc this "gamer" nil); _DRAWrectangleText BGbmp font2 10 50 w-140 50 colorTexte 0 (_loc this "instructions" nil); _DRAWtext BGbmp font (w/2)-60 130 TD_BASELINE|TD_CENTER colorTexte defWord; if premier then _DRAWtext BGbmp font2 10 170 TD_BASELINE|TD_LEFT colorTexte (_loc this "ready" nil) else _DRAWtext BGbmp font2 10 170 TD_BASELINE|TD_LEFT colorTexte (_loc this "close" nil); _DRAWtext BGbmp font2 160 170 TD_BASELINE|TD_LEFT colorTexte (_loc this "rebours" nil); _DRAWtext BGbmp font2 10 260 TD_BASELINE|TD_LEFT colorTexte (_loc this "myscore" nil); _DRAWtext BGbmp font2 110 260 TD_BASELINE|TD_LEFT colorTexte itoa score; _DRAWtext BGbmp font2 150 260 TD_BASELINE|TD_LEFT colorTexte (_loc this "top" nil); _DRAWtext BGbmp font2 w-250 260 TD_BASELINE|TD_LEFT colorTexte strcat itoa scoreTop loginTop; _DRAWtext BGbmp font2 10 275 TD_BASELINE|TD_LEFT colorTexte strcatn (_loc this "wordmax" nil)::" "::wordmax::nil; _DRAWline BGbmp w-120 10 w-120 h-10 DRAW_SOLID 1 colorTexte; _pseudo 1 font2 w; _STBLTbitmap win 0 0 w h BGbmp 0 0 wbmp hbmp; _PAINTwindow win );; /* fun [ObjWin U0] ObjWin */ fun _paint(wn, u)= let _GETwindowPositionSize win -> [_ _ w h] in let _GETbitmapSize BGbmp -> [wbmp hbmp] in _STBLTbitmap win 0 0 w h BGbmp 0 0 wbmp hbmp/*; _PAINTwindow win*/;; /* fun [S] I */ fun endDownload(file)= _DMSsend this Cregister []; 0;; /* fun [] I */ fun getWord()= _DMSevent this "clicReady" nil nil; _DMSsend this CgetWord [];; /* fun [ObjText I S] I */ fun _newLevel(objtext, u, s)= if premier then (set premier = 0; draw; getWord) else 0;; /* fun [ObjWin I] I */ fun _destroyevent(a,b)= _DSbitmap BGbmp; _DStext saisie; _DStext cpteur; _DSwindow win; _DMSreleaseZone this "clouvion";; /* fun [[ObjWin I I I I] S] I */ fun _resize(x,s)= let x->[wn x y w h] in let _GETbitmapSize BGbmp -> [wbmp hbmp] in ( _SIZEwindow win w h x y; _SIZEtext saisie 210 20 (w-200)/2-60 200; _SIZEtext cpteur 25 20 w-155 156; _STBLTbitmap win 0 0 w h BGbmp 0 0 wbmp hbmp ); 0;; fun _end(a)= /*_DMSdelete this;;*/0;; /* fun [DMI S S [User r1] Tag] I */ fun close(from, action, param, others, tag)= _DSbitmap BGbmp; _DStext saisie; _DStext cpteur; _DSwindow win; _DMSreleaseZone this "clouvion"; 0;; /* fun [ObjWin I I I I] I */ fun _clic(window, u, x, y, btn)= let _CRfont _channel 16 0 FF_WEIGHT "Arial" -> font in if premier then let _GETstringSize font (_loc this "ready" nil) -> [w h] in if (x > 10) && (x < (10+w)) && (y > 153) && (y < (153+h)) then (set premier = 0; draw; getWord) else 0 else let _GETstringSize font (_loc this "close" nil) -> [w h] in if (x > 10) && (x < (10+w)) && (y > 153) && (y < (153+h)) then close nil nil nil nil nil else 0;; /* fun [DMI S S [User r1] Tag] I */ fun show(from, action, param, others, tag)= close nil nil nil nil nil; set premier = 1; set rebours = 5; set score = 0; set delai = 1000; set palierScore = [0 0]; set defWord = ""; let _DMSgetZone this "clouvion" @_end @_resize nil -> [wn x y wZone hZone] in ( set win = if wn == nil then _CRwindow _channel DMSwin nil nil 500 290 WN_MENU _DMSgetName this else _CRwindow _channel wn x y wZone hZone WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this; _CBwinDestroy win @_destroyevent 0; _CBwinClick win @_clic 0; _CBwinPaint win @_paint 0; draw; let _GETwindowPositionSize win -> [_ _ w h] in (set saisie = _CReditLine _channel win ((w-200)/2)-60 210 200 20 ET_AHSCROLL|ET_ALIGN_CENTER|ET_DOWN ""; set cpteur = _CReditLine _channel win w-35-120 156 25 20 ET_DOWN ""); _CBlineOk saisie @_newLevel 0; /* _PAINTwindow win;*/ 0 ) ;; /* fun [] I */ fun _beforeclose()= _DMSsend this CnewScore [score]; _DSbitmap BGbmp; _DSwindow win; 0;; /* fun [S] I */ fun IniDMI(param)= let lineextr param -> [PcolorTexte[Pbackground _]] in ( set background = Pbackground; set colorTexte = atoi PcolorTexte; ); _RSCdownload this background background @endDownload 3; _DMSregister this @_beforeclose; _DMSdefineActions this ["show" @show]:: ["close" @close]:: nil; 0;; /* fun [Timer] I */ fun _winner(t)= _SETtext saisie (_loc this "bravo" nil); set defWord = ""; set score = score+10; set premier = 1; set rebours = 5; _DMSsend this CnewScore [score]; _DMSevent this "won" itoa score nil; _deltimer t; draw; 0;; /* fun [Timer] I */ fun _looser(t)= _SETtext saisie (_loc this "huuh" nil); set defWord = ""; let palierScore -> [level period] in (set score = 50*level; set delai = period); set premier = 1; set rebours = 5; _DMSsend this CnewScore [score]; _DMSevent this "lost" itoa score nil; _deltimer t; draw; 0;; /* fun [Timer I] I */ fun _temps(t, u)= _DMSevent this "endTime" nil nil; let _GETtext saisie -> text in if !strcmp text defWord then _winner t else _looser t; 0;; /* fun [Timer S] I */ fun _rebours(t, word)= set rebours = rebours-1; _SETtext cpteur itoa rebours; if premier then (_deltimer t; 0) else 0; if rebours < 1 then (set defWord = word; draw; _SETtextFocus saisie; _deltimer t; let (strlen defWord)*(delai-(delai/10)) -> delai2 in _rfltimer _starttimer _channel delai2 @_temps 0; if delai > 10 then ( let palierScore -> [level period] in if (50*(level+1)) == score then set palierScore = [level+1 delai] else nil; set delai = delai-(delai/10) ) else set delai = 10; 0) else 0;; /* fun [S] I */ fun __setWord(word)= _SETtext saisie ""; _rfltimer _starttimer _channel 1000 @_rebours word; 0;; /* fun [I] I */ fun __registered(param)= let lineextr param -> [top[login[max _]]] in (set loginTop = strcat " : " login; set wordmax = max; set scoreTop = atoi top); draw;; /* fun [Timer S] I */ fun _checkrebours(t, u)= if rebours == 5 then (_deltimer t; set usersList = lineextr u; draw; 0) else 0;; /* fun [S] I */ fun __user(param)= _rfltimer _starttimer _channel 100 @_checkrebours param; 0;;