|
|
@ -19,7 +19,10 @@ using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("kittens");
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(ui);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
|
|
|
|
|
|
|
|
//FIXME: possible race conditions with calling kittens from the IO thread and shutdown from Core.
|
|
|
|
//FIXME: possible race conditions with calling kittens from the IO thread and shutdown from Core.
|
|
|
|
volatile bool shutdown_flag = false;
|
|
|
|
volatile bool shutdown_flag = false;
|
|
|
@ -30,7 +33,7 @@ bool trackpos_flg = false;
|
|
|
|
bool statetrack = false;
|
|
|
|
bool statetrack = false;
|
|
|
|
int32_t last_designation[3] = {-30000, -30000, -30000};
|
|
|
|
int32_t last_designation[3] = {-30000, -30000, -30000};
|
|
|
|
int32_t last_mouse[2] = {-1, -1};
|
|
|
|
int32_t last_mouse[2] = {-1, -1};
|
|
|
|
uint32_t last_menu = 0;
|
|
|
|
df::ui_sidebar_mode last_menu = df::ui_sidebar_mode::Default;
|
|
|
|
uint64_t timeLast = 0;
|
|
|
|
uint64_t timeLast = 0;
|
|
|
|
|
|
|
|
|
|
|
|
command_result kittens (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result kittens (color_ostream &out, vector <string> & parameters);
|
|
|
@ -40,8 +43,6 @@ command_result trackpos (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result trackstate (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result trackstate (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result colormods (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result colormods (color_ostream &out, vector <string> & parameters);
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("kittens");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand("nyan","NYAN CAT INVASION!",kittens));
|
|
|
|
commands.push_back(PluginCommand("nyan","NYAN CAT INVASION!",kittens));
|
|
|
@ -103,9 +104,9 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(trackmenu_flg)
|
|
|
|
if(trackmenu_flg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (last_menu != df::global::ui->main.mode)
|
|
|
|
if (last_menu != ui->main.mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
last_menu = df::global::ui->main.mode;
|
|
|
|
last_menu = ui->main.mode;
|
|
|
|
out.print("Menu: %d\n",last_menu);
|
|
|
|
out.print("Menu: %d\n",last_menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -140,21 +141,13 @@ command_result trackmenu (color_ostream &out, vector <string> & parameters)
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if(df::global::ui)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
trackmenu_flg = true;
|
|
|
|
trackmenu_flg = true;
|
|
|
|
is_enabled = true;
|
|
|
|
is_enabled = true;
|
|
|
|
last_menu = df::global::ui->main.mode;
|
|
|
|
last_menu = ui->main.mode;
|
|
|
|
out.print("Menu: %d\n",last_menu);
|
|
|
|
out.print("Menu: %d\n",last_menu);
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
out.printerr("Can't read menu state\n");
|
|
|
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
command_result trackpos (color_ostream &out, vector <string> & parameters)
|
|
|
|
command_result trackpos (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -172,13 +165,12 @@ command_result trackstate ( color_ostream& out, vector< string >& parameters )
|
|
|
|
command_result colormods (color_ostream &out, vector <string> & parameters)
|
|
|
|
command_result colormods (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CoreSuspender suspend;
|
|
|
|
CoreSuspender suspend;
|
|
|
|
auto & vec = df::global::world->raws.creatures.alphabetic;
|
|
|
|
auto & vec = world->raws.creatures.alphabetic;
|
|
|
|
for(int i = 0; i < vec.size();i++)
|
|
|
|
for(df::creature_raw* rawlion : vec)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::creature_raw* rawlion = vec[i];
|
|
|
|
|
|
|
|
df::caste_raw * caste = rawlion->caste[0];
|
|
|
|
df::caste_raw * caste = rawlion->caste[0];
|
|
|
|
out.print("%s\nCaste addr 0x%x\n",rawlion->creature_id.c_str(), &caste->color_modifiers);
|
|
|
|
out.print("%s\nCaste addr 0x%x\n",rawlion->creature_id.c_str(), &caste->color_modifiers);
|
|
|
|
for(int j = 0; j < caste->color_modifiers.size();j++)
|
|
|
|
for(size_t j = 0; j < caste->color_modifiers.size();j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.print("mod %d: 0x%x\n", j, caste->color_modifiers[j]);
|
|
|
|
out.print("mod %d: 0x%x\n", j, caste->color_modifiers[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -284,7 +276,7 @@ command_result kittens (color_ostream &out, vector <string> & parameters)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
con.flush();
|
|
|
|
con.flush();
|
|
|
|
con.msleep(60);
|
|
|
|
con.msleep(60);
|
|
|
|
((int&)color) ++;
|
|
|
|
color = Console::color_value(int(color) + 1);
|
|
|
|
if(color > COLOR_MAX)
|
|
|
|
if(color > COLOR_MAX)
|
|
|
|
color = COLOR_BLUE;
|
|
|
|
color = COLOR_BLUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|