HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Struggling a bit with GUI icons  (Read 2048 times)

plusfourgames

  • General Accounts
  • *
  • Posts: 12
    • View Profile
[Resolved] Struggling a bit with GUI icons
« on: May 23, 12, 09:25:36 PM »

As I try to create my first GUI that uses icons, I find myself struggling with some pretty basic operations.

For now, all that I want to do is to display an image in a GUIIcon control.

I've looked out on the asset library, and I've found a bunch of .dds and .png files. These have GUID values associated with them.

After searching around, I found the _GUIIconClassMethods script and dug through that. I found a few methods with descriptions that sounded like they do the right things. In a nutshell, I've done the following and am not sure what it is that I'm doing wrong:

1. Made a GUI window. Put a GUIIcon on it.
2. Made a script to show the window. This works fine.
3. In my script that shows the window, I get a reference to my _GUIIcon by calls to FindGUIControlByName.
4. Once I have a reference to the icon, I call _SetIconID and pass in the GUID of an arbitrary .dds or .png file I found in the repository browser.
5. I then call _SetupIcon. I 'm not really sure if I'm supposed to call this. I'm basically just stabbing in the dark.
6. I set .build = true on my icon control.

Instead of rendering the image I'd hoped to see on screen, the icon remains a white box.

I've tried to piece together how inventory icons are working from the HJRef world, but I'm a little bit overwhelmed / easily distracted by some of the code I'm seeing in there at this point.

Can anyone explain to me the steps involved in setting the image on an icon such that it'll render in a window? A bit of detail on some of the fields of GUIIcon would also be helpful. Any direction someone could provide would be greatly appreciated.
« Last Edit: Nov 03, 12, 08:39:32 PM by HE-Cooper »
Logged

Alderdale

  • World Owners
  • ****
  • Posts: 12
    • View Profile
Re: Struggling a bit with GUI icons
« Reply #1 on: May 24, 12, 12:09:07 AM »

I'm sure you have seen this post but it seems there might be something in here that could help, it appears to have icons displaying in an inventory GUI being used to represent in game items.

https://community.heroengine.com/forums/index.php/topic,2420.0.html
Logged

plusfourgames

  • General Accounts
  • *
  • Posts: 12
    • View Profile
Re: Struggling a bit with GUI icons
« Reply #2 on: May 24, 12, 06:45:07 AM »

I'm sure you have seen this post but it seems there might be something in here that could help, it appears to have icons displaying in an inventory GUI being used to represent in game items.

https://community.heroengine.com/forums/index.php/topic,2420.0.html

Thanks for the link. There's a lot of good stuff in that post. I've looked over a few sources about Icons, but, so far, the information I've found has been a little bit different than what I'm looking for.

I've also read over this icons page on the wiki:
http://hewiki.heroengine.com/wiki/Icon_system

It talks about how to use icons for drag and drop, but not so much about the basics of just getting an image to render on one of them. I'd think it would be only a few lines of code to do what I'm trying to do, but I might be mistaken.
Logged

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: Struggling a bit with GUI icons
« Reply #3 on: May 24, 12, 06:50:26 AM »

Simplest path to an image in the GUI is open the GUI editor, drag in a _panel, set its resource to a dds or png or jpg.

Have you started with the GUI tutorials? There's also a few good ones here on the forums, but until you are super leet, and even then, there aren't many reasons not to, building ui using the editor is the way to go.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Struggling a bit with GUI icons
« Reply #4 on: May 24, 12, 07:51:20 PM »

Are you getting errors? (client-side errors show up in the Console panel, as well as the Script Error panel).  If you truly did it in the order you listed, it would not work.  If a control's prototype lists it as having children, those children do not get created until it is built, i.e. when build gets set to true.  Before that, it has no children to access.  You can set properties for the root control itself before building, but not for children until after building.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

plusfourgames

  • General Accounts
  • *
  • Posts: 12
    • View Profile
Re: Struggling a bit with GUI icons
« Reply #5 on: May 24, 12, 09:36:32 PM »

Simplest path to an image in the GUI is open the GUI editor, drag in a _panel, set its resource to a dds or png or jpg.

I did this, and it worked well. This is a good way to get some image to render in a GUI. I'm ultimately trying to do more than this, but I'm trying to take small steps to learn some of the mechanics involved before designing or implementing a complicated system.

Quote
Have you started with the GUI tutorials? There's also a few good ones here on the forums, but until you are super leet, and even then, there aren't many reasons not to, building ui using the editor is the way to go.

I have gone through the GUI tutorial that I found, and it was helpful. For reference, this was the one I went through:
http://wiki.heroengine.com/wiki/GUI_Tutorial

It's a very good tutorial for the basics of making a custom GUI control and showing a window. What I'm looking for now, though, is more information on the particulars of clean engine's out-of-the-box controls. Are there more GUI tutorials somewhere that demonstrate how to use some of the other controls that come with clean engine?

For example, the Sun tutorials for using individual Swing controls are fantastic. When I want to solve a GUI problem in HSL, I find myself not knowing quite where to start. In this case, I just started doing text searches through client classes that are GUI controls. I stumbled upon _GUIIcon and blindly guessed at which methods to call on the control based on the methods' names and the comments in that control's script. I did this until I realized that I was having trouble to get it to do even basic things. At that point, I made this post on the forums, and was pointed to the _panel control. I've been experimenting with panels and see that at least one of the "looks-like-a-bunch-of-icons" systems (E_AbilityBar) was implemented as a bunch of panels.

I'm at the point now where I can do basic things with GUIs. I can use the editor to make windows. I can extend simple controls like buttons to make them process events in a way that I want. I've been developing in MVC GUI frameworks for a fairly long time, and I like to think that I understand at least the fundamentals of how to apply OOP paradigms to GUI development. Where I'm falling short now is in having a straightforward way to figure out how I can use more of the specific controls made available in clean engine HSL. When I see individual GUI control classes in clean engine, I'm not sure what they are or the mechanics of how to use them (ie what specific calls I need to make on them in order to do specific things). I'm just groping around in code, using trial and error, and asking questions on the boards when I get stuck.

Am I going about this wrong? Is there a better way I could be learning the mechanics of HSL's GUI system?

Having looked at its code and experimented with its methods, I'm still not really sure what the GUIIcon control is or how it could be used.

Quote
Are you getting errors? (client-side errors show up in the Console panel, as well as the Script Error panel).  If you truly did it in the order you listed, it would not work.  If a control's prototype lists it as having children, those children do not get created until it is built, i.e. when build gets set to true.

If I understand what you're saying, Scott, it's that I have to instantiate and build my window before getting references to its child controls. I think I've been doing that since the beginning. I should have made that more clear in my original list of steps. As long as I call window.build beforehand, I seem to be able to get references to any child controls that I want.

As always, thanks for the responses and help you guys have given me so far. I wouldn't have made it this far along without the helpful responses on these forums.
Logged