/* ----------------------------------------------------------------------------- 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 getOs3dVersion = fun [] I;; proto getVersionS = fun [] S;; proto initOs3dEditor = fun [S] I;; proto startloc = fun [S] I;; proto startlocEx = fun [S S] I;; proto XMLload = fun [S] XMLfile;; proto XMLclose = fun [XMLfile] I;; proto XMLgetMarkByValue = fun [XMLfile S] XMLmark;; proto XMLgetParam = fun [XMLmark S] S;; //Navigator window typeof winAX = ObjWin;; typeof APPBASEDIR = S;; fun cbCloseApp(dlg, p, rep)= _closemachine; 0;; fun getStringSize2(font, txtList, w, h)= if txtList == nil then [w+1 h] else let txtList -> [first next] in let _GETstringSize font first -> [nw nh] in getStringSize2 font next (if nw>w then nw else w) (nh+h) ;; fun getStringSize(font, str)= getStringSize2 font (lineextr str) 0 0;; 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;; fun cbErrorDialogBtn(btn, p)= let p -> [win font] in ( _DSwindow win; _DSfont font; ); cbCloseApp nil nil nil; 0;; fun errorDialog(father, title, content, error)= let _SETdefaultFont _CRfont _channel 10 0 FF_PIXEL "Arial" -> font in let getStringSize font content -> [fw fh] in let if fw < 200 then 200 else fw -> fw in let fw + 60 -> w in let fh + 200 -> h in let _GETdesktopSize -> [sw sh] in let _CRwindow _channel father ((sw / 2) - (w / 2)) ((sh / 2) - (h / 2)) w h WN_DIALOG|WN_NOSCOL title -> win in ( _CRtext _channel win 5 5 (w - 10) (fh + 20) 0 content; _CRtext _channel win 5 (fh + 20) (w - 10) (h - 35 - fh - 20) ET_AHSCROLL|ET_AVSCROLL|ET_VSCROLL|ET_HSCROLL|ET_BORDER error; _CBbutton (_CRbutton _channel win ((w / 2) - 45) (h - 25) 90 20 PB_DEFAULT "Ok") @cbErrorDialogBtn [win font]; _CBwinDestroy win @cbErrorDialogBtn [win font]; _TOPwindow win; ); 0;; fun secureLoad(pack)= let _testpak pack -> ret in if (ret == nil) then ( _load pack; ret; ) else ( _fooS strcat ">>>>> Compilation error : " ret; ret; );; /** loadOS3D [S] I * launch Editor * * return 0 **/ fun loadOS3D(file)= 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/android.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":: "os3deditor/os3dstruct.pkg":: "os3deditor/os3ddocsrv.pkg":: "os3deditor/os3dplugit.pkg":: "os3deditor/os3dnav.pkg":: "os3deditor/os3dlogs.pkg":: "os3deditor/os3dtools.pkg":: "os3deditor/os3dsettingshadows.pkg":: "os3deditor/os3dsettingphysics.pkg":: "os3deditor/os3dsettingrendering.pkg":: "os3deditor/os3dsettingenv.pkg":: "os3deditor/os3dmaterialeditor.pkg":: "os3deditor/os3dthemeeditor.pkg":: "os3deditor/os3deditor.pkg":: nil -> lfiles in let nil -> ret in ( while (lfiles != nil) && ((set ret = secureLoad (strcat APPBASEDIR (hd lfiles))) == nil) do ( set lfiles = tl lfiles; ); if (lfiles == nil) then ( //get current language let XMLload strcat APPBASEDIR "os3deditor/config.xml" -> confstr in let XMLgetMarkByValue confstr "config" -> configmark in let XMLgetParam configmark "language" -> lang in //use default if needed let if (lang == nil) then _getress "DefaultLanguage" else lang -> lang in ( XMLclose confstr; startlocEx strcat APPBASEDIR "os3deditor/lang/os3deditor" lang; //init loc ); // launch Editor initOs3dEditor file; 0; ) else ( errorDialog nil "OpenSpace3D Error :" "This version of OpenSpace3D Editor is not compatible with your Scol Voy@ger version.\nPlease perform an update." ret; //_DLGrflmessage (_DLGMessageBox _channel nil "Error" "This version of OpenSpace3D Editor is not compatible with your Scol Voy@ger version, please perform an update" 0) @cbCloseApp nil; 0; ); ); 0;; /** 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) && (curver == nil) 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; );; /** cbKillOs3d [Timer u0] I * timer callback to closemachine after opening scolring * * return 0 **/ fun cbKillOs3d(trm, p)= _deltimer trm; _closemachine; 0;; /** cbDlScol [MessageBox u0 I] I * open scolring and quit * * return 0 **/ fun cbDlScol(msgbox, p, rep)= if rep == 1 then ( _openbrowserhttp "http://www.scolring.org"; _rfltimer _starttimer _channel 1000 @cbKillOs3d nil; 0; ) else ( _closemachine; ); 0;; fun cbCloseTimer(trm, p)= _deltimer trm; _closemachine; 0;; /** main [S] I * initialize the application * * return 0 **/ fun main(file) = let getVoyagerVersion -> curver in if curver < iMinVoyagerVersion 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. Download the Scol Voy@ager now ?" 2) @cbDlScol nil; 0; ) else ( _setActivePartition "./OpenSpace3D" 1; // get the os3dload.pkg parent directory let _envchannel _channel -> env in let loaderRemovelastPathDir loaderGetFilePath _envfirstname env nil -> path in set APPBASEDIR = path; _load strcat APPBASEDIR "os3deditor/os3dversion.pkg"; getOs3dVersion; loadOS3D file; 0; ); 0;;