diff --git a/CMakeLists.txt b/CMakeLists.txt index 21013dea2..175542cc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") ENDIF() SET(DFHACK_OUTPUT_DIR "${dfhack_BINARY_DIR}/bin" CACHE STRING "Where should be the produced libraries and binaries stored.") +SET(DFHACK_PLUGIN_OUTPUT_DIR "${DFHACK_OUTPUT_DIR}/plugins") ## where to put things during the build (force MSVC to behave) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${DFHACK_OUTPUT_DIR}) @@ -45,6 +46,8 @@ SET(DFHACK_LIBRARY_DESTINATION .) SET(DFHACK_BINARY_DESTINATION .) # Memory.xml goes here: SET(DFHACK_DATA_DESTINATION .) +# Plugins go here +SET(DFHACK_PLUGIN_DESTINATION plugins) # Includes go here: SET(DFHACK_INCLUDES_DESTINATION dev/include) # the Windows .lib files go here: diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 755aa2f07..04df47a5b 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -131,11 +131,12 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) -ADD_CUSTOM_TARGET( memxmlcopy +ADD_CUSTOM_TARGET( prepare DEPENDS ${dfhack_SOURCE_DIR}/Memory.xml COMMAND ${CMAKE_COMMAND} -E make_directory ${DFHACK_OUTPUT_DIR} +COMMAND ${CMAKE_COMMAND} -E make_directory ${DFHACK_PLUGIN_OUTPUT_DIR} COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${DFHACK_OUTPUT_DIR}) -ADD_DEPENDENCIES(dfhack memxmlcopy) +ADD_DEPENDENCIES(dfhack prepare) install(TARGETS dfhack LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp index 66892dba2..ea90979e7 100644 --- a/library/Console-windows.cpp +++ b/library/Console-windows.cpp @@ -49,6 +49,7 @@ FILE * dfout_C = 0; duthomhas::stdiobuf * stream_o = 0; HANDLE g_hConsoleOut; // Handle to debug console +HWND ConsoleWindow; // FIXME: prime candidate for being a singleton... indeed. Console::Console() @@ -61,6 +62,9 @@ Console::Console() // Allocate a console! AllocConsole(); + ConsoleWindow = GetConsoleWindow(); + HMENU hm = GetSystemMenu(ConsoleWindow,false); + DeleteMenu(hm, SC_CLOSE, MF_BYCOMMAND); // set the screen buffer to be big enough to let us scroll text GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); diff --git a/library/Core.cpp b/library/Core.cpp index cd479bf51..e1a961fd0 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -32,12 +32,13 @@ distribution. #include using namespace std; +#include "dfhack/Error.h" +#include "dfhack/Process.h" #include "dfhack/Core.h" #include "dfhack/Console.h" #include "dfhack/VersionInfoFactory.h" #include "ModuleFactory.h" -#include "dfhack/Error.h" -#include "dfhack/Process.h" + #include "dfhack/modules/Gui.h" #include "dfhack/modules/Vegetation.h" #include "dfhack/modules/Maps.h" @@ -72,16 +73,23 @@ static int getdir (string dir, vector &files) int fIOthread(void * _core) { Core * core = (Core *) _core; +#ifdef LINUX_BUILD + string path = core->p->getPath() + "/plugins/"; +#else + string path = core->p->getPath() + "\\plugins\\"; +#endif + vector filez; map plugins; - getdir(core->p->getPath(), filez); + getdir(path, filez); const char * (*_PlugName)(void) = 0; int (*_PlugRun)(Core *) = 0; for(int i = 0; i < filez.size();i++) { if(strstr(filez[i].c_str(),".plug.")) { - DFLibrary * plug = OpenPlugin(filez[i].c_str()); + string fullpath = path + filez[i]; + DFLibrary * plug = OpenPlugin(fullpath.c_str()); if(!plug) { dfout << "Can't load plugin " << filez[i] << endl; @@ -101,7 +109,7 @@ int fIOthread(void * _core) ClosePlugin(plug); continue; } - dfout << filez[i] << endl; + dfout << "Loaded plugin " << filez[i] << endl; plugins[string(_PlugName())] = _PlugRun; } } @@ -229,6 +237,7 @@ int Core::Shutdown ( void ) allModules.clear(); memset(&(s_mods), 0, sizeof(s_mods)); dfout << std::endl; + // kill the console object delete con; con = 0; return -1; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 85d3fab3b..9510aca6d 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -16,6 +16,12 @@ MACRO(DFHACK_PLUGIN PLUGIN_NAME PLUGIN_SOURCES) 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}) ENDMACRO() DFHACK_PLUGIN(reveal reveal.cpp)