/* Sound Environment Editor - DMS - dec 97 - by Sébastien METROT */ /* Rev. 1.0 - Mar. '98 - by Marc BARILLEY */ /* Rev. 1.1 - Sep. '98 - by Marc BARILLEY */ /* Rev. 1.2 - Jan. '99 - by Patrice FAVRE */ // add mp3 format in Dialog Box to add a sound - iri, july 2007 typeof envname = ObjText;; typeof browseenv = ObjButton;; typeof browsecombo = ObjListTab;; typeof addButton = ObjButton;; typeof editButton = ObjButton;; typeof delButton = ObjButton;; typeof soundlist=[[S S] r1];; typeof currentSelection = I;; typeof editWin = ObjWin;; 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 _SETtext name n else nil; };; fun _browsefile(x,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 "actionC" then set soundlist = listcat soundlist [name sound]::nil else nil else nil; _parser tl l };; fun _strcmp (i1, i2)= let i1->[n1 s1] in let i2->[n2 s2] in if strcmp n1 n2 then 0 else 1;; 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; };; fun _updatelist ()= _RSTlistTab browsecombo; addtocombo soundlist 0;; 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 nil else { set soundlist = listcat soundlist [name sound]::nil; _updatelist; _DSwindow w };; 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 };; fun _quiteditwin (obj,u)= _DSwindow u;; fun _editwin (name,sound,v)= let _LDbitmap _channel _checkpack "dms/sound/soundenv/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 "1160-SOUNDE-addsoundel" nil) else (_locEditor "1161-SOUNDE-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 "1190-SOUNDE-soundfile:" nil); /* loc( _CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER "Action Name :"; ) */ _CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER (_locEditor "1200-SOUNDE-actionname" 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 "1280-SOUNDE-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 "1280-SOUNDE-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 "1310-SOUNDE-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 buildAction (l)= if l==nil then nil else let hd l -> [name sound] in ("sound"::sound::nil)::("actionC"::name::nil)::("eventC"::name::nil)::buildAction tl l;; fun save (filename, n)= ("action"::"start"::"start"::nil):: ("actionC"::"destroy"::"destroy"::nil):: ("actionC"::"loopOnAll"::nil):: ("actionC"::"loop"::nil):: ("actionC"::"random"::nil):: ("actionC"::"once"::nil):: ("actionC"::"playSound"::nil):: ("actionC"::"stopSound"::nil):: ("actionC"::"disable"::nil):: ("actionC"::"enable"::nil):: ("eventC"::"in"::"in"::nil):: ("eventC"::"stopped"::"stopped"::nil):: ("event"::"destroyed"::"destroyed"::nil):: ("action"::"!stopmidi!"::nil):: ("action"::"!startmidi!"::nil):: ("action"::"!stopall!"::nil):: ("action"::"!enable!"::nil):: ("action"::"!disable!"::nil):: ("registerF"::buildRegs soundlist):: buildAction 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/soundenv/soundenv.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 "2270-SOUNDE-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 "Action Name"; ) */ _ADDlistTabColumn browsecombo 0 w/2-10 0 (_locEditor "2290-SOUNDE-actionname" nil); /* loc( _ADDlistTabColumn browsecombo 1 w/2-10 0 "File"; ) */ _ADDlistTabColumn browsecombo 1 w/2-10 0 (_locEditor "2300-SOUNDE-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 "2330-SOUNDE-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 "2340-SOUNDE-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 "2350-SOUNDE-del" nil) @rflDelSound browsecombo; if s==nil then nil else openDMI ed ); 0;;