dfhack/examples/position.cpp

62 lines
1.4 KiB
C++

// Just show some position data
#include <iostream>
#include <climits>
#include <integers.h>
#include <vector>
#include <ctime>
using namespace std;
#include <DFTypes.h>
2010-05-23 15:06:10 -06:00
#include <DFContextManager.h>
#include <DFContext.h>
2010-04-04 16:48:19 -06:00
#include <modules/Position.h>
int main (void)
{
2010-04-04 16:48:19 -06:00
DFHack::Position * Position = 0;
2010-05-23 15:06:10 -06:00
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
2010-05-23 15:06:10 -06:00
DF = DFMgr.getSingleContext();
DF->Attach();
Position = DF->getPosition();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
2010-04-04 16:48:19 -06:00
if (Position)
{
int32_t x,y,z;
int32_t width,height;
2010-04-04 16:48:19 -06:00
if(Position->getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
2010-04-04 16:48:19 -06:00
if(Position->getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
2010-04-04 16:48:19 -06:00
if(Position->getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}
else
{
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
}
2010-05-23 15:06:10 -06:00
if(!DF->Detach())
{
cerr << "Can't detach from DF" << endl;
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}