/* ----------------------------------------------------------------------------- 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 PlugRoomItem = [ NRI_instance : PInstance, NRI_netcomm : NetComm, NRI_item : S, NRI_value : S ]mkPlugRoomItem;; fun deleteOb(inst, constr)= 0;; fun cbRoomChanged(inst, netstr, room, constr)= // if item does not exist then we create it with default value if ((netRoomGetItemValue netstr constr.NRI_item) != nil) then nil else netUpdateRoomItem netstr constr.NRI_item constr.NRI_value; 0;; fun cbGetRoomItem(inst, netstr, item, value, constr)= if (strcmp item constr.NRI_item) then nil else ( set constr.NRI_value = value; SendPluginEvent inst "Value changed" value nil; ); 0;; fun cbSetValue(inst, from, action, param, reply, constr)= netUpdateRoomItem constr.NRI_netcomm constr.NRI_item param; 0;; fun cbGetValue(inst, from, action, param, reply, constr)= SendPluginEvent inst "Value" constr.NRI_value nil; 0;; fun newOb(inst)= let getPluginInstanceParam inst "item" -> sitem in let getPluginInstanceParam inst "value" -> svalue in let mkPlugRoomItem [inst netcomOS3D sitem svalue] -> constr in ( setPluginInstanceCbNetRoomChanged inst mkfun4 @cbRoomChanged constr; setPluginInstanceCbNetRoomGetItem inst mkfun5 @cbGetRoomItem 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;;