/***************************************************************/ /* */ /* PBSIGHTS.PKG */ /* */ /* plug-in PhotoPaintBall */ /* client - guns sights management */ /* */ /* version 5 : Loïc Berthelot, dec 2000 */ /* */ /* nouvelle version 4.5 : Loïc Berthelot nov 2000 */ /* */ /* Photo3 Plugin - DMS - march 00 - by Sylvain HUET */ /* */ /***************************************************************/ /***************************************************************/ /* */ /* */ /* DATA STRUCTS : */ /* struct SightEl */ /* typeof sightsLib : tab SightEl */ /* var sightsLibSize : I */ /* */ /* */ /* INTERNAL BODY : */ /* sights_start2 : fun [] I */ /* */ /* */ /* EXTERNAL BODY : */ /* sights_free : fun [I] I */ /* sights_destroy : fun [] I */ /* sights_start : fun [] I */ /* */ /* */ /***************************************************************/ /******************************************************************************/ /* */ /* D A T A S T R U C T S */ /* */ /******************************************************************************/ /* Bitmap resource for a gun sight */ /* */ /* we store a lot of informations */ /* in order to make dynamic */ /* process faster */ struct SightEl = [ /* alphabitmap filename */ filename_SEL : S, /* bitmap of sight */ b_SEL : ObjBitmap, /* size */ width_SEL : I, height_SEL : I, /* size / 2 */ halfWidth_SEL : I, halfHeight_SEL : I, /* transparency color */ transparencyColor_SEL : I ] mkSightEl;; typeof sightsLib = tab SightEl;; var sightsLibSize = 10;; /******************************************************************************/ /* */ /* I N T E R N A L B O D Y */ /* */ /******************************************************************************/ /******************************************/ /* sights_start2 [] I */ /* */ /* create sight bitmap */ /******************************************/ fun sights_start2() = let 0 -> i in while (i < sightsLibSize) do ( let strcatn pbItemsPath::(itoa i)::"/"::pbDefault.sightBmpFln_PBD::nil -> filename in let _checkpack filename -> file in if (file == nil) then defines_fofError "photoSights.pkg sights_start2() " filename else ( let _LDalphaBitmap _channel file -> aBmp in let _GETalphaBitmaps aBmp -> [bmp _] in let _GETbitmapSize bmp -> [w h] in let _GETpixel16 bmp 0 0 -> transparencyColor in ( set sightsLib.(i) = mkSightEl [filename nil w h (w/2) (h/2) transparencyColor]; let _CRbitmap _channel w h -> newBmp in set sightsLib.(i).b_SEL = _CPbitmap16 newBmp 0 0 bmp 0 0 w h nil; _DSalphaBitmap aBmp; _DSbitmap bmp; ); ); set i = i+1; ); pbFlags_set "sights"; 1 ;; /******************************************************************************/ /* */ /* E X T E R N A L B O D Y */ /* */ /******************************************************************************/ /******************************************/ /* sights_free [I] I */ /* */ /* free graphic ressources from the */ /* sight, identified by index */ /******************************************/ fun sights_free (index) = _DSbitmap sightsLib.(index).b_SEL; 1 ;; /******************************************/ /* sights_destroy [] I */ /* */ /* destroy the sights lib */ /******************************************/ fun sights_destroy() = let 0 -> i in while (i < sightsLibSize) do ( sights_free i; set i = i+1; ); 1 ;; /******************************************/ /* sights_start [] I */ /* */ /* construct the sights lib */ /******************************************/ fun sights_start () = set sightsLib = mktab sightsLibSize nil; sights_start2; 1 ;;