HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: 1 [2]

Author Topic: Need help understanding GUI  (Read 3068 times)

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Need help understanding GUI
« Reply #15 on: Apr 26, 15, 03:01:34 PM »

I've tried but I still can't figure out how to link items with icons in a GUI. I was looking at the Item and Icon systems as well, and again the Wiki doesn't help us non-programmers figure out how to use the system.

So far, I still don't know how to make objects in a list show up as icons in a window. This is one of the most basic things, yet I haven't found a tutorial on how it works. I have seen code, including in HJRef and the Social game, but what I am looking for is someone to explain to me what each line actually does.

How would you make a list, and corresponding GUI, dynamic so you can change the number of objects? I have seen an example in HJRef where every 7 levels (or something like that) you get more inventory slots. While I might be able to copy the code and make it work, I am really trying to understand it.

Any help is appreciated!  :-[
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1404
    • View Profile
    • Forever Interactive, Inc.
Re: Need help understanding GUI
« Reply #16 on: Apr 26, 15, 06:07:13 PM »

Quote
How would you make a list, and corresponding GUI, dynamic so you can change the number of objects?
As Thazager wrote, each player would have an inventory as a list of items they currently possess.  That list can be added to and removed from at will to change the list.

Quote
I've tried but I still can't figure out how to link items with icons in a GUI.
The Item System would be used by your designers to define each item type that exists, with each one having a unique spec key (ID).  For each item type you would define the path in the repository to the image that is to be used as the item type's icon.

Each item (as stored in players' inventories) represents one single instance of its item type, and each item contains a spec key which refers to an item type to indicate which type it is.  That key can be used to look up the corresponding item type spec and from that you would read the icon image path for use in the gui.



So, assuming the item types have been created at design-time, and at run-time items get created and added to players' inventories as they acquire them, here is the gist of the process to display a player's inventory, in pseudo-code:

inventoryGUI = <create or get reference to already-created gui>
clear inventoryGUI icon space
for each item in player.inventory
  itemSpec = GetItemSpec(item.SpecKey)
  icon = <create new icon control>
  icon.texture = itemSpec.iconImagePath
  add icon to inventoryGUI icon space
end loop
display inventoryGUI


This is just off the top of my head.  There are numerous ways it could be done; that would be up to your programmer.  But I hope this gives you a feel for how the process of populating a gui with icons corresponding to a player's inventory could work.
« Last Edit: Apr 26, 15, 06:10:05 PM by FI-ScottZ »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1404
    • View Profile
    • Forever Interactive, Inc.
Re: Need help understanding GUI
« Reply #17 on: Apr 26, 15, 06:21:07 PM »

Things that could also be stored on each item spec would be anything that will be the same for all instances of a given type, such as title, description, fixed statistics, etc.  Those would also be read from each item's spec and used in the item display.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Need help understanding GUI
« Reply #18 on: Apr 26, 15, 07:02:05 PM »

Have you been able to make an inventory, that can add or remove items, and print the contents of it into the console?
If not, I'd suggest getting that working first.

An inventory that has icons is nice, but it's best to lay the foundation for a GUI that shows icons.
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Need help understanding GUI
« Reply #19 on: Apr 26, 15, 07:22:34 PM »

Thanks Scott, I actually get that! I understand the Item spec, and have even modified mine a bit with other fields. It's mostly the GUI I have been having trouble with.

I'm going to work with this and the information Thazager has provided (for Icon space) and see if I can get it to work now.

Thanks a bunch!

Jrome, that is a good point, I do also have to implement a method to add/remove items from the inventory, but I believe that part is fairly easy. I'll let you know if that proves problematic as well, LOL.
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Need help understanding GUI
« Reply #20 on: Apr 26, 15, 07:58:05 PM »

Jrome, that is a good point, I do also have to implement a method to add/remove items from the inventory, but I believe that part is fairly easy. I'll let you know if that proves problematic as well, LOL.

It might be fairly easy, but it's difficult to test the GUI related aspects without basic functionality. Unless you plan to emulate the inventory functionality.
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Need help understanding GUI
« Reply #21 on: Apr 26, 15, 08:37:16 PM »

What's the proper method to query the player.inventory list to see what is in it?
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Need help understanding GUI
« Reply #22 on: Apr 26, 15, 09:23:25 PM »

What's the proper method to query the player.inventory list to see what is in it?

Assuming you are using the Item system :

Code: [Select]

Get the PlayerCharacter (has an _ItemcontainerOwner class as a parent)

owner. _GetItemContainerByName("Inventory")

Once you have a noderef of class _ItemContainer you can get the list of items by looping through the field named
"_containedItems (I think it's called that)

« Last Edit: Apr 26, 15, 09:26:52 PM by Jrome90 »
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Need help understanding GUI
« Reply #23 on: Apr 26, 15, 09:41:28 PM »

Thanks
Logged
Pages: 1 [2]