/* ----------------------------------------------------------------------------- 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 ctrltexwidth ctrltexheight ctrlautosize ctrltext ctrlbgcolor ctrlfname ctrlcolor ctrlfsize ctrlfbold 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 itoa (ftoi (getEdCtrlFloatValue ctrltexwidth)) -> texwidth in let itoa (ftoi (getEdCtrlFloatValue ctrltexheight)) -> texheight in let getEdCtrlCheckState ctrlautosize -> autosize in let getEdCtrlColorButtonColor ctrlbgcolor -> bgcolor in let getEdCtrlTextLineValue ctrlfname -> fname in let getEdCtrlColorButtonColor ctrlcolor -> color in let itoa (ftoi (getEdCtrlFloatValue ctrlfsize)) -> fsize in let getEdCtrlCheckState ctrlfbold -> fbold in let getEdCtrlEditTextValue ctrltext -> text in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["material" matname]:: ["technique" itoa technique]:: ["pass" itoa pass]:: ["texture" itoa texture]:: ["texwidth" texwidth]:: ["texheight" texheight]:: ["autosize" itoa autosize]:: ["fontname" fname]:: ["color" itoa color]:: ["fontsize" fsize]:: ["fontbold" itoa fbold]:: ["text" text]:: ["bgcolor" itoa bgcolor]:: ["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 ( if (size == nil) then nil else 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 ( if (size == nil) then nil else 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 ( if (size == nil) then nil else 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 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 cbDlgGetPath(dlg, p, pfile)= 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 "OS3DTEXTURETEXT_0006") (loc "OS3DTEXTURETEXT_0021") 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 getPathFile path "" -> [fpath fname] in ( setEdCtrlButtonEnable ctrlbtn 1; _DLGrflopen _DLGOpenFile _channel winstr.EDW_win fpath fname "Bitmaps\0*.bmp;*.jpg;*.png;*.tga;\0Bitmap\0*.bmp\0Jpeg\0*.jpg\0Png\0*.png\0Targa\0*.tga\0All\0*.*\0\0" @cbDlgGetPath [inst ctrlbtn winstr ctrlpath ctrlurl ctrlisurl]; ); 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 cbCheckAutoSize(ctrl, state, p)= let p -> [ctrltexwidth ctrltexheight] in ( setEdCtrlFloatEnable ctrltexwidth !state; setEdCtrlFloatEnable ctrltexheight !state; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 560] -> [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 atoi (getPluginInstanceParam inst "texwidth") -> texwidth in let if texwidth == nil then 512 else texwidth -> texwidth in let atoi (getPluginInstanceParam inst "texheight") -> texheight in let if texheight == nil then 512 else texheight -> texheight in let atoi (getPluginInstanceParam inst "autosize") -> autosize in let if autosize == nil then 0 else autosize -> autosize in let atoi (getPluginInstanceParam inst "bgcolor") -> bgcolor in let if bgcolor == nil then 0xffffff else bgcolor -> bgcolor in let getPluginInstanceParam inst "fontname" -> fname in let if fname == nil then "Arial" else fname -> fname in let atoi (getPluginInstanceParam inst "color") -> color in let if color == nil then 0 else color -> color in let atoi (getPluginInstanceParam inst "fontsize") -> fsize in let if fsize == nil then 12 else fsize -> fsize in let atoi (getPluginInstanceParam inst "fontbold") -> fbold in let if fbold == nil then 0 else fbold -> fbold in let getPluginInstanceParam inst "text" -> text in let if text == nil then (loc "OS3DTEXTURETEXT_0005") else text -> text 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 210 EDWIN_RESIZE_MW nil (loc "OS3DTEXTURETEXT_0011") (loc "OS3DTEXTURETEXT_0013") -> 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 (ypos + 2) 170 20 (loc "OS3DTEXTURETEXT_0015") 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) 160 20 (loc "OS3DTEXTURETEXT_0010") 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) 160 20 (loc "OS3DTEXTURETEXT_0012") 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) 160 20 (loc "OS3DTEXTURETEXT_0017") 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) 160 20 (loc "OS3DTEXTURETEXT_0016") nil -> labelpass in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmattex in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTEXTURETEXT_0020") nil -> labeltexsize in let crEdCtrlFloat winstr 180 ypos 60 20 (itof texwidth) 1.0 4096.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrltexwidth in let crEdCtrlLabel winstr 250 (ypos + 2) 10 20 "x" nil -> labeltexsize in let crEdCtrlFloat winstr 265 ypos 60 20 (itof texheight) 1.0 4096.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrltexheight in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DTEXTURETEXT_0002") EDWIN_RESIZE_MW -> ctrlautosize in let crEdFrameWindow _channel ewinstr 0 0 iw 300 EDWIN_RESIZE_MW nil (loc "OS3DTEXTURETEXT_0019") (loc "OS3DTEXTURETEXT_0013") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 290 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DTEXTURETEXT_0003") nil -> labelbgcolor in let crEdCtrlColorButton winstr 180 ypos 100 20 bgcolor 0 EDWIN_RESIZE_MW nil -> ctrlbgcolor in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTEXTURETEXT_0008") nil -> labelcolor in let crEdCtrlTextLine winstr 180 ypos 170 20 fname nil EDWIN_RESIZE_MW -> ctrlfname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTEXTURETEXT_0007") nil -> labelcolor in let crEdCtrlColorButton winstr 180 ypos 100 20 color 0 EDWIN_RESIZE_MW nil -> ctrlcolor in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTEXTURETEXT_0009") nil -> labelfsize in let crEdCtrlFloat winstr 180 ypos 60 20 (itof fsize) 1.0 1024.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlfsize in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DTEXTURETEXT_0004") EDWIN_RESIZE_MW -> ctrlfbold in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DTEXTURETEXT_0018") nil -> labeltext in let crEdCtrlEditText winstr 10 (set ypos = ypos + 25) iw-20 120 text nil EDWIN_RESIZE_MW -> ctrltext in let crEdFrameWindow _channel ewinstr 0 0 iw 45 EDWIN_RESIZE_MW nil (loc "OS3DTEXTURETEXT_0014") (loc "OS3DTEXTURETEXT_0013") -> 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 "OS3DTEXTURETEXT_0001") EDWIN_RESIZE_MW -> ctrlinit in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityGetResourceGroup obj -> group in ( 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 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; ); setEdCtrlFloatEnable ctrltexwidth !autosize; setEdCtrlFloatEnable ctrltexheight !autosize; setEdCtrlCheckCbState ctrlautosize mkfun3 @cbCheckAutoSize [ctrltexwidth ctrltexheight]; setEdCtrlCheckState ctrlautosize autosize; setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlfbold fbold; [mkfun1 @cbCloseEdit [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlmattex ctrltexwidth ctrltexheight ctrlautosize ctrltext ctrlbgcolor ctrlfname ctrlcolor ctrlfsize ctrlfbold ctrlinit] nil]; ); );;