Problem:

Every time I make a 2d game, I have to code up a custom inventory management UI in SDL or make up one with hard-coded data/positions etc..

Solution:

A single header library that I can pull into my CMake project that uses SDL2 that I can invoke as such:

CreateInventory(Path to SupportedItemData.json)

Supported Item Data is a json of the format: ItemName, MaxItemCount, ItemImagePng Callback to ClickHandlers

In the Game Loop, I drop in an inventory object Then I call inventoryItems.render() in the draw() call of the gameLoop. The interaction with the inventory class will be limited.

Implementation details:

SDL based Immediate mode UI Inventory: Font CreateInventory(ItemList<Item>) Render: Rectangle chrome Sub rectangles Textures within rectangles AddItem: RemoveItem: Collapse ClickCallbacks() -> User defined

Item: MaxCapacity, Image Texture