/* Score Client - DMS - Mar 98 - by Sylvain HUET */ typeof win=ObjWin;; typeof highT=ObjText;; typeof highL=ObjList;; typeof curT=ObjText;; typeof curL=ObjList;; typeof messT=ObjText;; typeof closeB=ObjButton;; typeof last=S;; struct Score=[nameScore:S,scoreScore:I]mkScore;; typeof current=[Score r1];; typeof high=[Score r1];; fun AToHigh(l)= if l==nil then nil else let l->[a n] in if nil==hd a then AToHigh n else (mkScore[hd a atoi hd tl a])::AToHigh n;; fun addline(li,l,i)= if l==nil then 0 else let l->[a n] in (_ADDlist li 1000 strcatn (itoa i)::" . "::(a.nameScore)::" : "::(itoa a.scoreScore)::nil; addline li n i+1);; fun _destroyE(a,b)= _DMSdelete this;; fun _end(b)= _DMSdelete this;; fun _resize(x,s)= let x->[wn x y w h] in _SIZEwindow win w h x y; 0;; fun _resizeE(a,b,w,h)= if (h<100)||(w<70) then nil else let (h-30)/2->h1 in (_SIZEtext highT w-10 20 5 5; _SIZElist highL w-10 h1-30 5 30; _SIZEtext curT w-10 20 5 h1+5; _SIZElist curL w-10 h1-30 5 h1+30; _SIZEtext messT w-65 20 5 h-25; _SIZEbutton closeB 50 20 w-55 h-25);; fun createwin(w0,h0,p)= let if h0<100 then 100 else h0->h in let if w0<70 then 70 else w0->w in let (h-30)/2->h1 in (set highT=_CRtext _channel win 5 5 w-10 20 ET_BORDER+ET_AHSCROLL if p!=nil then p else strcat _DMSgetName this (_loc this "SC_HIGH" nil); set highL=_CRlist _channel win 5 30 w-10 h1-30 LB_DOWN+LB_VSCROLL; set curT=_CRtext _channel win 5 h1+5 w-10 20 ET_BORDER+ET_AHSCROLL (_loc this "SC_CURRENT" nil); set curL=_CRlist _channel win 5 h1+30 w-10 h1-30 LB_DOWN+LB_VSCROLL; set messT=_CRtext _channel win 5 h-25 w-65 20 ET_DOWN+ET_AHSCROLL ""; set closeB=_CBbutton (_CRbutton _channel win w-55 h-25 50 20 0 (_loc this "SC_CLOSE" nil)) @_destroyE 0; );; fun __setHigh(s)= set last=s; set high=AToHigh strextr s; _RSTlist highL; addline highL high 1;; fun __setCur(s)= set current=AToHigh strextr s; _RSTlist curL; addline curL current 1;; fun __endGame(s,i)= _SETtext messT strcatn (_loc this "SC_RESULT" nil)::" : "::s::" : "::(itoa i)::nil;; fun IniDMI(param)= let _DMSgetZone this "Score" @_end @_resize @_end ->[wn x y w h] in if wn==nil then (set win=_CRwindow _channel DMSwin nil nil 300 300 WN_MENU+WN_MINBOX+WN_SIZEBOX _DMSgetName this; _CBwinDestroy win @_destroyE 0; createwin 300 300 param) else (set win=_CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this; createwin w h param); _CBwinSize win @_resizeE 0; 0;; fun __setName(p)= _SETtext highT if p!=nil then p else strcat _DMSgetName this (_loc this "SC_HIGH" nil);; defcom CsetHigh=setHigh S;; defcom CstartS=startS S;; defcom CendS=endS;; typeof wine=ObjWin;; typeof highe=ObjText;; typeof sesse=ObjText;; fun _send(a,b)=_DMSsend this CsetHigh [_GETtext highe];; fun _starts(a,b)=_DMSsend this CstartS [_GETtext sesse];; fun _ends(a,b)=_DMSsend this CendS [];; fun _destroye(a,b)=set wine=nil;; fun __edit(s)= if wine!=nil then nil else (set wine=_CRwindow _channel DMSwin nil nil 320 220 WN_MENU+WN_MINBOX (_loc this "SC_ADMIN" nil); _CBwinDestroy wine @_destroye 0; _CRtext _channel wine 5 5 290 20 ET_DOWN+ET_AHSCROLL (_loc this "SC_ADMIN" nil); set highe=_CReditText _channel wine 5 30 250 150 ET_DOWN+ET_HSCROLL+ET_VSCROLL last; _CBbutton (_CRbutton _channel wine 260 150 55 20 0 (_loc this "SC_SEND" nil)) @_send 0; _CBbutton (_CRbutton _channel wine 5 190 70 20 0 (_loc this "SC_STARTS" nil)) @_starts 0; set sesse=_CReditLine _channel wine 75 190 170 20 ET_DOWN+ET_AHSCROLL s; _CBbutton (_CRbutton _channel wine 245 190 70 20 0 (_loc this "SC_ENDS" nil)) @_ends 0);;