Merge branch 'dfapi' of git://github.com/peterix/dfhack into dfapi

Conflicts:
	plugins/CMakeLists.txt
develop
Warmist 2011-07-17 00:11:21 +03:00
commit 6c75e8cd88
12 changed files with 86 additions and 21 deletions

@ -390,10 +390,10 @@ int Core::SDL_Event(SDL::Event* ev, int orig_return)
{ {
hotkey_states[idx] = 1; hotkey_states[idx] = 1;
Gui * g = getGui(); Gui * g = getGui();
if(g->hotkeys && g->interface && g->menu_state) if(g->hotkeys && g->df_interface && g->df_menu_state)
{ {
t_viewscreen * ws = g->GetCurrentScreen(); t_viewscreen * ws = g->GetCurrentScreen();
if(ws->getClassName() == "viewscreen_dwarfmodest" && *g->menu_state == 0x23) if(ws->getClassName() == "viewscreen_dwarfmodest" && *g->df_menu_state == 0x23)
return orig_return; return orig_return;
else else
{ {

@ -120,6 +120,11 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
} }
} }
uint32_t Process::getBase()
{
return 0;
}
static int getdir (string dir, vector<string> &files) static int getdir (string dir, vector<string> &files)
{ {
DIR *dp; DIR *dp;

@ -330,6 +330,13 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
} }
} }
uint32_t Process::getBase()
{
if(d)
return d->base;
return 0x400000;
}
string Process::doReadClassName (void * vptr) string Process::doReadClassName (void * vptr)
{ {
int rtti = readDWord((uint32_t)vptr - 0x4); int rtti = readDWord((uint32_t)vptr - 0x4);

@ -264,6 +264,7 @@ namespace DFHack
{ {
return my_descriptor; return my_descriptor;
}; };
uint32_t getBase();
/// get the DF Process ID /// get the DF Process ID
int getPID(); int getPID();
/// get the DF Process FilePath /// get the DF Process FilePath

@ -114,11 +114,11 @@ namespace DFHack
* Gui screens * Gui screens
*/ */
/// handle to the interface object /// handle to the interface object
t_interface * interface; t_interface * df_interface;
/// Get the current top-level view-screen /// Get the current top-level view-screen
t_viewscreen * GetCurrentScreen(); t_viewscreen * GetCurrentScreen();
/// The DF menu state (designation menu ect) /// The DF menu state (designation menu ect)
uint32_t * menu_state; uint32_t * df_menu_state;
/* /*
* Hotkeys (DF's zoom locations) * Hotkeys (DF's zoom locations)

@ -86,21 +86,21 @@ Gui::Gui()
// Setting up menu state // Setting up menu state
try try
{ {
menu_state = (uint32_t *) OG_Gui->getAddress("current_menu_state"); df_menu_state = (uint32_t *) OG_Gui->getAddress("current_menu_state");
} }
catch(Error::All &) catch(Error::All &)
{ {
menu_state = 0; df_menu_state = 0;
}; };
// Setting up the view screen stuff // Setting up the view screen stuff
try try
{ {
interface = (t_interface *) OG_Gui->getAddress ("interface"); df_interface = (t_interface *) OG_Gui->getAddress ("interface");
} }
catch(exception &) catch(exception &)
{ {
interface = 0; df_interface = 0;
}; };
OffsetGroup * OG_Position; OffsetGroup * OG_Position;
@ -140,9 +140,9 @@ bool Gui::Finish()
t_viewscreen * Gui::GetCurrentScreen() t_viewscreen * Gui::GetCurrentScreen()
{ {
if(!interface) if(!df_interface)
return 0; return 0;
t_viewscreen * ws = &interface->view; t_viewscreen * ws = &df_interface->view;
while(ws) while(ws)
{ {
if(ws->child) if(ws->child)

@ -96,19 +96,17 @@ ENDMACRO(DFHACK_PLUGIN)
#endmacro() #endmacro()
#RECURSE_DIRS() #RECURSE_DIRS()
add_subdirectory (qtplug)
add_subdirectory (dfusion) add_subdirectory (dfusion)
DFHACK_PLUGIN(reveal reveal.cpp) OPTION(BUILD_QTPLUG "Build the experimental Qt plugin." OFF)
if(BUILD_QTPLUG)
add_subdirectory (qtplug)
endif()
OPTION(BUILD_KITTENS "Build the kittens plugin." OFF) OPTION(BUILD_KITTENS "Build the kittens plugin." OFF)
if(BUILD_KITTENS) if(BUILD_KITTENS)
DFHACK_PLUGIN(kittens kittens.cpp) DFHACK_PLUGIN(kittens kittens.cpp)
endif() endif()
DFHACK_PLUGIN(prospector prospector.cpp)
DFHACK_PLUGIN(cleanmap cleanmap.cpp)
DFHACK_PLUGIN(weather weather.cpp)
DFHACK_PLUGIN(vdig vdig.cpp)
DFHACK_PLUGIN(colonies colonies.cpp)
IF(UNIX) IF(UNIX)
OPTION(BUILD_KILL_GAME "Build the kill gmae plugin." OFF) OPTION(BUILD_KILL_GAME "Build the kill gmae plugin." OFF)
@ -116,3 +114,10 @@ IF(UNIX)
DFHACK_PLUGIN(die die.cpp) DFHACK_PLUGIN(die die.cpp)
endif() endif()
endif() endif()
DFHACK_PLUGIN(reveal reveal.cpp)
DFHACK_PLUGIN(prospector prospector.cpp)
DFHACK_PLUGIN(cleanmap cleanmap.cpp)
DFHACK_PLUGIN(weather weather.cpp)
DFHACK_PLUGIN(vdig vdig.cpp)
DFHACK_PLUGIN(colonies colonies.cpp)

@ -2,8 +2,10 @@
#include <dfhack/Console.h> #include <dfhack/Console.h>
#include <dfhack/Export.h> #include <dfhack/Export.h>
#include <dfhack/PluginManager.h> #include <dfhack/PluginManager.h>
#include <dfhack/VersionInfo.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <sstream>
#include "luamain.h" #include "luamain.h"
@ -16,7 +18,10 @@ using namespace DFHack;
static SDL::Mutex* mymutex=0; static SDL::Mutex* mymutex=0;
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters); DFhackCExport command_result dfusion (Core * c, vector <string> & parameters);
DFhackCExport command_result lua_run (Core * c, vector <string> & parameters);
typedef
int __stdcall (*dfprint)(const char*, char, char,void *ptr) ;
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -30,6 +35,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
lua::RegisterConsole(lua::glua::Get(),&c->con); lua::RegisterConsole(lua::glua::Get(),&c->con);
commands.push_back(PluginCommand("dfusion","Init dfusion system.",dfusion)); commands.push_back(PluginCommand("dfusion","Init dfusion system.",dfusion));
commands.push_back(PluginCommand("lua", "Run interactive interpreter.\
\n Options: <filename> = run <filename> instead",lua_run));
mymutex=SDL_CreateMutex(); mymutex=SDL_CreateMutex();
return CR_OK; return CR_OK;
} }
@ -71,10 +79,44 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
} }
DFhackCExport command_result lua_run (Core * c, vector <string> & parameters)
{
c->Suspend();
std::stringstream ss;
ss<<parameters[0];
long i;
ss>>i;
dfprint mprint=(dfprint)(0x27F030+i);
mprint("Hello world",1,4,0);
c->Resume();
return CR_OK;
Console &con=c->con;
SDL_mutexP(mymutex);
lua::state s=lua::glua::Get();
if(parameters.size()>0)
{
try{
s.loadfile(parameters[0]); //load file
s.pcall(0,0);// run it
}
catch(lua::exception &e)
{
con.printerr("Error:%s\n",e.what());
}
}
else
{
//TODO interpreter...
}
s.settop(0);// clean up
SDL_mutexV(mymutex);
return CR_OK;
}
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters) DFhackCExport command_result dfusion (Core * c, vector <string> & parameters)
{ {
// do stuff
Console &con=c->con; Console &con=c->con;
con.print("%x\n",c->vinfo->getBase());
SDL_mutexP(mymutex); SDL_mutexP(mymutex);
lua::state s=lua::glua::Get(); lua::state s=lua::glua::Get();

@ -30,6 +30,8 @@ if(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND)
QT4_WRAP_UI(qtplug_UI_h ${qtplug_UI}) QT4_WRAP_UI(qtplug_UI_h ${qtplug_UI})
qt4_automoc(${qtplug_SRCS}) qt4_automoc(${qtplug_SRCS})
DFHACK_PLUGIN(qtplug ${qtplug_SRCS} ${qtplug_RC_SRCS} ${qtplug_UI_h}) DFHACK_PLUGIN(qtplug ${qtplug_SRCS} ${qtplug_RC_SRCS} ${qtplug_UI_h})
# a small texture file
install(FILES terrain.png DESTINATION ${DFHACK_LIBRARY_DESTINATION})
target_link_libraries(qtplug ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ) target_link_libraries(qtplug ${OPENGL_LIBRARIES} ${QT_LIBRARIES} )
ELSE(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6) ELSE(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6)
MESSAGE(STATUS "Can't build the Qt plugin. Your Qt is too old.") MESSAGE(STATUS "Can't build the Qt plugin. Your Qt is too old.")

@ -9,6 +9,7 @@
#include <QGLShaderProgram> #include <QGLShaderProgram>
#include <QGLPixelBuffer> #include <QGLPixelBuffer>
#include <iostream> #include <iostream>
#include <GL/gl.h>
struct Vertex struct Vertex
{ {
@ -193,7 +194,7 @@ void GLWidget::paintGL()
mvp.rotate(d->rx,0,1,0); mvp.rotate(d->rx,0,1,0);
d->prog.setUniformValue(d->mvpUniform,mvp); d->prog.setUniformValue(d->mvpUniform,mvp);
glActiveTexture(GL_TEXTURE0); //glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, d->terrain); glBindTexture(GL_TEXTURE_2D, d->terrain);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

@ -20,6 +20,7 @@ using namespace DFHack;
static int runnable(void *); static int runnable(void *);
static SDL::Mutex * instance_mutex = 0; static SDL::Mutex * instance_mutex = 0;
static bool running = false; static bool running = false;
static SDL::Thread * QTThread;
DFhackCExport command_result runqt (Core * c, vector <string> & parameters); DFhackCExport command_result runqt (Core * c, vector <string> & parameters);
@ -47,7 +48,7 @@ DFhackCExport command_result runqt (Core * c, vector <string> & parameters)
if(!running) if(!running)
{ {
running = true; running = true;
SDL::Thread * IO = SDL_CreateThread(runnable, 0); QTThread = SDL_CreateThread(runnable, 0);
} }
else else
{ {
@ -59,7 +60,8 @@ DFhackCExport command_result runqt (Core * c, vector <string> & parameters)
static int runnable(void *) static int runnable(void *)
{ {
QApplication app(0, 0); int zero = 0;
QApplication app(zero, 0);
blankslade appGui; blankslade appGui;
appGui.show(); appGui.show();
int ret = app.exec(); int ret = app.exec();

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB