Menu System

Started by
4 comments, last by Rob Loach 19 years, 2 months ago
How would you go about making a menu system/class?
Rob Loach [Website] [Projects] [Contact]
Advertisement
?
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.
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);
Rob Loach [Website] [Projects] [Contact]
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!
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.
... Or a nice GUI library made for SDL. I see these, has anyone tried one out?
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement