/* Jukebox - DMS - juin 00 - by Ariane Bitoun */ defcom CAddSound=addsound S;; defcom Cfinished=finished S;; defcom CDownloaded=downloaded S I;; defcom Cstarted=started S;; defcom CMnuRemoveQ=removeq S I;; defcom CMnuRemoveL=removel S I;; defcom CMnuEditL=editl S S S I;; defcom CMnuAddSoundL=addsoundl S S S;; defcom CMnuPutNextQ=putnextl S I;; defcom CChangeNbMax=changenbmax I I;; typeof nbloop = I;; typeof soundlist = [[S S] r1];; /* [name file] */ typeof playinglist = [[S Multi] r1];; /* [name multi] */ typeof containerl=ObjContainer;; typeof containerq=ObjContainer;; typeof queue=CompList;; typeof list=CompList;; typeof Verdana14=ObjFont;; typeof NbMaxL=I;; typeof NbMaxQ=I;; proto activate = fun [DMI S S S] I;; /*********************/ typeof IndexClicked=I;; typeof IndexClickedMemory=I;; typeof menul=ObjMenu;; typeof MnuAddL=ObjMenuItem;; typeof MnuRemoveL=ObjMenuItem;; typeof MnuEditL=ObjMenuItem;; typeof MnuAddQueueL=ObjMenuItem;; typeof MnuOptionL=ObjMenuItem;; typeof menuq=ObjMenu;; typeof MnuPutNextQ=ObjMenuItem;; typeof MnuRemoveQ=ObjMenuItem;; /*********************/ /****UTILITAIRES****/ fun MY_strcmp_name (i1, i2)= let i1->[n1 s1] in let i2->[n2 s2] in if strcmp n1 n2 then 0 else 1;; fun MY_pos_in_list(lst,name,n)= if lst==nil then nil else let lst -> [[a _] nxt] in if !strcmp a name then n else MY_pos_in_list nxt name n+1;; fun MY_listcat (l1, l2)= if l1==nil then l2 else let l1 -> [val nxt] in val::(MY_listcat nxt l2);; /*Utilitaire pour concatener dans une string la premiere colonne d'une liste*/ fun selectname(l)= { if l!=nil then let hd l->[name sound] in name::selectname tl l else nil };; fun NameStr(l)= strbuild (selectname l)::nil;; fun MY_exist_in_list(list,tup,n)= if list==nil then n else let tup->[n1 s1] in let hd list->[n2 s2] in if !strcmp n1 n2 then MY_exist_in_list tl list tup n+1 else MY_exist_in_list tl list tup n;; /****FIN UTILITAIRES****/ /*fonction appellée lorsque le multi change de mode*/ fun reflex (multi, name, newstate)= if newstate == MEDIA_MODE_STOP then ( _DMSsend this Cfinished [name]; _DMSevent this "finished" name nil; multi) else if newstate == MEDIA_MODE_PLAY then ( _DMSsend this Cstarted [name]; multi) else nil;; /*CB appellée a la fin du chargement des fichiers son : __downloadsound*/ fun _downloaded (file, name_index)= if file==nil then 0 else (let name_index ->[name index] in let _CRmulti _channel DMSwin 0 0 0 0 _checkpack file nil -> multi in (set playinglist = MY_listcat playinglist [name multi]::nil; _DMSsend this CDownloaded [name index] ); 0 );; /*joue le morceau n° index de la liste liste*/ fun playListe(liste,index)= let hd playinglist -> [name multi] in let _GETmultiMode multi-> mode in if mode==MEDIA_MODE_PLAY then (_SETmultiReflexMode multi nil name; _DSmulti multi ) else nil; let nth_list playinglist index -> [name multi] in (_SETmultiReflexMode multi @reflex name; _DMSevent this "started" name nil; _PLAYmulti multi; ) ;; /*stoppe le morceau n° index de la liste liste*/ fun stopSound(liste,index)= let nth_list playinglist index -> [name multi] in (_SETmultiReflexMode multi nil name; _DMSevent this "finished" name nil; _DSmulti multi) ;; /*Affiche dans un objet complist, une liste de string*/ proto loadliste = fun [CompList [S r1] I] S;; fun loadliste(lstobj,listname,index)= if listname!=nil then (let hd listname->name in _ADDcompList lstobj index [name nil]; let index+1 -> index in loadliste lstobj tl listname index; "" ) else "";; /*Ajoute un morceau dans la file d'attente*/ fun AddSoundInQueue(lstcompl,toto, index)= if (_GETcompListCount queue) < NbMaxQ then (let _GETcompListValue lstcompl index ->[name _] in if name==nil then nil else (_DMSsend this CAddSound [name]) ) else nil ;; /*Affiche l'interface client*/ fun show(param)= set Verdana14=_CRfont _channel 14 0 0 "Verdana"; let _DMSgetZone this "Liste" nil nil nil -> [objwinl cxl cyl cll chl] in let _DMSgetZone this "Queue" nil nil nil -> [objwinq cxq cyq clq chq] in let hd strextr param->listsound in (set containerl = _CRcontainerFromObjWin _channel objwinl cxl cyl cll chl CO_CHILDINSIDE|CO_NOCAPTION 0 "Titre Container" ; set containerq = _CRcontainerFromObjWin _channel objwinq cxq cyq clq chq CO_CHILDINSIDE|CO_NOCAPTION 0 "Titre Container" ; set queue = _CRcompList _channel containerq nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|LST_TOP|LST_HIGHLIGHT_SELECTED OBJ_CONTAINER_CLICK clq chq 10 LST_VERTICAL Verdana14 1 [(make_rgb 255 0 0) 10 0 0] nil nil; set list= _CRcompList _channel containerl nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|LST_TOP|LST_HIGHLIGHT_SELECTED OBJ_CONTAINER_DBLCLICK cll chl 10 LST_VERTICAL Verdana14 1 [(make_rgb 0 255 0) 10 0 0] nil nil; set NbMaxL=atoi hd hd tl strextr param; set NbMaxQ=atoi hd tl hd tl strextr param; loadliste queue tl tl hd tl strextr param 0; loadliste list hd strextr param 0; _CBcompListDblClick list @AddSoundInQueue queue; _PAINTcontainer containerl; _PAINTcontainer containerq; 0 );; /****************************************************************************************************/ /****************************************************************************************************/ fun _OpenBrowse(d,b,s)= let _PtoScol s -> n in if n==nil then nil else let b -> [name sound] in { _SETtext sound n; if !strcmp _GETtext name "" then let strfind "." n 0->nb in { if nb==nil then ( _SETtext name ""; _SETtext sound "") else let substr n 0 nb -> tmp in ( _SETtext name tmp) } else nil; };; fun _browsefile(name,sound)= let _DMSgetZone this "Liste" nil nil nil -> [editWin cxl cyl cll chl] in _DLGrflopen _DLGOpenFile _channel editWin nil nil "Sound Files (*.mid,*.wav)\0*.mid;*.wav\0\0"@_OpenBrowse sound;; /* _DLGrflopen _DLGOpenFile _channel editWin nil nil "Sound Files (*.mid,*.wav,*.mp3)\0*.mid;*.wav;*.mp3\0\0"@_OpenBrowse sound;;*/ fun _ok(obj,u)= let u -> [o n s w] in let _GETtext n->name in let _GETtext s->sound in if (!strcmp name "") || !strcmp sound "" then nil else (let _checkpack sound ->path in if path==nil then (_DLGMessageBox _channel w "Error" "Choose a file in folder Partition" 0;0) else let MY_exist_in_list soundlist [name ""] 0 -> nbinstances in if nbinstances!=0 then (_DLGMessageBox _channel w "Error" "This alias already exists" 0;nil) else (_DMSsend this CMnuAddSoundL [name sound _getpack path]; _DSwindow w ) );; fun _quiteditwin (obj,w)= _DSwindow w;; fun _editwin (name,sound,v)= let if v==1 then "Add Sound Element" else "Edit Sound Element" -> winname in let _DMSgetZone this "Liste" nil nil nil -> [editWin cxl cyl cll chl] in let _CRwindow _channel editWin 0 0 400 80 WN_MENU winname -> w in ( _CRtext _channel w 5 5 90 20 ET_ALIGN_CENTER "Sound File :"; _CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER "Alias :"; let _LDbitmap _channel _checkpack "Dms/Scs/bitmaps/Modules/open.bmp" -> openButtonIcone in let _GETbitmapSize openButtonIcone -> [wi hi] in let _CReditLine _channel w 100 5 290-wi 20 ET_DOWN|ET_AHSCROLL sound -> s in let _CReditLine _channel w 100 30 295 20 ET_DOWN|ET_AHSCROLL name -> n in ( _CBbutton _CRbuttonBitmap _channel w openButtonIcone 395-wi 5 wi hi 0 @_browsefile [n s]; _CBbutton _CRbutton _channel w 5 55 70 20 0 "OK" @_ok ["" n s w]; _CBbutton _CRbutton _channel w 340 55 55 20 0 "Cancel" @_quiteditwin w; ) );; proto createsoundliste = fun [[S r1] [S r1]] I;; fun createsoundliste (namelist, adresslist)= if namelist==nil||adresslist==nil then 0 else ( let hd namelist -> name in let hd adresslist -> sound in (set soundlist=MY_listcat soundlist [name sound]::nil); createsoundliste tl namelist tl adresslist; 0 );; /** LIST **/ fun _ActivateMenuL(ObjCont, param,x,y,button,mask)= if IndexClicked==nil then (_DImenuItem MnuEditL; _DImenuItem MnuAddQueueL; _DImenuItem MnuRemoveL;0) else (set IndexClickedMemory=IndexClicked; set IndexClicked=nil; _ENmenuItem MnuEditL; if (sizelist playinglist) < NbMaxQ then _ENmenuItem MnuAddQueueL else _DImenuItem MnuAddQueueL; _ENmenuItem MnuRemoveL;0); if (sizelist soundlist) < NbMaxL then _ENmenuItem MnuAddL else _DImenuItem MnuAddL; let _DMSgetZone this "Liste" nil nil nil -> [objwin cx cy cl ch] in _DRAWmenu objwin menul cx+cl-10 y+cy+25 PM_LEFT_ALIGN||PM_TOP_ALIGN; 0 ;; fun _ActivateMenuList(ObjLst, param,index)= set IndexClicked=index;; /*CB Menu AddQueue*/ fun _clickMenuAddQueueL(ChoiceMenu,w)=AddSoundInQueue list IndexClicked IndexClickedMemory;; fun _clickMnuRemoveL(ChoiceMenu,param)= let _GETcompListValue list IndexClickedMemory ->[name _] in _DMSsend this CMnuRemoveL [name IndexClickedMemory];; fun _clickMnuEditL(ChoiceMenu,param)= let nth_list soundlist IndexClickedMemory -> [name sound] in _editwin name sound 0;; fun _clickMnuAddL(ChoiceMenu,w)= _editwin nil nil 1;; /**************************************PB ICI nombremaxL nombremaxQ valeurs non changées****************************************************/ fun _okMnuOptionL(obj,u)= let u -> [nbremaxL nbremaxQ w] in (_DMSsend this CChangeNbMax [atoi _GETtext nbremaxL atoi _GETtext nbremaxQ]; _DSwindow w );; fun _clickMnuOptionL(ChoiceMenu,param)= let "Preference" -> winname in let _DMSgetZone this "Liste" nil nil nil -> [editWin cxl cyl cll chl] in let _CRwindow _channel editWin 0 0 400 80 WN_MENU winname -> w in ( _CRtext _channel w 5 5 290 20 ET_ALIGN_CENTER "Maximum number of sounds in list :"; _CRtext _channel w 5 30 290 20 ET_ALIGN_CENTER "Maximum number of sounds in Queue :"; let _CReditLine _channel w 300 5 90 20 ET_DOWN|ET_AHSCROLL|ET_NUMBER itoa NbMaxL -> nbremaxL in let _CReditLine _channel w 300 30 90 20 ET_DOWN|ET_AHSCROLL|ET_NUMBER itoa NbMaxQ -> nbremaxQ in ( _CBbutton _CRbutton _channel w 5 55 70 20 0 "OK" @_okMnuOptionL [ nbremaxL nbremaxQ w]; _CBbutton _CRbutton _channel w 340 55 55 20 0 "Cancel" @_quiteditwin w ) );; /** QUEUE **/ fun _ActivateMenuQ(ObjCont, param,x,y,button,mask)= if IndexClicked==nil then nil else (set IndexClickedMemory=IndexClicked; set IndexClicked=nil; if (IndexClickedMemory==0||IndexClickedMemory==1||IndexClickedMemory==2) then _DImenuItem MnuPutNextQ else _ENmenuItem MnuPutNextQ; let _DMSgetZone this "Queue" nil nil nil -> [objwin cx cy cl ch] in _DRAWmenu objwin menuq cx+cl-10 y+cy+25 PM_LEFT_ALIGN||PM_TOP_ALIGN;); 0;; fun _ActivateMenuQueue(ObjLst, param,index)= set IndexClicked=index;; fun _clickMnuPutNextQ(ChoiceMenu,param)= let _GETcompListValue queue IndexClickedMemory ->[name _] in if name==nil then nil else (_DMSsend this CMnuPutNextQ [name IndexClickedMemory]);; fun _clickMnuRemoveQ(ChoiceMenu,param)= let _GETcompListValue queue IndexClickedMemory ->[name _] in if name==nil then nil else (_DMSsend this CMnuRemoveQ [name IndexClickedMemory]);; fun showadmin(param)= set Verdana14=_CRfont _channel 14 0 0 "Verdana"; let _DMSgetZone this "Liste" nil nil nil -> [objwinl cxl cyl cll chl] in let _DMSgetZone this "Queue" nil nil nil -> [objwinq cxq cyq clq chq] in (set containerl = _CRcontainerFromObjWin _channel objwinl cxl cyl cll chl CO_CHILDINSIDE|CO_NOCAPTION 0 "Titre Container" ; set containerq = _CRcontainerFromObjWin _channel objwinq cxq cyq clq chq CO_CHILDINSIDE|CO_NOCAPTION 0 "Titre Container" ; set queue = _CRcompList _channel containerq nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|LST_TOP|LST_HIGHLIGHT_SELECTED OBJ_CONTAINER_DBLCLICK clq chq 10 LST_VERTICAL Verdana14 1 [(make_rgb 255 0 0) 10 0 0] nil nil; set list= _CRcompList _channel containerl nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|LST_TOP|LST_HIGHLIGHT_SELECTED OBJ_CONTAINER_DBLCLICK cll chl 10 LST_VERTICAL Verdana14 1 [(make_rgb 0 255 0) 10 0 0] nil nil; set menul=_CRpopupMenu _channel; set MnuAddL = _APPitem _channel menul ME_ENABLED "Add"; set MnuRemoveL = _APPitem _channel menul ME_ENABLED "Remove"; set MnuOptionL = _APPitem _channel menul ME_ENABLED "Options"; set MnuAddQueueL = _APPitem _channel menul ME_ENABLED "Add Queue"; _CBmenu MnuAddQueueL @_clickMenuAddQueueL objwinl; _CBmenu MnuRemoveL @_clickMnuRemoveL ""; _CBmenu MnuAddL @_clickMnuAddL objwinl; _CBmenu MnuOptionL @_clickMnuOptionL ""; set menuq=_CRpopupMenu _channel; set MnuPutNextQ = _APPitem _channel menuq ME_ENABLED "Put Next"; set MnuRemoveQ = _APPitem _channel menuq ME_ENABLED "Remove"; _CBmenu MnuPutNextQ @_clickMnuPutNextQ ""; _CBmenu MnuRemoveQ @_clickMnuRemoveQ ""; loadliste list hd strextr param 0; loadliste queue tl tl hd tl tl strextr param 0; set NbMaxL=atoi hd hd tl tl strextr param; set NbMaxQ=atoi hd tl hd tl tl strextr param; createsoundliste hd strextr param hd tl strextr param; _CBcompListDblClick list @_ActivateMenuList ""; _CBcontainerDblClick containerl @_ActivateMenuL ""; _CBcompListDblClick queue @_ActivateMenuQueue ""; _CBcontainerDblClick containerq @_ActivateMenuQ ""; _PAINTcontainer containerl; _PAINTcontainer containerq; 0 );; /*****************************************************************************************************/ /****************************************************************************************************/ fun IniDMI (param)= set soundlist=nil; set playinglist=nil;; /****** DEFCOM ****/ /*Affiche le jukebox*/ fun __show (param)= show param;; fun __admin (param)= showadmin param;; /*Joue le morceau name*/ fun __playsound(name)= playListe playinglist (MY_pos_in_list playinglist name 0);; /*Joue le morceau name*/ fun __stopsound(name,index)= stopSound playinglist index;; /*up-load un fichier, et appelle _downloaded lorsque c'est fini */ fun __downloadsound(name,sound,index)= _RSCdownload this sound sound mknode @_downloaded [name index] 1;; /*Ajoute un son dans la liste d'attente*/ fun __addsound(namelist)= loadliste _RSTcompList queue hd strextr namelist 0; _PAINTcontainer containerq;; /*supprime un son dans la liste d'attente*/ fun __removesoundq(name,index, namelist)= let nth_list playinglist index ->[namecli _] in if !strcmp name namecli then set playinglist= remove_nth_from_list playinglist index else nil; loadliste _RSTcompList queue hd strextr namelist 0; _PAINTcontainer containerq; 0 ;; /*Met a jour soundlist et son affichage dans l'objet list appellé par les fonctionnelités des menus contextuels*/ fun __updatesoundlist (string)= _RSTcompList list; loadliste list hd strextr string 0; set soundlist=nil; createsoundliste hd strextr string hd tl strextr string; _PAINTcontainer containerl;; /*Change les nombre max de morceaux pour chacune des listes*/ fun __changenbmax(nbmaxL,nbmaxQ)= set NbMaxL=nbmaxL; set NbMaxQ=nbmaxQ;;