Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Help me pick a GUI please.

This thread is locked; no one can reply to it. rss feed Print
Help me pick a GUI please.
ryancoboy
Member #14,468
July 2012

Hello everyone. This is my fist post here, so hopefully I'm posting in the right section and saying the right things. If not, I apologize in advanced.

little bit of background information on me:
been using C++ for about 5 years.
been using Allegro5 for about 6 months (I love it so far).

I made a simple tower defense game with allegro to build up my skills with allegro.

But my main project is a RPG game that I've been working on for ~4 years. I just recently finished a text version of the game. Now I want to make it a graphical game(2d).

As I've started working on some things I have come to realize that it would be very helpful to have some sort of GUI lib. In terms of features all I really need are: Textboxes (just to get user input), buttons, and scroll/slider bars.

FYI I use Windows 7, and Visual C++ 2010 (I know a lot of people hate it and I know why, but it's, for the most part, simple for me to use and understand).

The biggest problem I've been having with trying different GUI's is installing them. I have close to zero experience installing/adding new libs.

With all that in mind hopefully you guys can give me some ideas of GUI's to use and perhaps instructions on how to install them.

Thanks for any and all help,
-Ryan

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

jmasterx
Member #11,410
October 2009

There's my gui library Agui. The goal of my library was ease of use, flexibility, and functionality. As a result it has a ton of well documented functions.

My TextField can have character limits, passwords, numbers only, text selection with mouse and keyboard, and much more.

My TextBox has even more features and I have an ExtendedTextBox which allows individual characters to have color.

The whole library is built to use UTF-8 Unicode too.

The big drawback that many people do not like is how you make things look different. I built it originally for the game I'm making and I wanted total control, so you have to subclass each Widget and paint it to your liking.

For example, in my game this is how my TextField is custom painted:

#SelectExpand
1 void TextField::paintBackground( const agui::PaintEvent &paintEvent ) 2 { 3 agui::Image* img = NULL; 4 if(isFocused()) 5 { 6 img = m_focusImage; 7 } 8 else 9 { 10 img = m_bgImage; 11 } 12 13 paintEvent.graphics()->drawNinePatchImage(img,agui::Point(0,0),getSize()); 14 } 15 16 void TextField::paintComponent( const agui::PaintEvent &paintEvent ) 17 { 18 int caretLoc = getCaretLocation(); 19 int textLoc = getTextOffset(); 20 21 agui::Rectangle sideclip = getInnerRectangle(); 22 sideclip = agui::Rectangle(sideclip.getX() + getLeftPadding() , 23 sideclip.getY() + 2,sideclip.getSize().getWidth() - getLeftPadding() 24 - getRightPadding() + 1, sideclip.getHeight() - 4); 25 26 paintEvent.graphics()->pushClippingRect(sideclip); 27 28 if(getSelectionStart() != getSelectionEnd() && (isFocused() || !isHidingSelection()) ) 29 { 30 agui::Rectangle selRect = agui::Rectangle( 31 getSelectionLocation(), 32 (getInnerHeight() / 2) - 33 (getFont()->getLineHeight() / 2), 34 getSelectionWidth(), 35 getFont()->getLineHeight()); 36 37 paintEvent.graphics()->drawFilledRectangle( 38 selRect,getSelectionBackColor()); 39 } 40 41 42 paintEvent.graphics()->drawText(agui::Point(textLoc, + 43 ((getInnerSize().getHeight() - getFont()->getLineHeight()) / 2)),getText().c_str(), 44 getFontColor(),getFont()); 45 46 47 if(isFocused()) 48 { 49 if(isBlinking()) 50 paintEvent.graphics()->drawLine(agui::Point(caretLoc + 1, 51 ((getInnerSize().getHeight() / 2) + (getFont()->getLineHeight() / 2))), 52 agui::Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) - 53 (getFont()->getLineHeight() / 2))), 54 agui::Color(0,0,0)); 55 } 56 57 paintEvent.graphics()->popClippingRect(); 58 59 }

It should be pretty easy to install and use, and if you find bugs I'm very quick to fix them, but it's generally pretty solid.

