3D HUD

Everytime you click the mouse the main mouse listener in the RenderLoop calls the pick mehtod on the HUD. This method dispatches this event to all Widgets. just overrider the pick method of RectangularWidget with a super call. There you can get the information you need.
[/quote]
OK.

OK.

Hmm please wait 30 minutes I added that to my TODO list ;D I’m studying the JWS mechanism used by William Denniss on the site.

Hmm Qudus the button widget does not work really good, cause the image change is called directly from the AWT Event thread (may cause threadind problems : Xith doesn’t support multi-threading). I think I can use ScheduledOperations to change image, but how to implement that, HUD is not based on an ExtRenderLoop ?

I’ll investigate please don’t do that for me (hey it’s not fun if you just code everything ;D 8) )

Woohooo ! Now buttons work perfectly with scheduled operations ! Qudus, check out your tk.

Now I’ll just hack some listener thing so you can actually catch and handle button events.

[quote="<MagicSpark.org [ BlueSky ]>,post:22,topic:27660"]
Hmm Qudus the button widget does not work really good, cause the image change is called directly from the AWT Event thread (may cause threadind problems : Xith doesn’t support multi-threading). I think I can use ScheduledOperations to change image, but how to implement that, HUD is not based on an ExtRenderLoop ?
[/quote]
hey, good point. And well done. I only changed it a bit, so that not an ExtRenderLoop is expected but an OperationScheduler which is an interface implemented by ExtRenderLoop. I think, this is a little cleaner and I wrote this interface for such a purpose.

[quote="<MagicSpark.org [ BlueSky ]>,post:22,topic:27660"]
I’ll investigate please don’t do that for me (hey it’s not fun if you just code everything ;D 8) )
[/quote]
Sorry. I shouldn’t do that.

[quote="<MagicSpark.org [ BlueSky ]>,post:22,topic:27660"]
Woohooo ! Now buttons work perfectly with scheduled operations ! Qudus, check out your tk.
[/quote]
Really cool. I added some contructors to the ImageButton class and completed the javadoc for them.

[quote="<MagicSpark.org [ BlueSky ]>,post:22,topic:27660"]
Now I’ll just hack some listener thing so you can actually catch and handle button events.
[/quote]
Can’t wait to see them. Should be senseful to lean on Swing in that point, too, right?

hey, good point. And well done. I only changed it a bit, so that not an ExtRenderLoop is expected but an OperationScheduler which is an interface implemented by ExtRenderLoop. I think, this is a little cleaner and I wrote this interface for such a purpose.
[/quote]
Hmmyeah you’re absolutely right.

Sorry. I shouldn’t do that.
[/quote]
Oh at least it’s done ^^ That’s all whats important.

Really cool. I added some contructors to the ImageButton class and completed the javadoc for them.
[/quote]
Thanks.

Can’t wait to see them. Should be senseful to lean on Swing in that point, too, right?
[/quote]
Yes indeed.

Text buttons now work. But there’s a slight problems with mouse events : they are dispatched twice. (See the “Basic button” to which one “.” only should be added per event : as you click there are two dots added).

And also the picking doesn’t work properly anymore when you resize the window.

Ans last see the commented line : when I add a background between a TextButton it hides the button background and shows the text (uncomment the line to see the effect).

The ActionListener is now working perfectly (apart from double events).

So the Exit button now really exits.

Here’s a screenshot of what has been done.

I think I got the idea about this problem with ImageButtons and the Background. ;D

The Image is never added to an instance of WidgetContainer. Maybe the problem disappeares when you implement an inner class to the ImageButton class which implements WidgetContainer. Link the getContainer mehtod of this class with the Container of the ImageButton. Then add the Image to this container. Only when you add a Widget to a Container, the coordinates are correctly calculated. I don’t know if this solves the problem and i’m not at home so I cannot code it. But I tjhink it’s worth a try.

And don’t directly add the Image to the ImageButton’s container, cause this would disturb the children count of the HUD.

Qudus

[quote="<MagicSpark.org [ BlueSky ]>,post:26,topic:27660"]
Text buttons now work. But there’s a slight problems with mouse events : they are dispatched twice. (See the “Basic button” to which one “.” only should be added per event : as you click there are two dots added).

And also the picking doesn’t work properly anymore when you resize the window.

Ans last see the commented line : when I add a background between a TextButton it hides the button background and shows the text (uncomment the line to see the effect).

The ActionListener is now working perfectly (apart from double events).

So the Exit button now really exits.
[/quote]
Did you recently check out your CVS today? I worked on this problem just three hours ago.

[quote="<MagicSpark.org [ BlueSky ]>,post:26,topic:27660"]
Here’s a screenshot of what has been done.
[/quote]
Where???

Sorry I missed the screenshot : I wanted to send this message yesterday but the forums were down when I wanted so I saved my message to a text file and forgot to attach the image today ^^

Here it is.

Works!!!

I got the problem concerning the ImageButtons. Finally the solution was easier than I expected.

Amos, please don’t put this constructor with the hardcoded image names to the TextButton. I don’t think, we should put hardcoded filenames to any class in the tk.

What do you say about merging ImageButton and TextButton to one class? We would put all constructors of both classes together and had one class being able to render a button with or without text and with or without images.

What was it ?

This was temporary, of course. We should provide some basic geometry (rectangle) as default.

That may be great iff it doesn’t impact on performance when you just want an ImageButton.

[quote="<MagicSpark.org [ BlueSky ]>,post:31,topic:27660"]

What was it ?
[/quote]
Ah, sorry. I thought, you could see it in the source code. A connection between the Image and a container (the HUD) had to be esteblished. See the init method of the ImageButton.

[quote="<MagicSpark.org [ BlueSky ]>,post:31,topic:27660"]

This was temporary, of course. We should provide some basic geometry (rectangle) as default.
[/quote]
Yes. We should save three images in a subpackage of the hud package. then we should be able to load them from the TextureLoader without knowing the exact full path.

[quote="<MagicSpark.org [ BlueSky ]>,post:31,topic:27660"]

That may be great iff it doesn’t impact on performance when you just want an ImageButton.
[/quote]
It doesn’t if no text is wanted, the Text2D thing won’t be generated and vise versa.

Ok, I’ve merged TextButton and ImageButton to Button. Watch CVS.

Didn’t took time to see but if you say so must be ok.

the HUD discussion has been preceeded in these threads, too:

http://www.java-gaming.org/forums/index.php?topic=14292.0
http://www.java-gaming.org/forums/index.php?topic=14383.0
http://www.java-gaming.org/forums/index.php?topic=14353.0

Since the HUD code base as grown a bit, I decided to split it into subpackages. For backwards compatiblity I’ve added wrappers at the old place of each Widget, which are the only things used from outside the hud package (besides the HUD itself, which has stayed at it’s old place).

Please tell me, if I broke something by accident.

Marvin

Yes you broke the WidgetActionListener.

[quote="<MagicSpark.org [ BlueSky ]>,post:37,topic:27660"]
Yes you broke the WidgetActionListener.
[/quote]
Oh, sorry. I’ll add a Compatiplity-layer for it.

EDIT: Done.