Sign in to follow this  
Rob Loach

Menu System

Recommended Posts

Toadhead    244
?
What do you mean?
If you mean how to program one:

You will first need to create a window, than some objects with sprites file [file] and [ Help] etc.
Than when you click on them the sprite will change (in formal windows windows the background will become blue and the letters white), and some new sprites will be drawn: print, sace, save as etc. and when you click on them something will happen (you will save the file)

If this is not what you mean sorry, but than you should be more clear about what you wanti n your post.

Share this post


Link to post
Share on other sites
Rob Loach    1504
Yeah, it would help if I told you what I'm using. I'm using SDL and have SDL_TTF support. I don't have to worry about rendering it as I have a nice set of functions and classes to control that. I was thinking more the functionality of it and how it would work.

A function like this might work:

std::string MenuDisplay(
std::string MenuItems, // Parsed by "|"
std::string font,
int r, int g, int b,
int selR, int selG, int selB,
int x, int y);

Share this post


Link to post
Share on other sites
desertcube    514
Quote:
Original post by Rob Loach
Yeah, it would help if I told you what I'm using. I'm using SDL and have SDL_TTF support. I don't have to worry about rendering it as I have a nice set of functions and classes to control that. I was thinking more the functionality of it and how it would work.
A function like this might work:
std::string MenuDisplay(
std::string MenuItems, // Parsed by "|"
std::string font,
int r, int g, int b,
int selR, int selG, int selB,
int x, int y);

I'm still not sure what you want, you know how to draw the menu, but don't know how to organise it? If so, I would personally create a little structure to handle each menu item, something like:

struct Colour //Helper class, can give it comparision operators or conversion methods etc
{
Colour(int r, int g, int b):red(r), green(g), blue(b) {}

int red;
int green;
int blue;
}
struct MenuItem
{
std::string text;
std::string font;
Colour default;
Colour selected;
int x, y;

typedef void (*Callback)(const MenuItem &); //Function pointer
Callback callback; //Callback function
};



Then you can store a vector of them and iterate over them to draw them. Just a basic example at this stage, I'm not entirely sure what you are after!

Share this post


Link to post
Share on other sites
Telastyn    3777
This maybe isn't standard or ideal, but food for thought.

My menus are nothing more than list render objects with children that are buttons.

If you already have a [text] button class, and a class to listify things, it's pretty trivial to smush 'em together.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this