Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
0.8.3:inventory [2021/09/03 13:07] – [Visual Items] admin | 0.8.3:inventory [2021/09/03 13:11] (current) – [Visual Items] admin | ||
---|---|---|---|
Line 393: | Line 393: | ||
<file pascal> | <file pascal> | ||
+ | [...] | ||
+ | |||
+ | /// define callback event for assets loading | ||
+ | GorillaInventory.OnLoadResource := DoOnInventoryLoadResource; | ||
+ | |||
+ | [...] | ||
+ | |||
procedure TForm1.DoOnInventoryLoadResource(const AInventory : TGorillaInventory; | procedure TForm1.DoOnInventoryLoadResource(const AInventory : TGorillaInventory; | ||
const AResIdx : Integer; const AResource : String; | const AResIdx : Integer; const AResource : String; | ||
Line 400: | Line 407: | ||
LBmp : FMX.Graphics.TBitmap; | LBmp : FMX.Graphics.TBitmap; | ||
begin | begin | ||
+ | /// get your package previously created | ||
LPckg := GorillaAssetsManager1.GetPackage(' | LPckg := GorillaAssetsManager1.GetPackage(' | ||
if not Assigned(LPckg) then | if not Assigned(LPckg) then | ||
raise Exception.Create(' | raise Exception.Create(' | ||
| | ||
+ | /// try to find an asset by resource filename + extension | ||
LAsset := LPckg.FindAsset(AResource); | LAsset := LPckg.FindAsset(AResource); | ||
if not Assigned(LAsset) then | if not Assigned(LAsset) then | ||
raise Exception.CreateFmt(' | raise Exception.CreateFmt(' | ||
| | ||
+ | /// check if it really is a texture / image asset | ||
if not (LAsset is TGorillaTextureAsset) then | if not (LAsset is TGorillaTextureAsset) then | ||
raise Exception.CreateFmt(' | raise Exception.CreateFmt(' | ||
| | ||
+ | /// copy the image to inventory image (duplication!) | ||
LBmp := TGorillaTextureAsset(LAsset).GetBitmap(); | LBmp := TGorillaTextureAsset(LAsset).GetBitmap(); | ||
try | try |