/* ----------------------------------------------------------------------------- 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 getEvents(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 = ["EVENT" elem]::ndata; set i = i + 1; ); ndata; );; fun loadXMLEvents(xmlpath) = let XMLload xmlpath -> xmlfilestr in let nil -> levents in let XMLgetMarkByValue xmlfilestr "root" -> xmlroot in let XMLgetMarksByValueFromMark xmlroot "Event" -> xmlEvents in let sizelist xmlEvents -> nbItems in let 0 -> i in ( while i < nbItems do ( let nth_list xmlEvents i -> event in ( let XMLgetParam event "name" -> paramevent in if (paramevent == nil) || (!strcmp "" strtrim paramevent) then nil else set levents = (paramevent)::levents; ); set i = i + 1; ); levents; );; fun cbDestroyEdit()= 0;; fun cbCloseEdit(p)= let p -> [ctrlxmlname crlstate ctrlinit] in let getEdCtrlTextLineValue ctrlxmlname -> xmlpath in let getEdCtrlTextLineValue crlstate -> state in let getEdCtrlCheckState ctrlinit -> init in let loadXMLEvents xmlpath -> events in ["path" xmlpath]:: ["state" state]:: ["init" itoa init]:: (getEvents events);; fun cbDlgGetXml(dlg, p, pfile)= let p -> [inst ctrlbtn winstr ctrlxmlname ] in ( if pfile == nil then nil else let _PtoScol pfile -> file in if file == nil then ( _DLGMessageBox _channel winstr.EDW_win "Error" "Your file have to be in a scol partition." 0; 0; ) else ( setEdCtrlTextLineValue ctrlxmlname file; ); setEdCtrlButtonEnable ctrlbtn 1; ); 0;; fun cbBtnPickObj (ctrlbtn, p)= let p -> [inst winstr ctrlxmlname] in let getEdCtrlTextLineValue ctrlxmlname -> xmlpath in let getPathFile xmlpath "" -> [fpath fname] in ( setEdCtrlButtonEnable ctrlbtn 0; _DLGrflopen _DLGOpenFile _channel winstr.EDW_win fpath fname "Media\0*.xml;\0Xml\0*.xml\0All\0*.*\0\0" @cbDlgGetXml [inst ctrlbtn winstr ctrlxmlname]; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 150] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "path") -> xmlpath in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 0 else init -> init in let (getPluginInstanceParam inst "state") -> state in let if state == nil then "normal" else state -> state in let crEdFrameWindow _channel ewinstr 0 0 iw 155 EDWIN_RESIZE_MW nil "Settings" "Minimize / Restore" -> winfrm in let crEdWindow _channel winfrm 0 18 iw 140 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 "Xml path" nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 xmlpath nil EDWIN_RESIZE_MW -> ctrlxmlname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> filebtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshxmlname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 "State" nil -> labelstate in let crEdCtrlTextLine winstr 180 ypos 100 20 state nil EDWIN_RESIZE_MW -> ctrlstate in let crEdCtrlCheck winstr 10 (set ypos = ypos + 75) 280 20 "Enable on init" EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlCheckState ctrlinit init; setEdCtrlButtonCb filebtn mkfun2 @cbBtnPickObj [inst winstr ctrlxmlname]; setEdCtrlTextLineEnable ctrlxmlname 0; setEdCtrlButtonCb refreshxmlname mkfun2 @cbRefreshBtn [ctrlxmlname]; [mkfun1 @cbCloseEdit[ctrlxmlname ctrlstate ctrlinit] @cbDestroyEdit]; ); );;