First dfusion plugin commit

Signed-off-by: Warmist <Warmist@gmail.com>
develop
Warmist 2011-07-16 17:22:45 +03:00
parent 70dbc3cef9
commit 75cffcb347
3 changed files with 153 additions and 0 deletions

@ -97,6 +97,7 @@ ENDMACRO(DFHACK_PLUGIN)
#RECURSE_DIRS() #RECURSE_DIRS()
add_subdirectory (qtplug) add_subdirectory (qtplug)
add_subdirectory (dfusion)
DFHACK_PLUGIN(reveal reveal.cpp) DFHACK_PLUGIN(reveal reveal.cpp)
OPTION(BUILD_KITTENS "Build the kittens plugin." OFF) OPTION(BUILD_KITTENS "Build the kittens plugin." OFF)

@ -0,0 +1,100 @@
#FIXME: inherit all macros and stuff from the dfhack SDK
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32")
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32")
ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO(CAR)
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO(CDR)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF (${value} STREQUAL ${value2})
ENDFOREACH (value2)
ENDMACRO(LIST_CONTAINS)
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name)
LIST_CONTAINS(is_option ${arg} ${option_names})
IF (is_option)
SET(${prefix}_${arg} TRUE)
ELSE (is_option)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option)
ENDIF (is_arg_name)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DFHACK_PLUGIN_OUTPUT_DIR})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${DFHACK_PLUGIN_OUTPUT_DIR})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${DFHACK_PLUGIN_OUTPUT_DIR})
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
#MESSAGE("Depends: ${PLUGIN_DEPENDS}")
#IF (PLUGIN_AUTO_INSTALL)
# MESSAGE("Auto install")
#ENDIF (PLUGIN_AUTO_INSTALL)
#IF (PLUGIN_NO_MODULE)
# MESSAGE("No module")
#ENDIF (PLUGIN_NO_MODULE)
ENDMACRO(DFHACK_PLUGIN)
# add all subdirectories. can be used in those subdirectories, etc...
# needs a re-run of cmake to pick up the changes
#macro(RECURSE_DIRS)
# file(GLOB sub-dir RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
# foreach(dir ${sub-dir})
# if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
# add_subdirectory (${dir})
# endif()
# endforeach()
#endmacro()
#RECURSE_DIRS()
DFHACK_PLUGIN(dfusion dfusion.cpp)

@ -0,0 +1,52 @@
#include <dfhack/Core.h>
#include <dfhack/Console.h>
#include <dfhack/Export.h>
#include <dfhack/PluginManager.h>
#include <vector>
#include <string>
using std::vector;
using std::string;
using namespace DFHack;
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void )
{
return "dfusion";
}
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{
commands.clear();
commands.push_back(PluginCommand("DFusion","Init dfusion system.",dfusion));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( Core * c )
{
// shutdown stuff
return CR_OK;
}
DFhackCExport command_result plugin_onupdate ( Core * c )
{
/*if(timering == true)
{
uint64_t time2 = GetTimeMs64();
uint64_t delta = time2-timeLast;
timeLast = time2;
c->con.print("Time delta = %d ms\n", delta);
}
return CR_OK;*/
return CR_OK;
}
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters)
{
// do stuff
return CR_OK;
}