/* ----------------------------------------------------------------------------- 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 getAnimations(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in let if (!strcmp "[default] " substr elem 0 10) then substr elem 10 1024 else elem -> elem in let strcat "animation_" (itoa i) -> elemname in set ndata = [elemname elem]::ndata; set i = i + 1; ); ndata; );; fun getActions(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in //if (!strcmp "[default] " substr elem 0 10) then nil else let if (!strcmp "[default] " substr elem 0 10) then substr elem 10 1024 else elem -> elem in ( set ndata = ["ACTION" elem]::ndata; set ndata = ["EVENT" (strcat elem " end")]::ndata; ); set i = i + 1; ); ndata; );; fun getDefaultAnimations(l)= let sizelist l -> size in let nil -> defanim in let 0 -> i in ( while ((i < size) && (defanim == nil)) do ( let nth_list l i -> elem in if (strcmp "[default] " substr elem 0 10) then nil else set defanim = elem; set i = i + 1; ); defanim; );; fun loadAnimations(inst, defanim)= let nil -> ndata in let 0 -> i in ( let getPluginInstanceParam inst (strcat "animation_" (itoa i)) -> elem in while (elem != nil) do ( let if (!strcmp elem defanim) then strcat "[default] " elem else elem -> elem in set ndata = if i == 0 then elem::nil else lcat ndata elem::nil; set i = i + 1; set elem = getPluginInstanceParam inst (strcat "animation_" (itoa i)); ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrltransitionspeed ctrlanimations ctrlauto ctrlwaitend ctrlinit] in let getEdCtrlListElems ctrlanimations -> lanimations in let getDefaultAnimations lanimations -> defanim in let getEdCtrlCheckState ctrlauto -> autoswitch in let getEdCtrlCheckState ctrlwaitend -> waitend in let getEdCtrlCheckState ctrlinit -> init in ["transitionSpeed" (ftoa (getEdCtrlFloatValue ctrltransitionspeed))]:: ["defaultAnim" (substr defanim 10 1024)]:: ["autoSwitch" (itoa autoswitch)]:: ["waitend" (itoa waitend)]:: ["init" (itoa init)]:: lcat getAnimations lanimations getActions lanimations;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbAddList(ctrlstr, p)= let p -> [ctrlanimations ctrlselectanimation] in let getEdCtrlTextLineValue ctrlselectanimation -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems ctrlanimations -> lelem in let if lelem == nil then strcat "[default] " value else value -> value in ( if (isStringInListi lelem value) || (isStringInListi lelem strcat "[default] " value) then nil else ( addEdCtrlList ctrlanimations value nil nil; selectEdCtrlList ctrlanimations value; ); ); 0;; fun cbDelList(ctrlstr, p)= let p -> [ctrlanimations ctrlselectanimation] in let getSelectedEdCtrlList ctrlanimations -> [name _ _] in ( delEdCtrlList ctrlanimations name; if strcmp "[default] " substr name 0 10 then nil else ( let getEdCtrlListElemByPos ctrlanimations 0 -> [_ [defname _]] in if defname == nil then ( setEdCtrlTextLineValue ctrlselectanimation ""; 0; ) else ( renameEdCtrlListElement ctrlanimations defname (strcat "[default] " defname); 0; ); ); let getSelectedEdCtrlList ctrlanimations -> [sname _ _] in setEdCtrlTextLineValue ctrlselectanimation sname; ); 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlanimations ctrlanimname] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DgetAnimationByName sessionstr val -> anim in if anim == nil then nil else ( setEdCtrlTextLineValue ctrlanimname val; cbAddList ctrlanimations [ctrlanimations ctrlanimname]; ); 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlanimations ctrlanimname animname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeAnim animname mkfun3 @cbSelectObj [inst winstr viewstr ctrlanimations ctrlanimname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbSelectAnim(ctrlstr, pos, elem, lval, type, ctrlselectanimation)= setEdCtrlTextLineValue ctrlselectanimation elem; 0;; fun cbSetDefault(ctrlstr, p)= let p -> [ctrlanimations ctrlselectanimation] in let getSelectedEdCtrlList ctrlanimations -> [name _ _] in if name == nil || !strcmp "[default] " substr name 0 10 then nil else let getDefaultAnimations getEdCtrlListElems ctrlanimations -> defanim in ( if defanim == nil then nil else renameEdCtrlListElement ctrlanimations defanim substr defanim 10 1024; renameEdCtrlListElement ctrlanimations name strcat "[default] " name; setEdCtrlTextLineValue ctrlselectanimation strcat "[default] " name; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [400 375] -> [iw ih] in let 10 -> ypos in ( let atof (getPluginInstanceParam inst "transitionSpeed") -> transitionspeed in let if transitionspeed == nil then 200.0 else transitionspeed -> transitionspeed in let getPluginInstanceParam inst "defaultAnim" -> defanim in let atoi (getPluginInstanceParam inst "autoSwitch") -> autoswitch in let if autoswitch == nil then 1 else autoswitch -> autoswitch in let atoi (getPluginInstanceParam inst "waitend") -> waitend in let if waitend == nil then 0 else waitend -> waitend in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in ( setEdWindowSize ewinstr iw ih; let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DANIMATIONSWITCHER_0001") (loc "OS3DANIMATIONSWITCHER_0007") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 200 20 (strcat (loc "OS3DANIMATIONSWITCHER_0010") " ") nil -> labeltransitionspeed in let crEdCtrlFloat winstr 210 ypos 80 20 transitionspeed 0.0 10000.0 10.0 0 nil EDWIN_RESIZE_MW -> ctrltransitionspeed in let crEdFrameWindow _channel ewinstr 0 0 iw 210 EDWIN_RESIZE_MW nil (loc "OS3DANIMATIONSWITCHER_0002") (loc "OS3DANIMATIONSWITCHER_0007") -> winfrm2 in let crEdWindow _channel winfrm2 0 18 iw 190 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr2 in let crEdCtrlLabel winstr2 10 ((set ypos = 10) + 2) (iw - 20) 20 (loc "OS3DANIMATIONSWITCHER_0003") nil -> labelanimations in let crEdCtrlList winstr2 10 (set ypos = ypos + 25) (iw - 20) 120 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlanimations in let crEdCtrlTextLine winstr2 10 (set ypos = ypos + 125) (iw - 230) 20 nil nil EDWIN_RESIZE_MW -> ctrlselectanimation in let crEdCtrlButton winstr2 (iw - 215) ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr2 (iw - 155) ypos 70 20 (loc "OS3DANIMATIONSWITCHER_0009") EDWIN_RESIZE_MW -> ctrlbtndel in let crEdCtrlButton winstr2 (iw - 80) ypos 70 20 (loc "OS3DANIMATIONSWITCHER_0005") EDWIN_RESIZE_MW -> ctrlbtndef in let crEdFrameWindow _channel ewinstr 0 0 iw 115 EDWIN_RESIZE_MW nil (loc "OS3DANIMATIONSWITCHER_0008") (loc "OS3DANIMATIONSWITCHER_0007") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) (iw - 20) 20 (loc "OS3DANIMATIONSWITCHER_0004") EDWIN_RESIZE_MW -> ctrlauto in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DANIMATIONSWITCHER_0011") EDWIN_RESIZE_MW -> ctrlwaitend in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DANIMATIONSWITCHER_0006") EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlTextLineEnable ctrlselectanimation 0; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlanimations ctrlselectanimation ""]; setEdCtrlButtonCb ctrlbtndel mkfun2 @cbDelList [ctrlanimations ctrlselectanimation]; setEdCtrlButtonCb ctrlbtndef mkfun2 @cbSetDefault [ctrlanimations ctrlselectanimation]; fillEdCtrlList ctrlanimations (loadAnimations inst defanim); setEdCtrlListCbClick ctrlanimations mkfun6 @cbSelectAnim ctrlselectanimation; setEdCtrlCheckState ctrlauto autoswitch; setEdCtrlCheckState ctrlwaitend waitend; setEdCtrlCheckState ctrlinit init; [mkfun1 @cbCloseEdit [ctrltransitionspeed ctrlanimations ctrlauto ctrlwaitend ctrlinit] nil]; ); ); );;