Inventory menus pictures -how

Topics regarding Scripting with Reality Factory
Post Reply
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Inventory menus pictures -how

Post by Veleran » Fri Aug 12, 2016 9:09 am

Is the previous inventory system that worked like the Hud abandoned and you have to use only that new tool Gui editor?
I am having trouble understanding what to do because i need more help docs,just a few words about the general procedure.

What do you do?first,stitch all your inventory items pics into one big through an image edit program and then run the gui image editor tool and then what...

I would post in the general section but instead chose this.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Inventory menus pictures -how

Post by Allanon » Mon Aug 15, 2016 12:34 am

I haven't tried to add inventory items but I did look to see how to do it. Look in the \gui\imagesets folder and open the itemicon.imageset file with a text editor to see how the pictures are assigned. You can also open the itemicon.tga file with an image editor to see how the images are placed. And in the scripts folder there is the inventory.s file which is the script that controls the inventory.

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Inventory menus pictures -how

Post by QuestOfDreams » Tue Aug 16, 2016 9:38 pm

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.

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Inventory menus pictures -how

Post by Veleran » Wed Sep 07, 2016 1:48 am

Did you say there is an example inventory script to see how that double click to use attribute thing is done?

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Inventory menus pictures -how

Post by Allanon » Wed Sep 07, 2016 8:17 am

Veleran wrote:Did you say there is an example inventory script to see how that double click to use attribute thing is done?
In the inventory_main.layout file that I provided you will find the following code which is slot 5 and it's for the Potion of Healing:

Code: Select all

<Window Type="RFLook/Static" Name="Inventory/MainWindow/Slot5" >
				<Property Name="UnifiedPosition" Value="{{0.28,0},{0.36,0}}" />
				<Property Name="UnifiedSize" Value="{{0.2,0},{0.2,0}}" />
				<Event Name="DragDropItemDropped" Function="Inventory_OnItemDropped" />
			
				<Window Type="DragContainer" Name="DragContainer5" >
					<Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.05,0},{0.95,0},{0.95,0}" />
 
               <Event Name="MouseDoubleClick" Function="Inventory_OnUseHealing" />


					<Window Type="RFLook/StaticImage" Name="DragContainer5/Image" >
						<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}" />
						<Property Name="Image" Value="set:ItemIcons image:PotionOfHealing" />
						<Property Name="MousePassThroughEnabled" Value="True" />
						<Window Type="RFLook/StaticText" Name="DragContainer5/Value" >
							<Property Name="Text">-1</Property>
							<Property Name="FrameEnabled" Value="False" />
							<Property Name="HorzFormatting" Value="RightAligned" />
							<Property Name="VertFormatting" Value="VertCentred" />
							<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
							<Property Name="UnifiedAreaRect" Value="{{0.75,0},{0.75,0},{0.97,0},{0.97,0}}" />
							<Property Name="BackgroundEnabled" Value="False" />
						</Window>
					</Window>
				</Window>

			</Window>

Notice this line of code:

Code: Select all

<Event Name="MouseDoubleClick" Function="Inventory_OnUseHealing" />
That makes it so when the Potion of Healing is double clicked it executes the Inventory_OnUseHealing function in the inventory.s script.

The Inventory_OnUseHealing function looks like this:

Code: Select all

Inventory_OnUseHealing[(eargs)
	{
		m_args = GUI.toMouseEventArgs(eargs);

		item = Inventory.GetItem(m_args.window);

		if(item != null)
		{
			item.Modify("health", 10);
		}
	}]

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Inventory menus pictures -how

Post by Veleran » Thu Sep 08, 2016 10:54 am

I can only drag the inventory items into another slot but when i double click to use them nothing happens.
I did not add any script myself and did not touch those you made.

I also noticed that in screen 1920 x 1080 the items pics look shorter that they are,the images dimensions are not the same with the inventory bitmap.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Inventory menus pictures -how

Post by Allanon » Thu Sep 08, 2016 6:55 pm

Veleran wrote:I can only drag the inventory items into another slot but when i double click to use them nothing happens.
I did not add any script myself and did not touch those you made.

I also noticed that in screen 1920 x 1080 the items pics look shorter that they are,the images dimensions are not the same with the inventory bitmap.
I just tested the double click and it worked fine for me. Only the heal and mana potions have double click events. Also make sure your health or mana are low when double clicking them because they won't add more above the max. Each vial adds 10 units. If they don't work then make sure you copied all the attributes and scripts correctly.

You can adjust the size in the layout and/or imageset files. I haven't tried using different resolutions.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Inventory menus pictures -how

Post by Allanon » Thu Sep 08, 2016 9:15 pm

I did find an error in the inventory.txt file. There are 2 [potionofmana_tt] entries, the second one should be [potionofhealth_tt]. This just caused the mana potion tooltip to display Potion of Health and the heath potion to have no tooltip.

Post Reply