Added a plugin that starts up and shuts down protobufs. Will add actual map export functionality to it tomorrow.
parent
1e59811e65
commit
fb41e457c4
@ -0,0 +1,35 @@
|
||||
PROJECT(mapexport)
|
||||
SET(MAPEXPORT_SOURCE_DIR ${dfhack_SOURCE_DIR}/plugins/mapexport)
|
||||
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/
|
||||
)
|
||||
|
||||
#Generated protobuf files and the headers they will require
|
||||
SET(PROJECT_HDRS
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/once.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/common.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/io/coded_stream.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/wire_format_lite_inl.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/generated_message_util.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/repeated_field.h
|
||||
${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/extension_set.h
|
||||
proto/Tile.pb.h
|
||||
)
|
||||
|
||||
SET(PROJECT_SRCS
|
||||
mapexport.cpp
|
||||
proto/Tile.pb.cc
|
||||
)
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT proto/Tile.pb.cc proto/Tile.pb.h
|
||||
COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto --cpp_out=proto ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto
|
||||
DEPENDS protoc ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto
|
||||
)
|
||||
|
||||
DFHACK_PLUGIN(mapexport ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES libprotobuf-lite)
|
@ -0,0 +1,45 @@
|
||||
#include "Core.h"
|
||||
#include <Console.h>
|
||||
#include <Export.h>
|
||||
#include <PluginManager.h>
|
||||
#include "proto/Tile.pb.h"
|
||||
using namespace DFHack;
|
||||
|
||||
DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters);
|
||||
|
||||
DFhackCExport const char * plugin_name ( void )
|
||||
{
|
||||
return "mapexport";
|
||||
}
|
||||
|
||||
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
||||
{
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
commands.clear();
|
||||
commands.push_back(PluginCommand("mapexport", "Starts up and shuts down protobufs.", mapexport, true));
|
||||
return CR_OK;
|
||||
}
|
||||
|
||||
DFhackCExport command_result plugin_shutdown ( Core * c )
|
||||
{
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
return CR_OK;
|
||||
}
|
||||
|
||||
DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters)
|
||||
{
|
||||
for(int i = 0; i < parameters.size();i++)
|
||||
{
|
||||
if(parameters[i] == "help" || parameters[i] == "?")
|
||||
{
|
||||
c->con.print("This doesn't do anything at all yet.\n");
|
||||
return CR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
c->Suspend();
|
||||
dfproto::Tile tile;
|
||||
c->con.print("Hold on, I'm working on it!\n");
|
||||
c->Resume();
|
||||
return CR_OK;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dfproto;
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
message Tile
|
||||
{
|
||||
required uint32 x = 1;
|
||||
required uint32 y = 2;
|
||||
required uint32 tiletype = 3;
|
||||
optional uint32 material = 4;
|
||||
}
|
Loading…
Reference in New Issue