diff --git a/.travis.yml b/.travis.yml
index a7ec15f..2a3ecda 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,6 @@ before_install:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo add-apt-repository ppa:sonkun/sfml-development -y
- sudo apt-get update -q
- - sudo apt-get install gcc-4.8 g++-4.8 libsfml-dev -y
+ - sudo apt-get install gcc-4.8 g++-4.8 -y
script: make CC='g++-4.8'
diff --git a/Examples/GameMenu_sample/GameMenu_sample.vcxproj b/Examples/GameMenu_sample/GameMenu_sample.vcxproj
new file mode 100644
index 0000000..05bf911
--- /dev/null
+++ b/Examples/GameMenu_sample/GameMenu_sample.vcxproj
@@ -0,0 +1,126 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}
+ GameMenu_sample
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ MultiByte
+
+
+ Application
+ false
+ v140
+ true
+ MultiByte
+
+
+ Application
+ true
+ v140
+ MultiByte
+
+
+ Application
+ false
+ v140
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ Disabled
+ true
+
+
+
+
+ Level3
+ Disabled
+ true
+ C:\Users\sidhi\Desktop\Projects\GameMenu\include;%(AdditionalIncludeDirectories)
+
+
+ C:\Users\sidhi\libraries\SFML-2.4.1\lib;C:\Users\sidhi\Desktop\Projects\GameMenu\lib\x64\Debug;%(AdditionalLibraryDirectories)
+ GameMenu.lib;sfml-window-d.lib;sfml-graphics-d.lib;sfml-system-d.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+
+
+ true
+ true
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ C:\Users\sidhi\Desktop\Projects\GameMenu\include;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ C:\Users\sidhi\libraries\SFML-2.4.1\lib;C:\Users\sidhi\Desktop\Projects\GameMenu\lib\x64\Debug;%(AdditionalLibraryDirectories)
+ GameMenu.lib;sfml-window-d.lib;sfml-graphics-d.lib;sfml-system-d.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/GameMenu_sample/GameMenu_sample.vcxproj.filters b/Examples/GameMenu_sample/GameMenu_sample.vcxproj.filters
new file mode 100644
index 0000000..0e9352d
--- /dev/null
+++ b/Examples/GameMenu_sample/GameMenu_sample.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/Examples/GameMenu_sample/sansation.ttf b/Examples/GameMenu_sample/sansation.ttf
new file mode 100644
index 0000000..d85fbc8
Binary files /dev/null and b/Examples/GameMenu_sample/sansation.ttf differ
diff --git a/Examples/GameMenu_sample/tests/sample_menu.cpp b/Examples/GameMenu_sample/tests/sample_menu.cpp
new file mode 100644
index 0000000..e23c467
--- /dev/null
+++ b/Examples/GameMenu_sample/tests/sample_menu.cpp
@@ -0,0 +1,37 @@
+#include "GameMenu\GameMenu.h"
+#include
+#include
+
+namespace test {
+ class testAction : public gmenu::Action {
+ public:
+ bool start() {
+ return true;
+ }
+ };
+}
+
+void main() {
+ sf::RenderWindow w( sf::VideoMode( 800, 600 ), "Sample Title", sf::Style::Close);
+ std::vector itemList;
+ std::string text[4] = { "Option1", "Option2","Option3", "Option4" };
+ gmenu::MenuItem item;
+ sf::Font font;
+ font.loadFromFile( "sansation.ttf" );
+ gmenu::Style style( font, font );
+ style.layout = gmenu::Layout::TitleLeft|gmenu::Layout::ItemLeft;
+ style.TitleColor = sf::Color::White;
+ style.ItemColor = sf::Color::Cyan;
+ style.Selected = sf::Color::Yellow;
+ style.PaddingTitle.top = 250;
+ style.PaddingItems.top = 30;
+ style.PaddingItems.left = -100;
+ for ( int i = 0; i < 4; ++i ) {
+ item.title = text[i];
+ item.action = std::make_shared < test::testAction>();
+ itemList.push_back( item );
+ }
+ gmenu::Menu menu( w, "Sample Menu", itemList, style );
+ menu.createMenu();
+}
+
diff --git a/GameMenu.sln b/GameMenu.sln
index d23161e..dd0444d 100644
--- a/GameMenu.sln
+++ b/GameMenu.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameMenu", "GameMenu.vcxproj", "{02870BF4-F128-4D1D-AB7C-6720D328CBDC}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameMenu_sample", "Examples\GameMenu_sample\GameMenu_sample.vcxproj", "{A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -21,6 +23,14 @@ Global
{02870BF4-F128-4D1D-AB7C-6720D328CBDC}.Release|x64.Build.0 = Release|x64
{02870BF4-F128-4D1D-AB7C-6720D328CBDC}.Release|x86.ActiveCfg = Release|Win32
{02870BF4-F128-4D1D-AB7C-6720D328CBDC}.Release|x86.Build.0 = Release|Win32
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Debug|x64.ActiveCfg = Debug|x64
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Debug|x64.Build.0 = Debug|x64
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Debug|x86.ActiveCfg = Debug|Win32
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Debug|x86.Build.0 = Debug|Win32
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Release|x64.ActiveCfg = Release|x64
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Release|x64.Build.0 = Release|x64
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Release|x86.ActiveCfg = Release|Win32
+ {A28CCAFC-BA0D-4833-8D9B-3D2F18B69FED}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/GameMenu.vcxproj b/GameMenu.vcxproj
index 3ec6633..4d10ad7 100644
--- a/GameMenu.vcxproj
+++ b/GameMenu.vcxproj
@@ -17,6 +17,14 @@
Release
x64
+
+ Test
+ Win32
+
+
+ Test
+ x64
+
{02870BF4-F128-4D1D-AB7C-6720D328CBDC}
@@ -51,6 +59,12 @@
true
Unicode
+
+ v140
+
+
+ v140
+
@@ -69,7 +83,19 @@
-
+
+ C:\Users\sidhi\libraries\SFML-2.4.1\include;C:\Users\sidhi\Desktop\Projects\GameMenu\include;$(IncludePath)
+
+
+ C:\Users\sidhi\libraries\SFML-2.4.1\include;C:\Users\sidhi\Desktop\Projects\GameMenu\include;$(IncludePath)
+ $(SolutionDir)lib\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)lib\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)lib\$(Platform)\$(Configuration)\
+
@@ -78,7 +104,7 @@
Disabled
WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
true
- C:\Users\sidhi\Desktop\Projects\GameMenu\include;C:\Users\sidhi\libraries\SFML-2.4.1\include;%(AdditionalIncludeDirectories)
+ C:\Users\sidhi\Desktop\Projects\GameMenu\include;%(AdditionalIncludeDirectories)
Windows
@@ -92,7 +118,7 @@
Disabled
_DEBUG;_LIB;%(PreprocessorDefinitions)
true
- C:\Users\sidhi\Desktop\Projects\GameMenu\include;C:\Users\sidhi\libraries\SFML-2.4.1\include;%(AdditionalIncludeDirectories)
+ C:\Users\sidhi\Desktop\Projects\GameMenu\include;%(AdditionalIncludeDirectories)
Windows
@@ -134,6 +160,18 @@
true
+
+
+ C:\Users\sidhi\Desktop\Projects\GameMenu\lib;C:\Users\sidhi\libraries\SFML-2.4.1\lib;%(AdditionalLibraryDirectories)
+ sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;%(AdditionalDependencies)
+
+
+
+
+ C:\Users\sidhi\Desktop\Projects\GameMenu\lib;C:\Users\sidhi\libraries\SFML-2.4.1\lib;%(AdditionalLibraryDirectories)
+ sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;%(AdditionalDependencies)
+
+
diff --git a/ReadMe.md b/ReadMe.md
index 495fb6d..911112e 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -12,23 +12,53 @@ The main purpose of the library is to make creation of menu's in games easy. Thi
####To use the library
- * First create a `gmenu::Menu` object, the will constructor need:
+ * First Need to decide the menu items, ie the options available (eg Start, Exit, Highscore etc)
+ * Create A vector of `gmenu::MenuItem`. Which contains the title of the item and Action it will perform.
- * `sf::Renderwindow *` the main screen where Menu will be displayed.
- * `std::string` Menu title - The main heading of menu
- * `sf::Font` The font title will be displayed in
- * `gmenu::MenuItems *` This is an pointer to array of **MenuItem - the structure representing a menu option**.
+ The definition of `gmenu::MenuItem` is:
+
+ ```cpp
+ struct MenuItem {
+ std::shared_ptr action;
+ std::string title;
+ };
+ ```
+
+ Here `gmenu::Action` is an abstract Class that acts as an interface.
+ The virtual method `bool DerivedAction::start()` will be called by the Menu when that item is selected.
+
+
+* Now create a style. `gmenu::Style`
+ * It requires two paramenters ( `sf::Font` ) to initialize.
+ * `gmenu::Style` can be used to define the look of the menu.
+
+ ```cpp
+ sf::Font &TitleFont;
+ sf::Font &ItemFont;
+
+ sf::Color TitleColor = sf::Color::Green;;
+ sf::Color ItemColor = sf::Color::Red ;
+ sf::Color Selected = sf::Color::Blue;
+
+ unsigned int TitleFontSize = 50;
+ unsigned int ItemFontSize = 20;
- ```cpp
- struct MenuItem {
- Action *action;
- std::string title;
- sf::Font font;
- };
- ```
- 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.
-
-* `menu.createMenu()` to start the menu
+ float MenuItemScaleFactor = 0.25; // This determines the distance between options.
+
+ int layout = Layout::Default; // Bitflag, Defines the layout of menu. eg. Layout::ItemLeft| Layout::TitleCentre
+
+ struct {
+ signed int top, left;
+ } PaddingTitle, PaddingItems; // this is the padding that will extra displacement that will always be added.
+ ```
+
+* Now create an object of `gmenuMenu` which require the following parameters:
+ * `sf::RenderWindow` : Where menu is to be created
+ * `std::vector` : Vector containing MenuItems.
+ * `gmenu::Style`: That defines the style.
+
+* Vola, your menu is ready to be used.
+
##Screenshots
diff --git a/Screenshots/2016-12-22 (1).png b/Screenshots/2016-12-22 (1).png
new file mode 100644
index 0000000..b83a53f
Binary files /dev/null and b/Screenshots/2016-12-22 (1).png differ
diff --git a/Screenshots/2016-12-22 (2).png b/Screenshots/2016-12-22 (2).png
new file mode 100644
index 0000000..da8fdef
Binary files /dev/null and b/Screenshots/2016-12-22 (2).png differ
diff --git a/Screenshots/2016-12-22.png b/Screenshots/2016-12-22.png
new file mode 100644
index 0000000..e78c41d
Binary files /dev/null and b/Screenshots/2016-12-22.png differ
diff --git a/Screenshots/Thumbs.db b/Screenshots/Thumbs.db
new file mode 100644
index 0000000..a8d7a4d
Binary files /dev/null and b/Screenshots/Thumbs.db differ
diff --git a/include/GameMenu/GameMenu.h b/include/GameMenu/GameMenu.h
index d13fafe..c09c875 100644
--- a/include/GameMenu/GameMenu.h
+++ b/include/GameMenu/GameMenu.h
@@ -10,6 +10,7 @@
/*--- Headers ---*/
#include
+#include
namespace gmenu {
@@ -28,24 +29,66 @@ namespace gmenu {
};
struct MenuItem {
- Action *action;
+ std::shared_ptr action;
std::string title;
- sf::Font font;
};
+ /* BitFlags for Different possible Layouts */
+ enum Layout {
+
+ TitleCentre = 1 << 0,
+ TitleRight = 1 << 1,
+ TitleLeft = 1 << 2,
+
+ ItemCentre = 1 << 3,
+ ItemRight = 1 << 4,
+ ItemLeft = 1 << 5,
+
+ Default = TitleCentre | ItemCentre,
+
+ };
+
+ /* Defines the style of the menu */
+ struct Style {
+ sf::Font &TitleFont;
+ sf::Font &ItemFont;
+
+ sf::Color TitleColor = sf::Color::Green;;
+ sf::Color ItemColor = sf::Color::Red ;
+ sf::Color Selected = sf::Color::Blue;
+
+ unsigned int TitleFontSize = 50;
+ unsigned int ItemFontSize = 20;
+
+ float MenuTitleScaleFactor = 1.25;
+ float MenuItemScaleFactor = 0.25;
+
+ struct {
+ signed int top, left;
+ } PaddingItems, PaddingTitle;
+
+ int layout = Layout::Default;
+ Style(sf::Font &mf, sf::Font &itmf):
+ TitleFont( mf ), ItemFont( itmf ), PaddingTitle {10,0}, PaddingItems {0,0}
+ {
+ }
+ };
+
+
+
+
class Menu {
/* Generic Menu - can be instantiated to generate a custom menu as needed over a sf::RenderWindow */
public:
- /* Only accesible constructor */
- Menu(sf::RenderWindow *window, std::string title,sf::Font titleFont, MenuItem* items, int8_t length)
- : Menu(window, title, titleFont) {
- setMenuItems(items, length);
+ /* Only available constructor */
+ Menu(sf::RenderWindow &wnd, std::string title, std::vector