Plugins go into a folder, disabled console close button on windows because of bugs.

develop
Petr Mrázek 2011-06-22 18:04:22 +02:00
parent 8f27966540
commit 857decbcce
5 changed files with 30 additions and 7 deletions

@ -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:

@ -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}

@ -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);

@ -32,12 +32,13 @@ distribution.
#include <cstring>
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<string> &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 <string> filez;
map <string, int (*)(Core *)> 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;

@ -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)