Graphic module

develop
Petr Mrázek 2011-12-07 20:37:09 +01:00
parent f7d78539d3
commit 647916e109
7 changed files with 51 additions and 6 deletions

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

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

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

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

@ -43,5 +43,6 @@ namespace DFHack
Module* createMaps();
Module* createVermin();
Module* createNotes();
Module* createGraphic();
}
#endif

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

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