/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ var sSavePath = "tmp/save/";; fun deleteOb(inst)= 0;; fun cbLoad(inst, from, action, param, rep) = let strcatn sSavePath::"file"::param::".sav"::nil -> savefilepath in let XMLload savefilepath -> xmlfile in ( let XMLgetMarkByValue xmlfile "root" -> xmlroot in let XMLgetMarkByValueFromMarkSons xmlroot "GameData" -> initmark in ( let XMLgetParam XMLgetMarkByValueFromMark initmark "Scene" "range" -> idwanted in _DMSevent this (getPluginInstanceEvent inst "Id") idwanted nil; let oneLineTransform XMLserialize xmlfile "" -> xmlLoad in _DMSevent this (getPluginInstanceEvent inst "Set Data") xmlLoad nil; ); ); 0;; fun cbSave(inst, from, action, param, rep) = let strToListSep param "\n" -> paramlist in let strcatn sSavePath::"file"::(nth_list paramlist 1)::".sav"::nil -> savefilepath in let XMLloadString (nth_list paramlist 0) -> xmlfile in ( XMLwrite xmlfile savefilepath; //Move this somewhere with a real text _DMSevent this (getPluginInstanceEvent inst "Save succeded") nil nil; ); 0;; fun cbGetInfo(inst, from, action, param, rep) = let strcatn sSavePath::"file"::param::".sav"::nil -> filepath in let XMLload filepath -> xmlfile in let XMLgetMarkByValue xmlfile "root" -> xmlroot in let XMLgetMarkByValueFromMarkSons xmlroot "GameData" -> initmark in ( let XMLgetParam XMLgetMarkByValueFromMark initmark "Scene" "range" -> idwanted in let XMLgetParam XMLgetMarkByValueFromMark initmark "Timer" "seconds" -> timerwanted in let strcatn param::"\n"::idwanted::"\n"::timerwanted::nil -> params in _DMSevent this (getPluginInstanceEvent inst "Data info") params nil; ); 0;; fun newOb(inst)= PluginRegisterAction inst "Load" @cbLoad; PluginRegisterAction inst "Save" @cbSave; PluginRegisterAction inst "Get data info" @cbGetInfo; setPluginInstanceCbDel inst @deleteOb; 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;