Add ability for remotefortressreader.cpp to send over the current screen

develop
Japa 2016-03-20 16:27:05 +05:30
parent 2f86683d37
commit 14e61db99d
2 changed files with 33 additions and 0 deletions

@ -454,4 +454,18 @@ message PlantRaw
message PlantRawList
{
repeated PlantRaw plant_raws = 1;
}
message ScreenTile
{
optional uint32 character = 1;
optional uint32 foreground = 2;
optional uint32 background = 3;
}
message ScreenCapture
{
optional uint32 width = 1;
optional uint32 height = 2;
repeated ScreenTile tiles = 3;
}

@ -61,6 +61,7 @@
#include "df/caste_raw.h"
#include "df/enabler.h"
#include "df/graphic.h"
//DFhack specific headers
#include "modules/Maps.h"
@ -92,6 +93,7 @@ DFHACK_PLUGIN("RemoteFortressReader");
using namespace df::global;
#else
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(gps);
#endif
// Here go all the command declarations...
@ -114,6 +116,7 @@ static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessag
static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage *in, CreatureRawList *out);
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out);
static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, ScreenCapture *out);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos);
@ -167,6 +170,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetCreatureRaws", GetCreatureRaws);
svc->addFunction("GetWorldMapCenter", GetWorldMapCenter);
svc->addFunction("GetPlantRaws", GetPlantRaws);
svc->addFunction("CopyScreen", CopyScreen);
return svc;
}
@ -2033,3 +2037,18 @@ static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in
}
return CR_OK;
}
static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, ScreenCapture *out)
{
df::graphic * gps = df::global::gps;
out->set_width(gps->dimx);
out->set_height(gps->dimy);
for (int i = 0; i < (gps->dimx * gps->dimy); i++)
{
int index = i * 4;
auto tile = out->add_tiles();
tile->set_character(gps->screen[index]);
tile->set_foreground(gps->screen[index + 1] | (gps->screen[index + 3] * 8));
tile->set_background(gps->screen[index]);
}
}