summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek2011-12-07 20:37:09 +0100
committerPetr Mrázek2011-12-07 20:37:09 +0100
commit647916e109fd0d2a95311f78dfb15f33a3a9b8c1 (patch)
tree20b47a7520e79abf387f0c81e2eb73619760d8ef
parentf7d78539d34ee5d9529a32fecfe17537ec1b6bee (diff)
downloaddfhack-647916e109fd0d2a95311f78dfb15f33a3a9b8c1.tar.gz
dfhack-647916e109fd0d2a95311f78dfb15f33a3a9b8c1.tar.bz2
dfhack-647916e109fd0d2a95311f78dfb15f33a3a9b8c1.tar.xz
Graphic module
-rw-r--r--library/CMakeLists.txt2
-rw-r--r--library/Core.cpp2
-rw-r--r--library/FakeSDL-windows.cpp45
-rw-r--r--library/include/dfhack/Core.h4
-rw-r--r--library/private/ModuleFactory.h1
-rwxr-xr-xpackage/linux/dfhack2
-rw-r--r--plugins/CMakeLists.txt1
7 files changed, 51 insertions, 6 deletions
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index afa60d1c..195ffa6e 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -55,6 +55,7 @@ include/dfhack/modules/Translation.h
include/dfhack/modules/Vegetation.h
include/dfhack/modules/Vermin.h
include/dfhack/modules/World.h
+include/dfhack/modules/Graphic.h
)
SET(PROJECT_SRCS
@@ -89,6 +90,7 @@ modules/Translation.cpp
modules/Vegetation.cpp
modules/Vermin.cpp
modules/World.cpp
+modules/Graphic.cpp
)
SET(PROJECT_HDRS_LINUX
diff --git a/library/Core.cpp b/library/Core.cpp
index efc9cf83..f218f275 100644
--- a/library/Core.cpp
+++ b/library/Core.cpp
@@ -45,6 +45,7 @@ using namespace std;
#include "ModuleFactory.h"
#include "dfhack/modules/Gui.h"
#include "dfhack/modules/World.h"
+#include "dfhack/modules/Graphic.h"
using namespace DFHack;
#include "dfhack/SDL_fakes/events.h"
@@ -788,3 +789,4 @@ MODULE_GETTER(Buildings);
MODULE_GETTER(Constructions);
MODULE_GETTER(Vermin);
MODULE_GETTER(Notes);
+MODULE_GETTER(Graphic);
diff --git a/library/FakeSDL-windows.cpp b/library/FakeSDL-windows.cpp
index ee569c83..d388b75d 100644
--- a/library/FakeSDL-windows.cpp
+++ b/library/FakeSDL-windows.cpp
@@ -33,6 +33,7 @@ distribution.
#include <stdio.h>
#include "tinythread.h"
+#include "dfhack/modules/Graphic.h"
/*
* Plugin loading functions
@@ -284,9 +285,44 @@ DFhackCExport vPtr SDL_SetVideoMode(int width, int height, int bpp, uint32_t fla
{
return _SDL_SetVideoMode(width, height, bpp, flags);
}
-static int (*_SDL_UpperBlit)(vPtr src, vPtr srcrect, vPtr dst, vPtr dstrect) = 0;
-DFhackCExport int SDL_UpperBlit(vPtr src, vPtr srcrect, vPtr dst, vPtr dstrect)
-{
+
+static int (*_SDL_UpperBlit)(DFHack::DFSDL_Surface* src, DFHack::DFSDL_Rect* srcrect, DFHack::DFSDL_Surface* dst, DFHack::DFSDL_Rect* dstrect) = 0;
+DFhackCExport int SDL_UpperBlit(DFHack::DFSDL_Surface* src, DFHack::DFSDL_Rect* srcrect, DFHack::DFSDL_Surface* dst, DFHack::DFSDL_Rect* dstrect)
+{
+ if ( dstrect != NULL && dstrect->h != 0 && dstrect->w != 0 )
+ {
+ DFHack::Core & c = DFHack::Core::getInstance();
+ DFHack::Graphic* g = c.getGraphic();
+ DFHack::DFTileSurface* ov = g->Call(dstrect->x/dstrect->w, dstrect->y/dstrect->h);
+
+ if ( ov != NULL )
+ {
+ if ( ov->paintOver )
+ {
+ _SDL_UpperBlit(src, srcrect, dst, dstrect);
+ }
+
+ DFHack::DFSDL_Rect* dstrect2 = new DFHack::DFSDL_Rect;
+ dstrect2->x = dstrect->x;
+ dstrect2->y = dstrect->y;
+ dstrect2->w = dstrect->w;
+ dstrect2->h = dstrect->h;
+
+ if ( ov->dstResize != NULL )
+ {
+ DFHack::DFSDL_Rect* r = (DFHack::DFSDL_Rect*)ov->dstResize;
+ dstrect2->x += r->x;
+ dstrect2->y += r->y;
+ dstrect2->w += r->w;
+ dstrect2->h += r->h;
+ }
+
+ int result = _SDL_UpperBlit(ov->surface, ov->rect, dst, dstrect2);
+ delete dstrect2;
+ return result;
+ }
+ }
+
return _SDL_UpperBlit(src, srcrect, dst, dstrect);
}
@@ -745,7 +781,7 @@ bool FirstCall()
_SDL_SetVideoMode = (void*(*)(int, int, int, uint32_t))GetProcAddress(realSDLlib,"SDL_SetVideoMode");
_SDL_ShowCursor = (int (*)(int))GetProcAddress(realSDLlib,"SDL_ShowCursor");
_SDL_UnlockSurface = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_UnlockSurface");
- _SDL_UpperBlit = (int (*)(void*, void*, void*, void*))GetProcAddress(realSDLlib,"SDL_UpperBlit");
+ _SDL_UpperBlit = (int (*)(DFHack::DFSDL_Surface*, DFHack::DFSDL_Rect*, DFHack::DFSDL_Surface*, DFHack::DFSDL_Rect*))GetProcAddress(realSDLlib,"SDL_UpperBlit");
_SDL_WM_SetCaption = (void (*)(const char*, const char*))GetProcAddress(realSDLlib,"SDL_WM_SetCaption");
_SDL_WM_SetIcon = (void (*)(void*, uint8_t*))GetProcAddress(realSDLlib,"SDL_WM_SetIcon");
_SDL_mutexP = (int (*)(vPtr))GetProcAddress(realSDLlib,"SDL_mutexP");
@@ -781,4 +817,3 @@ bool FirstCall()
inited = true;
return 1;
}
-
diff --git a/library/include/dfhack/Core.h b/library/include/dfhack/Core.h
index 2d453bc1..2d7941af 100644
--- a/library/include/dfhack/Core.h
+++ b/library/include/dfhack/Core.h
@@ -32,6 +32,7 @@ distribution.
#include <map>
#include <stdint.h>
#include "dfhack/Console.h"
+#include "dfhack/modules/Graphic.h"
struct WINDOW;
@@ -121,6 +122,8 @@ namespace DFHack
Vermin * getVermin();
/// get the notes module
Notes * getNotes();
+ /// get the graphic module
+ Graphic * getGraphic();
/// sets the current hotkey command
bool setHotkeyCmd( std::string cmd );
/// removes the hotkey command and gives it to the caller thread
@@ -171,6 +174,7 @@ namespace DFHack
Constructions * pConstructions;
Vermin * pVermin;
Notes * pNotes;
+ Graphic * pGraphic;
} s_mods;
std::vector <Module *> allModules;
DFHack::PluginManager * plug_mgr;
diff --git a/library/private/ModuleFactory.h b/library/private/ModuleFactory.h
index af34c35a..3677d355 100644
--- a/library/private/ModuleFactory.h
+++ b/library/private/ModuleFactory.h
@@ -43,5 +43,6 @@ namespace DFHack
Module* createMaps();
Module* createVermin();
Module* createNotes();
+ Module* createGraphic();
}
#endif
diff --git a/package/linux/dfhack b/package/linux/dfhack
index 7cbcb421..d539237f 100755
--- a/package/linux/dfhack
+++ b/package/linux/dfhack
@@ -67,7 +67,7 @@ case "$1" in
esac
# Reset terminal to sane state in case of a crash
-reset $DF_RESET_OPTS
+# reset $DF_RESET_OPTS
if [ -n "$DF_POST_CMD" ]; then
eval $DF_POST_CMD
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 3f8859e7..c08bcd9e 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -57,6 +57,7 @@ DFHACK_PLUGIN(deramp deramp.cpp)
DFHACK_PLUGIN(flows flows.cpp)
DFHACK_PLUGIN(filltraffic filltraffic.cpp)
DFHACK_PLUGIN(seedwatch seedwatch.cpp)
+DFHACK_PLUGIN(versionosd versionosd.cpp)
# this is the skeleton plugin. If you want to make your own, make a copy and then change it
OPTION(BUILD_SKELETON "Build the skeleton plugin." OFF)