Skip to content

Commit 2ebefe4

Browse files
authored
Update ReadMe.md
1 parent d52fab7 commit 2ebefe4

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

ReadMe.md

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,54 @@ The main purpose of the library is to make creation of menu's in games easy. Thi
1212

1313
####To use the library
1414

15-
* First create a `gmenu::Menu` object, the will constructor need:
15+
* First Need to decide the menu items, ie the options available (eg Start, Exit, Highscore etc)
16+
* Create A vector of `gmenu::MenuItem`. Which contains the title of the item and Action it will perform.
1617

17-
* `sf::Renderwindow *` the main screen where Menu will be displayed.
18-
* `std::string` Menu title - The main heading of menu
19-
* `sf::Font` The font title will be displayed in
20-
* `gmenu::MenuItems *` This is an pointer to array of **MenuItem - the structure representing a menu option**.
18+
The definition of `gmenu::MenuItem` is:
19+
20+
```cpp
21+
struct MenuItem {
22+
std::shared_ptr<Action> action;
23+
std::string title;
24+
};
25+
```
26+
27+
Here `gmenu::Action` is an abstract Class that acts as an interface.
28+
The virtual method `bool DerivedAction::start()` will be called by the Menu when that item is selected.
29+
30+
31+
* Now create a style. `gmenu::Style`
32+
* It requires two paramenters ( `sf::Font` ) to initialize.
33+
* `gmenu::Style` can be used to define the look of the menu.
34+
35+
```cpp
36+
sf::Font &TitleFont;
37+
sf::Font &ItemFont;
38+
39+
sf::Color TitleColor = sf::Color::Green;;
40+
sf::Color ItemColor = sf::Color::Red ;
41+
sf::Color Selected = sf::Color::Blue;
42+
43+
unsigned int TitleFontSize = 50;
44+
unsigned int ItemFontSize = 20;
45+
46+
float MenuTitleScaleFactor = 0.125; //This scale determines the distance between Title and the first option
47+
float MenuItemScaleFactor = 0.25; // This determines the distance between options.
2148

22-
```cpp
23-
struct MenuItem {
24-
Action *action;
25-
std::string title;
26-
sf::Font font;
27-
};
28-
```
29-
Here `Action` is an **abstract class** with one virtual method `bool start` This is where you will implement the action to be performed when the option is selected.
30-
31-
* `menu.createMenu()` to start the menu
49+
int layout = Layout::Default; // Bitflag, Defines the layout of menu. eg. Layout::ItemLeft| Layout::TitleCentre
50+
51+
struct {
52+
signed int top, left;
53+
} Padding; // this is the padding that will extra displacement that will always be added.
54+
```
55+
56+
* Now create an object of `gmenuMenu` which require the following parameters:
57+
* `sf::RenderWindow` : Where menu is to be created
58+
* `std::vector<gmenu::MenuItem>` : Vector containing MenuItems.
59+
* `gmenu::Style`: That defines the style.
60+
61+
* Vola, your menu is ready to be used.
62+
3263

3364
##Screenshots
3465

0 commit comments

Comments
 (0)