Merge branch 'master', remote branch 'peterix'
commit
8fd3eafecd
@ -0,0 +1,28 @@
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distributed this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# We use MSBuild as the build tool for VS 10
|
||||
FIND_PROGRAM(CMAKE_MAKE_PROGRAM
|
||||
NAMES MSBuild
|
||||
HINTS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir]
|
||||
"$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/"
|
||||
"c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/"
|
||||
"$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/"
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)
|
||||
SET(MSVC10 1)
|
||||
SET(MSVC_VERSION 1600)
|
||||
|
@ -1,4 +0,0 @@
|
||||
mkdir build-real
|
||||
cd build-real
|
||||
cmake ..\.. -G"Visual Studio 7"
|
||||
pause
|
@ -1,4 +0,0 @@
|
||||
mkdir build-real
|
||||
cd build-real
|
||||
cmake ..\.. -G"Visual Studio 7 .NET 2003"
|
||||
pause
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
www.sourceforge.net/projects/dfhack
|
||||
Copyright (c) 2009 Petr Mrázek (peterix)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
/*! \page index
|
||||
<center>
|
||||
\htmlonly
|
||||
<h1>DFHack</h1>
|
||||
<!--<img src="logo.png" alt="DFHack"/><br/>-->
|
||||
\endhtmlonly
|
||||
</center>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
DFHack is a Dwarf Fortress memory access library and a set of basic tools using
|
||||
this library. The library is a work in progress, so things might change as more
|
||||
tools are written for it.
|
||||
|
||||
It is an attempt to unite the various ways tools access DF memory and allow for
|
||||
easier development of new tools. In general, you can use it to move memory
|
||||
objects in and out of Dwarf Fortress really fast, regardless of DF version or OS.
|
||||
|
||||
First part of the manual deals with the basic of using DFHack as a library:
|
||||
<ul>
|
||||
PLACEHOLDER TERRITORY!
|
||||
|
||||
<li>Section \ref blah discusses some weird stuff
|
||||
<a href="target">this is a link</a>
|
||||
<li>Section \ref starting tells you how to cromulate at a distance!
|
||||
</ul>
|
||||
|
||||
Second part has some details on DFHack development:
|
||||
|
||||
<ul>
|
||||
<li>Section \ref starting tells you how to cromulate at a distance!
|
||||
</ul>
|
||||
|
||||
The third part describes how to use the supported DFHack utilities
|
||||
|
||||
<ul>
|
||||
<li>Section \ref dfattachtest shows how to use the \c dfattachtest program
|
||||
<li>Section \ref dfcleanmap shows how to use the \c dfcleanmap program
|
||||
<li>Section \ref dfexpbench shows how to use the \c dfexpbench program
|
||||
<li>Section \ref dfflows shows how to use the \c dfflows program
|
||||
<li>Section \ref dfliquids shows how to use the \c dfliquids program
|
||||
<li>Section \ref dfprobe shows how to use the \c dfprobe program
|
||||
<li>Section \ref dfprospector shows how to use the \c dfprospector program
|
||||
<li>Section \ref dfreveal shows how to use the \c dfreveal program
|
||||
<li>Section \ref dfsuspend shows how to use the \c dfsuspend program
|
||||
<li>Section \ref dfunstuck shows how to use the \c dfunstuck program
|
||||
<li>Section \ref dfvdig shows how to use the \c dfvdig program
|
||||
</ul>
|
||||
*/
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
project(dfoffsetedit)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
find_package(Qt4 QUIET)
|
||||
if(QT4_FOUND)
|
||||
add_subdirectory (src)
|
||||
else(QT4_FOUND)
|
||||
MESSAGE(STATUS "Qt4 libraries not found - offset editor can't be built.")
|
||||
endif(QT4_FOUND)
|
@ -0,0 +1,25 @@
|
||||
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set ( dfoffsetedit_SRCS
|
||||
dfedit.cpp
|
||||
memxmlModel.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET ( dfoffsetedit_UI
|
||||
gui/main.ui
|
||||
)
|
||||
|
||||
SET( dfoffsetedit_RCS
|
||||
gui/resources.qrc
|
||||
)
|
||||
|
||||
# this command will generate rules that will run rcc on all files from dfoffsetedit_RCS
|
||||
# in result dfoffsetedit_RC_SRCS variable will contain paths to files produced by rcc
|
||||
QT4_ADD_RESOURCES( dfoffsetedit_RC_SRCS ${dfoffsetedit_RCS} )
|
||||
|
||||
QT4_WRAP_UI(dfoffsetedit_UI_h ${dfoffsetedit_UI})
|
||||
qt4_automoc(${dfoffsetedit_SRCS})
|
||||
|
||||
add_executable(dfoffsetedit ${dfoffsetedit_SRCS} ${dfoffsetedit_RC_SRCS} ${dfoffsetedit_UI_h})
|
||||
target_link_libraries(dfoffsetedit ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
|
@ -0,0 +1,95 @@
|
||||
#include "dfedit.h"
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include "memxmlModel.h"
|
||||
|
||||
dfedit::dfedit(QWidget *parent): QMainWindow(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
connect(ui.actionOpen,SIGNAL(triggered(bool)),this,SLOT(slotOpen(bool)));
|
||||
connect(ui.actionQuit,SIGNAL(triggered(bool)),this,SLOT(slotQuit(bool)));
|
||||
connect(ui.actionRun_DF,SIGNAL(triggered(bool)),this,SLOT(slotRunDF(bool)));
|
||||
connect(ui.actionSave,SIGNAL(triggered(bool)),this,SLOT(slotSave(bool)));
|
||||
connect(ui.actionSave_As,SIGNAL(triggered(bool)),this,SLOT(slotSaveAs(bool)));
|
||||
connect(ui.actionSetup_DF_executables,SIGNAL(triggered(bool)),this,SLOT(slotSetupDFs(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.actionRun_DF->setIcon(QIcon::fromTheme("system-run"));
|
||||
ui.actionRun_DF->setIconText(tr("Run DF"));
|
||||
ui.actionQuit->setIcon(QIcon::fromTheme("application-exit"));
|
||||
ui.actionQuit->setIconText(tr("Run DF"));
|
||||
}
|
||||
|
||||
dfedit::~dfedit()
|
||||
{}
|
||||
|
||||
void dfedit::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 dfedit::slotQuit(bool )
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void dfedit::slotSave(bool )
|
||||
{
|
||||
// blah
|
||||
}
|
||||
|
||||
void dfedit::slotRunDF(bool )
|
||||
{
|
||||
// blah
|
||||
}
|
||||
|
||||
void dfedit::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 dfedit::slotSetupDFs(bool )
|
||||
{
|
||||
// dialog showing all the versions in Memory.xml that lets the user set up ways to run those versions...
|
||||
// currently unimplemented
|
||||
}
|
||||
|
||||
#include "dfedit.moc"
|
@ -0,0 +1,26 @@
|
||||
#ifndef dfedit_H
|
||||
#define dfedit_H
|
||||
|
||||
#include <QtGui/QMainWindow>
|
||||
#include "ui_main.h"
|
||||
#include "memxmlModel.h"
|
||||
|
||||
class dfedit : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
dfedit(QWidget *parent = 0);
|
||||
virtual ~dfedit();
|
||||
|
||||
private:
|
||||
Ui::MainWindow ui;
|
||||
MemXMLModel * mod;
|
||||
public slots:
|
||||
void slotOpen(bool);
|
||||
void slotQuit(bool);
|
||||
void slotSave(bool);
|
||||
void slotSaveAs(bool);
|
||||
void slotRunDF(bool);
|
||||
void slotSetupDFs(bool);
|
||||
};
|
||||
#endif // dfedit_H
|
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 114 KiB |
@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>633</width>
|
||||
<height>622</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/main_icon/main_64.png</normaloff>:/main_icon/main_64.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="entryView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_As"/>
|
||||
<addaction name="actionRun_DF"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="descriptioDock">
|
||||
<property name="features">
|
||||
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="DescriptionPanel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:600;">Title text</span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Some other text.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockWidget">
|
||||
<property name="floating">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Entries</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTreeView" name="structureView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>633</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_As"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<addaction name="actionSetup_DF_executables"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuSettings"/>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_As">
|
||||
<property name="text">
|
||||
<string>Save As</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRun_DF">
|
||||
<property name="text">
|
||||
<string>Run DF</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetup_DF_executables">
|
||||
<property name="text">
|
||||
<string>Setup DF executables</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Binary file not shown.
After Width: | Height: | Size: 718 B |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="main_icon">
|
||||
<file>main_64.png</file>
|
||||
<file>main_16.png</file>
|
||||
<file>main_32.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -0,0 +1,11 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include "dfedit.h"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
dfedit appGui;
|
||||
appGui.show();
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
|
||||
**
|
||||
** This file was part of the example classes of the Qt Toolkit.
|
||||
** Now it's being hacked into some other shape... :)
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "memxmlModel.h"
|
||||
#include <QtGui>
|
||||
#include <QtXml>
|
||||
#include <QDomNode>
|
||||
#include <QHash>
|
||||
|
||||
class DomItem
|
||||
{
|
||||
public:
|
||||
DomItem(QDomNode &node, int row, DomItem *parent = 0);
|
||||
~DomItem();
|
||||
DomItem *child(int i);
|
||||
DomItem *parent();
|
||||
QDomNode node() const;
|
||||
int row();
|
||||
|
||||
private:
|
||||
QDomNode domNode;
|
||||
QHash<int,DomItem*> childItems;
|
||||
DomItem *parentItem;
|
||||
int rowNumber;
|
||||
};
|
||||
|
||||
DomItem::DomItem(QDomNode &node, int row, DomItem *parent)
|
||||
{
|
||||
domNode = node;
|
||||
// Record the item's location within its parent.
|
||||
rowNumber = row;
|
||||
parentItem = parent;
|
||||
}
|
||||
|
||||
DomItem::~DomItem()
|
||||
{
|
||||
QHash<int,DomItem*>::iterator it;
|
||||
for (it = childItems.begin(); it != childItems.end(); ++it)
|
||||
delete it.value();
|
||||
}
|
||||
|
||||
QDomNode DomItem::node() const
|
||||
{
|
||||
return domNode;
|
||||
}
|
||||
|
||||
DomItem *DomItem::parent()
|
||||
{
|
||||
return parentItem;
|
||||
}
|
||||
|
||||
DomItem *DomItem::child(int i)
|
||||
{
|
||||
if (childItems.contains(i))
|
||||
return childItems[i];
|
||||
|
||||
if (i >= 0 && i < domNode.childNodes().count()) {
|
||||
QDomNode childNode = domNode.childNodes().item(i);
|
||||
DomItem *childItem = new DomItem(childNode, i, this);
|
||||
childItems[i] = childItem;
|
||||
return childItem;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DomItem::row()
|
||||
{
|
||||
return rowNumber;
|
||||
}
|
||||
|
||||
MemXMLModel::MemXMLModel(QDomDocument document, QObject *parent)
|
||||
: QAbstractItemModel(parent), domDocument(document)
|
||||
{
|
||||
rootItem = new DomItem(domDocument, 0);
|
||||
}
|
||||
|
||||
MemXMLModel::~MemXMLModel()
|
||||
{
|
||||
delete rootItem;
|
||||
}
|
||||
|
||||
int MemXMLModel::columnCount(const QModelIndex & parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return 3;
|
||||
}
|
||||
|
||||
QVariant MemXMLModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
DomItem *item = static_cast<DomItem*>(index.internalPointer());
|
||||
|
||||
QDomNode node = item->node();
|
||||
QStringList attributes;
|
||||
QDomNamedNodeMap attributeMap = node.attributes();
|
||||
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return node.nodeName();
|
||||
case 1:
|
||||
for (int i = 0; (unsigned int)(i) < attributeMap.count(); ++i)
|
||||
{
|
||||
QDomNode attribute = attributeMap.item(i);
|
||||
attributes << attribute.nodeName() + "=\"" +attribute.nodeValue() + "\"";
|
||||
}
|
||||
return attributes.join(" ");
|
||||
case 2:
|
||||
return node.nodeValue().split("\n").join(" ");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags MemXMLModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return Qt::ItemIsEnabled;
|
||||
}
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant MemXMLModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return tr("Name");
|
||||
case 1:
|
||||
return tr("Attributes");
|
||||
case 2:
|
||||
return tr("Value");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex MemXMLModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
DomItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<DomItem*>(parent.internalPointer());
|
||||
|
||||
DomItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex MemXMLModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
if (!child.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
|
||||
DomItem *parentItem = childItem->parent();
|
||||
|
||||
if (!parentItem || parentItem == rootItem)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int MemXMLModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
DomItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<DomItem*>(parent.internalPointer());
|
||||
|
||||
return parentItem->node().childNodes().count();
|
||||
}
|
||||
|
||||
#include "memxmlModel.moc"
|
@ -0,0 +1,30 @@
|
||||
#ifndef memxmlModel_H
|
||||
#define memxmlModel_H
|
||||
|
||||
#include <qabstractitemmodel.h>
|
||||
#include <qdom.h>
|
||||
|
||||
class DomItem;
|
||||
|
||||
class MemXMLModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MemXMLModel(QDomDocument document, QObject *parent = 0);
|
||||
~MemXMLModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
private:
|
||||
QDomDocument domDocument;
|
||||
DomItem *rootItem;
|
||||
};
|
||||
#endif // memxmlModel
|
@ -0,0 +1,73 @@
|
||||
// clears the "tasked" flag on all items
|
||||
// original code by Quietust (http://www.bay12forums.com/smf/index.php?action=profile;u=18111)
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <climits>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
#include <DFHack.h>
|
||||
#include <dfhack/DFVector.h>
|
||||
#include <dfhack/DFTypes.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
DFHack::Process * p;
|
||||
unsigned int i;
|
||||
DFHack::ContextManager DFMgr("Memory.xml");
|
||||
DFHack::Context * DF;
|
||||
try
|
||||
{
|
||||
DF = DFMgr.getSingleContext();
|
||||
DF->Attach();
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
cerr << e.what() << endl;
|
||||
#ifndef LINUX_BUILD
|
||||
cin.ignore();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
DFHack::memory_info * mem = DF->getMemoryInfo();
|
||||
p = DF->getProcess();
|
||||
uint32_t item_vec_offset = 0;
|
||||
try
|
||||
{
|
||||
item_vec_offset = p->getDescriptor()->getAddress ("items_vector");
|
||||
}
|
||||
catch(DFHack::Error::MissingMemoryDefinition & e)
|
||||
{
|
||||
cerr << "missing offset for the item vector, exiting :(" << endl;
|
||||
#ifndef LINUX_BUILD
|
||||
cin.ignore();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
DFHack::DfVector <uint32_t> p_items (p, item_vec_offset);
|
||||
uint32_t size = p_items.size();
|
||||
|
||||
int numtasked = 0;
|
||||
for (i=0;i<size;i++)
|
||||
{
|
||||
DFHack::t_itemflags flags;
|
||||
flags.whole = p->readDWord(p_items[i] + 0x0C);
|
||||
if (flags.bits.in_job)
|
||||
{
|
||||
flags.bits.in_job = 0;
|
||||
p->writeDWord(p_items[i] + 0x0C, flags.whole);
|
||||
numtasked++;
|
||||
}
|
||||
}
|
||||
cout << "Found and untasked " << numtasked << " items." << endl;
|
||||
|
||||
#ifndef LINUX_BUILD
|
||||
cout << "Done. Press any key to continue" << endl;
|
||||
cin.ignore();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue