/***************************************************************/ /* */ /* PBCONTROL.PKG */ /* */ /* plug-in PhotoPaintBall */ /* client - player controls screen */ /* */ /* version 5 : Loïc Berthelot, mars 2001 */ /* */ /* nouvelle version 4.5 : Loïc Berthelot nov 2000 */ /* avec l'aide de Olivier Lamotte */ /* */ /* Photo3 Plugin - DMS - march 00 - by Sylvain HUET */ /* */ /***************************************************************/ /***************************************************************/ /* */ /* */ /* DATA STRUCTS : */ /* struct PBControl */ /* typeof pbControl : PBControl */ /* */ /* */ /* BODY : */ /* control_destroy : fun [] I */ /* control_render : fun [Ob [ObjSurface [I I]]] I */ /* control_write : fun [I I S] I */ /* control_start : fun [] I */ /* */ /* */ /***************************************************************/ /******************************************************************************/ /* */ /* D A T A S T R U C T S */ /* */ /******************************************************************************/ struct PBControl = [ /* 1 if controls screen ON, 0 if OFF */ enable_PBCTRL : I, /* bitmap containing controls screen */ bmp_PBCTRL : ObjBitmap, /* width */ w_PBCTRL : I, /* height */ h_PBCTRL : I, /* transparency color */ tc_PBCTRL : I, /* font */ font_PBCTRL : ObjFont, /* background color */ bkgColor_PBCTRL : I, /* foreground color */ frgColor_PBCTRL : I ] mkPBControl;; typeof pbControl = PBControl;; /******************************************************************************/ /* */ /* B O D Y */ /* */ /******************************************************************************/ /***************************************/ /* control_destroy [] I */ /* */ /* free bitmap */ /***************************************/ fun control_destroy () = _DSbitmap pbControl.bmp_PBCTRL; set pbControl = nil; 1 ;; /********************************************/ /* control_render [Ob [ObjSurface [I I]]] I */ /* */ /* postrender callback */ /* make the controls screen appear */ /********************************************/ fun control_render (o, param) = MOVE_MouseMove o param; let param -> [surf [surfW surfH]] in _Bitmap2Surface surf 0 0 pbControl.bmp_PBCTRL 0 0 pbControl.w_PBCTRL pbControl.h_PBCTRL pbControl.tc_PBCTRL; 1 ;; /***************************************/ /* control_write [I I S] I */ /* */ /* write a text sequence in the */ /* controls bitmap */ /***************************************/ fun control_write (x, y, text) = _DRAWtext pbControl.bmp_PBCTRL pbControl.font_PBCTRL x y TD_TOP|TD_LEFT pbControl.bkgColor_PBCTRL text; _DRAWtext pbControl.bmp_PBCTRL pbControl.font_PBCTRL (x+2) (y-2) TD_TOP|TD_LEFT pbControl.frgColor_PBCTRL text; 1 ;; fun PB_GetKeyLoc (code) = MOVEACTION_GetKeyId (MOVE_GetMoveActionFromCode code) MOVE_GetUserKeyboard ;; /***************************************/ /* control_start [] I */ /* */ /* create the controls screen bitmap */ /***************************************/ fun control_start () = let make_rgb 0 0 0 -> bkgColor in let make_rgb 255 255 0 -> frgColor in let 300 -> titleW in let 65 -> titleH in let make_rgb 0 0 255 -> tc in let 400 -> wholeW in let 400 -> wholeH in let _CRbitmap _channel wholeW wholeH -> wholeBmp in let _FILLbitmap wholeBmp tc -> tmp in let _CRbitmap _channel titleW titleH -> newBmp in let _CRbitmap8 _channel titleW titleH -> newBmp8 in let mktab 768 0 -> palette in let 0 -> i in let 0 -> c in let while (i < 768) do ( set palette.(i) = c; set palette.(i+1) = c; set palette.(i+2) = c; set i = i+3; set c = c+1; ) -> tmp in let _SETbitmapPalette newBmp8 palette -> tmp in let _FILLbitmap8 newBmp8 0 -> tmp in let 255 -> r1 in let 0 -> g1 in let 0 -> b1 in let 255 -> r2 in let 255 -> g2 in let 0 -> b2 in let r1 -> rc in let g1 -> gc in let b1 -> bc in let 0 -> i in let while (i < titleW) do ( set rc = r1 + ((i*(r2-r1))/titleW); set gc = g1 + ((i*(g2-g1))/titleW); set bc = b1 + ((i*(b2-b1))/titleW); _DRAWline newBmp i 0 i (titleH-1) DRAW_SOLID 1 (make_rgb rc gc bc); set i=i+1; ) -> tmp in let _CRfont _channel 50 0 FF_WEIGHT "Arial" -> font in ( _DRAWtext8 newBmp8 font 12 5 TD_TOP|TD_LEFT 0xFFFFFF "PaintBall 1.0"; _DRAWrectangle8 newBmp8 12 (titleH-5) (titleW-12) 3 DRAW_SOLID 1 0xFFFFFF DRAW_SOLID 0xFFFFFF; _DRAWtext wholeBmp font 10 5 TD_TOP|TD_LEFT 0 "PaintBall 1.0"; _DRAWrectangle wholeBmp 10 (titleH-3) (titleW-10) 3 DRAW_SOLID 1 0 DRAW_SOLID 0; _DSfont font; let _CRfont _channel 16 0 FF_WEIGHT "Arial" -> font in let _CRalphaBitmap _channel newBmp newBmp8 nil nil -> newAlpha in ( set pbControl = mkPBControl [0 wholeBmp wholeW wholeH tc font bkgColor frgColor]; _CPalphaBitmap pbControl.bmp_PBCTRL 0 0 newAlpha 0 0 titleW titleH; /* control_write 10 75 _loc this "PAINTBALL_MOVE" nil; control_write 200 75 _loc this "PAINTBALL_MOVE1" nil; control_write 10 100 _loc this "PAINTBALL_MOVECAM" nil; control_write 200 100 _loc this "PAINTBALL_MOVECAM1" nil; control_write 10 125 _loc this "PAINTBALL_SHOOT" nil; control_write 200 125 _loc this "PAINTBALL_SHOOT1" nil; control_write 10 150 _loc this "PAINTBALL_RELOAD" nil; control_write 200 150 _loc this "PAINTBALL_RELOAD1" nil; control_write 10 175 _loc this "PAINTBALL_TARGET" nil; control_write 200 175 _loc this "PAINTBALL_TARGET1" nil; */ control_write 10 100 _loc this "PAINTBALL_CHAT" nil; control_write 200 100 PB_GetKeyLoc "CHAT"; control_write 10 125 _loc this "PAINTBALL_SCORE" nil; control_write 200 125 PB_GetKeyLoc "SCORE"; control_write 10 150 _loc this "PAINTBALL_SCREEN" nil; control_write 200 150 PB_GetKeyLoc "SCREEN"; control_write 10 175 _loc this "PAINTBALL_START" nil; control_write 200 175 PB_GetKeyLoc "START"; control_write 10 200 _loc this "PAINTBALL_CONFIG" nil; control_write 200 200 "V"; /*control_write 10 300 ". quit the game :"; control_write 200 300 "q";*/ /* MODIF */ _DSbitmap8 newBmp8; _DSbitmap newBmp; _DSalphaBitmap newAlpha; _DSfont pbControl.font_PBCTRL; 1; ); ) ;;