I use the CMAKE system just like Allegro. I can guide you through that if you need.

Another really great library is GWEN http://code.google.com/p/gwen/ .

I have not used it, but it makes painting easier. I can't speak for its functionality, but give its demo a try if you want.

ryancoboy
Member #14,468
July 2012

Well to be honest the two GUI's i was leaning the most towards was indeed yours, agui, and GWEN.

Both of these seemed to have all the features I was needing and more, just in case I wanted more in the future.

I do really like how well documented your GUI is, which is the main reason why I was really interested in yours. And is the main reason I think I like Allegro so much. Good documentation goes a long ways, IMO.

But like I said before I haven't a clue on how to get either of these (agui or GWEN) linked into my project. Only reason I was able to get Allegro installed was due to the install tutorial ;D .

I am pretty confused on the whole CMake thing (I don't recall anything about "CMake" when I installed Allegro). If, there's any way you could point me in the right direction(tutorial, etc...) to learning more about this, "CMake" thing, i would appreciate it a lot. Furthermore, I'm still pretty confused on how to add all these directories in Visual C++ (it seems so simple once you understand it, which is what's making me really mad >:( )

Thanks,
-Ryan

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

jmasterx
Member #11,410
October 2009

I'll explain basically what CMAKE is.

The reason you did not need to use CMAKE for Allegro is that you used pre compiled binaries. Once you have the lib file, which you do because you're using precompiled binaries, you just need to tell MSVC where everything is. (I'll get to that).

What CMAKE does is it runs a script, usually CMakeLists.txt. This script lets you choose certain things, like in Allegro, you can choose to have the examples or not. Then it will generate the appropriate project file for you. A vcprojx or something. On Mac it can make you an XCode project.

So for Agui, get CMake for Windows http://www.cmake.org/
Next you'll need a tool called TortoiseSVN http://tortoisesvn.net/
get and install both of these.

Next, make a folder anywhere you like called agui_svn.
Right click it and click SVN Checkout. Then in the URL of Repository TextField enter

http://agui.googlecode.com/svn/

What you just did is download the latest revision of the Agui source code.

Next you need to compile that source code and generate the lib file.

In agui_svn/trunk create a new folder called MSVC.

Notice the CMakeLists.txt in the trunk folder.

Open up CMAKE.
For the source folder, point it to agui_svn/trunk
Where to build, point it to agui_svn/trunk/MSVC

Click Configure. You'll be given a list of options. Select Visual Studio 2010 if it's not already selected.

Click finish.

Let it do its thing.

You now have the option to not compile the allegro backend or to build agui as a DLL. I highly advise AGAINST building it as a DLL.

Leave the default options.

Click Generate, and then go to your MSVC directory.
There's files in there now :o
Open the agui sln (solution)

This is where things get a bit tricky. I'll try not to overcomplicated this.

You basically have 2 types of compilations. Debug, and Release.
Within those, you can build with what is called MT or MD. MT is if your library links to the runtime library (the thing that has std vector, strlen, malloc, etc) or not.

It is important that you build it in accordance to your project preferences.

To check this, in your game project, right click your project in solution explorer in msvc, click properties, under C/C++, click Code Generation.

You'll see something like Multithreaded DLL.

You need to do the same thing for Agui and Agui_Allegro5 projects and make sure it is the same as your game project.

All that's left is to decide debug or release.

Right click the solution this time in solution explorer and click properties.

Click Configuration to your left. You'll see 4 projects all on Debug.

When you're ready for the release compile, go here and change them all to release with debug info.

For both Debug and Release with debug info, click build in the menu bar and select rebuild solution.

Agui expects to find Allegro5 installed (in your include paths), which should not be a problem, but if it is you'll get lots of errors.

To add your include files and lib files you'll need to go and do this:

Quote:

To specify a per-user directory list

On the View menu, click Property Manager.

In Property Manager, click a configuration-and-platform node; for example, Debug | Win32.

The node expands and displays a user property sheet such as Microsoft.Cpp.<platform>.user, where <platform> is a system-defined value such as Win32 or X64. The <platform> value and the platform for the project must be the same.

