You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+45-15
Original file line number
Diff line number
Diff line change
@@ -12,23 +12,53 @@ The main purpose of the library is to make creation of menu's in games easy. Thi
12
12
13
13
####To use the library
14
14
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.
16
17
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
+
structMenuItem {
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
+
unsignedint TitleFontSize = 50;
44
+
unsignedint ItemFontSize = 20;
21
45
22
-
```cpp
23
-
structMenuItem {
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
46
+
float MenuItemScaleFactor = 0.25; // This determines the distance between options.
47
+
48
+
int layout = Layout::Default; // Bitflag, Defines the layout of menu. eg. Layout::ItemLeft| Layout::TitleCentre
49
+
50
+
struct {
51
+
signed int top, left;
52
+
} PaddingTitle, PaddingItems; // this is the padding that will extra displacement that will always be added.
53
+
```
54
+
55
+
* Now create an object of `gmenuMenu` which require the following parameters:
0 commit comments