2009-11-11 18:39:43 -07:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
#include <ctime>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-05-25 22:48:23 -06:00
|
|
|
#include <DFHack.h>
|
2009-11-11 18:39:43 -07:00
|
|
|
|
2011-03-01 14:18:26 -07:00
|
|
|
std::ostream &operator<<(std::ostream &stream, DFHack::t_gamemodes funzies)
|
|
|
|
{
|
|
|
|
char * gm[]=
|
|
|
|
{
|
|
|
|
"Fort",
|
|
|
|
"Adventurer",
|
|
|
|
"Kittens!",
|
|
|
|
"Menus",
|
|
|
|
"Arena",
|
|
|
|
};
|
|
|
|
char * cm[]=
|
|
|
|
{
|
|
|
|
"Managing",
|
|
|
|
"Direct Control",
|
|
|
|
"Kittens!",
|
|
|
|
"Menus"
|
|
|
|
};
|
|
|
|
if(funzies.game_mode <= DFHack::GM_MAX && funzies.control_mode <= DFHack::CM_MAX)
|
|
|
|
stream << "Game mode: " << gm[funzies.game_mode] << ", Control mode: " << cm[funzies.control_mode];
|
|
|
|
else
|
|
|
|
stream << "Game mode is too funky: (" << funzies.game_mode << "," << funzies.control_mode << ")";
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
2010-11-10 18:09:43 -07:00
|
|
|
int main (int argc, char** argv)
|
2009-11-11 18:39:43 -07:00
|
|
|
{
|
2010-11-10 18:09:43 -07:00
|
|
|
bool quiet = false;
|
|
|
|
for(int i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
string test = argv[i];
|
|
|
|
if(test == "-q")
|
|
|
|
{
|
|
|
|
quiet = true;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
}
|
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
DFHack::Position * Position = 0;
|
2011-02-28 22:59:23 -07:00
|
|
|
DFHack::World * World = 0;
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
2009-11-11 18:39:43 -07:00
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
|
|
|
Position = DF->getPosition();
|
2011-02-28 22:59:23 -07:00
|
|
|
World = DF->getWorld();
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2011-03-01 14:18:26 -07:00
|
|
|
DFHack::t_gamemodes gmm;
|
|
|
|
if(World->ReadGameMode(gmm))
|
2011-02-28 22:59:23 -07:00
|
|
|
{
|
2011-03-01 14:18:26 -07:00
|
|
|
cout << gmm << endl;
|
2011-02-28 22:59:23 -07:00
|
|
|
}
|
2010-04-04 16:48:19 -06:00
|
|
|
if (Position)
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
2011-02-28 22:59:23 -07:00
|
|
|
int32_t x,y,z;
|
|
|
|
int32_t width,height;
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-02-28 22:59:23 -07:00
|
|
|
if(Position->getViewCoords(x,y,z))
|
2010-03-26 06:01:46 -06:00
|
|
|
cout << "view coords: " << x << "/" << y << "/" << z << endl;
|
2011-02-28 22:59:23 -07:00
|
|
|
if(Position->getCursorCoords(x,y,z))
|
2010-03-26 06:01:46 -06:00
|
|
|
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
|
2011-02-28 22:59:23 -07:00
|
|
|
if(Position->getWindowSize(width,height))
|
|
|
|
cout << "window size : " << width << " " << height << endl;
|
2009-11-17 20:35:43 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
if(!DF->Detach())
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
|
|
|
cerr << "Can't detach from DF" << endl;
|
2009-11-11 18:39:43 -07:00
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2009-11-11 18:39:43 -07:00
|
|
|
#ifndef LINUX_BUILD
|
2010-11-10 18:32:33 -07:00
|
|
|
if(!quiet)
|
|
|
|
{
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
}
|
2009-11-11 18:39:43 -07:00
|
|
|
#endif
|
|
|
|
return 0;
|
2009-12-13 14:03:19 -07:00
|
|
|
}
|