You can see where the similarities lie, the ui hander is like the Stage and the list is like the List in Scene2D, this was pretty fun to write, it might not look pretty but at least I am not fighting with a whole bunch of exceptions to get Scene2D to agree :p

"This code works flawlessly first time and exactly how I wanted it"Said no programmer ever

I don't have any of the problems with Scene2D (like exceptions).IIRC there is an "old" skin file around and if you try to use that you'll likely get errors, because Scene2D received an update for the SelectBox or something.

Once you're using a current version of the default skin you're good to go.

Also you don't really need to use the skin if all you're doing is creating two buttons. The setup is quite slim without a skin too.

I feel your pain... when I used LibGDX, Scene2D was the one part I always feared when creating games. Its just so bloated and unnecessary when creating a simple menu that consists of a few buttons. I ended up just writing my own GUI code which worked perfectly fine.

If you want to make a complex GUI with sliders, editable text areas, checkboxes and other stuff then homebrewing stuff just does not cut it and becomes a big waste of time. In my experience Scene2D UI is quite elegant and requires few lines of code to get going.

Also, I cant really see the complexity in Scene2D ui, it's actually very simple and is just a couple of lines more than you are using. Yeah setting up a skin is some work, but actually a lot easier than in for example TWL IMHO.

:scratches-head: are we talking about the 23 lines of code in the OP because basic Swing GUIs I've worked have required 400-600 lines of code just to get a few buttons and text boxes aligned and properly resizing. You can always make a utility class to create basic menus for you if your menus always consist of a few buttons in the same positions.

Agreed.. I don't see how OP's code is messy. Yes it could use .addCallBack() so you don't have to add call back in the constructor, but other than that, the code seems rather clean.

Here is what you would start calling messy. Adding few buttons without functions is one thing. Its other thing to make everything work together. Here is a really small project I worked on for couple of days. It had like 5 buttons and 1 JList.

I have run into many issues with scene2d's ui stuff. It is sad that I have to say to stay away from it. There are focus issues, rendering issues where things get cutoff oddly. I have tried multiple version of libgdx but they all have the same issues.

Tedious?Also scene2d actually uses less than one line to resize elements:

1

table.add(button).fill();

But you can also set align, borders, manually set w/h, etc too. I think it's just the way of thought that's different, instead of thinking about each button and where it goes you think about the table as a whole.

In the hypothetical editor: right-click component in debug mode to bring up a pop-up stacktrace of alignment functions taking place on it.Could be interesting, might actually do it. Not now though, the rest of my spring break is devoted to this damn CPU emulator I'm writing.

Having worked with some other (some of them "homebrew") ui libraries I have to say I love scene2d and scene2d.ui. Sometimes the ui creation and handling code can become a bit messy, but you can make your code a lot cleaner by using factories to create the ui elements you are using...

The backbone of my UI's is the table actor/widget. If you know what the table is capable of and are a bit creative you can achieve pretty much very fast. Also it's not bad to already have some nice widgets ready... Would not wan't to implement the scrollpane or textboxes myself

Except you are missing the creation and setup of tgr stage, the table, sizing both.

Them setting up the skin so that it has a font and drawables.

Neither of which are present in your code example. I suppose your UI library doesnt magically render itself or create that "list" variable out of thin air?

I felt precisely the same about pretty much any UI library I used and baked my own UI code. But after some time you really need some extra functionality like additional types of widgets, or an easy way to restyle the whole thing. Some time later you end up with an unmanageable inconsistent and buggy mess which eats up half your game development time. Then compare the homebrew solution to something like the Scene2D UI and you get a sensible comparison.

OP, since your problem is "fighting with a whole bunch of exceptions to get Scene2D to agree" I assume you haven't taken the effort to understand the API. Presenting your opinion so crudely (scene2d is "annoying as shit") isn't going to lead to productive discussion. Complain until you are blue in the face, but don't be surprised that I don't care about you or your problems. If your goal is solely to complain, remember that scene2d is provided to you at considerable effort for free. If you don't like it, don't use it.

StumpyStrust, AFAIK scene2d works correctly. It has been in use in many complex apps for years, so it would quickly become apparent if something didn't work. A UI library has a number of problems that are difficult to solve in a nice way, such as drawing, responsive layout and event routing. scene2d has a solid approach to these, but it may not be easily apparent why it works the way it does. I'm happy to discuss what you find doesn't work, but in a different thread.

OP, since your problem is "fighting with a whole bunch of exceptions to get Scene2D to agree" I assume you haven't taken the effort to understand the API. Presenting your opinion so crudely (scene2d is "annoying as shit") isn't going to lead to productive discussion. Complain until you are blue in the face, but don't be surprised that I don't care about you or your problems. If your goal is solely to complain, remember that scene2d is provided to you at considerable effort for free. If you don't like it, don't use it.

Sorry I will reword, setting up a skin is annoying, I find it quite over whelming it you want something simple. I have read the documentation, I get it. I can easily setup a basic ui with it.

Just because I find it tedious does not mean I don't know how to work it.

I never complained about the functionality, nor at any point did I say I never appreciated the free use of the library.

I find your reply pretty aggressive, for no reason at all.

"This code works flawlessly first time and exactly how I wanted it"Said no programmer ever

Yeah well in the end, Scene2D is a good library, its used by many to good effect, made by volunteers who know what they are doing. Considering that, its just not so nice to use words like "utter tedious", "tedious as hell", "that was horrible", "god annoying", "tedious and ugly library". It would be sad if a post like this would put newbies off using a good library for no good reason.

Yeah well in the end, Scene2D is a good library, its used by many to good effect, made by volunteers who know what they are doing. Considering that, its just not so nice to use words like "utter tedious", "tedious as hell", "that was horrible", "god annoying", "tedious and ugly library". It would be sad if a post like this would put newbies off using a good library for no good reason.

Fair enough I could have chosen my words better, I would never discourage someone to to use this library!

I never said it was ugly, I said it can make your code look ugly, especially if your just making something simple.

"This code works flawlessly first time and exactly how I wanted it"Said no programmer ever

Maybe my post was harsh. I felt your criticism was quite intense with no hint of an attempt at being productive.

Skin does a couple things:

1) Makes for a centralized place to find resources (colors, fonts, widget styles, etc).2) Makes it convenient to convert textures, regions, etc to a drawable, tinted drawable, etc.3) Makes it easier to reuse the resources in subsequent apps by specifying the skin as JSON.

If you are making a simple UI and don't need #3, you probably don't want to spend the extra effort to describe your skin as JSON.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org