A control to display an image? Like, a screenshot?

I’ve browsed the wiki and it’s not complete yet. Since the wiki search isn’t helping, at all, I’m asking here…

So, I’ve implemented a multiple save in Disenthral and I take a screenshot when saving. I want to display that when giving the user a choice to load a game.

I’ve looked but couldn’t find a way to cleanly do it. Anyone has a suggestion?

It’s been so long since I’ve touched that GUI that I’m kinda lost now. >.<

Anyway, thanks for reading. :slight_smile:

You can take a look at how ScreenshotAppState does this. Instead of saving to a PNG file, you can load the image directly as a Texture2D with AWTLoader class.

1 Like
@Momoko_Fan said: You can take a look at how ScreenshotAppState does this. Instead of saving to a PNG file, you can load the image directly as a Texture2D with AWTLoader class.

I’m not sure he’s having trouble getting the screenshots. I read the post as him having trouble getting the image into a tonegodgui control or something. ie: not a JME problem.

As @pspeed suggested, I thought there was a control in t0neg0d’s gui to exactly do that kind of job. Looks like not.

I guess I’ll just use an undecorated button.

@madjack said: I've browsed the wiki and it's not complete yet. Since the wiki search isn't helping, at all, I'm asking here...

So, I’ve implemented a multiple save in Disenthral and I take a screenshot when saving. I want to display that when giving the user a choice to load a game.

I’ve looked but couldn’t find a way to cleanly do it. Anyone has a suggestion?

It’s been so long since I’ve touched that GUI that I’m kinda lost now. >.<

Anyway, thanks for reading. :slight_smile:

Are you using texture atlasing? If so:

Create a new texture…
Add it to the element via:
[java]
element.setTextureAtlasImage(newTexture, “x=0|y=0|w=” + newTexture.getImage().getWidth() + “|h=” + newTexture.getImage().getHeight() + ");
[/java]

This should display the image just fine. Is you thumbnail and and composite the saves, just alter the querystring to the desire coords.

Though using a button’s icon would allow for the interaction you want as well (if it supposed to be clickable)

I don’t and have no plan to use texture atlassing ever. Also, with a button (or any element that is), it has the drawback of being impossible to reset the background image. So I guess I’ll be forced to use an overlay image on top of that “placeholder” button. If I remember right from Friday morning, I might be forced to redo a button every time I want to change that button’s image.

But don’t quote me on that. I might remember wrong.

@madjack said: I don't and have no plan to use texture atlassing ever. Also, with a button (or any element that is), it has the drawback of being impossible to reset the background image. So I guess I'll be forced to use an overlay image on top of that "placeholder" button. If I remember right from Friday morning, I might be forced to redo a button every time I want to change that button's image.

But don’t quote me on that. I might remember wrong.

This doesn’t sound right. Do you mean reset after using an effect? Or just swap out the image? Or? Give me the entire example of what you are trying to do, and I’ll write the example for you. You shouldn’t need to do anything special to get this to work.

Have you tried:

[java]
Element.getMaterial().setTexture(“ColorMap”, someTexture);
[/java]

You shouldn’t HAVE to do this, but… remember:

Element = Node = All functionality of a Node = + more functionality.
The default material = Unshaded + a bunch of other functionality (like clipping, yadda, yadda).

Point being… the material still has all the same Uniforms as Unshaded. And the Element class allows you to retrieve the material.

So, if all else fails (which really… it shouldn’t!), you can just directly set the texture yourself to any element you like.

2 Likes

NOTE:

Element.setColorMap(“path to texture image”);

Will do this for you

Heh… one last note! Using texture atlases only take minimal time to set up your general UI. The GUI library then uses the shared image and you get !!! performance boost.

This also does not lock you into a single atlas image, You can create as many as you like… i.e.

1 for general UI componants
1 for all icons
1 for incidentals
1 as an easteregg in your game where you tell everyone how ultimately awesome I am (when I don’t have my pyramid)

etc, etc, etc…

Anyways. you may very well like the results. and it makes tracking your UI images a WHOLE LOT easier.

1 Like
@t0neg0d said: This doesn't sound right. Do you mean reset after using an effect? Or just swap out the image?

My bad.

There isn’t a default way included in the lib to change the background image. Something along the line of element.setDefaultImg(String pathToImg), hoop jumping we have to do…

FYI, I’m working on a little thing you might want to consider adding. I’ll post more when I have something working.

1 Like
@madjack said: My bad.

There isn’t a default way included in the lib to change the background image. Something along the line of element.setDefaultImg(String pathToImg), hoop jumping we have to do…

FYI, I’m working on a little thing you might want to consider adding. I’ll post more when I have something working.

No hoop jumping. Use:

[java]
Element.setColorMap(“path”);
[/java]

This sets the default image. The reason this is named this is, there are multiple texture types you can set on the element.

Yes, I know it’s not hard, I know some people will say “damn you’re lazy” or whatnot. I think it would be better if there was a method that simply did it by itself. I like to try to protect (not literally) the inner stuff when I can. In this case the Material.

Anyway, it’s not a huge thing.

Oh and it’s exactly what I’m doing.

[java]screenie.getMaterial().setTexture(“ColorMap”, ss);[/java]

@madjack said: Yes, I know it's not hard, I know some people will say "damn you're lazy" or whatnot. I think it would be better if there was a method that simply did it by itself. I like to try to protect (not literally) the inner stuff when I can. In this case the Material.

Anyway, it’s not a huge thing.

Oh and it’s exactly what I’m doing.

[java]screenie.getMaterial().setTexture(“ColorMap”, ss);[/java]

Hehe… read the post above yours… It’s a method in Element… I don’t call getMaterial().

The method is:

[java]
Element.setColorMap(“path”);
[/java]

Why not simply use something like setDefaultTexture(path)? That ColorMap IS the default texture, why muddle things and call it something else? :stuck_out_tongue: