From 18c7bede5b86234116a76fd6571e190b1eb9e711 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jan 2012 18:40:29 -0700 Subject: Actually works with windows now. --- mingw.bld | 2 +- src/interface.h | 2 ++ src/interfaceconsole.cpp | 16 ++++++++++++++++ src/interfaceconsole.h | 2 ++ src/interfacegats.cpp | 4 ++++ src/interfacegats.h | 2 ++ src/main.cpp | 18 +++++++++--------- 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/mingw.bld b/mingw.bld index e4f923f..a8bea52 100644 --- a/mingw.bld +++ b/mingw.bld @@ -53,7 +53,7 @@ target "stage.exe" CXXFLAGS += "-O2 -frtti -fexceptions -Wall -Ilibbu++/support/windows -Isrc"; - LDFLAGS += "-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -lmingw32 -Llibbu++ -lbu++win -Llibbu++/support/windows -lbz2"; + LDFLAGS += "-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -lmingw32 -Llibbu++ -lbu++win -Llibbu++/support/windows -lbz2 -Wl,-subsystem,console"; CXXFLAGS += "-Ilibbu++"; } 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: Interface(); virtual ~Interface(); + virtual void run( class Game *pGame )=0; + virtual void display( const class SmlNode *pSml )=0; }; 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 @@ #include "interfaceconsole.h" #include "smlnode.h" +#include "gamestate.h" #include @@ -19,6 +20,21 @@ InterfaceConsole::~InterfaceConsole() { } +void InterfaceConsole::run( Game *pGame ) +{ + GameState gs( pGame ); + gs.init(); + + while( gs.isRunning() ) + { + char buf[1024]; + sio << sio.nl << "command> " << sio.flush; + fgets( buf, 1024, stdin ); + + gs.execCommand( buf ); + } +} + void InterfaceConsole::appendToken( Bu::String &sCurLine, Bu::String &sNextToken, int &iLineLen, int &iNextLen ) { 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: InterfaceConsole(); virtual ~InterfaceConsole(); + virtual void run( class Game *pGame ); + virtual void display( const class SmlNode *pSml ); private: 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() { } +void InterfaceGats::run( class Game *pGame ) +{ +} + void InterfaceGats::display( const SmlNode *pSml ) { 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: InterfaceGats(); virtual ~InterfaceGats(); + virtual void run( class Game *pGame ); + virtual void display( const class SmlNode *pSml ); }; 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 @@ #include "gamestate.h" #include "options.h" +#include "interfaceplugger.h" + #include #include @@ -25,21 +27,19 @@ int main( int argc, char *argv[] ) } srandom( time( NULL ) ); + Interface *pIface = InterfacePlugger::getInstance().instantiate( + opt.sInterface + ); + GameBuilder bld; bld.parse( opt.sFile ); Game *pGame = bld.getGame(); - GameState gs( pGame ); - gs.init(); + pIface->run( pGame ); - while( gs.isRunning() ) - { - char buf[1024]; - sio << sio.nl << "command> " << sio.flush; - fgets( buf, 1024, stdin ); + delete pGame; - gs.execCommand( buf ); - } + InterfacePlugger::getInstance().destroy( pIface ); return 0; } -- cgit v1.2.3