Either double-click the user property sheet, or click the user property sheet and then click Properties in the shortcut menu.

The <User Property Sheet> Property Pages dialog box is displayed, and the VC++ Directories node is highlighted.

Edit the directory lists, as described earlier in step 3 of "To specify a project directory list".

So in there you can add include and lib directories.

Lets discard that for a second and put some files in there place.

I do not know how or where you store your libraries so try to adapt the following to your needs.

I set up my libraries like this.

Create a folder c:/lib
Add folders include and lib to c:/lib
In the agui_svn/trunk/include folder, copy the Agui folder to c:/lib/include
Now navigate to agui_svn/trunk/MSVC/Debug

rename agui.lib and agui_allegro5.lib to agui_d.lib and agui_allegro5_d.lib
move these to c:/lib/lib

Now head to the Release With Debug Info folder in MSVC (or whatever it is called) and copy the agui and agui_allegro5 libs to the same folder.

Now, getting back to those property pages and include directories.
Add c:/lib/include to your include directories and c:/lib/lib to your Library directories.

Close MSVC.

Now open your project, right click its name in solution explorer, for both Debug and Release, you'll need to navigate to linker->input and add agui.lib and agui_allegro5.lib to your additional dependencies.

After that, try to compile my agui example.

Good Luck

Luiji99
Member #12,254
September 2010

That is insanely overcomplicated.

Programming should be fun. That's why I hate Java.
http://www.entertainingsoftware.com/

jmasterx
Member #11,410
October 2009

By all means, write the simplified version :)

ryancoboy
Member #14,468
July 2012

First of all I just wanted to thank you for being so helpful and spending your time to help me out.

