diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 82c0ee986..5847f3b6f 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -7,22 +7,96 @@ IF(UNIX) ENDIF() include_directories("${dfhack_SOURCE_DIR}/library/include") +MACRO(CAR var) + SET(${var} ${ARGV1}) +ENDMACRO(CAR) -MACRO(DFHACK_PLUGIN PLUGIN_NAME PLUGIN_SOURCES) - ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES}) - TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack) - IF(UNIX) - SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "") - 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() +MACRO(CDR var junk) + SET(${var} ${ARGN}) +ENDMACRO(CDR) + +MACRO(LIST_CONTAINS var value) + SET(${var}) + FOREACH (value2 ${ARGN}) + IF (${value} STREQUAL ${value2}) + SET(${var} TRUE) + ENDIF (${value} STREQUAL ${value2}) + ENDFOREACH (value2) +ENDMACRO(LIST_CONTAINS) + +MACRO(PARSE_ARGUMENTS prefix arg_names option_names) + SET(DEFAULT_ARGS) + FOREACH(arg_name ${arg_names}) + SET(${prefix}_${arg_name}) + ENDFOREACH(arg_name) + FOREACH(option ${option_names}) + SET(${prefix}_${option} FALSE) + ENDFOREACH(option) + + SET(current_arg_name DEFAULT_ARGS) + SET(current_arg_list) + FOREACH(arg ${ARGN}) + LIST_CONTAINS(is_arg_name ${arg} ${arg_names}) + IF (is_arg_name) + SET(${prefix}_${current_arg_name} ${current_arg_list}) + SET(current_arg_name ${arg}) + SET(current_arg_list) + ELSE (is_arg_name) + LIST_CONTAINS(is_option ${arg} ${option_names}) + IF (is_option) + SET(${prefix}_${arg} TRUE) + ELSE (is_option) + SET(current_arg_list ${current_arg_list} ${arg}) + ENDIF (is_option) + ENDIF (is_arg_name) + ENDFOREACH(arg) + SET(${prefix}_${current_arg_name} ${current_arg_list}) +ENDMACRO(PARSE_ARGUMENTS) + +MACRO(DFHACK_PLUGIN) + PARSE_ARGUMENTS(PLUGIN + "LINK_LIBRARIES;DEPENDS" + "SOME_OPT" + ${ARGN} + ) + CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS}) + CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS}) + + ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES}) + TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES}) + IF(UNIX) + SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "") + 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}) + #MESSAGE("Depends: ${PLUGIN_DEPENDS}") + #IF (PLUGIN_AUTO_INSTALL) + # MESSAGE("Auto install") + #ENDIF (PLUGIN_AUTO_INSTALL) + #IF (PLUGIN_NO_MODULE) + # MESSAGE("No module") + #ENDIF (PLUGIN_NO_MODULE) +ENDMACRO(DFHACK_PLUGIN) + +# add all subdirectories. can be used in those subdirectories, etc... +# needs a re-run of cmake to pick up the changes +#macro(RECURSE_DIRS) +# file(GLOB sub-dir RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) +# foreach(dir ${sub-dir}) +# if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir}) +# add_subdirectory (${dir}) +# endif() +# endforeach() +#endmacro() + +#RECURSE_DIRS() +add_subdirectory (qtplug) DFHACK_PLUGIN(reveal reveal.cpp) OPTION(BUILD_KITTENS "Build the kittens plugin." OFF) diff --git a/plugins/qtplug/CMakeLists.txt b/plugins/qtplug/CMakeLists.txt new file mode 100644 index 000000000..38be38bb5 --- /dev/null +++ b/plugins/qtplug/CMakeLists.txt @@ -0,0 +1,39 @@ +find_package(Qt4 QUIET) +find_package(OpenGL QUIET) + +if(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND) + IF(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6) + set( QT_USE_QTGUI TRUE ) + set( QT_USE_QTOPENGL TRUE ) + INCLUDE( ${QT_USE_FILE} ) + + include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) + + set ( qtplug_SRCS + qtplug.cpp + blankslade.cpp + glwidget.cpp + ) + + SET ( qtplug_UI + gui/main.ui + ) + + SET( qtplug_RCS + gui/resources.qrc + ) + + # this command will generate rules that will run rcc on all files from blankslade_RCS + # in result blankslade_RC_SRCS variable will contain paths to files produced by rcc + QT4_ADD_RESOURCES( qtplug_RC_SRCS ${qtplug_RCS} ) + + QT4_WRAP_UI(qtplug_UI_h ${qtplug_UI}) + qt4_automoc(${qtplug_SRCS}) + DFHACK_PLUGIN(qtplug ${qtplug_SRCS} ${qtplug_RC_SRCS} ${qtplug_UI_h}) + target_link_libraries(qtplug ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ) + 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.") + ENDIF(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6) +else(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND) + MESSAGE(STATUS "Required libraries (Qt, GL, GLU) not found - Qt plugin can't be built.") +endif(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND) \ No newline at end of file diff --git a/plugins/qtplug/blankslade.cpp b/plugins/qtplug/blankslade.cpp new file mode 100644 index 000000000..73c49b5b4 --- /dev/null +++ b/plugins/qtplug/blankslade.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2010 Petr Mrázek (peterix) + * See LICENSE for details. + */ + +#include "blankslade.h" +#include +#include +#include "glwidget.h" + +blankslade::blankslade(QWidget *parent): QMainWindow(parent) +{ + ui.setupUi(this); + GLWidget * glw = new GLWidget(); + ui.gridding->addWidget(glw); + connect(ui.actionOpen,SIGNAL(triggered(bool)),this,SLOT(slotOpen(bool))); + connect(ui.actionQuit,SIGNAL(triggered(bool)),this,SLOT(slotQuit(bool))); + connect(ui.actionSave,SIGNAL(triggered(bool)),this,SLOT(slotSave(bool))); + connect(ui.actionSave_As,SIGNAL(triggered(bool)),this,SLOT(slotSaveAs(bool))); + ui.actionOpen->setIcon(QIcon::fromTheme("document-open")); + ui.actionOpen->setIconText(tr("Open")); + ui.actionSave->setIcon(QIcon::fromTheme("document-save")); + ui.actionSave->setIconText(tr("Save")); + ui.actionSave_As->setIcon(QIcon::fromTheme("document-save-as")); + ui.actionSave_As->setIconText(tr("Save As")); + ui.actionQuit->setIcon(QIcon::fromTheme("application-exit")); + ui.actionQuit->setIconText(tr("Run DF")); +} + +blankslade::~blankslade() +{} + +void blankslade::slotOpen(bool ) +{ + /* + QFileDialog fd(this,tr("Locate the Memoxy.xml file")); + fd.setNameFilter(tr("Memory definition (*.xml)")); + fd.setFileMode(QFileDialog::ExistingFile); + fd.setAcceptMode(QFileDialog::AcceptOpen); + int result = fd.exec(); + if(result == QDialog::Accepted) + { + QStringList files = fd.selectedFiles(); + QString fileName = files[0]; + QDomDocument doc("memxml"); + QFile file(fileName); + if(!file.open(QIODevice::ReadOnly)) + { + return; + } + if(!doc.setContent(&file)) + { + file.close(); + return; + } + mod = new MemXMLModel(doc,this); + ui.entryView->setModel(mod); + file.close(); + } + */ +} + +void blankslade::slotQuit(bool ) +{ + close(); +} + +void blankslade::slotSave(bool ) +{ + // blah +} + +void blankslade::slotRunDF(bool ) +{ + // blah +} + +void blankslade::slotSaveAs(bool ) +{ + QFileDialog fd(this,tr("Choose file to save as...")); + fd.setNameFilter(tr("Memory definition (*.xml)")); + fd.setFileMode(QFileDialog::AnyFile); + fd.selectFile("Memory.xml"); + fd.setAcceptMode(QFileDialog::AcceptSave); + int result = fd.exec(); + if(result == QDialog::Accepted) + { + QStringList files = fd.selectedFiles(); + QString file = files[0]; + qDebug() << "File:" << file; + } +} + +void blankslade::slotSetupDFs(bool ) +{ +} + +#include "blankslade.moc" diff --git a/plugins/qtplug/blankslade.h b/plugins/qtplug/blankslade.h new file mode 100644 index 000000000..bae0eeb17 --- /dev/null +++ b/plugins/qtplug/blankslade.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010 Petr Mrázek (peterix) + * See LICENSE for details. + */ + +#ifndef blankslade_H +#define blankslade_H + +#include +#include "ui_main.h" + +class blankslade : public QMainWindow +{ + Q_OBJECT +public: + blankslade(QWidget *parent = 0); + virtual ~blankslade(); + +private: + Ui::MainWindow ui; +public slots: + void slotOpen(bool); + void slotQuit(bool); + void slotSave(bool); + void slotSaveAs(bool); + void slotRunDF(bool); + void slotSetupDFs(bool); +}; +#endif // blankslade_H diff --git a/plugins/qtplug/glwidget.cpp b/plugins/qtplug/glwidget.cpp new file mode 100644 index 000000000..d2d1f9412 --- /dev/null +++ b/plugins/qtplug/glwidget.cpp @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2010 Petr Mrázek (peterix) + * See LICENSE for details. + */ + +#include "glwidget.h" +#include +#include +#include +#include +#include + +struct Vertex +{ + float texcoord[2]; + float color[3]; + float position[3]; +}; + +#define FRS 0.0625 +#define FRX FRS/2 + +// this is crap +const Vertex house_vert[] = +{ + // walls + { { 0.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -4.0, -4.0, -4.0 } }, + { { 0.0, FRS }, { 0.0, 1.0, 0.0 }, { -4.0, -4.0, 4.0 } }, + { { FRS, FRS }, { 0.0, 1.0, 1.0 }, { 4.0, -4.0, 4.0 } }, + { { FRS, 0.0 }, { 1.0, 0.0, 0.0 }, { 4.0, -4.0, -4.0 } }, + + { { 0.0, 0.0 }, { 1.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } }, + { { 0.0, FRS }, { 1.0, 1.0, 0.0 }, { -4.0, 4.0, 4.0 } }, + { { FRS, FRS }, { 1.0, 1.0, 1.0 }, { 4.0, 4.0, 4.0 } }, + { { FRS, 0.0 }, { 0.0, 0.0, 1.0 }, { 4.0, 4.0, -4.0 } }, + + { { 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { -4.0, -4.0, -4.0 } }, + { { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { -4.0, -4.0, 4.0 } }, + { { FRS, FRS }, { 1.0, 0.0, 0.0 }, { -4.0, 4.0, 4.0 } }, + { { FRS, 0.0 }, { 1.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } }, + + { { 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 4.0, -4.0, -4.0 } }, + { { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { 4.0, -4.0, 4.0 } }, + { { FRS, FRS }, { 1.0, 0.0, 0.0 }, { 4.0, 4.0, 4.0 } }, + { { FRS, 0.0 }, { 1.0, 0.0, 1.0 }, { 4.0, 4.0, -4.0 } }, + // roof + { { 0.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } }, + { { FRS, 0.0 }, { 0.0, 1.0, 1.0 }, { 4.0, 4.0, -4.0 } }, + { { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } }, + + { { FRS, 0.0 }, { 1.0, 0.0, 0.0 }, { 4.0, 4.0, -4.0 } }, + { { FRS, FRS }, { 1.0, 1.0, 0.0 }, { 4.0, 4.0, 4.0 } }, + { { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } }, + + { { FRS, FRS }, { 0.0, 1.0, 0.0 }, { 4.0, 4.0, 4.0 } }, + { { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { -4.0, 4.0, 4.0 } }, + { { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } }, + + { { 0.0, FRS }, { 0.0, 1.0, 0.0 }, { -4.0, 4.0, 4.0 } }, + { { 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { -4.0, 4.0, -4.0 } }, + { { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } } +}; + +const unsigned char house_idx[] = +{ + // walls + 0, 1, 2, 0, 2, 3, + 4, 5, 6, 4, 6, 7, + 8, 9, 10, 8, 10, 11, + 12, 13, 14, 12, 14, 15, + // roof + 16, 17, 18, + 19, 20, 21, + 22, 23, 24, + 25, 26, 27 +}; + +class GLWPrivate +{ +public: + QGLBuffer *VBO; + QGLBuffer *EBO; + QGLShaderProgram prog; + int positionAttrib; + int colorAttrib; + int texcoordsAttrib; + int mvpUniform; + int textureUniform; + int terrain; + float pz,rx,ry; + QPoint lastMouse; +}; + +GLWidget::GLWidget() +{ + d = new GLWPrivate; + d->pz = -140.0f; + d->rx = d->ry = 0.0f; + d->VBO = d->EBO = 0; + startTimer( 10 ); +} + +GLWidget::~GLWidget() +{ + if(d->VBO) delete d->VBO; + if(d->EBO) delete d->EBO; + delete d; +} + +const char * VS_src = +"#version 130\n" +"in vec3 position; in vec3 color; uniform mat4 mvp; out vec3 c;" +"in vec2 tc_in; out vec2 coord;" +"void main()" +"{" + "gl_Position = mvp*vec4(position,1);" + "c = color;" + "coord = tc_in;" +"}"; + +const char * FS_src = +"#version 130\n" +"in vec3 c;" +//"out vec4 gl_FragColor;" +"in vec2 coord; uniform sampler2D tex;" +"void main()" +"{" +// "gl_FragColor = vec4(c,1);" +// "gl_FragColor = mix( texture(tex, coord), vec4(c,1), 0.5);" +// "gl_FragColor = vec4(c,1) - texture(tex, coord);" + "gl_FragColor = vec4(c,1) * texture(tex, coord);" +"}"; + +//initialization of OpenGL +void GLWidget::initializeGL() +{ + bool test = 1; + test &= d->prog.addShaderFromSourceCode(QGLShader::Vertex,VS_src); + test &= d->prog.addShaderFromSourceCode(QGLShader::Fragment,FS_src); + test &= d->prog.link(); + if(!test) + std::cout << "OUCH!" << std::endl; + + d->positionAttrib = d->prog.attributeLocation("position"); + d->colorAttrib = d->prog.attributeLocation("color"); + d->texcoordsAttrib = d->prog.attributeLocation("tc_in"); + + d->mvpUniform = d->prog.uniformLocation("mvp"); + d->textureUniform = d->prog.uniformLocation("tex"); + + if(d->positionAttrib == -1 || d->colorAttrib == -1 || d->mvpUniform == -1) + std::cout << "Bad attribs!" << std::endl; + + QGLBuffer &VBO = *(d->VBO = new QGLBuffer(QGLBuffer::VertexBuffer)); + VBO.create(); + VBO.bind(); + VBO.allocate(sizeof(house_vert)); + VBO.write(0,house_vert,sizeof(house_vert)); + + QGLBuffer &EBO = *(d->EBO = new QGLBuffer(QGLBuffer::IndexBuffer)); + EBO.create(); + EBO.bind(); + EBO.allocate(sizeof(house_idx)); + EBO.write(0,house_idx,sizeof(house_idx)); + + QImage texture; + texture.load("terrain.png"); + d->terrain = bindTexture(texture); + + glClearColor(0.0f, 0.0f, 0.0f, 0.f); + + glShadeModel( GL_SMOOTH ); + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); + glEnable( GL_TEXTURE_2D ); + glEnable( GL_DEPTH_TEST ); +} + +void GLWidget::paintGL() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + d->prog.bind(); + + QMatrix4x4 projection; + QMatrix4x4 mvp; + + //projection.ortho(-10,10,-10,10,1,1000); + float aspect = (float)width()/(float)height(); + projection.perspective(10,aspect,1,1000); + mvp = projection; + + mvp.translate(0,0,d->pz); + mvp.rotate(d->ry,1,0,0); + mvp.rotate(d->rx,0,1,0); + d->prog.setUniformValue(d->mvpUniform,mvp); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, d->terrain); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + d->prog.setUniformValue(d->textureUniform,0); + + d->prog.enableAttributeArray(d->positionAttrib); + d->prog.enableAttributeArray(d->colorAttrib); + d->prog.enableAttributeArray(d->texcoordsAttrib); + + d->VBO->bind(); + + d->prog.setAttributeBuffer(d->texcoordsAttrib, GL_FLOAT, offsetof(Vertex, texcoord), 2, sizeof(Vertex)); + d->prog.setAttributeBuffer(d->positionAttrib, GL_FLOAT, offsetof(Vertex, position), 3, sizeof(Vertex)); + d->prog.setAttributeBuffer(d->colorAttrib, GL_FLOAT, offsetof(Vertex, color), 3, sizeof(Vertex)); + + d->EBO->bind(); + + glDrawElements(GL_TRIANGLES, d->EBO->size(), GL_UNSIGNED_BYTE, NULL); + + d->prog.release(); +} + +void GLWidget::resizeGL(int width, int height) +{ + glViewport(0, 0, width, height); +} + +void GLWidget::mousePressEvent(QMouseEvent *event) +{ + d->lastMouse = event->pos(); +} + +void GLWidget::mouseMoveEvent(QMouseEvent *event) +{ + int dx = event->x() - d->lastMouse.x(); + int dy = event->y() - d->lastMouse.y(); + + if (event->buttons() & Qt::LeftButton) + { + d->rx = d->rx + dx; + d->ry = d->ry + dy; + } + d->lastMouse = event->pos(); +} + +void GLWidget::timerEvent(QTimerEvent *event) +{ + updateGL(); +} diff --git a/plugins/qtplug/glwidget.h b/plugins/qtplug/glwidget.h new file mode 100644 index 000000000..935a6569c --- /dev/null +++ b/plugins/qtplug/glwidget.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010 Petr Mrázek (peterix) + * See LICENSE for details. + */ + +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include + +class GLWPrivate; +class GLWidget : public QGLWidget +{ +public: + GLWidget(); + ~GLWidget(); + + float rot; + void resizeGL(int width, int height); + +protected: + void initializeGL(); + void paintGL(); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void timerEvent(QTimerEvent *event); + +private: + GLWPrivate * d; +}; + +#endif // GLWIDGET_H diff --git a/plugins/qtplug/gui/33.png b/plugins/qtplug/gui/33.png new file mode 100644 index 000000000..cb35481f8 Binary files /dev/null and b/plugins/qtplug/gui/33.png differ diff --git a/plugins/qtplug/gui/diamant.png b/plugins/qtplug/gui/diamant.png new file mode 100644 index 000000000..794e04de4 Binary files /dev/null and b/plugins/qtplug/gui/diamant.png differ diff --git a/plugins/qtplug/gui/icon.svgz b/plugins/qtplug/gui/icon.svgz new file mode 100644 index 000000000..52fbdc1b5 Binary files /dev/null and b/plugins/qtplug/gui/icon.svgz differ diff --git a/plugins/qtplug/gui/koule.png b/plugins/qtplug/gui/koule.png new file mode 100644 index 000000000..6eb067164 Binary files /dev/null and b/plugins/qtplug/gui/koule.png differ diff --git a/plugins/qtplug/gui/krychle.png b/plugins/qtplug/gui/krychle.png new file mode 100644 index 000000000..856e5415c Binary files /dev/null and b/plugins/qtplug/gui/krychle.png differ diff --git a/plugins/qtplug/gui/main.ui b/plugins/qtplug/gui/main.ui new file mode 100644 index 000000000..755f08f0d --- /dev/null +++ b/plugins/qtplug/gui/main.ui @@ -0,0 +1,361 @@ + + + MainWindow + + + + 0 + 0 + 662 + 836 + + + + + 0 + 0 + + + + MainWindow + + + + :/main_icon/main_64.png:/main_icon/main_64.png + + + + + 0 + + + 0 + + + + + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::RightDockWidgetArea + + + Scéna + + + 2 + + + + + + + + + + + Exponent n + + + + + + + Qt::Horizontal + + + + + + + + + + Exponent e + + + + + + + Qt::Horizontal + + + + + + + + + + + + + + + + + Světlo + + + Qt::AlignCenter + + + + + + + Objekt + + + Qt::AlignCenter + + + + + + + + + + + + Textura + + + Qt::AlignCenter + + + + + + + + + + 1 + 1 + + + + + 96 + 96 + + + + + 0 + 0 + + + + + + + + :/blah/tileable.jpg:/blah/tileable.jpg + + + + 80 + 80 + + + + false + + + false + + + + + + + + + + + Render + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + pushButton_2 + verticalLayoutWidget + pushButton + gridLayoutWidget + + + + + + 0 + 0 + + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::TopDockWidgetArea + + + Ukázky + + + 1 + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 1 + + + QAbstractItemView::SelectItems + + + + 32 + 32 + + + + QListView::Static + + + QListView::TopToBottom + + + true + + + QListView::Adjust + + + QListView::SinglePass + + + 10 + + + QListView::ListMode + + + true + + + false + + + false + + + false + + + + Koule + + + + :/blah/koule.png:/blah/koule.png + + + + + Krychle + + + + :/blah/krychle.png:/blah/krychle.png + + + + + Válec + + + + :/blah/valec.png:/blah/valec.png + + + + + Diamant + + + + :/blah/diamant.png:/blah/diamant.png + + + + + a=3,b=3 + + + + :/blah/33.png:/blah/33.png + + + + + + + + + + Open + + + + + Save + + + + + Save As + + + + + Quit + + + + + + + + diff --git a/plugins/qtplug/gui/main_16.png b/plugins/qtplug/gui/main_16.png new file mode 100644 index 000000000..9f04527a3 Binary files /dev/null and b/plugins/qtplug/gui/main_16.png differ diff --git a/plugins/qtplug/gui/main_32.png b/plugins/qtplug/gui/main_32.png new file mode 100644 index 000000000..bf279550f Binary files /dev/null and b/plugins/qtplug/gui/main_32.png differ diff --git a/plugins/qtplug/gui/main_64.png b/plugins/qtplug/gui/main_64.png new file mode 100644 index 000000000..79445450a Binary files /dev/null and b/plugins/qtplug/gui/main_64.png differ diff --git a/plugins/qtplug/gui/resources.qrc b/plugins/qtplug/gui/resources.qrc new file mode 100644 index 000000000..a32753619 --- /dev/null +++ b/plugins/qtplug/gui/resources.qrc @@ -0,0 +1,15 @@ + + + main_64.png + main_16.png + main_32.png + + + tileable.jpg + 33.png + diamant.png + koule.png + krychle.png + valec.png + + diff --git a/plugins/qtplug/gui/tileable.jpg b/plugins/qtplug/gui/tileable.jpg new file mode 100644 index 000000000..fdea09b9a Binary files /dev/null and b/plugins/qtplug/gui/tileable.jpg differ diff --git a/plugins/qtplug/gui/valec.png b/plugins/qtplug/gui/valec.png new file mode 100644 index 000000000..17d304403 Binary files /dev/null and b/plugins/qtplug/gui/valec.png differ diff --git a/plugins/qtplug/qtplug.cpp b/plugins/qtplug/qtplug.cpp new file mode 100644 index 000000000..b103c0237 --- /dev/null +++ b/plugins/qtplug/qtplug.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "blankslade.h" + +using std::vector; +using std::string; +using std::stack; +using namespace DFHack; +static int runnable(void *); +static SDL::Mutex * instance_mutex = 0; +static bool running = false; + +DFhackCExport command_result runqt (Core * c, vector & parameters); + +DFhackCExport const char * plugin_name ( void ) +{ + return "Qt Test"; +} + +DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) +{ + instance_mutex = SDL_CreateMutex(); + commands.clear(); + commands.push_back(PluginCommand("runqt","Open an interactive Qt gui.",runqt)); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( Core * c ) +{ + return CR_OK; +} + +DFhackCExport command_result runqt (Core * c, vector & parameters) +{ + SDL_mutexP(instance_mutex); + if(!running) + { + running = true; + SDL::Thread * IO = SDL_CreateThread(runnable, 0); + } + else + { + c->con.printerr("The Qt test plugin is already running!\n"); + } + SDL_mutexV(instance_mutex); + return CR_OK; +} + +static int runnable(void *) +{ + QApplication app(0, 0); + blankslade appGui; + appGui.show(); + int ret = app.exec(); + SDL_mutexP(instance_mutex); + running = false; + SDL_mutexV(instance_mutex); + return ret; +}