summaryrefslogtreecommitdiff
path: root/src/interfaceconsole.cpp
blob: e07bffe0eedc593a4fc4fa0fc4731811bf66dcb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "interfaceconsole.h"

#include "smlnode.h"
#include "gamestate.h"

#include <bu/sio.h>

#include <bu/plugger.h>

#include "smlrenderervt100.h"
#include <gats/types.h>
#include <gats/gatsstream.h>
#include <bu/file.h>

PluginInterface3( plugin_interface_console, console, InterfaceConsole,
		Interface, "Mike Buland", 1, 0 );

using namespace Bu;

InterfaceConsole::InterfaceConsole()
{
}

InterfaceConsole::~InterfaceConsole()
{
}

void InterfaceConsole::run( Game *pGame )
{
	GameState gs( pGame, this );
	gs.init();

	int iStep = 0;
	while( gs.isRunning() )
	{
		char buf[1024];
		sio << sio.nl << "command> " << sio.flush;
		fgets( buf, 1024, stdin );

		gs.execCommand( buf );

		Gats::Object *pObj = gs.toGats();
		File fOut( Bu::String("test-%1.save").arg( iStep++ ), File::WriteNew );
		Gats::GatsStream gs( fOut );
		gs.writeObject( pObj );

		delete pObj;
	}	
}

void InterfaceConsole::display( const class SmlNode *pSml )
{
	SmlRendererVt100 rend;
	rend.render( sio, pSml );
}