summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interface.h2
-rw-r--r--src/interfaceconsole.cpp16
-rw-r--r--src/interfaceconsole.h2
-rw-r--r--src/interfacegats.cpp4
-rw-r--r--src/interfacegats.h2
-rw-r--r--src/main.cpp18
6 files changed, 35 insertions, 9 deletions
diff --git a/src/interface.h b/src/interface.h
index bc4bd06..7f46e98 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -7,6 +7,8 @@ public:
7 Interface(); 7 Interface();
8 virtual ~Interface(); 8 virtual ~Interface();
9 9
10 virtual void run( class Game *pGame )=0;
11
10 virtual void display( const class SmlNode *pSml )=0; 12 virtual void display( const class SmlNode *pSml )=0;
11}; 13};
12 14
diff --git a/src/interfaceconsole.cpp b/src/interfaceconsole.cpp
index 05ca56c..b30733a 100644
--- a/src/interfaceconsole.cpp
+++ b/src/interfaceconsole.cpp
@@ -1,6 +1,7 @@
1#include "interfaceconsole.h" 1#include "interfaceconsole.h"
2 2
3#include "smlnode.h" 3#include "smlnode.h"
4#include "gamestate.h"
4 5
5#include <bu/sio.h> 6#include <bu/sio.h>
6 7
@@ -19,6 +20,21 @@ InterfaceConsole::~InterfaceConsole()
19{ 20{
20} 21}
21 22
23void InterfaceConsole::run( Game *pGame )
24{
25 GameState gs( pGame );
26 gs.init();
27
28 while( gs.isRunning() )
29 {
30 char buf[1024];
31 sio << sio.nl << "command> " << sio.flush;
32 fgets( buf, 1024, stdin );
33
34 gs.execCommand( buf );
35 }
36}
37
22void InterfaceConsole::appendToken( Bu::String &sCurLine, 38void InterfaceConsole::appendToken( Bu::String &sCurLine,
23 Bu::String &sNextToken, int &iLineLen, int &iNextLen ) 39 Bu::String &sNextToken, int &iLineLen, int &iNextLen )
24{ 40{
diff --git a/src/interfaceconsole.h b/src/interfaceconsole.h
index 9272087..17b07e4 100644
--- a/src/interfaceconsole.h
+++ b/src/interfaceconsole.h
@@ -12,6 +12,8 @@ public:
12 InterfaceConsole(); 12 InterfaceConsole();
13 virtual ~InterfaceConsole(); 13 virtual ~InterfaceConsole();
14 14
15 virtual void run( class Game *pGame );
16
15 virtual void display( const class SmlNode *pSml ); 17 virtual void display( const class SmlNode *pSml );
16 18
17private: 19private:
diff --git a/src/interfacegats.cpp b/src/interfacegats.cpp
index bd936c7..c14a8f2 100644
--- a/src/interfacegats.cpp
+++ b/src/interfacegats.cpp
@@ -18,6 +18,10 @@ InterfaceGats::~InterfaceGats()
18{ 18{
19} 19}
20 20
21void InterfaceGats::run( class Game *pGame )
22{
23}
24
21void InterfaceGats::display( const SmlNode *pSml ) 25void InterfaceGats::display( const SmlNode *pSml )
22{ 26{
23 switch( pSml->getType() ) 27 switch( pSml->getType() )
diff --git a/src/interfacegats.h b/src/interfacegats.h
index b04abb3..ff1f760 100644
--- a/src/interfacegats.h
+++ b/src/interfacegats.h
@@ -9,6 +9,8 @@ public:
9 InterfaceGats(); 9 InterfaceGats();
10 virtual ~InterfaceGats(); 10 virtual ~InterfaceGats();
11 11
12 virtual void run( class Game *pGame );
13
12 virtual void display( const class SmlNode *pSml ); 14 virtual void display( const class SmlNode *pSml );
13}; 15};
14 16
diff --git a/src/main.cpp b/src/main.cpp
index 262e7c4..9df79a4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,6 +3,8 @@
3#include "gamestate.h" 3#include "gamestate.h"
4#include "options.h" 4#include "options.h"
5 5
6#include "interfaceplugger.h"
7
6#include <stdlib.h> 8#include <stdlib.h>
7#include <time.h> 9#include <time.h>
8 10
@@ -25,21 +27,19 @@ int main( int argc, char *argv[] )
25 } 27 }
26 srandom( time( NULL ) ); 28 srandom( time( NULL ) );
27 29
30 Interface *pIface = InterfacePlugger::getInstance().instantiate(
31 opt.sInterface
32 );
33
28 GameBuilder bld; 34 GameBuilder bld;
29 bld.parse( opt.sFile ); 35 bld.parse( opt.sFile );
30 Game *pGame = bld.getGame(); 36 Game *pGame = bld.getGame();
31 37
32 GameState gs( pGame ); 38 pIface->run( pGame );
33 gs.init();
34 39
35 while( gs.isRunning() ) 40 delete pGame;
36 {
37 char buf[1024];
38 sio << sio.nl << "command> " << sio.flush;
39 fgets( buf, 1024, stdin );
40 41
41 gs.execCommand( buf ); 42 InterfacePlugger::getInstance().destroy( pIface );
42 }
43 43
44 return 0; 44 return 0;
45} 45}