Added very basic viewport size and position sending.

develop
Japa 2014-12-12 21:04:23 +05:30
parent d11df5b87f
commit 6982de88bd
2 changed files with 32 additions and 0 deletions

@ -176,3 +176,15 @@ message PlantList
{
repeated PlantDef plant_list = 1;
}
message ViewInfo
{
optional int32 view_pos_x = 1;
optional int32 view_pos_y = 2;
optional int32 view_pos_z = 3;
optional int32 view_size_x = 4;
optional int32 view_size_y = 5;
optional int32 cursor_pos_x = 6;
optional int32 cursor_pos_y = 7;
optional int32 cursor_pos_z = 8;
}

@ -44,6 +44,7 @@
#include "modules/Maps.h"
#include "modules/MapCache.h"
#include "modules/Materials.h"
#include "modules/Gui.h"
#include "TileTypes.h"
#include <vector>
@ -68,6 +69,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
static command_result GetPlantList(color_ostream &stream, const BlockRequest *in, PlantList *out);
static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in);
static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, UnitList *out);
static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in, ViewInfo *out);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC);
void FindChangedBlocks();
@ -114,6 +116,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetTiletypeList", GetTiletypeList);
svc->addFunction("GetPlantList", GetPlantList);
svc->addFunction("GetUnitList", GetUnitList);
svc->addFunction("GetViewInfo", GetViewInfo);
return svc;
}
@ -670,3 +673,20 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in,
}
return CR_OK;
}
static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in, ViewInfo *out)
{
int x, y, z, w, h, cx, cy, cz;
Gui::getWindowSize(w, h);
Gui::getViewCoords(x, y, z);
Gui::getCursorCoords(cx, cy, cz);
out->set_view_pos_x(x);
out->set_view_pos_y(y);
out->set_view_pos_z(z);
out->set_view_size_x(w);
out->set_view_size_y(h);
out->set_cursor_pos_x(x);
out->set_cursor_pos_y(y);
out->set_cursor_pos_z(z);
return CR_OK;
}