/* ----------------------------------------------------------------------------- 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 cbCloseEdit(p)= let p -> [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex ctrlpath ctrlisurl ctrlurl ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getSelectedEdCtrlSelect ctrlmatname -> matname in let getSelectedEdCtrlSelectPos ctrlmattech -> technique in let getSelectedEdCtrlSelectPos ctrlmatpass -> pass in let getSelectedEdCtrlSelectPos ctrlmattex -> texture in let getEdCtrlTextLineValue ctrlpath -> path in let getEdCtrlCheckState ctrlisurl -> isurl in let getEdCtrlTextLineValue ctrlurl -> url in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["material" matname]:: ["technique" itoa technique]:: ["pass" itoa pass]:: ["texture" itoa texture]:: ["isurl" itoa isurl]:: ["url" url]:: ["path" path]:: ["init" itoa init]:: nil;; fun fillMaterialTextureSelector(viewstr, ctrlselect, mat, tech, pass)= if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfTexturesByTechniqueAndPass mat tech pass -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialTextureUnitGetNameByIndex mat tech pass i -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; ); 0;; fun cbMatPassName(ctrlstr, pos, elem, p)= let p -> [inst viewstr group ctrlmatname ctrlmattech ctrlmattex] in let getSelectedEdCtrlSelectPos ctrlmattech -> tech in let getSelectedEdCtrlSelect ctrlmatname -> matname in let V3DgetDefaultSession viewstr -> sessionstr in let if matname != nil then SO3SceneGetMaterial (V3DgetSession sessionstr) group matname else nil -> mat in fillMaterialTextureSelector viewstr ctrlmattex mat tech pos; 0;; fun fillMaterialPassSelector(viewstr, p, mat, tech)= let p -> [ctrlselect ctrlmatname ctrlmattech ctrlmattex] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfPassesByTechnique mat tech -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialPassGetNameByIndex mat tech i -> matname in let if (!strcmp matname "") then (itoa i) else matname -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialTextureSelector viewstr ctrlmattex mat tech 0; ); 0;; fun cbMatTechniqueName(ctrlstr, pos, elem, p)= let p -> [inst viewstr group ctrlmatname ctrlmatpass ctrlmattex] in let getSelectedEdCtrlSelect ctrlmatname -> matname in let V3DgetDefaultSession viewstr -> sessionstr in let if matname != nil then SO3SceneGetMaterial (V3DgetSession sessionstr) group matname else nil -> mat in fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlstr ctrlmattex] mat pos; 0;; fun fillMaterialTechSelector(viewstr, p, mat)= let p -> [ctrlselect ctrlmatname ctrlmatpass ctrlmattex] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfTechniques mat -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialTechniqueGetNameByIndex mat i -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlselect ctrlmattex] mat 0; ); 0;; fun cbMatName(ctrlstr, pos, elem, p)= let p -> [inst viewstr group ctrlmattech ctrlmatpass ctrlmattex] in let V3DgetDefaultSession viewstr -> sessionstr in let if elem != nil then SO3SceneGetMaterial (V3DgetSession sessionstr) group elem else nil -> mat in fillMaterialTechSelector viewstr [ctrlmattech ctrlstr ctrlmatpass ctrlmattex] mat; 0;; fun fillMaterialSelector(viewstr, p, objname)= let p -> [inst ctrlselect ctrlmattech ctrlmatpass ctrlmattex] in if objname == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityGetResourceGroup obj -> group in let SO3EntityMaterialList obj -> lmat in let nil -> lmatname in ( setEdCtrlSelectCb ctrlselect mkfun4 @cbMatName [inst viewstr group ctrlmattech ctrlmatpass ctrlmattex]; setEdCtrlSelectCb ctrlmattech mkfun4 @cbMatTechniqueName [inst viewstr group ctrlselect ctrlmatpass ctrlmattex]; setEdCtrlSelectCb ctrlmatpass mkfun4 @cbMatPassName [inst viewstr group ctrlselect ctrlmattech ctrlmattex]; let sizelist lmat -> size in let 0 -> i in while i < size do ( let nth_list lmat i -> mat in let SO3MaterialGetName mat -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialTechSelector viewstr [ctrlmattech ctrlselect ctrlmatpass ctrlmattex] (SO3SceneGetMaterial (V3DgetSession sessionstr) group (hd lmatname)); ); 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if obj == nil then nil else ( setEdCtrlTextLineValue ctrlobjname val; fillMaterialSelector viewstr [inst ctrlmatname ctrlmattech ctrlmatpass ctrlmattex] val; ); 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeEntity objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbDlgGetPath(pfile, p)= let p -> [inst ctrlbtn winstr ctrlpath ctrlurl ctrlisurl] in ( if pfile == nil then nil else let _PtoScol pfile -> file in if file == nil then ( _DLGMessageBox _channel winstr.EDW_win (loc "OS3DCHANGETEXTURE_0003") (loc "OS3DCHANGETEXTURE_0014") 0; 0; ) else ( setEdCtrlTextLineValue ctrlpath file; setEdCtrlTextLineValue ctrlurl nil; setEdCtrlCheckState ctrlisurl 0; 0; ); setEdCtrlButtonEnable ctrlbtn 1; ); 0;; fun cbBtnPickFile(ctrlbtn, p)= let p -> [inst winstr ctrlpath ctrlurl ctrlisurl] in let getEdCtrlTextLineValue ctrlpath -> path in let _GETdesktopSize -> [sw sh] in let getEdWindowPos mainInterf.MINT_winMain -> [nx ny] in let getEdWindowSize mainInterf.MINT_winMain -> [nmw nmh] in let [750 450] -> [iw ih] in let crEdOpenFileBitmapDialog _channel winstr nx + ((nmw / 2) - (iw / 2)) ny + ((nmh / 2) - (ih / 2)) iw ih "" ["Bitmaps" "bmp"::"jpg"::"png"::"tga"::nil]::["Bitmap" "bmp"::nil]::["Jpeg" "jpg"::nil]::["PNG" "png"::nil]::["Targa" "tga"::nil]::nil EDFILE_DIALOG_LIST_FOLDERS|EDFILE_DIALOG_SHOW_TOOLBAR nil path -> dlgfstr in ( setEdWindowIcon dlgfstr.EDFD_dialog sWinDlgIcon; setEdOpenFileDialogCb dlgfstr mkfun2 @cbDlgGetPath [inst ctrlbtn winstr ctrlpath ctrlurl ctrlisurl]; setEdCtrlButtonEnable ctrlbtn 1; ); 0;; fun cbCheckUrl(ctrl, state, p)= let p -> [ctrlurl ctrlpath pickbtn] in if state then ( setEdCtrlTextLineEnable ctrlurl 1 ; setEdCtrlTextLineValue ctrlpath nil; setEdCtrlButtonEnable pickbtn 0; ) else ( setEdCtrlTextLineEnable ctrlurl 0; setEdCtrlButtonEnable pickbtn 1; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun cbRefreshBtnSpec(pickbtn, p)= let p -> [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex] in ( setEdCtrlTextLineValue ctrlobjname ""; fillEdCtrlSelect ctrlmatname nil; fillEdCtrlSelect ctrlmattech nil; fillEdCtrlSelect ctrlmatpass nil; fillEdCtrlSelect ctrlmattex nil; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 290] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in let (getPluginInstanceParam inst "material") -> matname in let atoi (getPluginInstanceParam inst "technique") -> technique in let if technique == nil then 0 else technique -> technique in let atoi (getPluginInstanceParam inst "pass") -> pass in let if pass == nil then 0 else pass -> pass in let atoi (getPluginInstanceParam inst "texture") -> texture in let if texture == nil then 0 else texture -> texture in let (getPluginInstanceParam inst "path") -> path in let atoi (getPluginInstanceParam inst "isurl") -> isurl in let if isurl == nil then 0 else isurl -> isurl in let (getPluginInstanceParam inst "url") -> url in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 155 EDWIN_RESIZE_MW nil (loc "OS3DCHANGETEXTURE_0006") (loc "OS3DCHANGETEXTURE_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 145 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos + 2) 170 20 (loc "OS3DCHANGETEXTURE_0010") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 170 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshobjname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGETEXTURE_0005") nil -> labelmat in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmatname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGETEXTURE_0007") nil -> labeltech in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmattech in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGETEXTURE_0012") nil -> labelpass in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmatpass in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGETEXTURE_0011") nil -> labelpass in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmattex in let crEdFrameWindow _channel ewinstr 0 0 iw 85 EDWIN_RESIZE_MW nil (loc "OS3DCHANGETEXTURE_0004") (loc "OS3DCHANGETEXTURE_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 60 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 100 20 (loc "OS3DCHANGETEXTURE_0013") EDWIN_RESIZE_MW -> ctrlisurl in let crEdCtrlTextLine winstr 180 ypos (iw - 200) 20 url nil EDWIN_RESIZE_MW -> ctrlurl in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DCHANGETEXTURE_0002") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 170 20 path nil EDWIN_RESIZE_MW -> ctrlpath in let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> pickfilebtn in let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshpath in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DCHANGETEXTURE_0009") (loc "OS3DCHANGETEXTURE_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DCHANGETEXTURE_0001") EDWIN_RESIZE_MW -> ctrlinit in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityGetResourceGroup obj -> group in ( setEdCtrlCheckState ctrlisurl isurl; setEdCtrlCheckState ctrlinit init; setEdCtrlButtonCb pickfilebtn mkfun2 @cbBtnPickFile [inst winstr ctrlpath ctrlurl ctrlisurl]; setEdCtrlCheckCbState ctrlisurl mkfun3 @cbCheckUrl [ctrlurl ctrlpath pickfilebtn]; setEdCtrlTextLineEnable ctrlpath 0; setEdCtrlButtonCb refreshpath mkfun2 @cbRefreshBtn [ctrlpath]; if !isurl then ( setEdCtrlTextLineEnable ctrlurl 0; setEdCtrlButtonEnable pickfilebtn 1; ) else ( setEdCtrlTextLineEnable ctrlurl 1; setEdCtrlButtonEnable pickfilebtn 0; ); setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtnSpec [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex]; fillMaterialSelector viewstr [inst ctrlmatname ctrlmattech ctrlmatpass ctrlmattex] objname; selectEdCtrlSelect ctrlmatname matname; let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetMaterial (V3DgetSession sessionstr) group matname -> mat in if mat == nil then nil else ( fillMaterialTechSelector viewstr [ctrlmattech ctrlmatname ctrlmatpass ctrlmattex] mat; selectEdCtrlSelectByPos ctrlmattech technique; fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlmattech ctrlmattex] mat technique; selectEdCtrlSelectByPos ctrlmatpass pass; fillMaterialTextureSelector viewstr ctrlmattex mat technique pass; selectEdCtrlSelectByPos ctrlmattex texture; ); [mkfun1 @cbCloseEdit [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex ctrlpath ctrlisurl ctrlurl ctrlinit] nil]; ); );;