Let's start simple and assume that we keep the overall look and feel of the basic GUI widgets like sliders, check boxes, window frames etc. (changing that is quite a bit advanced).
For the inventory, there are several components that need to be set up:
- inventory.ini
- inventory text file(s) (as defined in language.ini file; holds any text to be displayed in the inventory)
- inventory Simkin script
- CEGUI files (mainly imageset and layout files, but could also include a completely different scheme)
inventory.ini file
In the inventory.ini file you specify some general properties of the inventory, first of all the Simkin script driving the inventory.
Secondly, it defines the game state the inventory lives in. If you want to interact with the inventory while also controlling the player this needs to be set to 'play' (the player must not be controlled via mouse input in that case), otherwise set it to 'dialog' and the player will not receive any input commands.
Let's assume, our inventory lives in the dialog state and ignore the slot managment option as well as any other GUI schemes for now.
More important are the CEGUI layout files. These describe the layout of any window used in the inventory. There must be at least one layout file (one window) that will be shown when the inventory is invoked. However, you can use as many layout files as you want to describe any aspect of your inventory.
Last but not least, the inventory.ini file holds the description of any item that can be shown in the inventory. Each item starts with a section name that can be used in the inventory script. 4 windows are used to describe an inventory item:
- the window representing the item (note that each window can have child windows)
- a text window that will show the item's text as defined in the corresponding section of the inventory text file
- a value window that will show the actual amount of the item available
- the parent window
The inventory basically supports 2 ways of displaying the items. One is a simple list of items (including icons) and the other are draggable windows like in the demo. The former requires the inventory items to use a window of type 'ItemEntry', the latter a window of type 'DragContainer'.
inventory text file
This file (or files if multiple languages are used) holds any text used in the inventory. The section name of the item description in the inventory.ini file must match the section name of the item text to be displayed in the item's text window.
inventory Simkin script
This script defines the behaviour of your inventory. There are several global objects that you can use in this script, like the
GUI class, the
DialogState class and, of course, the
Inventory and
InventoryItem classes.
If you have created an additional imageset for example, you can load it in the
main function of this script to make it useable (alternatively you can define them in any used CEGUI .scheme file).
In the
main function you may also define allowed item combinations.
As described in the manual, there are certain GUI events that the script must react to, i.e. the 'Shown' event of the main inventory window.
You can bind many GUI events like 'mouse double click' or 'drag item dropped' to methods defined in this script. See the documentation on
Handling GUI Events from Simkin and
GUI Event Reference under Scripting->Related Pages.
It's up to you how to react to those events.
CEGUI files
imageset files can be created/edited via a text editor or the CEImagesetEditor and allow to define multiple sub-images on a single image file. This way you can keep all related (often small) images organized in one file and improve rendering performance. Each sub-image has a unique name that can be referred to by any GUI element (widget) definition or window displaying an image (e.g. RFLook/StaticImage if you use the RFLook scheme).
layout files can be created/edited via a text editor or the CELayoutEditor and define the hierachy of windows and thus the appearance of the inventory. Here you need to define the windows representing the inventory items as well as their parent windows and any other widgets you want to have in your inventory. Furthermore, as mentioned above, layout files allow for event binding.