Added: Added bnp manager plugin basic layout, list and unpack for ovqt

This commit is contained in:
Krolock 2012-01-04 09:51:10 +01:00
parent be53b772b5
commit 34bfcc1af8
25 changed files with 1647 additions and 0 deletions

View file

@ -7,6 +7,7 @@ ADD_SUBDIRECTORY(disp_sheet_id)
ADD_SUBDIRECTORY(object_viewer)
ADD_SUBDIRECTORY(georges_editor)
ADD_SUBDIRECTORY(translation_manager)
ADD_SUBDIRECTORY(bnp_manager)
# Note: Temporarily disabled until development continues.
#ADD_SUBDIRECTORY(zone_painter)
# Ryzom Specific Plugins

View file

@ -0,0 +1,46 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES})
FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUG_BNP_MANAGER_HDR bnp_manager_plugin.h
bnp_manager_window.h
bnp_dirtree_dialog.h
bnp_filesystem_model.h
bnp_file.h
bnp_filelist_dialog.h
)
SET(OVQT_PLUG_BNP_MANAGER_UIS bnp_dirtree_form.ui
bnp_filelist_dialog.ui
)
SET(OVQT_PLUGIN_BNP_MANAGER_RCS bnp_manager.qrc)
SET(QT_USE_QTGUI TRUE)
QT4_ADD_RESOURCES(OVQT_PLUGIN_BNP_MANAGER_RC_SRCS ${OVQT_PLUGIN_BNP_MANAGER_RCS})
QT4_WRAP_CPP(OVQT_PLUG_BNP_MANAGER_MOC_SRC ${OVQT_PLUG_BNP_MANAGER_HDR})
QT4_WRAP_UI(OVQT_PLUG_BNP_MANAGER_UI_HDRS ${OVQT_PLUG_BNP_MANAGER_UIS})
SOURCE_GROUP(QtResources FILES ${OVQT_PLUG_BNP_MANAGER_UIS} ${OVQT_PLUGIN_BNP_MANAGER_RCS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUG_BNP_MANAGER_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_PLUG_BNP_MANAGER_MOC_SRC})
SOURCE_GROUP("BNP Manager Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_bnp_manager MODULE ${SRC} ${OVQT_PLUG_BNP_MANAGER_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUGIN_BNP_MANAGER_RC_SRCS} ${OVQT_PLUG_BNP_MANAGER_UI_HDRS})
TARGET_LINK_LIBRARIES(ovqt_plugin_bnp_manager ovqt_plugin_core nelmisc nelgeorges ${QT_LIBRARIES})
NL_DEFAULT_PROPS(ovqt_plugin_bnp_manager "NeL, Tools, 3D: Object Viewer Qt Plugin: BNP Manager")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_bnp_manager)
NL_ADD_LIB_SUFFIX(ovqt_plugin_bnp_manager)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
INSTALL(TARGETS ovqt_plugin_bnp_manager LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)

View file

@ -0,0 +1,87 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "bnp_dirtree_dialog.h"
#include "bnp_filesystem_model.h"
// Qt includes
#include <QtGui/QWidget>
// NeL includes
#include <nel/misc/debug.h>
namespace BNPManager
{
CBnpDirTreeDialog::CBnpDirTreeDialog(QString bnpPath, QWidget *parent)
: QDockWidget(parent),
m_DataPath(bnpPath)
{
// Setup the dialog
m_ui.setupUi(this);
// Filter settings to only display files with bnp extension.
// Could be changed to display all files and react according to the extension:
// Bnp file: opened and displayed
// all other files: added to the currently opened bnp file
QStringList filter;
filter << tr("*.bnp");
// Setup the directory tree model
m_dirModel= new BNPFileSystemModel;
m_dirModel->setRootPath(m_DataPath);
m_dirModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::AllEntries);
m_dirModel->setNameFilters(filter);
m_dirModel->setNameFilterDisables(0);
m_ui.dirTree->setModel(m_dirModel);
m_ui.dirTree->setRootIndex(m_dirModel->index(m_DataPath));
// Trigger if one filename is activated
// In future drag&drop should be also possible
connect(m_ui.dirTree, SIGNAL(activated(QModelIndex)),
this, SLOT(fileSelected(QModelIndex)));
}
// ***************************************************************************
CBnpDirTreeDialog::~CBnpDirTreeDialog()
{
}
// ***************************************************************************
void CBnpDirTreeDialog::fileSelected(QModelIndex index)
{
if (index.isValid() && !m_dirModel->isDir(index))
{
// emit the according signal to BNPManagerWindow class
Q_EMIT selectedForm(m_dirModel->fileInfo(index).filePath());
}
}
// ***************************************************************************
void CBnpDirTreeDialog::changeFile(QString file)
{
}
// ***************************************************************************
void CBnpDirTreeDialog::BnpPathChanged(QString path)
{
}
// ***************************************************************************
}

View file

@ -0,0 +1,80 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_DIRTREE_DIALOG_H
#define BNP_DIRTREE_DIALOG_H
// Qt includes
#include <QtGui/QWidget>
// STL includes
// NeL includes
// Project includes
#include "ui_bnp_dirtree_form.h"
namespace BNPManager
{
class BNPFileSystemModel;
class CBnpDirTreeDialog : public QDockWidget
{
Q_OBJECT
public:
/**
* Constructor
* \param path to root directory, which should be displayed
*/
CBnpDirTreeDialog(QString bnpPath, QWidget *parent = 0);
/**
* Destructor
*/
~CBnpDirTreeDialog();
/**
* Change the root path for the dir tree view
* \param data path to the new directory
*/
void BnpPathChanged(QString);
private:
Ui::CBnpDirTreeDialog m_ui;
// path ro data root directory
QString m_DataPath;
BNPFileSystemModel *m_dirModel;
Q_SIGNALS:
void selectedForm(const QString);
private Q_SLOTS:
/**
* Triggered if the user activates (double klick on windows)
* a file name in the dir tree view
* \param selected ModelIndex (filename)
*/
void fileSelected(QModelIndex index);
void changeFile(QString file);
};
}
#endif

View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CBnpDirTreeDialog</class>
<widget class="QDockWidget" name="CBnpDirTreeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>141</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="windowTitle">
<string>BNP Datapath</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QTreeView" name="dirTree">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../../object_viewer_qt.qrc"/>
<include location="../core/core.qrc"/>
<include location="bnp_manager.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,204 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "bnp_file.h"
// Nel includes
#include <nel/misc/debug.h>
#include <nel/misc/file.h>
#include <nel/misc/path.h>
#include <nel/misc/algo.h>
#include <nel/misc/common.h>
// Qt includes
using namespace NLMISC;
using namespace std;
namespace BNPManager
{
NLMISC_SAFE_SINGLETON_IMPL(BNPFileHandle);
BNPFileHandle::BNPFileHandle()
{
m_offsetFromBeginning = 0;
}
// ***************************************************************************
BNPFileHandle::~BNPFileHandle()
{
// Erase the list
m_packedFiles.clear();
}
// ***************************************************************************
void BNPFileHandle::releaseInstance()
{
if (_Instance)
{
NLMISC::INelContext::getInstance().releaseSingletonPointer("BNPFileHandle", _Instance);
delete _Instance;
_Instance = NULL;
}
}
// ***************************************************************************
bool BNPFileHandle::unpack(const string &dirName, const vector<string>& fileList)
{
FILE *bnp = fopen (m_activeBNPFile.c_str(), "rb");
FILE *out;
if (bnp == NULL)
return false;
TPackedFilesList::iterator it_files = m_packedFiles.begin();
for (it_files; it_files != m_packedFiles.end(); it_files++)
{
// Check if the file should be unpacked or not
if (find(fileList.begin(), fileList.end(), it_files->m_name) != fileList.end())
{
string filename = dirName + "/" + it_files->m_name;
out = fopen (filename.c_str(), "wb");
if (out != NULL)
{
nlfseek64 (bnp, it_files->m_pos, SEEK_SET);
uint8 *ptr = new uint8[it_files->m_size];
if (fread (ptr, it_files->m_size, 1, bnp) != 1)
{
nlwarning("%s read error", filename.c_str());
return false;
}
if (fwrite (ptr, it_files->m_size, 1, out) != 1)
{
nlwarning("%s write error", filename.c_str());
return false;
}
fclose (out);
delete [] ptr;
}
}
}
fclose (bnp);
return true;
}
// ***************************************************************************
// Read the header from a big file
bool BNPFileHandle::readHeader(const std::string &filename)
{
m_packedFiles.clear();
m_activeBNPFile = filename;
FILE *f = fopen (filename.c_str(), "rb");
if (f == NULL)
{
nlwarning("Could not open file!");
return false;
}
nlfseek64 (f, 0, SEEK_END);
uint32 nFileSize=CFile::getFileSize (filename );
nlfseek64 (f, nFileSize-sizeof(uint32), SEEK_SET);
uint32 nOffsetFromBegining;
if (fread (&nOffsetFromBegining, sizeof(uint32), 1, f) != 1)
{
fclose (f);
return false;
}
#ifdef NL_BIG_ENDIAN
NLMISC_BSWAP32(nOffsetFromBegining);
#endif
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
{
nlwarning("Could not read offset from begining");
fclose (f);
return false;
}
uint32 nNbFile;
if (fread (&nNbFile, sizeof(uint32), 1, f) != 1)
{
nlwarning("Could not read number of files!");
fclose (f);
return false;
}
#ifdef NL_BIG_ENDIAN
NLMISC_BSWAP32(nNbFile);
#endif
for (uint32 i = 0; i < nNbFile; ++i)
{
uint8 nStringSize;
char sName[256];
if (fread (&nStringSize, 1, 1, f) != 1)
{
nlwarning("Error reading packed filename!");
fclose (f);
return false;
}
if (fread (sName, 1, nStringSize, f) != nStringSize)
{
fclose (f);
return false;
}
sName[nStringSize] = 0;
PackedFile tmpPackedFile;
tmpPackedFile.m_name = sName;
if (fread (&tmpPackedFile.m_size, sizeof(uint32), 1, f) != 1)
{
nlwarning("Error reading packed file size!");
fclose (f);
return false;
}
#ifdef NL_BIG_ENDIAN
NLMISC_BSWAP32(tmpBNPFile.Size);
#endif
if (fread (&tmpPackedFile.m_pos, sizeof(uint32), 1, f) != 1)
{
nlwarning("Error reading packed file position!");
fclose (f);
return false;
}
#ifdef NL_BIG_ENDIAN
NLMISC_BSWAP32(tmpBNPFile.Pos);
#endif
m_packedFiles.push_back (tmpPackedFile);
}
fclose (f);
return true;
}
// ***************************************************************************
void BNPFileHandle::list(TPackedFilesList& FileList)
{
PackedFile tmpFile;
TPackedFilesList::iterator it = m_packedFiles.begin();
while (it != m_packedFiles.end() )
{
tmpFile.m_name = it->m_name;
tmpFile.m_pos = it->m_pos;
tmpFile.m_size = it->m_size;
FileList.push_back(tmpFile);
it++;
}
}
// ***************************************************************************
} // namespace BNPManager

View file

@ -0,0 +1,103 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_FILE_H
#define BNP_FILE_H
// Project includes
// Nel includes
#include "nel/misc/types_nl.h"
#include <nel/misc/singleton.h>
// Qt includes
#include <QString>
namespace BNPManager
{
struct PackedFile
{
std::string m_name;
uint32 m_size;
uint32 m_pos;
};
typedef std::vector<PackedFile> TPackedFilesList;
class BNPFileHandle
{
NLMISC_SAFE_SINGLETON_DECL(BNPFileHandle)
/**
* Private constructor
*/
BNPFileHandle();
/**
* Private destructor
*/
~BNPFileHandle();
public:
// release memory
static void releaseInstance();
/*void append (const QString destFilename, const QString origFilename, uint32 sizeToRead);
void packRecurse();*/
/**
* Read the header from the bnp file and create a filelist
* \param filename (consisting the whole path)
*/
bool readHeader (const std::string &filename);
/**
* Append the header to a created bnp file
* \param filename (consisting the whole path)
*/
void appendHeader (const std::string &filename) {};
/**
* Create a list of all packed files inside the bnp file
* \param reference to the list, which has to be filled
*/
void list (TPackedFilesList& FileList);
/**
* Unpack the selected packed files into user defined dir
* \param directory path, where the files should be unpacked
* \param list of files, which has to be unpacked
*/
bool unpack (const std::string &dirName, const std::vector<std::string>& fileList);
private:
TPackedFilesList m_packedFiles;
// currently opened and displayed bnp file
std::string m_activeBNPFile;
// offset where the header of the bnp file begins
uint32 m_offsetFromBeginning;
};
}
#endif