So i got everything to the point where it compiles without 20+ linker errors (was stuck on that for a while). But as soon as the program starts i get a debug error! >:(

ill try to work on it a bit more to see if I can't figure it out. I'll post here again tomorrow if i fail (or when i get it working).

Again thank you very much for all of your help. You have been beyond helpful. I will defiantly keep all of this in mind for any future libs. i try to add.

@Luiji99: I totally agree with you ;D.

EDIT: "@Luiji99: I totally agree with you ;D." Just thought i should rephrase what i said there. I agree that the overall process is overly complex not his instructions.

also thought I'd add a couple things in regards to the error I'm getting.
when i compile an error box pops up and has no relevant info on it but the console window does have the error written on it. here's what it is: "Assertion failed: vec->_itemsize > 0, file allegro-5.0.x\src\misc\vector.c, line 170"

Hopefully that means something to you :P .

Thanks,
-Ryan

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

Luiji99
Member #12,254
September 2010

I've gotten that error before, but I don't remember what causes it. Something very vague, IIRC. =P

If I ever try to build Allegro 5.x on Windows I'll write a quick batch script to automate this process.

Programming should be fun. That's why I hate Java.
http://www.entertainingsoftware.com/

ryancoboy
Member #14,468
July 2012

Ok still the same problem but now I've pen pointed it.

the error occurs at this if statement: line 286

if(!al_init_ttf_addon())
{
throw std::exception("Allegro ttf addon failed to initialize");
}

i apologize but I'm not sure how to put things in code blocks on this site ???. I've done it on other sites but forgot how.

edit: also i should probably mention that the code mentioned above came from the agui example program.

seems to be the exact same problem as this: http://www.allegro.cc/forums/thread/606685

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

LennyLen
Member #5,313
December 2004
avatar

Luiji99 said:

If I ever try to build Allegro 5.x on Windows I'll write a quick batch script to automate this process.

BuildAllegro.bat#SelectExpand
1cmake ADD YOUR OPTIONS HERE 2make 3make install

ryancoboy
Member #14,468
July 2012

Great news! fixed the problem.

for anyone who encounters this problem all you need to do is add "al_init_font_addon()" prior to "al_init_ttf_addon()". After that everything compiled just fine.

@jmasterx you may want to consider adding this to your example code. It may prevent problems for others in the future. And again thank you for all your help. I can finally start trying out your GUI YAY! (well may be tomorrow it's 2:35 a.m. now) ;D

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

jmasterx
Member #11,410
October 2009

Are you sure you got the latest version of the source code?

Right here http://code.google.com/p/agui/source/browse/trunk/example/agui_example.cpp you will see that the call to the font addon is there.

If you are using 0.1.0, please do not, it is buggy.

ryancoboy
Member #14,468
July 2012

hmmmm....well that's odd. The code that I got/used, I acquired via the SVN link you gave me.

EDIT: I looked at the unmodified version of your example code on my computer and it has the font addon. WTF! ??? I'm not crazy! ;D. well to be honest I don't what happened. Your code is fine in that case. Anyways now that I'm exceptionally confused, I'm going to try to learn your GUI now.

Thanks for all your help,
-Ryan

-Ryan
----------------------------------------------------
If I'm asking, it's because I failed for over 2 hours trying to find the answer on Google / trying to fix it myself.

Luiji99
Member #12,254
September 2010

Did you even read his instructions, Lenny?

EDIT: Pardon me, but I should correct my earlier post: I meant a batch file to compile Agui, not Allegro. I really don't get why its so complicated under those instructions, though. Under GNU/Linux -- where I have compiled Allegro and Agui myself -- it's as simple as you say. Except that the example won't compile without modification and, even then, it doesn't run due to missing data files. (LTIC)

Programming should be fun. That's why I hate Java.
http://www.entertainingsoftware.com/

jmasterx
Member #11,410
October 2009

A lot of what I wrote is applicable to dealing with libraries in general. All of it is stuff that any serious C++ programmer should know.

It's MUCH easier in *nix based OS's. A simple call to svn co, and then the lines Lenny wrote and you're done. Windows is always more gui oriented which is slow.

There's also no built in /usr/lib in Windows >:( which is why I had him make one.

Which mods do you need to make to get the example running? I'll commit the changes. And what data is missing? it only depends on a ttf font that is provided as far as I know.

Anyhow, that example is terrible, if I had time to make quality examples I would, or if some were donated I'd commit them. Unfortunately I'm quite busy.

Luiji99
Member #12,254
September 2010

Oh, uh, okay, cool!

Modifications: you keep on saying throw std::exception("message!");, but there's no constructor in std::exception that accepts string by standard, and GCC doesn't implement that extension for some reason. I just replace those lines with throw std::runtime_exception("message!");, which is technically more correct. This also requires a `#include <stdexcept>`.

As for the data...be-ka-da-wa-huh? It works now. Nevermind on that one... :o

Also, it'd be nice if I could compile the example without manually typing out the entire command (i.e. CMake integration).

By the way, you do have a really nice GUI system, and I appreciate you releasing it as FLOSS. The only things that annoy me is how I can't Ctrl+A text boxes and how scrolling with my mouse is so slow, forcing me to resort to...*shudder*...dragging the scollbar. Duh, dah, DUUUUH!!!

Programming should be fun. That's why I hate Java.
http://www.entertainingsoftware.com/

jmasterx
Member #11,410
October 2009

I guess you do not have the latest svn.

Exceptions removed from example in svn.
ctrl c, a, and v added to textfield and box in svn. No native clipboard support in linux though.

The default scroll rates are slow, but with the way I intended its use, your subclass scrollbars should set the v and hscroll rates to their liking and you should construct your scrollable objects with instances of those. That way you have global control, but then individual scrollable widgets can override them, you could also override it at the instance level if 1 perticular widget needs a different scroll rate.

Certainly how I do scrolling in general is a weak area in the library. I was just starting out in C++ when I took on the project, so there were a few things I did not know. But if there is a parameter you need to tweak, it's probably tweakable or virtual. It's designed to be really flexable.

Glad you like it :)

Luiji99
Member #12,254
September 2010

You certainly have, which is impressive had just started out with C++.

Yes, I didn't have the latest SVN, I had the latest tarball.

Programming should be fun. That's why I hate Java.
http://www.entertainingsoftware.com/

Go to: