/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2018 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 getInOut(l, prefix, suffix, tag)= 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 = [tag (strcatn prefix::elem::suffix::nil)]::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlport ctrlmessage ctrlbroadcast ctrlinit] in ( let getEdCtrlFloatValue ctrlport -> port in let getEdCtrlListElems ctrlmessage -> levent in let getEdCtrlCheckState ctrlbroadcast -> broadcast in let getEdCtrlCheckState ctrlinit -> init in ["port" ftoa port]:: ["broadcast" itoa broadcast]:: ["init" itoa init]:: (lcat (getInOut levent "Send " "" "ACTION") (getInOut levent "" " message" "EVENT")) );; fun cbAddActEvnt(ctrlstr, value, p)= let p -> [liststr ctrladdevent] in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem (value)) then nil else ( addEdCtrlList liststr (value) nil nil; setEdCtrlTextLineValue ctrlstr nil; ); 0;; fun cbAddList(ctrlstr, p)= let p -> [liststr ctrladdevent] in let getEdCtrlTextLineValue ctrladdevent -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem (value)) then nil else ( addEdCtrlList liststr (value) nil nil; setEdCtrlTextLineValue ctrladdevent nil; ); 0;; fun cbDelList(ctrlstr, p)= let p -> [liststr ctrladdevent] in let getSelectedEdCtrlList liststr -> [name _ _] in delEdCtrlList liststr name; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [420 260] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let atof (getPluginInstanceParam inst "port") -> port in let if (port == nil) then 1201.0 else port -> port in let atoi (getPluginInstanceParam inst "broadcast") -> broadcast in let if broadcast == nil then 0 else broadcast -> broadcast in let atoi (getPluginInstanceParam inst "init") -> isinit in let if isinit == nil then 1 else isinit -> isinit in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DTELNETSRV_0003") (loc "OS3DTELNETSRV_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 40 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ypos 160 20 (loc "OS3DTELNETSRV_0005") nil -> labeldstport in let crEdCtrlFloat winstr 180 ypos 160 20 port 1.0 65536.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlport in let crEdFrameWindow _channel ewinstr 0 0 iw 125 EDWIN_RESIZE_MW nil (loc "OS3DTELNETSRV_0006") (loc "OS3DTELNETSRV_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 105 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlList winstr 10 (set ypos = 10) (iw - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlmessage in let crEdCtrlTextLine winstr 10 (set ypos = ypos + 65) (iw - 70) 20 nil nil EDWIN_RESIZE_MW -> ctrladdevent in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd1 in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel1 in let crEdFrameWindow _channel ewinstr 0 0 iw 85 EDWIN_RESIZE_MW nil (loc "OS3DTELNETSRV_0007") (loc "OS3DTELNETSRV_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 65 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DTELNETSRV_0008") EDWIN_RESIZE_MW -> ctrlbroadcast in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DTELNETSRV_0009") EDWIN_RESIZE_MW -> ctrlinit in ( //clean up events names let nil -> lkeyword in ( while (levent != nil) do ( let hd levent -> evt in let strToWordList evt -> line in let strcatnSep (revertlist tl (revertlist line)) " " -> keyword in set lkeyword = keyword::lkeyword; set levent = tl levent; ); fillEdCtrlList ctrlmessage (revertlist lkeyword); ); setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList [ctrlmessage ctrladdevent]; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList [ctrlmessage ctrladdevent]; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt [ctrlmessage ctrladdevent]; setEdCtrlCheckState ctrlbroadcast broadcast; setEdCtrlCheckState ctrlinit isinit; [mkfun1 @cbCloseEdit [ctrlport ctrlmessage ctrlbroadcast ctrlinit] nil]; ); );;