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 12:59] – [Inventory-Designer] admin | 0.8.3:inventory [2021/09/03 13:11] (current) – [Visual Items] admin | ||
---|---|---|---|
Line 370: | Line 370: | ||
To allow better abstraction and separation between the logical and the visual part of an inventory, we introduced visual items in v0.8.3.1812+. | To allow better abstraction and separation between the logical and the visual part of an inventory, we introduced visual items in v0.8.3.1812+. | ||
You can now define 3 levels of detail plus a model filename for each visual item. (This may be extended in future releases.) | You can now define 3 levels of detail plus a model filename for each visual item. (This may be extended in future releases.) | ||
- | |||
- | This is also the first step to work together with a specific assets package. At the moment use the " | ||
A visual item standalone entity inside of the inventory component and can be freely linked by image-index of each item template. | A visual item standalone entity inside of the inventory component and can be freely linked by image-index of each item template. | ||
Line 386: | Line 384: | ||
</ | </ | ||
+ | To remove a visual item, use: | ||
+ | <file pascal> | ||
+ | /// add a visual representation for an axe | ||
+ | GorillaInventory1.RemoveVisualItem(' | ||
+ | </ | ||
+ | This is also the first step to work together with asset packages. At the moment you can use the " | ||
+ | <file pascal> | ||
+ | [...] | ||
+ | |||
+ | /// define callback event for assets loading | ||
+ | GorillaInventory.OnLoadResource := DoOnInventoryLoadResource; | ||
+ | |||
+ | [...] | ||
+ | |||
+ | procedure TForm1.DoOnInventoryLoadResource(const AInventory : TGorillaInventory; | ||
+ | const AResIdx : Integer; const AResource : String; | ||
+ | const AItem : TGorillaInventoryVisualItem; | ||
+ | var LPckg : TGorillaAssetsPackage; | ||
+ | LAsset : TGorillaAsset; | ||
+ | LBmp : FMX.Graphics.TBitmap; | ||
+ | begin | ||
+ | /// get your package previously created | ||
+ | LPckg := GorillaAssetsManager1.GetPackage(' | ||
+ | if not Assigned(LPckg) then | ||
+ | raise Exception.Create(' | ||
+ | | ||
+ | /// try to find an asset by resource filename + extension | ||
+ | LAsset := LPckg.FindAsset(AResource); | ||
+ | if not Assigned(LAsset) then | ||
+ | raise Exception.CreateFmt(' | ||
+ | | ||
+ | /// check if it really is a texture / image asset | ||
+ | if not (LAsset is TGorillaTextureAsset) then | ||
+ | raise Exception.CreateFmt(' | ||
+ | | ||
+ | /// copy the image to inventory image (duplication!) | ||
+ | LBmp := TGorillaTextureAsset(LAsset).GetBitmap(); | ||
+ | try | ||
+ | ADestBitmap.Assign(LBmp); | ||
+ | finally | ||
+ | FreeAndNil(LBmp); | ||
+ | end; | ||
+ | end; | ||
+ | </ | ||
==== Inventory-Designer ==== | ==== Inventory-Designer ==== | ||