/* Jukebox - DMS - juin 00 - by Ariane Bitoun */ typeof browsecombo = ObjListTab;; typeof addButton = ObjButton;; typeof editButton = ObjButton;; typeof delButton = ObjButton;; typeof soundlist=[[S S] r1];; typeof currentSelection = I;; typeof editWin=ObjWin;; var TaillMaxL="30";; var TailleMaxQ="15";; 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; };; /*Ouvre la fenetre de selection de fichier avec filtres sur les sons*/ fun _browsefile(x,b)= _DLGrflopen _DLGOpenFile _channel editWin nil nil "Sound Files (*.mid,*.wav)\0*.mid;*.wav\0\0"@_OpenBrowse b;; /* _DLGrflopen _DLGOpenFile _channel editWin nil nil "Sound Files (*.mid,*.wav,*.mp3)\0*.mid;*.wav;*.mp3\0\0"@_OpenBrowse b;;*/ fun _parser (l)= if l==nil then 0 else let hd l-> [key [sound _]] in { if !strcmp key "sound" then let hd tl l -> [key [name _]] in if !strcmp key "alias" then set soundlist = listcat soundlist [name sound]::nil else nil else nil; _parser tl l };; /*Permet de sauvegarder les noms et alias des morceaux dans le fichier dmi avec les mots clefs name et sound*/ fun buildFile (l)= if l==nil then ("NbMaxL"::TaillMaxL::nil)::("NbMaxQ"::TailleMaxQ::nil)::nil else let hd l -> [name sound] in ("sound"::sound::nil)::("alias"::name::nil)::buildFile tl l;; /*Compare le premiere colonne de deux listes*/ fun _strcmp (i1, i2)= let i1->[n1 s1] in let i2->[n2 s2] in if strcmp n1 n2 then 0 else 1;; /*Ajoute tous les elements de soundliste d'indice >= index dans le ListTab*/ fun addtocombo (l, index)= if l==nil then browsecombo else let hd l -> [name file] in { _ADDlistTabItem browsecombo index index name; _SETlistTabItem browsecombo index 1 file; addtocombo tl l index+1; };; /*Vide et re-rempli entierement le ListTab a partir de soundlist*/ fun _updatelist ()= _RSTlistTab browsecombo; addtocombo soundlist 0;; /*CB utilisée par _editwin gere le fenetre de saisie d'un morceau (Ajout)*/ fun _okaddwin (obj,u)= let u -> [n s w] in let (_GETtext n)->name in let (_GETtext s)->sound in if (!strcmp name "") || (!strcmp sound "") then nil else let search_in_list soundlist @_strcmp [name ""]->elem in if elem!=nil then /* loc( (_DLGMessageBox _channel w "Error" "This alias already exists" 0; ) */ (_DLGMessageBox _channel w (_locEditor "1090-JUKEBO-error" nil) (_locEditor "1090-JUKEBO-thisaliasa" nil) 0; nil) else { set soundlist = listcat soundlist [name sound]::nil; _updatelist; _DSwindow w };; /*CB utilisée par _editwin gere le fenetre de saisie d'un morceau (EDITION)*/ fun _okeditwin (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 search_in_list soundlist @_strcmp [o ""] -> elem in if elem==nil then (nil) else { mutate elem <- [name sound]; _updatelist; _DSwindow w };; /*CB utilisée par _editwin ferme la fenetre de saisie d'un morceau*/ fun _quiteditwin (obj,u)= _DSwindow u;; /*Crée et gere la fenetre de saisie d'un morceau (ajout ou édition) fonction CB appellée : _okeditwin, _okaddwin, _quiteditwin, _browsefile */ fun _editwin (name,sound,v)= let _LDbitmap _channel _checkpack "dms/sound/jukebox/open.bmp" -> openButtonIcone in /* loc( let if v==1 then "Add Sound Element" else "Edit Sound Element" -> winname in ) */ let if v==1 then (_locEditor "1440-JUKEBO-addsoundel" nil) else (_locEditor "1441-JUKEBO-editsounde" nil) -> winname in let _CRwindow _channel editWin 0 0 400 80 WN_MENU winname -> w in { /* loc( _CRtext _channel w 5 5 90 20 ET_ALIGN_CENTER "Sound File :"; ) */ _CRtext _channel w 5 5 90 20 ET_ALIGN_CENTER (_locEditor "1470-JUKEBO-soundfile:" nil); /* loc( _CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER "Alias :"; ) */ _CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER (_locEditor "1480-JUKEBO-alias:" nil); 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]; if v==0 then /* loc( _CBbutton _CRbutton _channel w 5 55 55 20 0 "OK" @_okeditwin [name n s w] ) */ _CBbutton _CRbutton _channel w 5 55 55 20 0 (_locEditor "1560-JUKEBO-ok" nil) @_okeditwin [name n s w] else /* loc( _CBbutton _CRbutton _channel w 5 55 70 20 0 "OK" @_okaddwin [n s w]; ) */ _CBbutton _CRbutton _channel w 5 55 70 20 0 (_locEditor "1560-JUKEBO-ok" nil) @_okaddwin [n s w]; /* loc( _CBbutton _CRbutton _channel w 340 55 55 20 0 "Cancel" @_quiteditwin w; ) */ _CBbutton _CRbutton _channel w 340 55 55 20 0 (_locEditor "1590-JUKEBO-cancel" nil) @_quiteditwin w; } };; fun rflAddSound (obj, i)= _editwin nil nil 1;; fun rflListDclick (obj, u, ident, col)= let nth_list soundlist ident -> [name sound] in _editwin name sound 0;; fun rflEditSound (obj, i)= if currentSelection == nil then nil else let nth_list soundlist currentSelection -> [name sound] in _editwin name sound 0;; fun rflDelSound (obj, c)= if currentSelection == nil then nil else { set soundlist = remove_nth_from_list soundlist currentSelection; _updatelist; set currentSelection = nil; };; fun rflListClick (obj, u, ident)= set currentSelection = ident;; /* SCS */ fun load (l)= set soundlist=nil; _parser l; _updatelist; 0;; fun buildRegs (l)= if l==nil then nil else let hd l -> [name sound] in sound::buildRegs tl l;; fun save (filename, n)= /*("action"::"start"::"start"::nil)::*//*start=register*/ ("action"::"register"::"register"::nil):: ("action"::"unregister"::"unregister"::nil):: ("action"::"show"::"show"::nil):: ("action"::"edit"::"edit"::nil):: ("action"::"destroy"::"destroy"::nil):: ("eventS"::"destroyed"::"destroyed"::nil):: ("eventS"::"in"::"in"::nil):: ("eventC"::"finished"::"finished"::nil):: ("eventC"::"started"::"started"::nil):: ("zoneC"::"Liste"::nil):: ("zoneC"::"Queue"::nil):: buildFile soundlist ;; fun rflSizeEditWin (wn, blurp, w, h)= _SIZElistTab browsecombo w-10 h-55 5 25; _SIZEbutton addButton 30 20 5 h-25; _SIZEbutton editButton 30 20 40 h-25; _SIZEbutton delButton 30 20 95 h-25;; fun IniEditor(s)= let [315 180] -> [w h] in let startEditor _channel nil nil nil w h WN_MENU EDITOR_NORMAL s "dms/sound/jukebox/jukebox.dmc" nil nil @load @save nil -> ed in ( set editWin = getEditWin ed; _CBwinSize editWin @rflSizeEditWin 0; /* loc( _CRtext _channel editWin 10 5 w-10 20 ET_ALIGN_CENTER "Sound Files"; ) */ _CRtext _channel editWin 10 5 w-10 20 ET_ALIGN_CENTER (_locEditor "2450-JUKEBO-soundfiles" nil); set browsecombo= _CRlistTab _channel editWin 5 25 w-10 h-55 LV_SINGLESEL+LV_DOWN; /* loc( _ADDlistTabColumn browsecombo 0 w/2-10 0 "Alias"; ) */ _ADDlistTabColumn browsecombo 0 w/2-10 0 (_locEditor "2470-JUKEBO-alias" nil); /* loc( _ADDlistTabColumn browsecombo 1 w/2-10 0 "File"; ) */ _ADDlistTabColumn browsecombo 1 w/2-10 0 (_locEditor "2480-JUKEBO-file" nil); _CBlistTabDClick browsecombo @rflListDclick 0; _CBlistTabSelect browsecombo @rflListClick 0; /* loc( set addButton = _CBbutton _CRbutton _channel editWin 5 h-25 30 20 0 "Add" @rflAddSound browsecombo; ) */ set addButton = _CBbutton _CRbutton _channel editWin 5 h-25 30 20 0 (_locEditor "2510-JUKEBO-add" nil) @rflAddSound browsecombo; /* loc( set editButton = _CBbutton _CRbutton _channel editWin 40 h-25 35 20 0 "Edit" @rflEditSound browsecombo; ) */ set editButton = _CBbutton _CRbutton _channel editWin 40 h-25 35 20 0 (_locEditor "2520-JUKEBO-edit" nil) @rflEditSound browsecombo; /* loc( set delButton = _CBbutton _CRbutton _channel editWin 95 h-25 30 20 0 "Del" @rflDelSound browsecombo; ) */ set delButton = _CBbutton _CRbutton _channel editWin 95 h-25 30 20 0 (_locEditor "2530-JUKEBO-del" nil) @rflDelSound browsecombo; if s==nil then nil else openDMI ed ); 0;;