View file

@ -0,0 +1,122 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "bnp_filelist_dialog.h"
#include "bnp_file.h"
// Qt includes
#include <QtGui/QWidget>
// NeL includes
#include <nel/misc/debug.h>
using namespace std;
namespace BNPManager
{
BnpFileListDialog::BnpFileListDialog(QString bnpPath, QWidget *parent)
: QDockWidget(parent),
m_DataPath(bnpPath)
{
m_ui.setupUi(this);
}
// ***************************************************************************
BnpFileListDialog::~BnpFileListDialog()
{
}
// ***************************************************************************
void BnpFileListDialog::setupTable(int nbrows)
{
// delete all old entries
m_ui.tableWidget->clear();
// set 2 colums: filename and size
m_ui.tableWidget->setColumnCount(2);
// set number of rows according to the number of files in the bnp file
m_ui.tableWidget->setRowCount(nbrows);
// only entire rows can be selected
m_ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
// set the horizontal headers
QStringList labels;
labels << tr("Filename") << tr("Size");
m_ui.tableWidget->setHorizontalHeaderLabels(labels);
m_ui.tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Interactive);
m_ui.tableWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch );
m_ui.tableWidget->verticalHeader()->hide();
// set vertical size a little bit smaller
m_ui.tableWidget->verticalHeader()->setDefaultSectionSize(15);
m_ui.tableWidget->setShowGrid(false);
m_ui.tableWidget->setObjectName("tablewidget");
}
// ***************************************************************************
bool BnpFileListDialog::loadTable(const QString fileName)
{
// reference to the BNPFileHandle singletone instance
BNPFileHandle& myBNPFileHandle = BNPFileHandle::getInstance();
// string vector of all packed files inside a bnp
TPackedFilesList filelist;
int row = 0;
// read the header from the bnp file
if (!myBNPFileHandle.readHeader( fileName.toStdString()) )
{
return false;
}
myBNPFileHandle.list( filelist );
// create table with number of rows
setupTable(filelist.size());
// fill the table items
TPackedFilesList::iterator it = filelist.begin();
while (it != filelist.end() )
{
QTableWidgetItem *nameItem = new QTableWidgetItem (it->m_name.c_str() );
QTableWidgetItem *sizeItem = new QTableWidgetItem (tr("%1 KB").arg(it->m_size));
m_ui.tableWidget->setItem(row, 0, nameItem);
m_ui.tableWidget->setItem(row, 1, sizeItem);
it++;
row++;
}
return true;
}
// ***************************************************************************
void BnpFileListDialog::getSelections(TSelectionList& SelectionList)
{
QModelIndex index;
QAbstractItemModel *model = m_ui.tableWidget->model();
QItemSelectionModel *selection = m_ui.tableWidget->selectionModel();
QModelIndexList indexes = selection->selectedRows();
Q_FOREACH(index, indexes)
{
QVariant data = model->data(index);
QString filename = data.toString();
SelectionList.push_back( filename.toStdString() );
}
}
// ***************************************************************************
} // namespace BNPManager

View file

