本文整理汇总了C++中dfhack::Context::getTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getTranslation方法的具体用法?C++ Context::getTranslation怎么用?C++ Context::getTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfhack::Context
的用法示例。
在下文中一共展示了Context::getTranslation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int numargs, char ** args)
{
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
DFHack::Process * p;
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
p = DF->getProcess();
string check = "";
if(numargs == 2)
check = args[1];
DFHack::Creatures * Creatures = DF->getCreatures();
Materials = DF->getMaterials();
DFHack::Translation * Tran = DF->getTranslation();
uint32_t numCreatures;
if(!Creatures->Start(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if(!numCreatures)
{
cerr << "No creatures to print" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
mem = DF->getMemoryInfo();
if(!Materials->ReadInorganicMaterials())
{
cerr << "Can't get the inorganics types." << endl;
return 1;
}
if(!Materials->ReadCreatureTypesEx())
{
cerr << "Can't get the creature types." << endl;
return 1;
}
if(!Tran->Start())
{
cerr << "Can't get name tables" << endl;
return 1;
}
vector<uint32_t> addrs;
//DF.InitViewAndCursor();
for(uint32_t i = 0; i < numCreatures; i++)
{
DFHack::t_creature temp;
unsigned int current_job;
unsigned int mat_start;
unsigned int mat_end;
unsigned int j,k;
unsigned int matptr;
Creatures->ReadCreature(i,temp);
if(temp.mood>=0)
{
current_job = p->readDWord(temp.origin + 0x390);
if(current_job == 0)
continue;
mat_start = p->readDWord(current_job + 0xa4 + 4*3);
mat_end = p->readDWord(current_job + 0xa4 + 4*4);
for(j=mat_start;j<mat_end;j+=4)
{
matptr = p->readDWord(j);
for(k=0;k<4;k++)
printf("%.4X ", p->readWord(matptr + k*2));
for(k=0;k<3;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x8));
for(k=0;k<2;k++)
printf("%.4X ", p->readWord(matptr + k*2 + 0x14));
for(k=0;k<3;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x18));
for(k=0;k<4;k++)
printf("%.2X ", p->readByte(matptr + k + 0x24));
for(k=0;k<6;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x28));
for(k=0;k<4;k++)
printf("%.2X ", p->readByte(matptr + k + 0x40));
for(k=0;k<9;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x44));
printf(" [%p]\n", matptr);
}
//.........这里部分代码省略.........
示例2: main
int main (int numargs, char ** args)
{
DFHack::World * World;
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;
}
string check = "";
if(numargs == 2)
check = args[1];
Creatures = DF->getCreatures();
Materials = DF->getMaterials();
World = DF->getWorld();
current_year = World->ReadCurrentYear();
current_tick = World->ReadCurrentTick();
DFHack::Translation * Tran = DF->getTranslation();
uint32_t numCreatures;
if(!Creatures->Start(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if(!numCreatures)
{
cerr << "No creatures to print" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
mem = DF->getMemoryInfo();
Materials->ReadInorganicMaterials();
Materials->ReadOrganicMaterials();
Materials->ReadWoodMaterials();
Materials->ReadPlantMaterials();
Materials->ReadCreatureTypes();
Materials->ReadCreatureTypesEx();
Materials->ReadDescriptorColors();
if(!Tran->Start())
{
cerr << "Can't get name tables" << endl;
return 1;
}
vector<uint32_t> addrs;
//DF.InitViewAndCursor();
for(uint32_t i = 0; i < numCreatures; i++)
{
printf("%d/%d\n", i, numCreatures);
DFHack::t_creature temp;
Creatures->ReadCreature(i,temp);
if(check.empty() || string(Materials->raceEx[temp.race].rawname) == check)
{
cout << "index " << i << " ";
printCreature(DF,temp);
addrs.push_back(temp.origin);
}
printf("!\n");
}
if(addrs.size() <= 10)
{
interleave_hex(DF,addrs,200);
}
/*
uint32_t currentIdx;
DFHack::t_creature currentCreature;
DF.getCurrentCursorCreature(currentIdx);
cout << "current creature at index " << currentIdx << endl;
DF.ReadCreature(currentIdx, currentCreature);
printCreature(DF,currentCreature);
*/
Creatures->Finish();
DF->Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}