本文整理汇总了C++中dfhack::Context::getGui方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getGui方法的具体用法?C++ Context::getGui怎么用?C++ Context::getGui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfhack::Context
的用法示例。
在下文中一共展示了Context::getGui方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
if(argc < 2) {
::std::cout << "gimme a file!" << ::std::endl;
return 1;
}
::std::ifstream map_in(argv[1]);
::std::vector< ::std::string > dig_map;
while (map_in.good() && !map_in.eof() && !map_in.bad()) {
::std::string line;
map_in >> line;
dig_map.push_back(line);
}
dig_map.resize(dig_map.size() - 1);
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF = DFMgr.getSingleContext();
try {
DF->Attach();
} catch (::std::exception& e) {
::std::cerr << e.what() << ::std::endl;
#ifndef LINUX_BUILD
::std::cin.ignore();
#endif
return 1;
}
DFHack::Maps *layers = DF->getMaps();
if (layers && layers->Start()) {
dig(layers, DF->getGui(), dig_map, true);
::std::cout << "Finished digging" << ::std::endl;
layers->Finish();
if (!DF->Detach()) {
::std::cerr << "Unable to detach DF process" << ::std::endl;
}
} else {
::std::cerr << "Unable to init map" << ::std::endl;
}
#ifndef LINUX_BUILD
::std::cout << "Done. Press any key to continue" << ::std::endl;
::std::cin.ignore();
#endif
return 0;
}
示例2: main
//.........这里部分代码省略.........
//Init
cerr << "Attaching to DF..." << endl;
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
// init the map
DFHack::Maps *Mapz = DF->getMaps();
if (!Mapz->Start())
{
cerr << "Can't init map. Exiting." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
Mapz->getSize(x_max,y_max,z_max);
//Get cursor
int32_t cursorX, cursorY, cursorZ;
DFHack::Gui *Gui = DF->getGui();
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if (-30000==cursorX)
{
cout << "No cursor position found. Exiting." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
//Block coordinates
int32_t bx=cursorX/16, by=cursorY/16, bz=cursorZ;
//Tile coordinates within block
int32_t tx=cursorX%16, ty=cursorY%16, tz=cursorZ;
/*
//Access the DF interface to pause the game.
//Copied from the reveal tool.
DFHack::Gui *Gui =DF->getGui();
cout << "Pausing..." << endl;
Gui->SetPauseState(true);
DF->Resume();
waitmsec(1000);
DF->Suspend();
*/
//Verify that every z-level at this location exists.
for (int32_t Z = 0; Z<= bz ;Z++)
{
if ( ! Mapz->isValidBlock(bx,by,Z) )
{
cout << "This block does't exist! Exiting." << endl;
示例3: main
//.........这里部分代码省略.........
buildCommands["building_pressure_platest"]="Tp";
buildCommands["building_cage_trapst"]="Tc";
buildCommands["building_stonefall_trapst"]="Ts";
buildCommands["building_weapon_trapst"]="Tw";
buildCommands["building_spikest"]="";
buildCommands["building_animal_trapst"]="m";
buildCommands["building_screw_pumpst"]="Ms";
buildCommands["building_water_wheelst"]="Mw";
buildCommands["building_windmillst"]="Mm";
buildCommands["building_gear_assemblyst"]="Mg";
buildCommands["building_horizontal_axlest"]="Mh";
buildCommands["building_vertical_axlest"]="Mv";
buildCommands["building_supportst"]="S";
buildCommands["building_cagest"]="j";
buildCommands["building_archery_targetst"]="A";
buildCommands["building_restraintst"]="v";
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
try
{
DF->Attach();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Gui *Gui = DF->getGui();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Process * p = DF->getProcess();
OffsetGroup * OG_Maps = mem->getGroup("Maps");
OffsetGroup * OG_MapBlock = OG_Maps->getGroup("block");
OffsetGroup * OG_LocalFt = OG_Maps->getGroup("features")->getGroup("local");
uint32_t designations = OG_MapBlock->getOffset("designation");
uint32_t block_feature1 = OG_MapBlock->getOffset("feature_local");
uint32_t block_feature2 = OG_MapBlock->getOffset("feature_global");
uint32_t region_x_offset = OG_Maps->getAddress("region_x");
uint32_t region_y_offset = OG_Maps->getAddress("region_y");
uint32_t region_z_offset = OG_Maps->getAddress("region_z");
uint32_t feature1_start_ptr = OG_LocalFt->getAddress("start_ptr");
int32_t regionX, regionY, regionZ;
// read position of the region inside DF world
p->readDWord (region_x_offset, (uint32_t &)regionX);
p->readDWord (region_y_offset, (uint32_t &)regionY);
p->readDWord (region_z_offset, (uint32_t &)regionZ);
while(1){
int32_t cx1,cy1,cz1;
cx1 = -30000;
while(cx1 == -30000)
{
DF->ForceResume();
cout << "Set cursor at first position, then press any key";
cin.ignore();
DF->Suspend();
Gui->getCursorCoords(cx1,cy1,cz1);
}
uint32_t tx1,ty1,tz1;
tx1 = cx1/16;
示例4: main
int main (int argc, char* argv[])
{
// Command line options
bool updown = false;
if(argc > 1 && strcmp(argv[1],"-x") == 0)
updown = true;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
uint32_t x_max,y_max,z_max;
DFHack::Maps * Maps = DF->getMaps();
DFHack::Gui * Gui = DF->getGui();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map. Make sure you have a map loaded in DF." << endl;
DF->Detach();
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
cerr << "Cursor is not active. Point the cursor at a vein." << endl;
DF->Resume();
cin.ignore();
DF->Suspend();
Gui->getCursorCoords(cx,cy,cz);
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
cerr << "I won't dig the borders. That would be cheating!" << endl;
DF->Detach();
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
MapCache * MCache = new MapCache(Maps);
DFHack::t_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{
cerr << "This tile is non-vein. Bye :)" << endl;
delete MCache;
DF->Detach();
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <DFHack::DFCoord> flood;
flood.push(xy);
while( !flood.empty() )
{
DFHack::DFCoord current = flood.top();
flood.pop();
int16_t vmat2 = MCache->veinMaterialAt(current);
tt = MCache->tiletypeAt(current);
if(!DFHack::isWallTerrain(tt))
continue;
if(vmat2!=veinmat)
continue;
// found a good tile, dig+unset material
DFHack::t_designation des = MCache->designationAt(current);
DFHack::t_designation des_minus;
DFHack::t_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
//.........这里部分代码省略.........
示例5: main
int main (void)
{
uint32_t x_max,y_max,z_max;
DFHack::designations40d designations;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Maps *Maps =DF->getMaps();
DFHack::Gui *Gui =DF->getGui();
// walk the map, save the hide bits, reveal.
cout << "Pausing..." << endl;
// horrible hack to make sure the pause is really set
// preblem here is that we could be 'arriving' at the wrong time and DF could be in the middle of a frame.
// that could mean that revealing, even with suspending DF's thread, would mean unleashing hell *in the same frame*
// this here hack sets the pause state, resumes DF, waits a second for it to enter the pause (I know, BS value.) and suspends.
Gui->SetPauseState(true);
DF->Resume();
waitmsec(1000);
DF->Suspend();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
cout << "Revealing, please wait..." << endl;
Maps->getSize(x_max,y_max,z_max);
vector <hideblock> hidesaved;
for(uint32_t x = 0; x< x_max;x++)
{
for(uint32_t y = 0; y< y_max;y++)
{
for(uint32_t z = 0; z< z_max;z++)
{
if(Maps->isValidBlock(x,y,z))
{
hideblock hb;
hb.x = x;
hb.y = y;
hb.z = z;
// read block designations
Maps->ReadDesignations(x,y,z, &designations);
// change the hidden flag to 0
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
hb.hiddens[i][j] = designations[i][j].bits.hidden;
designations[i][j].bits.hidden = 0;
}
hidesaved.push_back(hb);
// write the designations back
Maps->WriteDesignations(x,y,z, &designations);
}
}
}
}
// FIXME: force game pause here!
DF->Detach();
cout << "Map revealed. The game has been paused for you." << endl;
cout << "Unpausing can unleash the forces of hell!" << endl << endl;
cout << "Press any key to unreveal." << endl;
cout << "Close to keep the map revealed." << endl;
cin.ignore();
cout << "Unrevealing... please wait." << endl;
// FIXME: do some consistency checks here!
DF->Attach();
Maps = DF->getMaps();
Maps->Start();
for(int i = 0; i < hidesaved.size();i++)
{
hideblock & hb = hidesaved[i];
Maps->ReadDesignations(hb.x,hb.y,hb.z, &designations);
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
designations[i][j].bits.hidden = hb.hiddens[i][j];
}
Maps->WriteDesignations(hb.x,hb.y,hb.z, &designations);
}
#ifndef LINUX_BUILD
//.........这里部分代码省略.........
示例6: main
int main (void)
{
int32_t x,y,z,tx,ty;
//DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
//DFHack::t_temperatures temp1,temp2;
uint32_t x_max,y_max,z_max;
int32_t oldT, newT;
int count, dirty;
//Brush defaults
DFHack::TileShape BrushClass = DFHack::WALL;
DFHack::TileMaterial BrushMat = DFHack::tilematerial_invalid;
int BrushType = -1;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
DFHack::Maps * Maps;
DFHack::Gui * Gui;
try
{
DF=DFMgr.getSingleContext();
DF->Attach();
Maps = DF->getMaps();
Maps->Start();
Maps->getSize(x_max,y_max,z_max);
Gui = DF->getGui();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
bool end = false;
cout << "Welcome to the Tile Drawing tool.\nType 'help' or ? for a list of available commands, 'q' to quit" << endl;
string mode = "wall";
string command = "";
while(!end)
{
DF->Resume();
cout << endl << ":";
getline(cin, command);
int ch = command[0];
if(command.length()<=0) ch=0;
if( ((int)command.find("help")) >=0 ) ch='?'; //under windows, find was casting unsigned!
switch(ch)
{
case '?':
cout << "Modes:" << endl
<< "O - draw Open Space" << endl
<< "M - draw material only (shape unchanged)" << endl
<< "m number - use Material value entered" << endl
<< "r - use Rock/stone material" << endl
<< "l - use Soil material" << endl
<< "v - use Vein material" << endl
<< "H - draw tile shape only (material unchanged)" << endl
<< "h number - draw Tile Shape value entered" << endl
<< "w - draw Wall tiles" << endl
<< "f - draw Floor tiles" << endl
<< "t number - draw exact tile type entered" << endl
<< "Commands:" << endl
<< "p - print tile shapes and materials, and current brush" << endl
<< "P - print all tile types" << endl
<< "q - quit" << endl
<< "help OR ? - print this list of commands" << endl
<< "d - being drawing" << endl
<< endl
<< "Usage:\nChoose a mode (default is walls), then enter 'd' to being drawing.\nMove the cursor in DF wherever you want to draw.\nPress any key to pause drawing." << endl;
break;
case 'p':
//Classes
printf("\nTile Type Classes:\n");
for(int i=0;i<DFHack::tileshape_count;++i)
{
printf("%4i ; %s\n", i, DFHack::TileShapeString[i] ,0 );
}
//Materials
printf("\nTile Type Materials:\n");
for(int i=0;i<DFHack::tilematerial_count;++i)
{
printf("%4i ; %s\n", i, DFHack::TileMaterialString[i] ,0 );
}
//fall through...
case 10:
case 13:
case 0:
//Print current cursor & brush settings.
cout << "\nCurrent Brush:\n";
cout << "tile = ";
if(BrushClass<0) cout<<"(not drawing)"; else cout<<DFHack::TileShapeString[BrushClass]; cout << endl;
cout << "mat = ";
if(BrushMat<0) cout<<"(not drawing)"; else cout<<DFHack::TileMaterialString[BrushMat]; cout << endl;
cout << "type = ";
if(BrushType<0){
cout<<"(not drawing)";
//.........这里部分代码省略.........
示例7: main
int main (int argc, char** argv)
{
bool temporary_terminal = TemporaryTerminal();
bool quiet = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
}
int32_t x,y,z;
uint32_t x_max,y_max,z_max;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
DFHack::Maps * Maps;
DFHack::Gui * Position;
Brush * brush = new RectangleBrush(1,1);
string brushname = "point";
try
{
DF=DFMgr.getSingleContext();
DF->Attach();
Maps = DF->getMaps();
Maps->Start();
Maps->getSize(x_max,y_max,z_max);
Position = DF->getGui();
}
catch (exception& e)
{
cerr << e.what() << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
bool end = false;
cout << "Welcome to the liquid spawner.\nType 'help' or '?' for a list of available commands, 'q' to quit.\nPress return after a command to confirm." << endl;
string mode="magma";
string flowmode="f+";
string setmode ="s.";
unsigned int amount = 7;
int width = 1, height = 1, z_levels = 1;
while(!end)
{
DF->Resume();
string command = "";
cout <<"[" << mode << ":" << brushname << ":" << amount << ":" << flowmode << ":" << setmode << "]# ";
getline(cin, command);
if (std::cin.eof())
{
command = "q";
std::cout << std::endl; // No newline from the user here!
}
if(command=="help" || command == "?")
{
cout << "Modes:" << endl
<< "m - switch to magma" << endl
<< "w - switch to water" << endl
<< "o - make obsidian wall instead" << endl
<< "of - make obsidian floors" << endl
<< "rs - make a river source" << endl
<< "f - flow bits only" << endl
<< "Set-Modes (only for magma/water):" << endl
<< "s+ - only add" << endl
<< "s. - set" << endl
<< "s- - only remove" << endl
<< "Properties (only for magma/water):" << endl
<< "f+ - make the spawned liquid flow" << endl
<< "f. - don't change flow state (read state in flow mode)" << endl
<< "f- - make the spawned liquid static" << endl
<< "0-7 - set liquid amount" << endl
<< "Brush:" << endl
<< "point - single tile [p]" << endl
<< "range - block with cursor at bottom north-west [r]" << endl
<< " (any place, any size)" << endl
<< "block - DF map block with cursor in it" << endl
<< " (regular spaced 16x16x1 blocks)" << endl
<< "column - Column from cursor, up through free space" << endl
<< "Other:" << endl
<< "q - quit" << endl
<< "help or ? - print this list of commands" << endl
<< "empty line - put liquid" << endl
<< endl
<< "Usage: point the DF cursor at a tile you want to modify" << endl
<< "and use the commands available :)" << endl;
}
else if(command == "m")
{
mode = "magma";
}
else if(command == "o")
{
mode = "obsidian";
}
else if(command == "of")
{
//.........这里部分代码省略.........
示例8: main
int main (int argc, const char* argv[])
{
// Command line options
bool updown = false;
bool quiet = true;
// let's be more useful when double-clicked on windows
#ifndef LINUX_BUILD
quiet = false;
#endif
int dig_up_n = 5;
int dig_down_n = 5;
for(int i = 1; i < argc; i++)
{
string arg_cur = argv[i];
string arg_next = "";
int arg_next_int = -99999;
/* Check if argv[i+1] is a number >= 0 */
if (i < argc-1) {
arg_next = argv[i+1];
arg_next_int = strtoint(arg_next);
if (arg_next != "0" && arg_next_int == 0) {
arg_next_int = -99999;
}
}
if (arg_cur == "-x")
{
updown = true;
}
else if (arg_cur == "-q")
{
quiet = true;
}
else if(arg_cur == "-u" && i < argc-1)
{
if (arg_next_int < 0 || arg_next_int >= 99999) {
usage(argc, argv);
return 1;
}
dig_up_n = arg_next_int;
i++;
}
else if(arg_cur == "-d" && i < argc-1)
{
if (arg_next_int < 0 || arg_next_int >= 99999) {
usage(argc, argv);
return 1;
}
dig_down_n = arg_next_int;
i++;
}
else
{
usage(argc, argv);
return 1;
}
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << "Error getting context: " << e.what() << endl;
if (!quiet)
cin.ignore();
return 1;
}
uint32_t x_max,y_max,z_max;
DFHack::Maps * Maps = DF->getMaps();
DFHack::Gui * Gui = DF->getGui();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map. Make sure you have a map loaded in DF." << endl;
DF->Detach();
if (!quiet)
cin.ignore();
return 1;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
if (cx == -30000)
{
cerr << "Cursor is not active. Point the cursor at the position to dig at." << endl;
DF->Detach();
if (!quiet)
//.........这里部分代码省略.........
示例9: main
int main (int argc, char *argv[])
{
bool print_refs = false;
bool print_hex = false;
bool print_acc = false;
for(int i = 1; i < argc; i++)
{
char *arg = argv[i];
if (arg[0] != '-')
continue;
for (; *arg; arg++) {
switch (arg[0]) {
case 'r':
print_refs = true;
break;
case 'x':
print_hex = true;
break;
case 'a':
print_acc = true;
break;
}
}
}
DFHack::Process * p;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Materials * Materials = DF->getMaterials();
Materials->ReadAllMaterials();
DFHack::Gui * Gui = DF->getGui();
DFHack::Items * Items = DF->getItems();
Items->Start();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
p = DF->getProcess();
int32_t x,y,z;
Gui->getCursorCoords(x,y,z);
std::vector<uint32_t> p_items;
Items->readItemVector(p_items);
uint32_t size = p_items.size();
// FIXME: tools should never be exposed to DFHack internals!
DFHack::OffsetGroup* itemGroup = mem->getGroup("Items");
uint32_t ref_vector = itemGroup->getOffset("item_ref_vector");
for(size_t i = 0; i < size; i++)
{
DFHack::dfh_item itm;
memset(&itm, 0, sizeof(DFHack::dfh_item));
Items->readItem(p_items[i],itm);
if (x != -30000
&& !(itm.base.x == x && itm.base.y == y && itm.base.z == z
&& itm.base.flags.on_ground
&& !itm.base.flags.in_chest
&& !itm.base.flags.in_inventory
&& !itm.base.flags.in_building))
continue;
printf(
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] *%d %s - %s\n",
i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable,
itm.wear_level,
itm.quantity,
Items->getItemClass(itm).c_str(),
Items->getItemDescription(itm, Materials).c_str()
);
if (print_hex)
hexdump(DF,p_items[i],0x300);
if (print_acc)
cout << Items->dumpAccessors(itm) << endl;
if (print_refs) {
DFHack::DfVector<uint32_t> p_refs(p, itm.origin + ref_vector);
for (size_t j = 0; j < p_refs.size(); j++) {
uint32_t vptr = p->readDWord(p_refs[j]);
//.........这里部分代码省略.........