@ -0,0 +1,81 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_FILELIST_DIALOG_H
#define BNP_FILELIST_DIALOG_H
// Qt includes
#include <QtGui/QWidget>
// STL includes
#include <vector>
#include <string>
// NeL includes
// Project includes
#include "ui_bnp_filelist_dialog.h"
namespace BNPManager
{
typedef std::vector<std::string> TSelectionList;
class BnpFileListDialog : public QDockWidget
{
Q_OBJECT
public:
// Constructor
BnpFileListDialog(QString bnpPath, QWidget *parent = 0);
// Destructor
~BnpFileListDialog();
/**
* Load the bnp file and setup the table view
* \param Filename
* \return true if everything went well
*/
bool loadTable(const QString filename);
/**
* Set the dimension of the table
* \param number of rows
*/
void setupTable(int nbrows);
/**
* Fill the files selected in the table view to
* unpack them.
* \param reference to a vector of filenames.
* \return true if everything went well
*/
void getSelections(TSelectionList& SelectionList);
private:
Ui::BnpFileListDialog m_ui;
// common data path as root folder for the dirtree view
QString m_DataPath;
};
}
#endif

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BnpFileListDialog</class>
<widget class="QDockWidget" name="BnpFileListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>141</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="windowTitle">
<string>BNP File List</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>15</number>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../../object_viewer_qt.qrc"/>
<include location="../core/core.qrc"/>
<include location="bnp_manager.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,52 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#include "bnp_filesystem_model.h"
#include <QApplication>
#include <QStyle>
namespace BNPManager
{
BNPFileSystemModel::BNPFileSystemModel(QObject *parent)
: QFileSystemModel(parent)
{
}
// ***************************************************************************
BNPFileSystemModel::~BNPFileSystemModel()
{
}
// ***************************************************************************
int BNPFileSystemModel::columnCount(const QModelIndex &) const
{
return 1;
}
// ***************************************************************************
QVariant BNPFileSystemModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DecorationRole)
{
if (isDir(index))
return QApplication::style()->standardIcon(QStyle::SP_DirIcon);
}
return QFileSystemModel::data(index, role);
}
// ***************************************************************************
} // namespace BNPManager

View file

@ -0,0 +1,49 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#ifndef BNP_FILESYSTEM_MODEL_H
#define BNP_FILESYSTEM_MODEL_H
#include <QtGui/QFileSystemModel>
namespace BNPManager
{
class BNPFileSystemModel : public QFileSystemModel
{
Q_OBJECT
public:
/**
* Constructor
*/
BNPFileSystemModel(QObject *parent = 0);
/**
* Destructor
*/
~BNPFileSystemModel();
int columnCount(const QModelIndex &) const;
QVariant data(const QModelIndex& index, int role) const ;
};
}
#endif

View file

@ -0,0 +1,9 @@
<RCC>
<qresource>
<file>images/ic_nel_bnp_make.png</file>
<file>images/ic_nel_delete_item.png</file>
<file>images/ic_nel_add_item.png</file>
<file>images/ic_nel_export.png</file>
<file>images/ic_nel_reset_all.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,37 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_MANAGER_CONSTANTS_H
#define BNP_MANAGER_CONSTANTS_H
namespace BNPManager
{
namespace Constants
{
//settings
const char * const BNP_MANAGER_SECTION = "BNPManager";
//resources
const char *const ICON_ADD = ":/images/ic_nel_add_item.png";
const char *const ICON_DELETE = ":/images/ic_nel_delete_item.png";
const char *const ICON_UNPACK = ":/images/ic_nel_export.png";
const char *const ICON_CLOSE = ":/images/ic_nel_reset_all.png";
} // namespace Constants
} // namespace Plugin
#endif

View file

@ -0,0 +1,89 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "bnp_manager_plugin.h"
#include "bnp_manager_window.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/menu_manager.h"
// NeL includes
#include "nel/misc/debug.h"
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QMainWindow>
namespace BNPManager
{
BNPManagerPlugin::BNPManagerPlugin()
{
}
BNPManagerPlugin::~BNPManagerPlugin()
{
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{
m_plugMan->removeObject(obj);
}
qDeleteAll(m_autoReleaseObjects);
m_autoReleaseObjects.clear();
}
bool BNPManagerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
m_plugMan = pluginManager;
addAutoReleasedObject(new BNPManagerContext(this));
return true;
}
void BNPManagerPlugin::extensionsInitialized()
{
}
void BNPManagerPlugin::shutdown()
{
}
void BNPManagerPlugin::setNelContext(NLMISC::INelContext *nelContext)
{
#ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS
m_libContext = new NLMISC::CLibraryContext(*nelContext);
}
void BNPManagerPlugin::addAutoReleasedObject(QObject *obj)
{
m_plugMan->addObject(obj);
m_autoReleaseObjects.prepend(obj);
}
/*void BNPManagerContext::open()
{
m_BnpManagerWindow->open();
}*/
}
Q_EXPORT_PLUGIN(BNPManager::BNPManagerPlugin)

View file

@ -0,0 +1,130 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_MANAGER_PLUGIN_H
#define BNP_MANAGER_PLUGIN_H
// Project includes
#include "../../extension_system/iplugin.h"
#include "../core/icontext.h"
#include "bnp_manager_window.h"
// NeL includes
#include "nel/misc/app_context.h"
#include <nel/misc/debug.h>
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace NLMISC
{
class CLibraryContext;
}
namespace ExtensionSystem
{
class IPluginSpec;
}
namespace BNPManager
{
class m_BnpManagerWindow;
class BNPManagerPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
BNPManagerPlugin();
virtual ~BNPManagerPlugin();
virtual bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
virtual void extensionsInitialized();
virtual void shutdown();
virtual void setNelContext(NLMISC::INelContext *nelContext);
void addAutoReleasedObject(QObject *obj);
protected:
NLMISC::CLibraryContext *m_libContext;
private:
ExtensionSystem::IPluginManager *m_plugMan;
QList<QObject *> m_autoReleaseObjects;
};
/**
* Implementation of the IContext interface
*
* \date 2011
*/
class BNPManagerContext : public Core::IContext
{
Q_OBJECT
public:
// Constructor
BNPManagerContext(QObject *parent = 0) : IContext(parent)
{
// run new manager window app
m_BnpManagerWindow = new BNPManagerWindow();
}
// Destructor
virtual ~BNPManagerContext() {}
virtual QString id() const
{
return QLatin1String("BNPManagerContext");
}
virtual QString trName() const
{
return tr("BNP Manager");
}
virtual QIcon icon() const
{
return QIcon(":/images/ic_nel_bnp_make.png");
}
virtual void open()
{
m_BnpManagerWindow->open();
}
virtual QUndoStack *undoStack()
{
return m_BnpManagerWindow->m_undoStack;
}
virtual QWidget *widget()
{
return m_BnpManagerWindow;
}
BNPManagerWindow *m_BnpManagerWindow;
};
} // namespace Plugin
#endif // BNP_MANAGER_PLUGIN_H

View file

@ -0,0 +1,223 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "bnp_manager_window.h"
#include "bnp_manager_constants.h"
#include "bnp_dirtree_dialog.h"
#include "bnp_filelist_dialog.h"
#include "bnp_file.h"
#include "../core/icore.h"
#include "../core/menu_manager.h"
#include "../core/core_constants.h"
#include "../../extension_system/iplugin_spec.h"
// NeL includes
#include <nel/misc/debug.h>
// Qt includes
#include <QDebug>
#include <QFileDialog>
#include <QToolBar>
#include <QTableWidget>
#include <QMessageBox>
#include <QSettings>
using namespace std;
using namespace NLMISC;
namespace BNPManager
{
BNPManagerWindow::BNPManagerWindow(QWidget *parent)
: QMainWindow(parent)
{
// add new mainwindow for sheet dockwidgets
QTableWidget* hideWidget = new QTableWidget(0,0,this);
setCentralWidget(hideWidget);
hideWidget->hide();
// Read the settings
readSettings();
// create main dialogs and display them
createDialogs();
// create actions like open, close, add etc.
createActions();
// create a toolbar with icons
createToolBars();
// this SLOT is triggered if the user activates a bnp files in the
// dirtree view
connect(m_BnpDirTreeDialog, SIGNAL(selectedForm(const QString)),
this, SLOT(loadFile(const QString)));
// not used
m_undoStack = new QUndoStack(this);
}
// ***************************************************************************
BNPManagerWindow::~BNPManagerWindow()
{
writeSettings();
}
// ***************************************************************************
void BNPManagerWindow::createDialogs()
{
// create dialog to list the contents of the specified
// bnp data file directory
m_BnpDirTreeDialog = new CBnpDirTreeDialog(tr(m_DataPath.toStdString().c_str()),this);
addDockWidget(Qt::LeftDockWidgetArea, m_BnpDirTreeDialog);
m_BnpDirTreeDialog->setVisible(true);
restoreDockWidget(m_BnpDirTreeDialog);
// create dialog to list the packed file contents of bnp files on
// the right hand side
m_BnpFileListDialog = new BnpFileListDialog(m_DataPath,this);
addDockWidget(Qt::RightDockWidgetArea, m_BnpFileListDialog);
m_BnpFileListDialog->setVisible(true);
restoreDockWidget(m_BnpFileListDialog);
}
// ***************************************************************************
void BNPManagerWindow::createActions()
{
// open action
m_openAction = new QAction(tr("&Open..."), this);
m_openAction->setIcon(QIcon(Core::Constants::ICON_OPEN));
m_openAction->setStatusTip(tr("Open file"));
connect(m_openAction, SIGNAL(triggered()), this, SLOT( open() ));
// close action
m_closeAction = new QAction(tr("&Close..."), this);
m_closeAction->setIcon(QIcon(Constants::ICON_CLOSE));
m_closeAction->setStatusTip(tr("Close the BNP File"));
connect(m_closeAction, SIGNAL(triggered()), this, SLOT( close() ));
// add files into the bnp file
m_addFilesAction = new QAction(tr("&Add..."), this);
m_addFilesAction->setIcon(QIcon(Constants::ICON_ADD));
m_addFilesAction->setStatusTip(tr("Add Files to BNP"));
connect(m_addFilesAction, SIGNAL(triggered()), this, SLOT( addFiles() ));
// delete files from the bnp file
m_deleteFilesAction = new QAction(tr("&Delete..."), this);
m_deleteFilesAction->setIcon(QIcon(Constants::ICON_DELETE));
m_deleteFilesAction->setStatusTip(tr("Delete Files"));
connect(m_deleteFilesAction, SIGNAL(triggered()), this, SLOT( deleteFiles() ));
// unpack selected files into user defined dir
m_unpackFilesAction = new QAction(tr("&Unpack..."), this);
m_unpackFilesAction->setIcon(QIcon(Constants::ICON_UNPACK));
m_unpackFilesAction->setStatusTip(tr("Unpack Files"));
connect(m_unpackFilesAction, SIGNAL(triggered()), this, SLOT( unpackFiles() ));
}
// ***************************************************************************
void BNPManagerWindow::createToolBars()
{
m_fileToolBar = addToolBar(tr("&File"));
m_fileToolBar->addAction(m_openAction);
m_fileToolBar->addAction(m_closeAction);
m_toolsBar = addToolBar(tr("&Tools"));
m_toolsBar->addAction(m_addFilesAction);
m_toolsBar->addAction(m_deleteFilesAction);
m_toolsBar->addAction(m_unpackFilesAction);
}
// ***************************************************************************
bool BNPManagerWindow::loadFile(const QString fileName)
{
m_BnpFileListDialog->loadTable(fileName);
return true;
}
// ***************************************************************************
void BNPManagerWindow::open()
{
QString fileName;
// file dialog to select with file should be opened
fileName = QFileDialog::getOpenFileName(this,
tr("Open BNP file"), tr(m_DataPath.toStdString().c_str()), tr("BNP Files (*.bnp)"));
// check if there is a filename
if (fileName.isNull())
return;
loadFile(fileName);
}
// ***************************************************************************
void BNPManagerWindow::close()
{
//TODO
}
// ***************************************************************************
void BNPManagerWindow::addFiles()
{
//TODO
}
// ***************************************************************************
void BNPManagerWindow::deleteFiles()
{
//TODO
}
// ***************************************************************************
void BNPManagerWindow::unpackFiles()
{
QFileDialog filedialog(this);
BNPFileHandle& myBNPFileHandle = BNPFileHandle::getInstance();
vector<string> selectedrows;
m_BnpFileListDialog->getSelections(selectedrows);
// Check if files were selected. If not, inform the user.
// TODO: Ask the user if nothing was selected, if he wants to unpack all
// files. This is more like Winzip.
if (selectedrows.empty())
{
QMessageBox::information(this, tr("BNP Manager"),
tr("No files were selected to unpack!"),
QMessageBox::Ok,
QMessageBox::Ok);
return;
}
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
tr(m_DataPath.toStdString().c_str()),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (myBNPFileHandle.unpack(dir.toStdString(),selectedrows))
{
QMessageBox::information(this, tr("BNP Manager"),
tr("All files has been exported successfully."),
QMessageBox::Ok,
QMessageBox::Ok);
}
}
// ***************************************************************************
void BNPManagerWindow::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
m_DataPath = settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString();
settings->endGroup();
}
// ***************************************************************************
void BNPManagerWindow::writeSettings()
{
}
} // namespace BNPManager

