Looking for a simple text menu like the ones in 2D Final Fantasy games to put into your SFML game??
I have been looking around for a very simple, easy to use rpg style text menu that C++ beginners will have no problem understanding. For some reason it appears no one makes these using SFML or this is such a noob thing that advanced programmers don't even give it a second thought, let alone make a class for it. So this is what I did.
Warning: I am a noob, so keep this in mind. I've spent weeks trying to make this class work and I have also sent every function through rigorous testing so there shouldn't be any problems with the code. The code is also heavily littered with comments and the functions have self explanatory names.
The menu class's declarations (Menu.h) and its definitions (Menu.cpp) are attached to this post. When using these make sure you have the header files that the class asks for.
A brief explanation of how it works
Basically the menu consists of 4 main things:
- a container deque (basically an array that can change size while the program is running like vectors can except they are slightly different) that holds every option in the menu.
- another container deque that holds a list of pointers that only point to the options that are supposed to be drawn to the screen.
- an sf::Rectangle object that works as the background for the menu
- an sf::Rectangle object that works as the border for the menu
I think most of it should be easy to figure out how to use, especially with the comments. BUT if anyone has any questions, problems, or bug reports, just send make a reply to this post or send me an email at
www.archentitykalim@gmail.com to let me know. I'm kinda busy right now but I will eventually make a full on tutorial for this if need be.
UPDATE!!! ATTACHMENT FILES HAVE ALSO BEEN UPDATED SO RE-DOWNLOAD THOSE IF YOU ALREADY DOWNLOADED THEM!!!
I added some extra functions to the class that you probably won't have to use but they are there just in case. These functions are:
- int getCurrentOption(); --- Returns the number of the current option.
- std::string getCurrentOptionString(); --- Returns the text string of the current option.
- std::string getFirstOptionString(); --- Returns the text string of the first option.
- int getLastOption(); --- Returns the number of the last option.
- std::string getLastOptionString(); --- Returns the text string of the last option.
- std::string getOptionString(int number); --- Returns the string of the chosen option.