From 2d490ab892c7067eccd524dc67b5e12cf759f8fd Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 18 Jan 2012 23:02:49 -0700 Subject: Interface system works. --- src/functiondisplay.cpp | 6 +++++- src/game.cpp | 2 ++ src/gamestate.cpp | 3 ++- src/gamestate.h | 6 +++++- src/interfaceconsole.cpp | 7 ++++++- src/variable.cpp | 10 +++++++++- 6 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/functiondisplay.cpp b/src/functiondisplay.cpp index 7328293..2f2209c 100644 --- a/src/functiondisplay.cpp +++ b/src/functiondisplay.cpp @@ -1,7 +1,9 @@ #include "functiondisplay.h" +#include "smlnode.h" #include #include "gamestate.h" +#include "interface.h" using namespace Bu; @@ -16,7 +18,9 @@ FunctionDisplay::~FunctionDisplay() void FunctionDisplay::call( class GameState &gState ) { Bu::String s = gState.popDeref().to( Variable::tString ).getString(); - sio << format( s ) << sio.nl; + SmlNode *pNode = SmlNode::parse( s ); + gState.getInterface()->display( pNode ); + delete pNode; /* Variable v = gState.popDeref(); diff --git a/src/game.cpp b/src/game.cpp index 3a432d9..4971c4b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7,6 +7,7 @@ #include "functionrandom.h" #include "functioninteger.h" #include "functionfloat.h" +#include "functiondebugstring.h" Game::Game() { @@ -18,6 +19,7 @@ Game::Game() addFunction( new FunctionRandom() ); addFunction( new FunctionInteger() ); addFunction( new FunctionFloat() ); + addFunction( new FunctionDebugString() ); } Game::~Game() diff --git a/src/gamestate.cpp b/src/gamestate.cpp index 7777b1f..0b721d4 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -8,8 +8,9 @@ #include using namespace Bu; -GameState::GameState( Game *pGame ) : +GameState::GameState( Game *pGame, Interface *pIface ) : pGame( pGame ), + pIface( pIface ), bRunning( true ), bReturnOnly( false ) { diff --git a/src/gamestate.h b/src/gamestate.h index 9e7a060..e139dfe 100644 --- a/src/gamestate.h +++ b/src/gamestate.h @@ -7,13 +7,16 @@ #include "enums.h" class Game; +class Interface; class GameState { public: - GameState( Game *pGame ); + GameState( Game *pGame, Interface *pIface ); virtual ~GameState(); + Interface *getInterface() { return pIface; } + void parse( class AstBranch *pAst ); void init(); @@ -46,6 +49,7 @@ private: typedef Bu::List ScopeList; typedef Bu::Hash ScopeHash; Game *pGame; + Interface *pIface; Scope sGlobal; Scope sPlayer; ScopeList lsLocal; diff --git a/src/interfaceconsole.cpp b/src/interfaceconsole.cpp index b30733a..94b45b9 100644 --- a/src/interfaceconsole.cpp +++ b/src/interfaceconsole.cpp @@ -22,7 +22,7 @@ InterfaceConsole::~InterfaceConsole() void InterfaceConsole::run( Game *pGame ) { - GameState gs( pGame ); + GameState gs( pGame, this ); gs.init(); while( gs.isRunning() ) @@ -56,6 +56,11 @@ void InterfaceConsole::appendToken( Bu::String &sCurLine, Bu::String InterfaceConsole::getVt100Style( const StyleStack &sStyle ) { +#ifdef WIN32 + // Windows...we don't do colors for windows... + return ""; +#endif + if( sStyle.isEmpty() ) { return "\x1B[0m"; diff --git a/src/variable.cpp b/src/variable.cpp index 0c83133..4cbf97d 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -1111,7 +1111,15 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v ) return f << "(varref:\"" << v.rValue->sName << "\")"; case Variable::tList: - return f << *v.lValue; + f << "\\["; + for( Variable::VariableArray::iterator i = v.lValue->begin(); + i; i++ ) + { + if( i != v.lValue->begin() ) + f << ", "; + f << *i; + } + return f << "\\]"; case Variable::tDictionary: return f << *v.hValue; -- cgit v1.2.3