/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ struct PlugUserItem = [ NUI_instance : PInstance, NUI_netcomm : NetComm, NUI_item : S, NUI_value : S ]mkPlugUserItem;; fun deleteOb(inst, constr)= 0;; fun cbGetUserItem(inst, netstr, userstr, item, value, constr)= if ((inst.INST_groupstr.GRP_project.PRJ_netUser == nil) && (userstr == netThisUser netstr)) || ((inst.INST_groupstr.GRP_project.PRJ_netUser != nil) && (userstr != inst.INST_groupstr.GRP_project.PRJ_netUser)) then nil else if (strcmp item constr.NUI_item) then nil else ( set constr.NUI_value = value; SendPluginEvent inst "Value changed" value nil; ); 0;; fun cbSetValue(inst, from, action, param, reply, constr)= netUpdateUserItem constr.NUI_netcomm constr.NUI_item param; 0;; fun cbGetValue(inst, from, action, param, reply, constr)= let if (inst.INST_groupstr.GRP_project.PRJ_netUser != nil) then inst.INST_groupstr.GRP_project.PRJ_netUser else netThisUser constr.NUI_netcomm -> userstr in let netUserGetItemValue constr.NUI_netcomm userstr constr.NUI_item -> value in if (value == nil) then nil else set constr.NUI_value = value; SendPluginEvent inst "Value" constr.NUI_value nil; 0;; fun newOb(inst)= let getPluginInstanceParam inst "item" -> sitem in let getPluginInstanceParam inst "value" -> svalue in let mkPlugUserItem [inst netcomOS3D sitem svalue] -> constr in ( setPluginInstanceCbNetUserGetItem inst mkfun6 @cbGetUserItem constr; PluginRegisterAction inst "Set value" mkfun6 @cbSetValue constr; PluginRegisterAction inst "Get value" mkfun6 @cbGetValue constr; setPluginInstanceCbDel inst mkfun2 @deleteOb constr; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;