Menus

DM6
Unregistered
 
Post: #1
Anyone have a good example on how to hook up some UI elements (specifically menus) to a C++/OpenGL/SDL app? I know Interface Builder is supposed to be easy, as is Cocoa, and I'm not trying to get out of learning them. But a good example project would help me a LOT more than Apple's docs. Many thanks for any help.

Duncan
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
The FlipSquare tutorial at CreateMacGames.org is a really good resource for learning Interface Builder. It's how I learned to use it, and I don't see how I could have figured it out otherwise.

http://www.createmacgames.org/index.php?...&Itemid=27

Alex Diener
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #3
IB is not going to be much use to you, since you can't use the Cocoa language from within a C++/SDL app. There are some GUI libraries available on http://www.libsdl.org that you could take a look at.

Cheers

- Iain
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #4
Rolling your own for your exact needs is usually good enough for editing apps (that no one else but your development team will use) or games that have limited menus...

If you are making a final game with menus as your main interface (eww!) you either need to rely heavily on one of the libraries mentioned above or use platform specific code like Cocoa. If you are going mac only, I'd say go Cocoa all the way. Interface builder + Cocoa, etc. will save you days of work. (So I hear. Smile )

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #5
Yes, but as I said, if you are using SDL with C or C++ then you are 'trapped' within your own C/C++ code. The only route in to modify the interface is to modify the .nib file which has the main menu bar etc. Even editing the SDLMain.m file, which would allow you to forward events from the UI to your C code, there is no route for you to control the UI from your code, for example to show dialog boxes using Cocoa.

At least that's what I've found so far...

- Iain
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #6
Yes, that's all true. I meant use a library with SDL or abandon SDL if you are going mac only and having a game that uses menus and standard interface elements primarily.

You could probably alter SDL enough to allow tweaking the interface through cocoa and .nibs, but... eventually, you are losing the benefits of SDL's cross platform compiling.

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
DM6
Unregistered
 
Post: #7
Thanks for clearing it up IBethune, I wasn't sure whether it was possible to do it through .nibs and Cocoa with SDL. But the GUI libraries on libsdl.com are too numerous to choose. Let's say it's for an action game that plays in a window, so menus would not be the main interface to the game. I want to keep the menus outside the OpenGL context, in the menubar where they belong. Any advice for which library is best suited to these needs/most reliable? Thanks for your help so far guys.

Duncan
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #8
no library compatible with SDL is going to give you access to the standard menu bar. Those GUI libs can only reach the graphics context you set up with SDL. You'd have to use IBethune's method to get access, and like he said, that's for MENU's only. Beyond that it would mean making a lot of Mac OS specific changes to the SDL code... perfectly legal as long as you supply a link to your version of the code with your game... however probably not worth the effort needed. Smile

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
DM6
Unregistered
 
Post: #9
OK, so if I'm fine with restricting myself to menus only, any tips on how to start modifying the .nib file? I'm a C++ programmer and I have no cocoa experience; any tutorials or sample files that could make it clear to me?

-Duncan
Quote this message in a reply
sam
Unregistered
 
Post: #10
With SDL as far as I can tell you change line 15s #define from 0 to 1 (in SDLMain.m)

And make SDLMain.nib
Quote this message in a reply
Apprentice
Posts: 12
Joined: 2004.08
Post: #11
sam Wrote:With SDL as far as I can tell you change line 15s #define from 0 to 1 (in SDLMain.m)

And make SDLMain.nib

What would you need to put in this nib to make it compatible with the SDLMain.m/h files?
Quote this message in a reply
DM6
Unregistered
 
Post: #12
Kevin Lindeman Wrote:What would you need to put in this nib to make it compatible with the SDLMain.m/h files?

I'd also very much like to know the answer to this.

-Duncan
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #13
Kevin Lindeman Wrote:What would you need to put in this nib to make it compatible with the SDLMain.m/h files?
I imagine a default Cocoa nib would do the trick. If not, experiment and find out. Smile
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #14
Look in SDL.framework/Resources: there's a default SDLMain.nib file there. I imagine you can make a copy of it and add your own stuff.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Diplomtennis
Unregistered
 
Post: #15
My name is Diplomtennis and I don┬ąt have a single clue about Cocoa. Blush

Can someone tell me step-by-step what to do, if I only want to add a simple Command - Q into a SDL Menue?

Or post a link to a good tutorial for Cocoa - dummies maybe?

Or can I do it in Carbon somehow too?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Does SDL have any support for pull down menus? WhatMeWorry 2 2,661 Nov 6, 2005 01:12 AM
Last Post: PowerMacX