/* ----------------------------------------------------------------------------- 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 getConditions(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 ( set ndata = [(strcat "condition_" (itoa i)) elem]:: ["GROUP" elem]:: ["ACTION" strcatn "Set "::elem::" state"::nil]:: ["ACTION" strcat "Check " elem]:: ["ACTION" strcat "Uncheck " elem]:: ["ACTION" strcat "Toggle " elem]:: ["EVENT" strcat elem " state"]:: ["EVENT" strcat elem " checked"]:: ["EVENT" strcat elem " unchecked"]:: ["GROUP" ""]:: ndata; ); set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlcondlist ctrlautoreset] in let getEdCtrlListElems ctrlcondlist -> lconditions in let getEdCtrlCheckState ctrlautoreset -> autoreset in ["autoreset" itoa autoreset]:: getConditions lconditions;; fun cbAddList(ctrlstr, p)= let p -> [ctrlcondlist ctrlcondname] in let getEdCtrlTextLineValue ctrlcondname -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else ( let getEdCtrlListElems ctrlcondlist -> lelem in if (isStringInListi lelem value) then nil else ( addEdCtrlList ctrlcondlist value nil nil; setEdCtrlTextLineValue ctrlcondname ""; ); ); 0;; fun cbDelList(ctrlstr, p)= let p -> [ctrlcondlist ctrlcondname] in let getSelectedEdCtrlList ctrlcondlist -> [name _ _] in delEdCtrlList ctrlcondlist name; 0;; fun cbValidateList(ctrlstr, val, p)= let p -> [ctrlcondlist ctrlcondname] in cbAddList ctrlcondlist p; 0;; fun loadConditions(inst)= let nil -> ndata in let 0 -> i in ( let getPluginInstanceParam inst (strcat "condition_" (itoa i)) -> condname in while (condname != nil) do ( set ndata = if i == 0 then condname::nil else lcat ndata condname::nil; set i = i + 1; set condname = getPluginInstanceParam inst (strcat "condition_" (itoa i)); ); ndata; );; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [400 235] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let atoi (getPluginInstanceParam inst "autoreset") -> autoreset in let if autoreset == nil then 0 else autoreset -> autoreset in let crEdFrameWindow _channel ewinstr 0 0 iw 180 EDWIN_RESIZE_MW nil (loc "OS3DCONDITIONLIST_0001") (loc "OS3DCONDITIONLIST_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 160 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlList winstr 10 (set ypos = 10) (iw - 20) 120 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlcondlist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 125) + 2) 160 20 (loc "OS3DCONDITIONLIST_0002") nil -> labelcondname in let crEdCtrlTextLine winstr 180 ypos (iw - 180 - 60) 20 nil nil EDWIN_RESIZE_MW -> ctrlcondname in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DCONDITIONLIST_0003") (loc "OS3DCONDITIONLIST_0005") -> 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) (iw - 20) 20 (loc "OS3DCONDITIONLIST_0004") EDWIN_RESIZE_MW -> ctrlautoreset in ( fillEdCtrlList ctrlcondlist (loadConditions inst); setEdCtrlButtonCb ctrlbtnadd mkfun2 @cbAddList [ctrlcondlist ctrlcondname]; setEdCtrlButtonCb ctrlbtndel mkfun2 @cbDelList [ctrlcondlist ctrlcondname]; setEdCtrlTextLineCbValidate ctrlcondname mkfun3 @cbValidateList [ctrlcondlist ctrlcondname]; setEdCtrlCheckState ctrlautoreset autoreset; [mkfun1 @cbCloseEdit [ctrlcondlist ctrlautoreset] nil]; ); );;