/************************************************************* Bastien BOURINEAU 03/2004 **************************************************************/ /**************** Main Windows function ******************/ // Main Window Mouse Callbacks fun cbMove(win, p, posx, posy, but) = set iMoveX = posx; set iMoveY = posy; if but==1 then ( set MoveClickStatus = MVCLICK_YES; ) else nil; 0;; fun mouseWheel(win, puser, x, y, delta, but)= set WeelDelta = delta; set WeelStatus = 1; 0 ;; fun cbClick(win, p, posx, posy, but) = if but==1 then ( set iClickX = posx; set iClickY = posy; set iClickStatus = CLICK_YES; ) else if but==2 then ( _DRAWmenu Win ContextMenu posx posy PM_LEFT_ALIGN; 0; ) else nil; 0;; fun cbUnclick(win, p, posx, posy, but) = set iClickStatus = CLICK_NO; set MoveClickStatus = MVCLICK_NO; 0;; fun KeyDown(key,param,a,b)= let 200 -> delta in if a==1 then _closemachine else if a==15 then if Rendu_filaire==0 then ( _CHKmenu RMenu 1; set Rendu_filaire=1; ) else ( _CHKmenu RMenu 0; set Rendu_filaire=0; ) else if a==328 then nil else if a==336 then nil else if a==331 then nil else if a==333 then nil else nil; 0;; fun CB_Closed (win,b)= _closemachine;; fun CB_dlsOpen (dlg, param, file)= if file == nil then nil else ( _Bitmap2Surface Buffer 0 0 load_bitmap 0 0 winW winH 0; _BLTsurface Win 0 0 Buffer 0 0 winW winH; set loadScreen=1; let _PtoScol file -> Sfile in ( set scenefile = Sfile; let getPathFile Sfile "" -> [path _] in set CurrentDir = path; ); Init_3D_Session; playSnd SndStart; ); 0 ;; fun OpenFile()= let _DLGOpenFile _channel Win CurrentDir nil "M3d\0*.m3d\0All\0*.*\0\0" -> dlgOpen in _DLGrflopen dlgOpen @CB_dlsOpen nil; 0 ;; fun endcolor1 (index)= if index==nil then nil else let index ->c in let (c>>16) & 255 -> B in let (c>>8) & 255 -> G in let c & 255 -> R in set BackgroundColor= [R G B]; 0;; fun CB_EMenu (mItem, param)= ExamineMode; set MoveMode = 1; _ENmenuItem IMenu; _CHKmenu WMenu 0; _CHKmenu EMenu 1; _CHKmenu FMenu 0; 0 ;; fun CB_WMenu (mItem, param)= AvMode; set MoveMode = 2; _DImenuItem IMenu; _CHKmenu WMenu 1; _CHKmenu EMenu 0; _CHKmenu FMenu 0; 0 ;; fun CB_FMenu (mItem, param)= FlyMode; set MoveMode = 3; _DImenuItem IMenu; _CHKmenu WMenu 0; _CHKmenu EMenu 0; _CHKmenu FMenu 1; 0 ;; fun CB_RMenu (mItem, param)= if Rendu_filaire==0 then ( _CHKmenu RMenu 1; set Rendu_filaire=1; ) else ( _CHKmenu RMenu 0; set Rendu_filaire=0; ); 0 ;; fun CB_OMenu (mItem, param)= OpenFile; 0 ;; fun CB_QMenu (mItem, param)= _closemachine; 0 ;; fun CB_IMenu (mItem, param)= if H3dFromM3dList==nil then (set ObjDist = Camdist) else GetObjsize H3dFromM3dList; M3setObjVec Session Camera [0 0 (-ObjDist)]; 0 ;; fun CB_PMenu (mItem, param)= RunH3dParticle EmitFromM3dList; 0 ;; fun CB_AMenu (mItem, param)= _DLGMessageBox _channel Win AboutTitle AboutText 0; 0 ;; fun CB_CMenu (mItem, param)= _CRcolorMap1 _channel nil 0 0 "" @endcolor1 0; 0 ;; fun create_interf ()= let _GETscreenSize -> [w h] in set Win = _CBwinDestroy _CRwindow _channel nil ((w / 2) - (winW /2)) ((h / 2) - (winH /2 )) winW (winH-1) WN_MENU "Technologies Navigator" @CB_Closed nil; _CBwinKeydown Win @KeyDown nil; _CBwinClick Win @cbClick nil; _CBwinWheel Win @mouseWheel nil; _CBwinUnclick Win @cbUnclick nil; _CBcursorMove Win @cbMove nil; set ContextMenu = _CRpopupMenu _channel; set EMenu = _APPitem _channel ContextMenu (if MoveMode==1 then ME_CHECKED else ME_UNCHECKED) ExamMnu; set WMenu = _APPitem _channel ContextMenu (if MoveMode==2 then ME_CHECKED else ME_UNCHECKED) WalkMnu; set FMenu = _APPitem _channel ContextMenu (if MoveMode==3 then ME_CHECKED else ME_UNCHECKED) FlyMnu; _APPitem _channel ContextMenu ME_SEPARATOR ""; if StandAloneView ==1 then ( set CMenu = _APPitem _channel ContextMenu ME_ENABLED BackMnu; set RMenu = _APPitem _channel ContextMenu ME_UNCHECKED WireMnu; set IMenu = _APPitem _channel ContextMenu (if MoveMode==1 then ME_ENABLED else ME_DISABLED) FitMnu; set PMenu = _APPitem _channel ContextMenu (if EmitFromM3dList!=nil then ME_ENABLED else ME_DISABLED) PartMnu; _APPitem _channel ContextMenu ME_SEPARATOR ""; set OMenu = _APPitem _channel ContextMenu ME_ENABLED OpenMnu; set QMenu = _APPitem _channel ContextMenu ME_ENABLED QuitMnu; _CBmenu CMenu @CB_CMenu nil; _CBmenu OMenu @CB_OMenu nil; _CBmenu QMenu @CB_QMenu nil; 0; )else ( set RMenu = _APPitem _channel ContextMenu ME_UNCHECKED WireMnu; set IMenu = _APPitem _channel ContextMenu (if MoveMode==1 then ME_ENABLED else ME_DISABLED) FitMnu; set PMenu = _APPitem _channel ContextMenu (if EmitFromM3dList!=nil then ME_ENABLED else ME_DISABLED) PartMnu; 0; ); _APPitem _channel ContextMenu ME_SEPARATOR ""; set AMenu = _APPitem _channel ContextMenu ME_ENABLED AboutMnu; _CBmenu AMenu @CB_AMenu nil; _CBmenu EMenu @CB_EMenu nil; _CBmenu WMenu @CB_WMenu nil; _CBmenu FMenu @CB_FMenu nil; _CBmenu RMenu @CB_RMenu nil; _CBmenu IMenu @CB_IMenu nil; _CBmenu PMenu @CB_PMenu nil; 0 ;; fun main()= srand time; // _showconsole; create_interf; loadSnd; // loading bitmap let _checkpack LoadingBitmap -> jpgfile in set load_bitmap = _LDjpeg _channel jpgfile; set loadScreen=1; if Back3d==1 then let _checkpack BackBitmap -> jpgfile in set back_bitmap = _LDjpeg _channel jpgfile else nil; if StandAloneView ==1 then ( OpenFile; 0; )else ( if scenefile!=nil then ( Init_3D_Session; playSnd SndStart; ) else nil; ); set Buffer = _CRsurface _channel winW winH; if View3D==1 then ( set BufferLeft = _CRsurface _channel winW winH; set BufferRight = _CRsurface _channel winW winH; set LeftBitmap = _CRbitmap _channel winW winH; set RightBitmap = _CRbitmap _channel winW winH; ) else nil; set bmpHand = _LDbitmap _channel _checkpack HandCursorFile; set csrHand = _CRcursor _channel bmpHand 12 6 0 32767; 0; set timer_paint = _starttimer _channel (1000 / 30); _rfltimer timer_paint @paint nil; 0;;