/* ----------------------------------------------------------------------------- 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 iMinVoyagerVersion = 0xe6013b4a;; proto initOs3dPlayer = fun [S S S S I] I;; //comm to navigator window defcomvar Px=;; //Navigator window typeof winAX = ObjWin;; typeof APPBASEDIR = S;; proto startloc = fun [S] I;; /** getVoyagerVersion [] I * retrive the Scol Voy@ger version * * return the Scol Voy@ger version **/ fun getVoyagerVersion()= let strextr _getpack _checkpack "locked/etc/version.txt" -> lver in let sizelist lver -> size in let nil -> curver in let 0 -> i in ( while i < size do ( let nth_list lver i -> elem in if strcmpi "version" hd elem then nil else set curver = htoi hd tl elem; set i = i + 1; ); curver; );; /** getVoyagerVersionS [] S * retrive the Scol Voy@ger version * * return the Scol Voy@ger version in string **/ fun getVoyagerVersionS()= let strextr _getpack _checkpack "locked/etc/version.txt" -> lver in let sizelist lver -> size in let nil -> curver in let 0 -> i in ( while (i < size) && (curver == nil) do ( let nth_list lver i -> elem in if strcmpi "version" hd elem then nil else set curver = hd tl elem; set i = i + 1; ); curver; );; fun loaderRemoveFirstDir(path)= let (strfind "/" path 0) -> pos in let if pos != 0 && pos != nil then pos + 1 else 0 -> pos in substr path pos (strlen path);; fun loaderRemovelastPathDir(path)= let if (!strcmp "/" (substr path ((strlen path) - 1) 1)) then substr path 0 ((strlen path) - 1) else path -> path in let 0 -> pos in ( while ((strfind "/" path pos + 1) != nil) do ( set pos = strfind "/" path pos + 1; ); substr path 0 pos + 1; );; fun loaderGetFilePath(longfile, file)= if (longfile==nil) || (strlen longfile)==0 || (nth_char longfile ((strlen longfile)-1)) == '/ || (nth_char longfile ((strlen longfile)-1)) == '\ then ( let if (nth_char longfile ((strlen longfile)-1)) == '/ then "/" else "\\" -> slash in if (strfind "." file 0) != nil then longfile else if file != nil then strcatn longfile::file::slash::nil else longfile; ) else loaderGetFilePath substr longfile 0 (strlen longfile)-1 strcat substr longfile ((strlen longfile)-1) 1 file;; /** cbVersionError [MessageBox u0 I] I * quit player * * return 0 **/ fun cbVersionError(msgbox, p, rep)= _closemachine; 0;; /** commandToAx [S S] I * send a command to navigator window * * return 0 **/ fun commandToAx(func, param)= if (winAX == nil) then nil else _onX Px strcatn func::" "::param::nil []; 0;; fun secureLoad(pack)= let _testpak pack -> ret in if (ret == nil) then ( commandToAx "OS3DPlayerLoading" pack; _load pack; 1; ) else ( commandToAx "OS3DPlayerError" strcat "Error on " pack; _fooS strcat ">>>>> Compilation error : " ret; 0; );; /** loadOS3D [S] I * launch Editor * * return 0 **/ fun loadOS3D(file, projname, pw, ph, fullscreen)= let "os3dlib/loc.pkg":: "os3dlib/tools.pkg":: "os3dlib/xmlparser.pkg":: "os3dlib/jsonparser.pkg":: "os3dlib/keyblib.pkg":: "os3dlib/ogrematparser.pkg":: "os3dlib/v3dlib.pkg":: "os3dlib/v3dlib_physics.pkg":: "os3dlib/2dglib.pkg":: "os3dlib/v3dui.pkg":: "os3dlib/minidhdms.pkg":: "os3dlib/mkapplet.pkg":: "os3dlib/netcomlib.pkg":: "os3dlib/os3dpaths.pkg":: "os3dlib/os3dstruct.pkg":: "os3dlib/os3dtypeconv.pkg":: "os3dlib/os3dplugins.pkg":: "os3dlib/os3dpluginscb.pkg":: "os3dlib/os3dloader.pkg":: "os3dlib/audiolib.pkg":: "os3dplayer/os3dversion.pkg":: "os3dplayer/os3dlogs.pkg":: "os3dplayer/os3dplayer.pkg":: nil -> lfiles in ( while (lfiles != nil) && (secureLoad (strcat APPBASEDIR (hd lfiles))) do ( set lfiles = tl lfiles; ); if (lfiles == nil) then ( //init loc startloc strcat APPBASEDIR "os3dplayer/lang/os3dplayer"; commandToAx "OS3DPlayerLoading" "Done."; // launch Player initOs3dPlayer file projname pw ph fullscreen; 0; ) else ( if (winAX == nil) then ( _DLGrflmessage (_DLGMessageBox _channel nil "Error" "This version of OpenSpace3D Player is not compatible with your Scol Voy@ger version, please perform an update or ask the webmaster to update his projects." 0) @cbVersionError nil; 0; ) else ( commandToAx "OS3DPlayerError" "This version of OpenSpace3D Player is not compatible with your Scol Voy@ger version, please perform an update or ask the webmaster to update his projects."; 0; ); 0; ); ); 0;; /** main [S S S S I] I * initialize the application * * return 0 **/ fun main(file, projname, pw ,ph, fullscreen) = set winAX = _GETactiveXWindow _channel WN_CHILD|WN_NOBORDER "ScolLoader"; if (winAX == nil) then nil else _setX _channel; let getVoyagerVersion -> curver in if curver < iMinVoyagerVersion then ( if (winAX == nil) then ( _DLGrflmessage (_DLGMessageBox _channel nil "Error" "You need a more recent Scol Voy@ger to start OpenSpace3D, you can download the last Scol Voy@ger on www.scolring.org." 0) @cbVersionError nil; 0; ) else ( commandToAx "OS3DPlayerError" "You need a more recent Scol Voy@ger to start OpenSpace3D, you can download the last Scol Voy@ger on www.scolring.org."; 0; ); 0; ) else ( //set the default active partition if exist _setActivePartition "./OpenSpace3D" 1; commandToAx "OS3DPlayerLoading" "Loading ..."; // get the os3dload.pkg parent directory let _envchannel _channel -> env in let loaderRemovelastPathDir loaderGetFilePath _envfirstname env nil -> path in set APPBASEDIR = path; loadOS3D file projname pw ph fullscreen; 0; ); 0;;