diff options
-rw-r--r-- | default.bld | 25 | ||||
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/options.cpp | 25 | ||||
-rw-r--r-- | src/options.h | 20 |
5 files changed, 75 insertions, 0 deletions
diff --git a/default.bld b/default.bld index 0c7f50c..5c3d9b1 100644 --- a/default.bld +++ b/default.bld | |||
@@ -1,4 +1,29 @@ | |||
1 | 1 | ||
2 | target "src/version.h" | ||
3 | { | ||
4 | requires ".git"; | ||
5 | profile "build" | ||
6 | { | ||
7 | fh = open("src/version.h.tmp"); | ||
8 | fh.write( | ||
9 | "#ifndef VERSION_H\n" | ||
10 | "#define VERSION_H\n" | ||
11 | "\n" | ||
12 | "#define FULLVER \"$(git describe)\"\n" | ||
13 | "\n" | ||
14 | "#endif"); | ||
15 | fh.close(); | ||
16 | if "$(cmp src/version.h.tmp src/version.h)" == "" then | ||
17 | { | ||
18 | execute("rm src/version.h.tmp"); | ||
19 | } | ||
20 | else | ||
21 | { | ||
22 | execute("mv src/version.h.tmp src/version.h"); | ||
23 | } | ||
24 | } | ||
25 | } | ||
26 | |||
2 | CC="g++"; | 27 | CC="g++"; |
3 | target "stage" | 28 | target "stage" |
4 | { | 29 | { |
diff --git a/src/.gitignore b/src/.gitignore index 6f29247..3492adb 100644 --- a/src/.gitignore +++ b/src/.gitignore | |||
@@ -2,3 +2,4 @@ parser.tab.c | |||
2 | parser.tab.h | 2 | parser.tab.h |
3 | parser.yy.c | 3 | parser.yy.c |
4 | parser.yy.h | 4 | parser.yy.h |
5 | version.h | ||
diff --git a/src/main.cpp b/src/main.cpp index 6646d79..7e2ef7f 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "gamebuilder.h" | 1 | #include "gamebuilder.h" |
2 | #include "game.h" | 2 | #include "game.h" |
3 | #include "gamestate.h" | 3 | #include "gamestate.h" |
4 | #include "options.h" | ||
4 | 5 | ||
5 | #include <stdlib.h> | 6 | #include <stdlib.h> |
6 | #include <time.h> | 7 | #include <time.h> |
@@ -14,6 +15,9 @@ using namespace Bu; | |||
14 | 15 | ||
15 | int main( int argc, char *argv[] ) | 16 | int main( int argc, char *argv[] ) |
16 | { | 17 | { |
18 | Options &opt = Options::getInstance(); | ||
19 | opt.parse( argc, argv ); | ||
20 | |||
17 | srandom( time( NULL ) ); | 21 | srandom( time( NULL ) ); |
18 | 22 | ||
19 | GameBuilder bld; | 23 | GameBuilder bld; |
diff --git a/src/options.cpp b/src/options.cpp new file mode 100644 index 0000000..7953add --- /dev/null +++ b/src/options.cpp | |||
@@ -0,0 +1,25 @@ | |||
1 | #include "options.h" | ||
2 | #include "version.h" | ||
3 | |||
4 | #include <bu/optparser.h> | ||
5 | |||
6 | Options::Options() | ||
7 | { | ||
8 | } | ||
9 | |||
10 | Options::~Options() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | void Options::parse( int argc, char *argv[] ) | ||
15 | { | ||
16 | Bu::OptParser opt; | ||
17 | |||
18 | opt.addHelpBanner("STAGE v" FULLVER | ||
19 | " - Simple, Textual, Adventure Game Environment"); | ||
20 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + | ||
21 | " [options] <filename>\n"); | ||
22 | opt.addHelpOption('h', "help"); | ||
23 | opt.parse( argc, argv ); | ||
24 | } | ||
25 | |||
diff --git a/src/options.h b/src/options.h new file mode 100644 index 0000000..42caa53 --- /dev/null +++ b/src/options.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef OPTIONS_H | ||
2 | #define OPTIONS_H | ||
3 | |||
4 | #include <bu/singleton.h> | ||
5 | #include <bu/string.h> | ||
6 | |||
7 | class Options : public Bu::Singleton<Options> | ||
8 | { | ||
9 | friend class Bu::Singleton<Options>; | ||
10 | private: | ||
11 | Options(); | ||
12 | virtual ~Options(); | ||
13 | |||
14 | public: | ||
15 | void parse( int argc, char *argv[] ); | ||
16 | |||
17 | Bu::String sFile; | ||
18 | }; | ||
19 | |||
20 | #endif | ||