/* ----------------------------------------------------------------------------- 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 getSelectedList(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 strcat "node_" (itoa i) -> elemname in set ndata = [elemname elem]::ndata; set i = i + 1; ); ndata; );; fun loadSelectedList(inst)= let nil -> ndata in let nil -> elem in let 0 -> i in ( while ((set elem = (getPluginInstanceParam inst (strcat "node_" (itoa i)))) != nil) do ( set ndata = elem::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrldstadress ctrdstport ctrlsrvport ctrlisprotocol ctrlmessage ctrlmode ctrlinit ctrlecho [selectedlist]] in ( let getEdCtrlTextLineValue ctrldstadress -> dstaddress in let getEdCtrlFloatValue ctrdstport -> dstport in let getEdCtrlFloatValue ctrlsrvport -> srvport in let getSelectedEdCtrlSelectPos ctrlisprotocol -> isprotocol in let getEdCtrlListElems ctrlmessage -> levent in let getSelectedEdCtrlSelectPos ctrlmode -> ismode in let getEdCtrlCheckState ctrlinit -> init in let getEdCtrlCheckState ctrlecho -> echo in ["dstaddress" dstaddress]:: ["dstport" ftoa dstport]:: ["srvport" ftoa srvport]:: ["isprotocol" itoa isprotocol]:: ["ismode" itoa ismode]:: ["init" itoa init]:: ["echo" itoa !echo]:: (lcat (getSelectedList selectedlist) (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 getTreeItemBitmapChecked(name, type)= if (type == iTypeNode) then sTreeBitmapNodeCheck else if (type == iTypeGroup) then sTreeBitmapGroupCheck else if (type == iTypeEntity) then sTreeBitmapEntityCheck else if (type == iTypeBone) then sTreeBitmapBoneCheck else if (type == iTypeLight) then sTreeBitmapLightCheck else if (type == iTypeCamera) then sTreeBitmapCameraCheck else if (type == iTypeParticle) then sTreeBitmapParticleCheck else if (type == iTypeCubeMap) then sTreeBitmapCubeMapCheck else if (type == iTypeReflectionMap) then sTreeBitmapReflectionMapCheck else if (type == iTypeAnim) then sTreeBitmapAnimCheck else if (type == iTypeCinematics) then sTreeBitmapAnimCheck else if (type == iTypeCompositor) then sTreeBitmapCompositorCheck else sTreeBitmapNodeCheck ;; fun getTreeItemBitmapUnChecked(name, type)= if (type == iTypeNode) then sTreeBitmapNode else if (type == iTypeGroup) then sTreeBitmapGroup else if (type == iTypeEntity) then sTreeBitmapEntity else if (type == iTypeBone) then sTreeBitmapBone else if (type == iTypeLight) then sTreeBitmapLight else if (type == iTypeCamera) then sTreeBitmapCamera else if (type == iTypeParticle) then sTreeBitmapParticle else if (type == iTypeCubeMap) then sTreeBitmapCubeMap else if (type == iTypeReflectionMap) then sTreeBitmapReflectionMap else if (type == iTypeAnim) then sTreeBitmapAnim else if (type == iTypeCinematics) then sTreeBitmapAnim else if (type == iTypeCompositor) then sTreeBitmapCompositor else sTreeBitmapNode ;; fun getTreeItemBitmapByTypeInList(name, type, p)= //if name is in the list, then choose the checked bitmap //let is in list l name -> checked in let p -> [selectedlist] in if (isStringInList selectedlist name) then getTreeItemBitmapChecked name type else getTreeItemBitmapUnChecked name type;; fun cbTreeObjectSelect(ctrl, father, item, val, type, x, y, p)= let p -> [selectedlist] in ( if (isStringInList selectedlist val) then ( set selectedlist = remove_string_from_list selectedlist val; setEdCtrlTreeItemBitmap ctrl item (getTreeItemBitmapUnChecked val type); ) else ( set selectedlist = val::selectedlist; setEdCtrlTreeItemBitmap ctrl item (getTreeItemBitmapChecked val type); ); mutate p <- [selectedlist]; ); 0;; fun cbTreeObjectCheck(ctrl, father, item, val, type, x, y, p)= let p -> [selectedlist] in ( if (isStringInList selectedlist val) then nil else ( set selectedlist = val::selectedlist; setEdCtrlTreeItemBitmap ctrl item (getTreeItemBitmapChecked val type); mutate p <- [selectedlist]; ); ); 0;; fun cbTreeObjectUnCheck(ctrl, father, item, val, type, x, y, p)= let p -> [selectedlist] in ( if !(isStringInList selectedlist val) then nil else ( set selectedlist = remove_string_from_list selectedlist val; setEdCtrlTreeItemBitmap ctrl item (getTreeItemBitmapUnChecked val type); mutate p <- [selectedlist]; ) ); 0;; fun cbSelectWithChildren(mnuitem, p)= let p -> [ctrltree itemstr plist] in let getEdCtrlTreeSonsItem ctrltree itemstr -> children in ( cbTreeObjectCheck ctrltree nil itemstr itemstr.EDTITEM_sValue itemstr.EDTITEM_iType nil nil plist; if (children == nil) then nil else ( while (children != nil) do ( let hd children -> son in ( cbTreeObjectCheck ctrltree itemstr son son.EDTITEM_sValue son.EDTITEM_iType nil nil plist; cbSelectWithChildren nil [ctrltree son plist]; ); set children = tl children; ); ); ); 0;; fun cbUnselectWithChildren(mnuitem, p)= let p -> [ctrltree itemstr plist] in let getEdCtrlTreeSonsItem ctrltree itemstr -> children in ( cbTreeObjectUnCheck ctrltree nil itemstr itemstr.EDTITEM_sValue itemstr.EDTITEM_iType nil nil plist; if (children == nil) then nil else ( while (children != nil) do ( let hd children -> son in ( cbTreeObjectUnCheck ctrltree itemstr son son.EDTITEM_sValue son.EDTITEM_iType nil nil plist; cbUnselectWithChildren nil [ctrltree son plist]; ); set children = tl children; ); ); ); 0;; fun cbSelect(mnuitem, p)= let p -> [ctrltree itemstr plist] in cbTreeObjectCheck ctrltree nil itemstr itemstr.EDTITEM_sValue itemstr.EDTITEM_iType nil nil plist; 0;; fun cbUnselect(mnuitem, p)= let p -> [ctrltree itemstr plist] in cbTreeObjectUnCheck ctrltree nil itemstr itemstr.EDTITEM_sValue itemstr.EDTITEM_iType nil nil plist; 0;; fun cbTreeObjectRSelect(ctrltree, father, itemstr, val, type, x, y, p)= let _CRpopupMenu _channel -> ctrlpopup in let _APPitem _channel ctrlpopup ME_ENABLED (loc "OS3DLOCALNETWORK_0027") -> ctrlSelectWithChildren in let _APPitem _channel ctrlpopup ME_ENABLED (loc "OS3DLOCALNETWORK_0028") -> ctrlUnselectWithChildren in let _APPitem _channel ctrlpopup ME_ENABLED (loc "OS3DLOCALNETWORK_0029") -> ctrlSelect in let _APPitem _channel ctrlpopup ME_ENABLED (loc "OS3DLOCALNETWORK_0030") -> ctrlUnselect in ( _DRAWmenu ctrltree.EDC_father.EDW_win ctrlpopup x y PM_RIGHT_ALIGN; _CBmenu ctrlSelectWithChildren @cbSelectWithChildren [ctrltree itemstr p]; _CBmenu ctrlUnselectWithChildren @cbUnselectWithChildren [ctrltree itemstr p]; _CBmenu ctrlSelect @cbSelect [ctrltree itemstr p]; _CBmenu ctrlUnselect @cbUnselect [ctrltree itemstr p]; ); 0;; fun cbSelectProtocol(ctrlisprotocol, pos, name, p)= let p -> [ctrldstadress ctrdstport ctrlsrvport] in ( if (pos == 2) then ( setEdCtrlTextLineEnable ctrldstadress 0; setEdCtrlFloatEnable ctrdstport 0; setEdCtrlFloatEnable ctrlsrvport 0; ) else ( setEdCtrlTextLineEnable ctrldstadress 1; setEdCtrlFloatEnable ctrdstport 1; setEdCtrlFloatEnable ctrlsrvport 1; ); );; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [420 670] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "dstaddress") -> dstaddress in let if dstaddress == nil then "127.0.0.1" else dstaddress -> dstaddress in let atof (getPluginInstanceParam inst "dstport") -> dstport in let if (dstport == nil) then 1201.0 else dstport -> dstport in let atof (getPluginInstanceParam inst "srvport") -> srvport in let if (srvport == nil) then 1201.0 else srvport -> srvport in let atoi (getPluginInstanceParam inst "isprotocol") -> isprotocol in let if isprotocol == nil then 0 else isprotocol -> isprotocol in let atoi (getPluginInstanceParam inst "ismode") -> ismode in let if ismode == nil then 0 else ismode ->ismode in let atoi (getPluginInstanceParam inst "init") -> isinit in let if isinit == nil then 1 else isinit -> isinit in let atoi (getPluginInstanceParam inst "echo") -> isecho in let crEdFrameWindow _channel ewinstr 0 0 iw 135 EDWIN_RESIZE_MW nil (loc "OS3DLOCALNETWORK_0003") (loc "OS3DLOCALNETWORK_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 115 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ypos 160 20 (loc "OS3DLOCALNETWORK_0004") nil -> labeladdr in let crEdCtrlTextLine winstr 180 ypos 170 20 dstaddress nil EDWIN_RESIZE_MW -> ctrldstadress in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) 160 20 (loc "OS3DLOCALNETWORK_0005") nil -> labeldstport in let crEdCtrlFloat winstr 180 ypos 160 20 dstport 1.0 65536.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrdstport in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) 160 20 (loc "OS3DLOCALNETWORK_0006") nil -> labelsrvport in let crEdCtrlFloat winstr 180 ypos 160 20 srvport 1.0 65536.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlsrvport in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) 160 20 (loc "OS3DLOCALNETWORK_0010") nil -> labelprotocol in let crEdCtrlSelect winstr 180 (ypos) 170 120 EDWIN_RESIZE_MW -> ctrlisprotocol in let crEdFrameWindow _channel ewinstr 0 0 iw 125 EDWIN_RESIZE_MW nil (loc "OS3DLOCALNETWORK_0009") (loc "OS3DLOCALNETWORK_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 320 EDWIN_RESIZE_MW nil (loc "OS3DLOCALNETWORK_0026") (loc "OS3DLOCALNETWORK_0002") ->winfrm in let crEdWindow _channel winfrm 0 18 iw 300 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlTree winstr 10 (set ypos = 10) (iw - 20) 250 EDWIN_RESIZE_MW -> ctrltree in let crEdCtrlLabel winstr 10 (set ypos = ypos + 260) 160 20 (loc "OS3DLOCALNETWORK_0032") nil -> labelmode in let crEdCtrlSelect winstr 180 (ypos) 170 120 EDWIN_RESIZE_MW -> ctrlmode in let crEdFrameWindow _channel ewinstr 0 0 iw 85 EDWIN_RESIZE_MW nil (loc "OS3DLOCALNETWORK_0011") (loc "OS3DLOCALNETWORK_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) iw 20 (loc "OS3DLOCALNETWORK_0013") EDWIN_RESIZE_MW -> ctrlecho in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DLOCALNETWORK_0012") EDWIN_RESIZE_MW -> ctrlinit in let [(loadSelectedList inst)] -> p in ( fillEdCtrlSelect ctrlisprotocol (loc "OS3DLOCALNETWORK_0007")::(loc "OS3DLOCALNETWORK_0008")::(loc "OS3DLOCALNETWORK_0031")::nil; selectEdCtrlSelectByPos ctrlisprotocol isprotocol; if (isprotocol == 2) then ( setEdCtrlTextLineEnable ctrldstadress 0; setEdCtrlFloatEnable ctrdstport 0; setEdCtrlFloatEnable ctrlsrvport 0; ) else ( setEdCtrlTextLineEnable ctrldstadress 1; setEdCtrlFloatEnable ctrdstport 1; setEdCtrlFloatEnable ctrlsrvport 1; ); setEdCtrlSelectCb ctrlisprotocol mkfun4 @cbSelectProtocol [ctrldstadress ctrdstport ctrlsrvport]; fillGroupTree ctrltree inst.INST_groupstr.GRP_project.PRJ_group iTypeGroup|iTypeNode|iTypeLight|iTypeCamera|iTypeEntity|iTypeBone|iTypeParticle|iTypeCubeMap|iTypeReflectionMap nil 0 mkfun3 @getTreeItemBitmapByTypeInList p; setEdCtrlTreeCbDbClick ctrltree mkfun8 @cbTreeObjectSelect p; setEdCtrlTreeCbRclick ctrltree mkfun8 @cbTreeObjectRSelect p; //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); ); fillEdCtrlSelect ctrlmode (loc "OS3DLOCALNETWORK_0035")::(loc "OS3DLOCALNETWORK_0034")::(loc "OS3DLOCALNETWORK_0033")::nil; selectEdCtrlSelectByPos ctrlmode ismode; setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList [ctrlmessage ctrladdevent]; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList [ctrlmessage ctrladdevent]; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt [ctrlmessage ctrladdevent]; setEdCtrlCheckState ctrlinit isinit; setEdCtrlCheckState ctrlecho !isecho; [mkfun1 @cbCloseEdit [ctrldstadress ctrdstport ctrlsrvport ctrlisprotocol ctrlmessage ctrlmode ctrlinit ctrlecho p] nil]; ); );;