Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » A5 gui

Credits go to jmasterx for helping out!
This thread is locked; no one can reply to it. rss feed Print
A5 gui
RickyLee
Member #11,573
December 2009

Does allegro 5 have a GUI like allegro 4 did? If not are there any simple 3rd party GUI's for allegro 5? I just need something simple to start with and care more about the functionality than the looks at this point.

jmasterx
Member #11,410
October 2009

RickyLee
Member #11,573
December 2009

Nice thanks!

Trent Gamblin
Member #261
April 2000
avatar

What makes those the "main" ones? What Allegro 5 games have been made with those?

GullRaDriel
Member #3,861
September 2003
avatar

No C Gui. A pity.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Trent Gamblin
Member #261
April 2000
avatar

With a little work you could now use GTK. Right now it only works on Linux... but you'd have to find a flexible way of placing the Allegro display widget.

jmasterx
Member #11,410
October 2009

I mean 'main' as in, fairly feature-full, and complete enough to properly make games.

I have used Agui for an unreleased game I'm working on and it has met my fairly GUI intensive needs.

Others are either missing several things, or missing several features, or intended for more specific purposes than a general purpose game UI.

If you're aware of other ones that offer a similar level of features that is used in an A5 game[s] I would like to know about it :)

Trent Gamblin
Member #261
April 2000
avatar

Depends what you mean by features. Offering text boxes isn't very useful for games. General purpose GUIs and game GUIs are different. Mine is completely customizable and built for games, not as a general purpose GUI. And it's been using in half a dozen games or more.

tobing
Member #5,213
November 2004
avatar

Maybe look into alguichan as well.

Trent Gamblin
Member #261
April 2000
avatar

Here's an example of what TGUI2 can do quite easily.

https://www.allegro.cc/files/attachment/607033

Kris Asick
Member #1,424
July 2001

When I'm done my current game project I should consider making my home-made GUI available to the Allegro community. It's not very fancy and barely functions without making your own custom objects, but it handles all the nitty-gritty stuff like states and focus automagically, which is the hardest part of making a GUI, and is easily portable between different libraries. (IE: It doesn't even NEED Allegro to run! ;D)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

pkrcel
Member #14,001
February 2012

Trent, do you have any documentation on TGUI2?

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

jmasterx
Member #11,410
October 2009

I had not added alguichan because Agui was modeled after guichan and ended up having more widgets and features. I also actively address bugs in Agui when someone posts them. I think guichan might be dead.

I had not seen TGUI in action, but it's pretty nice :) I'll be sure to include it in future posts.

If you do not have TextFields and TextBoxes, these were actually the most important widgets for my game, and they have a lot of functionality. If you want, you could add TextFields and TextBoxes to TGUI from Agui's source code:

http://code.google.com/p/agui/source/browse/#svn%2Ftrunk%2Fsrc%2FAgui%2FWidgets%2FTextBox

http://code.google.com/p/agui/source/browse/#svn%2Ftrunk%2Fsrc%2FAgui%2FWidgets%2FTextField

AMCerasoli
Member #11,955
May 2010
avatar

Right now it only works on Linux...

So it doesn't work...

Trent Gamblin
Member #261
April 2000
avatar

Are you a programmer or not? It "WORKS ON LINUX" is what I said. Get it to work on Windows if you want it on Windows. Lazy bastard.

AMCerasoli
Member #11,955
May 2010
avatar

Oh Oh! The little teddy bear got mad and it's going to eat me oh no! help help!

GullRaDriel
Member #3,861
September 2003
avatar

Gamer audience is not only on linux and vastly on windows. Fact. End.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Trent Gamblin
Member #261
April 2000
avatar

There are a lot of gamers who use Linux. Do you think Valve would be porting Steam if that wasn't the case? The fact still remains, that you're complaining about code I wrote because it doesn't work on your preferred operating system. You're probably too shit of coders to make it work yourself so you complain instead.

pkrcel
Member #14,001
February 2012

Hey Trent, before this gets a bit too hot of a topic..may I ask you again if you have any sort of documentation on TGUI2?

I managed to build the lib and the example (which is pretty straightforward and readable, and sparked a marked interest in TGUI myself), but before digging into the code I would like to know if you documented any of TGUI's "features" and a general tipoff on how to getting started with it.

Thanks a lot.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Trent Gamblin
Member #261
April 2000
avatar

Sorry pkrcel, I haven't got around to documenting it yet (in about 10 years since I first created it D:.) I think a good way to figure out how to use it (although documentation would be better) would be to read the source for AshEdit2 here (even though it's not very well done:) http://www.nooskewl.com/content/open-source.

