/* Move Plugin Client - DMS - August 2001 - by Macfly */ typeof class = S;; struct MoveManager = [ MOVEkeyboardsId : [MoveKeyboard r1], MOVEactivated : I, MOVEcentralPos : [I I], MOVEmultiPos : [I I], MOVEdecalPos : [I I], MOVEevents : [MoveEvent r1], MOVEactions : [MoveAction r1], MOVEpressedKeys : [I r1], MOVEcoordinates : [I I I], MOVEangles : [I I I], MOVEsensitivity : I, MOVEreverseMouse : I, /* 0 not reverse */ MOVEuserKeyboard : I, /* 0 : azerty ; 1 : qwerty */ MOVEcursorBmp : ObjBitmap, MOVEcursor : ObjCursor, MOVEkeydowntreated : I ]mkMoveManager;; typeof MoveMng = MoveManager;; fun MOVE_TreatKeyDown (val) = set MoveMng.MOVEkeydowntreated=val ;; fun MOVE_GetSensitivity () = MoveMng.MOVEsensitivity;; fun MOVE_GetReverseMouse () = MoveMng.MOVEreverseMouse;; fun MOVE_GetUserKeyboard () = MoveMng.MOVEuserKeyboard;; fun MOVE_GetKeyboards () = MoveMng.MOVEkeyboardsId;; fun MOVE_GetEvents () = MoveMng.MOVEevents;; fun MOVE_RemoveMoveAction (key, code) = set MoveMng.MOVEactions = MOVEACTION_RemoveFromKeyAndCode MoveMng.MOVEactions key code; 0 ;; fun MOVE_AddAction (scan, code) = let MOVEEVENT_PosInList MoveMng.MOVEevents code -> pos in set MoveMng.MOVEactions = MOVEACTION_Add MoveMng.MOVEactions scan code pos; 0 ;; fun MOVE_GetMoveActionFromCode (code) = search_in_list MoveMng.MOVEactions @MOVEACTION_CompareCode code ;; /*----------------------------------------------------------------------------------*/ fun MOVE_AddInListSorted (list, value) = if list == nil then [value::nil 1] else let list -> [cur next] in if cur == value then [list 0] else if cur > value then [value::list 1] else let MOVE_AddInListSorted next value -> [newlist result] in [cur::newlist result] ;; fun MOVE_RemoveInListSorted (list, value) = if list == nil then [nil 0] else let list -> [cur next] in if cur == value then [next 1] else if cur > value then [list 0] else let MOVE_RemoveInListSorted next value -> [newlist result] in [cur::newlist result] ;; fun MOVE_AddKeyPressed (scancode) = let MOVEACTION_SearchByKey MoveMng.MOVEactions scancode -> moveaction in if moveaction != nil then let MOVE_AddInListSorted MoveMng.MOVEpressedKeys scancode -> [newlist result] in ( if result then set MoveMng.MOVEpressedKeys = newlist else nil; [result moveaction] ) else nil ;; fun MOVE_RemoveKeyPressed (scancode) = let MOVE_RemoveInListSorted MoveMng.MOVEpressedKeys scancode -> [newlist result] in if result then ( set MoveMng.MOVEpressedKeys = newlist; MOVEACTION_SearchByKey MoveMng.MOVEactions scancode ) else nil ;; fun MOVE_ApplyMovement () = navig MoveMng.MOVEcoordinates MoveMng.MOVEangles ;; fun MOVE_Reinit () = set MoveMng.MOVEpressedKeys = nil; set MoveMng.MOVEcoordinates = [0 0 0]; set MoveMng.MOVEangles = [0 0 0]; MOVE_ApplyMovement ;; fun MOVE_TreatMovementChange (deplacement) = let deplacement -> [[x y z] [a b c]] in ( let MoveMng.MOVEcoordinates -> [xx yy zz] in set MoveMng.MOVEcoordinates = [xx+x yy+y zz+z]; let MoveMng.MOVEangles -> [aa bb cc] in set MoveMng.MOVEangles = [a b c]; ); MOVE_ApplyMovement ;; proto MOVE_KeyUp = fun [Ob I] I;; fun MOVE_ReleaseSpecial (elt, ob) = MOVE_KeyUp ob elt;; fun MOVE_Release (ob) = set MoveMng.MOVEactivated = 0; apply_on_list MoveMng.MOVEpressedKeys @MOVE_ReleaseSpecial ob; MOVE_Reinit; OB_ReleaseCursor ob ;; typeof MOVE_cbManageKey = fun [S I] I;; fun MOVE_TreatSpecial (ob, moveaction, downevent) = let nth_list MoveMng.MOVEevents moveaction.MOVEACTIONpos -> moveevent in let MOVEEVENT_GetCode moveevent -> code1 in if (!strcmpi code1 SPECIALEVENT_MOUSEMOVE) then if downevent then ( if MoveMng.MOVEactivated then MOVE_Release ob else if OB_TakeCursor ob then ( set MoveMng.MOVEactivated = 1; MOVE_Reinit; let C3D_GetCursorPos -> [x y] in set MoveMng.MOVEdecalPos = [x y]; OB_SetCursor ob MoveMng.MOVEcursor ) else nil ) else nil else ( exec MOVE_cbManageKey with [code1 downevent]; nil ) ;; fun MOVE_TreatMovement (ob, action, moveaction) = let MOVEACTION_GetMovement MoveMng.MOVEevents action moveaction MOVEEVENT_CONTINUE -> deplacement in if deplacement == nil then /* if action != nil then*/ ( MOVE_TreatSpecial ob moveaction (if action != nil then 1 else 0); nil ) /* else nil*/ else MOVE_TreatMovementChange deplacement ;; fun MOVE_KeyDown (ob, param) = if MoveMng.MOVEkeydowntreated then let param -> [scancode _] in let MOVE_AddKeyPressed scancode -> [result moveaction] in if result != nil then MOVE_TreatMovement ob result moveaction else nil else nil; 0 ;; fun MOVE_KeyUp (ob, scancode) = let MOVE_RemoveKeyPressed scancode -> moveaction in if moveaction != nil then MOVE_TreatMovement ob nil moveaction else nil; 0 ;; fun MOVE_MouseClick (ob, param) = let param -> [_ [x y btn]] in MOVE_KeyDown ob [(-btn) nil]; 0 ;; fun MOVE_MouseDClick (ob, param) = let param -> [_ [x y btn]] in 0; 0 ;; fun MOVE_MouseUnclick (ob, param) = let param -> [_ [x y btn]] in MOVE_KeyUp ob (-btn); 0 ;; fun MOVE_MouseMove (ob, param) = let C3D_GetCursorPos -> [x y] in if MoveMng.MOVEactivated then let MoveMng.MOVEdecalPos -> [xx yy] in let [(xx-x) (yy-y)] -> [depla deplb] in let MoveMng.MOVEmultiPos -> [mula mulb] in ( MOVE_TreatMovementChange [[0 0 0] [depla*mula deplb*mulb 0]]; if (depla == 0) && (deplb == 0) then ( C3D_ForceMousePos MoveMng.MOVEcentralPos; set MoveMng.MOVEdecalPos = MoveMng.MOVEcentralPos; ) else set MoveMng.MOVEdecalPos = [x y]; ) else nil; 0 ;; fun MOVE_KillFocus (dev, ob) = if MoveMng.MOVEactivated then ( MOVE_Release ob; ) else nil; 0 ;; fun MOVE_Save () = _storepack strbuild ((itoa MoveMng.MOVEsensitivity)::nil):: ((itoa MoveMng.MOVEreverseMouse)::nil):: ((itoa MoveMng.MOVEuserKeyboard)::nil):: nil "tmp/move/move.ini" ;; fun MOVE_CloseOb () = MOVEACTION_Save MoveMng.MOVEactions; MOVE_Save; MOVECONF_Close nil; _DSbitmap MoveMng.MOVEcursorBmp; _DScursor MoveMng.MOVEcursor; set MoveMng = nil; setView3dMoveManagement w3d 1; /* enable c3d default keys management for move */ 0 ;; proto control_render = fun[Ob [ObjSurface [I I]]] I;; proto control_start = fun[] I;; fun MOVE_CloseMainWindow (win, param, o) = MOVEACTION_Save MoveMng.MOVEactions; /* MODIF 26-10 */ let MOVEEVENT_Init -> moveevents in MOVEACTION_Init moveevents; control_start; if !pbData.alive_PBDATA then ObCbPostRender o @control_render /* FIN MODIF 26-10 */ else nil; MOVECONF_Close nil; _DSwindow win ;; fun MOVE_ShowConfiguration (o) = /*MODIF 26-10 */ if MoveConf != nil then nil else let _CBwinClose _CRwindow _channel nil 100 100 300 420 WN_MENU (_loc this "PAINTBALL_CONFIGURE" nil) mkfun3 @MOVE_CloseMainWindow o /* MODIF 26-10 */ nil -> win in ( MOVECONF_Open _channel win 0 0 300 420 MoveMng.MOVEevents MoveMng.MOVEactions; ); 0 ;; fun MOVE_ResizeView (ob, param) = let param -> [w h] in let [w/2 h/2] -> [ww hh] in ( set MoveMng.MOVEcentralPos = [ww hh]; let MoveMng.MOVEsensitivity -> mm in set MoveMng.MOVEmultiPos = [(mm*8000)/ww ((if MoveMng.MOVEreverseMouse then (-mm) else mm)*5000)/hh]; ); 0 ;; fun MOVE_SetReverseMouse (val) = set MoveMng.MOVEreverseMouse = val; MOVE_ResizeView nil (getView3dSize w3d) ;; fun MOVE_SetUserKeyboard (val) = set MoveMng.MOVEuserKeyboard = val ;; fun MOVE_SetSensitivity (val) = set MoveMng.MOVEsensitivity = val; MOVE_ResizeView nil (getView3dSize w3d) ;; fun MOVE_Init () = let _checkpack "tmp/move/move.ini" -> result in if result == nil then nil else let strextr _getpack result -> ll in ( let atoi hd hd ll -> sens in if sens > 0 then set MoveMng.MOVEsensitivity = sens else nil; set MoveMng.MOVEreverseMouse = atoi hd hd tl ll; set MoveMng.MOVEuserKeyboard = atoi hd hd tl tl ll ) ;; fun MOVE_NewOb (ob) = if MoveMng != nil then nil else ( let MOVEEVENT_Init -> moveevents in let _LDbitmap _channel _checkpack strcat PLUGpath thisplug "move/empty.bmp" -> bmp in set MoveMng = mkMoveManager [ MOVEKBD_Init 0 nil nil nil moveevents MOVEACTION_Init moveevents nil [0 0 0] [0 0 0] 2 0 0 bmp (_CRcursor _channel bmp 9 3 0 0xFFFFFF) 1 ]; MOVE_Init; MOVE_ResizeView ob (getView3dSize w3d); setView3dMoveManagement w3d 0; /* disable c3d default keys management for move */ OB_CBclickDown ob @MOVE_MouseClick; OB_CBclickUp ob @MOVE_MouseUnclick; OB_CBdoubleClick ob @MOVE_MouseDClick; OB_CBkeyboardDown ob @MOVE_KeyDown; OB_CBkeyboardUp ob @MOVE_KeyUp; OB_CBresizeView ob @MOVE_ResizeView; setView3dcbKillFocus w3d mkfun2 @MOVE_KillFocus ob; /* ObRegisterAction ob (strcat class ".ShowConfiguration") @MOVE_ShowConfiguration;*/ 0 ) ;;