/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun cbDestroyEdit(psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else _DSAudio sndpreview; 0;; fun cbCloseEdit(p)= let p -> [ctrlmohobinding ctrldirname ctrlobjname ctrlatt ctrlvolume ctrlpitch ctrlinner ctrlouter ctrloutervol psnd] in let psnd -> [_ _ sndpreview] in { if (sndpreview == nil) then nil else _DSAudio sndpreview; let getEdCtrlTextLineValue ctrldirname -> path in let getEdCtrlTextLineValue ctrlobjname -> source in let getEdCtrlFloatValue ctrlatt -> attenuation in let ftoi getEdCtrlFloatValue ctrlvolume -> volume in let getEdCtrlFloatValue ctrlpitch -> pitch in let ftoi getEdCtrlFloatValue ctrlinner -> innerangle in let ftoi getEdCtrlFloatValue ctrlouter -> outerangle in let ftoi getEdCtrlFloatValue ctrloutervol -> outervol in ["path" path]:: ["source" source]:: ["volume" itoa volume]:: ["pitch" ftoa pitch]:: ["attenuation" ftoa attenuation]:: ["innerangle" itoa innerangle]:: ["outerangle" itoa outerangle]:: ["outervol" itoa outervol]:: nil; };; fun fillMohoBindings(path, p)= let p -> [inst winstr ctrldirname ctrlmohobinding] in let getFilesFromDir path "dat"::nil -> mohofiles in { fillEdCtrlList ctrlmohobinding nil; let sizelist mohofiles -> size in { let 0 -> i in while (i < size) do { let nth_list mohofiles i -> file in addEdCtrlList ctrlmohobinding (getFileNameWithoutExt file) nil nil; set i = i + 1; }; 0; }; }; 0;; fun cbOpenDirectory(ctrlopendir, p, path)= let p -> [inst winstr ctrldirname ctrlmohobinding] in if path == nil then nil else { // Set directory setEdCtrlTextLineValue ctrldirname path; // Fill the binding list fillMohoBindings path p; }; 0;; fun cbBtnPickDir(ctrlstr, p)= let p -> [inst winstr ctrldirname ctrlmohobinding] in _DLGrflopenDir _DLGOpenDir _channel winstr.EDW_win nil (loc "OS3DMOHO_0010") @cbOpenDirectory p; 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrldirname ctrlmohobinding] in { setEdCtrlTextLineValue ctrldirname ""; fillEdCtrlList ctrlmohobinding nil; }; 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then { setEdCtrlTextLineValue ctrlobjname val; } else nil; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname] in { setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeCubeMap|iTypeBone objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname] mkfun1 @cbCloseRes ctrlbtn 0; }; 0;; fun cbRefreshObjBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun cbEditVolumeChange(ctrl, value, psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else _AudioSetVolume sndpreview ftoi value; 0;; fun cbEditPitchChange(ctrl, value, psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else _AudioSetPitch sndpreview value; 0;; fun cbEditPlayPause(tbstr, check, btn, mask, state, p)= let p -> [inst ctrldirname ctrlmohobinding ctrlvolume ctrlpitch psnd] in let psnd -> [_ _ sndpreview] in let getSelectedEdCtrlList ctrlmohobinding -> [mohoid _ _] in if(mohoid == nil) then nil else { let getEdCtrlTextLineValue ctrldirname -> dirname in let strcatn dirname::"/"::mohoid::nil -> basename in let _checkpack strcat basename ".mp3" -> soundpath in let if (soundpath == nil) then _checkpack strcat basename ".wav" else soundpath -> soundpath in let if (soundpath == nil) then _checkpack strcat basename ".ogg" else soundpath -> soundpath in let ftoi getEdCtrlFloatValue ctrlvolume -> volume in let getEdCtrlFloatValue ctrlpitch -> pitch in { if (state && (soundpath != nil)) then { if (sndpreview == nil) then nil else _DSAudio sndpreview; set sndpreview = _CRAudio _channel (strcat (getPluginInstanceName inst) "_preview") soundpath 1; mutate psnd <- [_ _ sndpreview]; _AudioSetVolume sndpreview volume; _AudioSetPitch sndpreview pitch; _AudioPlay sndpreview 1; } else if (sndpreview != nil) then { _AudioPause sndpreview; } else nil; }; }; 0;; fun cbEditSetupStop(tbstr, check, btn, mask, psnd)= let psnd -> [tbstr chkplaypause sndpreview] in if (sndpreview == nil) then nil else { _AudioStop sndpreview; _DSAudio sndpreview; mutate psnd <- [_ _ nil]; setEdToolBarCheckState tbstr chkplaypause 0; }; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 520] -> [iw ih] in let 10 -> ypos in { setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "path") -> path in let if path == nil then "" else path -> path in let (getPluginInstanceParam inst "source") -> objname in let atof (getPluginInstanceParam inst "volume") -> volume in let if volume == nil then 100.0 else volume -> volume in let atof (getPluginInstanceParam inst "pitch") -> pitch in let if pitch == nil then 1.0 else pitch -> pitch in let atof (getPluginInstanceParam inst "attenuation") -> attenuation in let if attenuation == nil then 1.0 else attenuation -> attenuation in let atof (getPluginInstanceParam inst "innerangle") -> innerangle in let if innerangle == nil then 360.0 else innerangle -> innerangle in let atof (getPluginInstanceParam inst "outerangle") -> outerangle in let if outerangle == nil then 360.0 else outerangle -> outerangle in let atof (getPluginInstanceParam inst "outervol") -> outervol in let if outervol == nil then 0.0 else outervol -> outervol in let crEdFrameWindow _channel ewinstr 0 0 iw 220 EDWIN_RESIZE_MW nil (loc "OS3DMOHO_0006") (loc "OS3DMOHO_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 200 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (set ypos = 10) (iw - 10) 20 (loc "OS3DMOHO_0003") nil -> labelmoho in let crEdCtrlTextLine winstr 10 (set ypos = ypos + 25) (iw - 110) 20 path nil EDWIN_RESIZE_MW -> ctrldirname in let crEdCtrlButton winstr (iw - 95) ypos 55 20 "..." nil -> dirbtn in let crEdCtrlButton winstr (iw - 35) ypos 35 20 "X" nil -> refreshdirname in let crEdCtrlList winstr 10 (set ypos = ypos + 25) (iw - 10) 130 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlmohobinding in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DMOHO_0016") (loc "OS3DMOHO_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 40 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DMOHO_0015") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshobjname in let crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DMOHO_0013") (loc "OS3DMOHO_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 95 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DMOHO_0014") nil -> labelvol in let crEdCtrlFloat winstr 180 ypos 100 20 volume 0.0 1000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlvolume in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMOHO_0012") nil -> labelpitch in let crEdCtrlFloat winstr 180 ypos 100 20 pitch 0.0 10000.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlpitch in let crEdWindowToolBar winstr 0 (set ypos = ypos + 30) iw 28 5 1 0x373737 ETB_HORIZONTAL -> tbstr in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_playpause.png" -> aplaypause in let crEdToolBarCheck tbstr aplaypause ETB_ALIGN_LEFT (loc "OS3DMOHO_0009") nil -> chkplaypause in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_stop.png" -> astop in let crEdToolBarButton tbstr astop ETB_ALIGN_LEFT (loc "OS3DMOHO_0017") nil -> chkstop in let crEdFrameWindow _channel ewinstr 0 0 iw 135 EDWIN_RESIZE_MW nil "3D sound setting" (loc "OS3DMOHO_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 115 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DMOHO_0011") nil -> labelatt in let crEdCtrlFloat winstr 180 ypos 100 20 attenuation 0.0 1.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlatt in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMOHO_0004") nil -> labelinner in let crEdCtrlFloat winstr 180 ypos 100 20 innerangle 0.0 360.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlinner in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMOHO_0007") nil -> labelouter in let crEdCtrlFloat winstr 180 ypos 100 20 outerangle 0.0 360.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlouter in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMOHO_0008") nil -> labelouter in let crEdCtrlFloat winstr 180 ypos 100 20 outervol 0.0 1000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrloutervol in let [tbstr chkplaypause nil] -> psnd in { // Force the drawing of icons on the toolbar setEdToolBarVisible tbstr 1; paintEdToolBar tbstr; // Fill the list fillMohoBindings path [inst winstr ctrldirname ctrlmohobinding]; setEdCtrlButtonCb dirbtn mkfun2 @cbBtnPickDir [inst winstr ctrldirname ctrlmohobinding]; setEdCtrlTextLineEnable ctrldirname 0; setEdCtrlButtonCb refreshdirname mkfun2 @cbRefreshBtn [ctrldirname ctrlmohobinding]; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshObjBtn [ctrlobjname]; setEdToolBarCheckCbClick tbstr chkplaypause mkfun6 @cbEditPlayPause [inst ctrldirname ctrlmohobinding ctrlvolume ctrlpitch psnd]; setEdToolBarButtonCbClick tbstr chkstop mkfun5 @cbEditSetupStop psnd; setEdCtrlFloatCbChange ctrlvolume mkfun3 @cbEditVolumeChange psnd; setEdCtrlFloatCbChange ctrlpitch mkfun3 @cbEditPitchChange psnd; [mkfun1 @cbCloseEdit [ctrlmohobinding ctrldirname ctrlobjname ctrlatt ctrlvolume ctrlpitch ctrlinner ctrlouter ctrloutervol psnd] mkfun1 @cbDestroyEdit psnd]; }; };;