|
|
@ -57,7 +57,6 @@ void printDwarves(DFHack::API & DF)
|
|
|
|
|
|
|
|
|
|
|
|
bool getDwarfSelection(DFHack::API & DF, DFHack::t_creature & toChange,string & changeString, string & commandString,int & eraseAmount,int &dwarfNum,bool &isName)
|
|
|
|
bool getDwarfSelection(DFHack::API & DF, DFHack::t_creature & toChange,string & changeString, string & commandString,int & eraseAmount,int &dwarfNum,bool &isName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DF.ForceResume();
|
|
|
|
|
|
|
|
static string lastText;
|
|
|
|
static string lastText;
|
|
|
|
bool dwarfSuccess = false;
|
|
|
|
bool dwarfSuccess = false;
|
|
|
|
|
|
|
|
|
|
|
@ -65,26 +64,25 @@ bool getDwarfSelection(DFHack::API & DF, DFHack::t_creature & toChange,string &
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string input;
|
|
|
|
string input;
|
|
|
|
cout << "\nSelect Dwarf to Change or q to Quit" << endl;
|
|
|
|
cout << "\nSelect Dwarf to Change or q to Quit" << endl;
|
|
|
|
|
|
|
|
DF.Resume();
|
|
|
|
getline (cin, input);
|
|
|
|
getline (cin, input);
|
|
|
|
|
|
|
|
DF.Suspend();
|
|
|
|
if(input == "q")
|
|
|
|
if(input == "q")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(input == "r")
|
|
|
|
else if(input == "r")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DF.Suspend();
|
|
|
|
|
|
|
|
printDwarves(DF);
|
|
|
|
printDwarves(DF);
|
|
|
|
DF.Resume();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!input.empty())
|
|
|
|
else if(!input.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
int num;
|
|
|
|
stringstream(input) >> num;//= atol(input.c_str());
|
|
|
|
stringstream(input) >> num;//= atol(input.c_str());
|
|
|
|
DF.Suspend();
|
|
|
|
|
|
|
|
dwarfSuccess = DF.ReadCreature(num,toChange);
|
|
|
|
dwarfSuccess = DF.ReadCreature(num,toChange);
|
|
|
|
DF.Resume();
|
|
|
|
|
|
|
|
string type = creaturestypes[toChange.type].id;
|
|
|
|
string type = creaturestypes[toChange.type].id;
|
|
|
|
if(type != "DWARF"){
|
|
|
|
if(type != "DWARF")
|
|
|
|
|
|
|
|
{
|
|
|
|
dwarfSuccess = false;
|
|
|
|
dwarfSuccess = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -244,7 +242,8 @@ bool moveToBaseWindow(DFHack::API &DF)
|
|
|
|
DFHack::DFWindow * w = DF.getWindow();
|
|
|
|
DFHack::DFWindow * w = DF.getWindow();
|
|
|
|
DFHack::t_viewscreen current;
|
|
|
|
DFHack::t_viewscreen current;
|
|
|
|
DF.ReadViewScreen(current);
|
|
|
|
DF.ReadViewScreen(current);
|
|
|
|
while(buildingtypes[current.type] != string("viewscreen_dwarfmode")){
|
|
|
|
while(buildingtypes[current.type] != string("viewscreen_dwarfmode"))
|
|
|
|
|
|
|
|
{
|
|
|
|
w->TypeSpecial(DFHack::F9); // cancel out of text input in names
|
|
|
|
w->TypeSpecial(DFHack::F9); // cancel out of text input in names
|
|
|
|
// DF.TypeSpecial(DFHack::ENTER); // cancel out of text input in hotkeys
|
|
|
|
// DF.TypeSpecial(DFHack::ENTER); // cancel out of text input in hotkeys
|
|
|
|
w->TypeSpecial(DFHack::SPACE); // should move up a level
|
|
|
|
w->TypeSpecial(DFHack::SPACE); // should move up a level
|
|
|
@ -287,6 +286,7 @@ int main (void)
|
|
|
|
cerr << "DF not found" << endl;
|
|
|
|
cerr << "DF not found" << endl;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DF.Suspend();
|
|
|
|
//Need buildingtypes for the viewscreen vtables, this really should not be just buildings, as viewscreen and items both use the same interface
|
|
|
|
//Need buildingtypes for the viewscreen vtables, this really should not be just buildings, as viewscreen and items both use the same interface
|
|
|
|
uint32_t numBuildings = DF.InitReadBuildings(buildingtypes);
|
|
|
|
uint32_t numBuildings = DF.InitReadBuildings(buildingtypes);
|
|
|
|
|
|
|
|
|
|
|
@ -297,11 +297,9 @@ int main (void)
|
|
|
|
cerr << "Can't get the creature types." << endl;
|
|
|
|
cerr << "Can't get the creature types." << endl;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DF.InitReadNameTables(names);
|
|
|
|
DF.InitReadNameTables(names);
|
|
|
|
numCreatures = DF.InitReadCreatures();
|
|
|
|
numCreatures = DF.InitReadCreatures();
|
|
|
|
DF.InitViewAndCursor();
|
|
|
|
DF.InitViewAndCursor();
|
|
|
|
DF.Suspend();
|
|
|
|
|
|
|
|
printDwarves(DF);
|
|
|
|
printDwarves(DF);
|
|
|
|
DFHack::t_creature toChange;
|
|
|
|
DFHack::t_creature toChange;
|
|
|
|
string changeString,commandString;
|
|
|
|
string changeString,commandString;
|
|
|
@ -311,6 +309,11 @@ int main (void)
|
|
|
|
DFHack::DFWindow * w = DF.getWindow();
|
|
|
|
DFHack::DFWindow * w = DF.getWindow();
|
|
|
|
while(getDwarfSelection(DF,toChange,changeString,commandString,eraseAmount,toChangeNum,isName))
|
|
|
|
while(getDwarfSelection(DF,toChange,changeString,commandString,eraseAmount,toChangeNum,isName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// limit length, DF doesn't accept input after this point
|
|
|
|
|
|
|
|
if(changeString.size() > 39)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
changeString.resize(39);
|
|
|
|
|
|
|
|
}
|
|
|
|
start:
|
|
|
|
start:
|
|
|
|
bool completed = false;
|
|
|
|
bool completed = false;
|
|
|
|
if(moveToBaseWindow(DF) && setCursorToCreature(DF))
|
|
|
|
if(moveToBaseWindow(DF) && setCursorToCreature(DF))
|
|
|
|