View file

@ -0,0 +1,146 @@
// Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Roland Winklmeier <roland.m.winklmeier@googlemail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BNP_MANAGER_WINDOW_H
#define BNP_MANAGER_WINDOW_H
// Project includes
//#include "ui_bnp_manager_window.h"
// Qt includes
#include <QtGui/QMainWindow>
#include <QtGui/QLabel>
#include <QtGui/QUndoStack>
#include <QtGui/QTableWidget>
namespace BNPManager
{
class CBnpDirTreeDialog;
class BnpFileListDialog;
class BNPFileHandle;
/**
* Main window class. Derived from QMainWindow and implements
* the basic layout like menue, toolbars and dialogs.
*
* \date 2011
*/
class BNPManagerWindow : public QMainWindow
{
Q_OBJECT
public:
// Constructor
BNPManagerWindow(QWidget *parent = 0);
//Destructor
~BNPManagerWindow();
QUndoStack *m_undoStack;
public Q_SLOTS:
/**
* Open a file dialog to choose which file should be opened.
* \return Filename string
*/
void open();
/**
* Load a certain bnp file into the manager
* \param Filename
* \return true if everything went well
*/
bool loadFile(const QString fileName);
/**
* close an opened bnp file and reset all views
*/
void close();
/**
* Add files into an opened bnp file.
* \param Filelist
*/
void addFiles();
/**
* Unpack the files marked in the filelist dialog into user defined
* directory.
* \param TBD
* \return true if everything went well
*/
void unpackFiles();
/**
* Delete marked files from the bnp file
* \param TBD
*/
void deleteFiles();
private:
/**
* Read plugin settings and set the window accordingly
*/
void readSettings();
/**
* Write plugin settings
*/
void writeSettings();
/**
* Create all plugin dialogs
*/
void createDialogs();
/**
* Create all plugin actions
*/
void createActions();
/**
* Create the plugin toolbar
*/
void createToolBars();
QToolBar *m_fileToolBar;
QToolBar *m_toolsBar;
QAction *m_openAction;
QAction *m_closeAction;
QAction *m_addFilesAction;
QAction *m_unpackFilesAction;
QAction *m_deleteFilesAction;
CBnpDirTreeDialog *m_BnpDirTreeDialog;
BnpFileListDialog *m_BnpFileListDialog;
QString m_DataPath;
BNPFileHandle *m_BNPFileHandle;
}; /* class BNPManagerWindow */
} /* namespace Plugin */
#endif

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BNPManagerWindow</class>
<widget class="QMainWindow" name="BNPManagerWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>BNP Manager</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true">QWidget#centralwidget {
image: url(:/images/ic_nel_georges_editor.png);
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item row="0" column="0">
<widget class="QTreeView" name="treeView"/>
</item>
</layout>
</widget>
<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>
</widget>
</widget>
<resources>
<include location="bnp_manager.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -0,0 +1,10 @@
<plugin-spec>
<library-name>ovqt_plugin_bnp_manager</library-name>
<name>BNPManager</name>
<version>0.1</version>
<vendor>Krolock</vendor>
<description>Edit BNP Files</description>
<dependencies>
<dependency plugin-name="Core" version="0.8"/>
</dependencies>
</plugin-spec>