For a few ideas to kick you off, it's designed to be integrated into a game loop easily. The basic flow is something like:

while (true) {
  al_wait_for_event(...);
  tgui::handleEvent(&event);
  if (logic) {
     tgui::update();
  }
  if (draw) {
     /* your drawing goes here, or after tgui::draw if you want */
     tgui::draw();
     al_flip_display();
  }
}

Setup looks something like this:

tgui::init();

ParentWidget = new ParentWidget(...);
ChildWidget = new ChildWidget(...);

tgui::addWidget(ParentWidget);
tgui::setNewWidgetParent(ParentWidget);
tgui::addWidget(ChildWidget);

tgui::setFocus(ChildWidget);

And of course the most important part is creating custom widgets. Basically you want to respond to certain "events" (method calls). Those are listed in tgui2.hpp as the virtual functions. The main ones are probably draw, update, mouseDown, mouseUp, mouseMove, keyDown, keyUp and so on. There are some widgets defined in the library already though only a small number. You can look in tgui2_widgets.cpp/hpp to see more details on how to create a widget. I recommend looking at TGUI_Frame first as that's really simple. It's just a rectangular "window" that you can drag around by the title bar.

Elias
Member #358
May 2000

You're probably too shit of coders to make it work yourself so you complain instead.

Actually, making GTK work in windows is rather simple - maybe instead try getting the win32 GUI to work under Linux - when you're done complain again :)

--
"Either help out or stop whining" - Evert

beoran
Member #12,636
March 2011

GullRaDriel, I'll be implementing a C GUI for my game Real soon Now (tm), so seen that there seems to be a need for it, I'll probably rip it out of my game and make a separate library out of it. Keep watching this place until then... :)

GullRaDriel
Member #3,861
September 2003
avatar

beoran: I'm waiting for it.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I have a fully implemented GUI for Allegro 4. It's public too, on sourceforge.

I am in the middle of redesigning my library to become independent of the library it uses, and right now I am finishing the Allegro 5 backend. After that I will begin porting all my widgets to the new library. It is event based, and has some really great convenience functions and objects. It makes input smooth like butter and init code simple. All objects are owned by the system and that is where you create them from, so you never have to manage memory AT ALL! The most you have to do is write one delete statement. :o

Simple example of how you would display an image and wait for a key with my system, Eagle :

#SelectExpand
1 2#include "Eagle5/backends/Allegro5backend.hpp" 3 4int main(int argc , char** argv) { 5 6 EagleSystem* sys = new Allegro5System(); 7 8 const int eagle_systems = EAGLE_GENERAL_SETUP; 9 10 if (eagle_systems != sys->Initialize(eagle_systems) {return 1;}/// FAIL, LAMER <,> 11 12 EagleGraphicsContext* win = sys->MakeGraphicsContext(EAGLE_FULLSCREEN_WINDOW); 13 14 EagleImage* splash = win->LoadImage("data/splash.png"); 15 16 win->DrawToBackBuffer(); 17 18 win->Draw(splash , 0.0 , 0.0); 19 win->FlipDisplay(); 20 21 sys->WaitForKey(); 22 23 /// BLAH BLAH BLAH 24 25 delete sys; 26 27 return 0; 28}

tobing
Member #5,213
November 2004
avatar

jmasterx said:

I had not added alguichan because Agui was modeled after guichan and ended up having more widgets and features. I also actively address bugs in Agui when someone posts them. I think guichan might be dead.

I didn't know this about Agui, so I really should have a look at it.

guichan is essentially abandoned now, that's right. Which is the reason I forked alguichan from that project, and I'm using that in my games.

Go to: