summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-01-18 23:02:49 -0700
committerMike Buland <eichlan@xagasoft.com>2012-01-18 23:02:49 -0700
commit2d490ab892c7067eccd524dc67b5e12cf759f8fd (patch)
tree77ddec53dd29f0e46670818321c045609062ff7b /src
parent3afa514e11dc16e3a166b39ad411465abd971d8a (diff)
downloadstage-2d490ab892c7067eccd524dc67b5e12cf759f8fd.tar.gz
stage-2d490ab892c7067eccd524dc67b5e12cf759f8fd.tar.bz2
stage-2d490ab892c7067eccd524dc67b5e12cf759f8fd.tar.xz
stage-2d490ab892c7067eccd524dc67b5e12cf759f8fd.zip
Interface system works.
Diffstat (limited to 'src')
-rw-r--r--src/functiondisplay.cpp6
-rw-r--r--src/game.cpp2
-rw-r--r--src/gamestate.cpp3
-rw-r--r--src/gamestate.h6
-rw-r--r--src/interfaceconsole.cpp7
-rw-r--r--src/variable.cpp10
6 files changed, 29 insertions, 5 deletions
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 @@
1#include "functiondisplay.h" 1#include "functiondisplay.h"
2 2
3#include "smlnode.h"
3#include <bu/sio.h> 4#include <bu/sio.h>
4#include "gamestate.h" 5#include "gamestate.h"
6#include "interface.h"
5 7
6using namespace Bu; 8using namespace Bu;
7 9
@@ -16,7 +18,9 @@ FunctionDisplay::~FunctionDisplay()
16void FunctionDisplay::call( class GameState &gState ) 18void FunctionDisplay::call( class GameState &gState )
17{ 19{
18 Bu::String s = gState.popDeref().to( Variable::tString ).getString(); 20 Bu::String s = gState.popDeref().to( Variable::tString ).getString();
19 sio << format( s ) << sio.nl; 21 SmlNode *pNode = SmlNode::parse( s );
22 gState.getInterface()->display( pNode );
23 delete pNode;
20 24
21/* 25/*
22 Variable v = gState.popDeref(); 26 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 @@
7#include "functionrandom.h" 7#include "functionrandom.h"
8#include "functioninteger.h" 8#include "functioninteger.h"
9#include "functionfloat.h" 9#include "functionfloat.h"
10#include "functiondebugstring.h"
10 11
11Game::Game() 12Game::Game()
12{ 13{
@@ -18,6 +19,7 @@ Game::Game()
18 addFunction( new FunctionRandom() ); 19 addFunction( new FunctionRandom() );
19 addFunction( new FunctionInteger() ); 20 addFunction( new FunctionInteger() );
20 addFunction( new FunctionFloat() ); 21 addFunction( new FunctionFloat() );
22 addFunction( new FunctionDebugString() );
21} 23}
22 24
23Game::~Game() 25Game::~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 @@
8#include <bu/sio.h> 8#include <bu/sio.h>
9using namespace Bu; 9using namespace Bu;
10 10
11GameState::GameState( Game *pGame ) : 11GameState::GameState( Game *pGame, Interface *pIface ) :
12 pGame( pGame ), 12 pGame( pGame ),
13 pIface( pIface ),
13 bRunning( true ), 14 bRunning( true ),
14 bReturnOnly( false ) 15 bReturnOnly( false )
15{ 16{
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 @@
7#include "enums.h" 7#include "enums.h"
8 8
9class Game; 9class Game;
10class Interface;
10 11
11class GameState 12class GameState
12{ 13{
13public: 14public:
14 GameState( Game *pGame ); 15 GameState( Game *pGame, Interface *pIface );
15 virtual ~GameState(); 16 virtual ~GameState();
16 17
18 Interface *getInterface() { return pIface; }
19
17 void parse( class AstBranch *pAst ); 20 void parse( class AstBranch *pAst );
18 21
19 void init(); 22 void init();
@@ -46,6 +49,7 @@ private:
46 typedef Bu::List<Scope *> ScopeList; 49 typedef Bu::List<Scope *> ScopeList;
47 typedef Bu::Hash<Bu::String, Scope *> ScopeHash; 50 typedef Bu::Hash<Bu::String, Scope *> ScopeHash;
48 Game *pGame; 51 Game *pGame;
52 Interface *pIface;
49 Scope sGlobal; 53 Scope sGlobal;
50 Scope sPlayer; 54 Scope sPlayer;
51 ScopeList lsLocal; 55 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()
22 22
23void InterfaceConsole::run( Game *pGame ) 23void InterfaceConsole::run( Game *pGame )
24{ 24{
25 GameState gs( pGame ); 25 GameState gs( pGame, this );
26 gs.init(); 26 gs.init();
27 27
28 while( gs.isRunning() ) 28 while( gs.isRunning() )
@@ -56,6 +56,11 @@ void InterfaceConsole::appendToken( Bu::String &sCurLine,
56 56
57Bu::String InterfaceConsole::getVt100Style( const StyleStack &sStyle ) 57Bu::String InterfaceConsole::getVt100Style( const StyleStack &sStyle )
58{ 58{
59#ifdef WIN32
60 // Windows...we don't do colors for windows...
61 return "";
62#endif
63
59 if( sStyle.isEmpty() ) 64 if( sStyle.isEmpty() )
60 { 65 {
61 return "\x1B[0m"; 66 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 )
1111 return f << "(varref:\"" << v.rValue->sName << "\")"; 1111 return f << "(varref:\"" << v.rValue->sName << "\")";
1112 1112
1113 case Variable::tList: 1113 case Variable::tList:
1114 return f << *v.lValue; 1114 f << "\\[";
1115 for( Variable::VariableArray::iterator i = v.lValue->begin();
1116 i; i++ )
1117 {
1118 if( i != v.lValue->begin() )
1119 f << ", ";
1120 f << *i;
1121 }
1122 return f << "\\]";
1115 1123
1116 case Variable::tDictionary: 1124 case Variable::tDictionary:
1117 return f << *v.hValue; 1125 return f << *v.hValue;