Merging default changes into branch.

This commit is contained in:
sfb 2011-07-01 07:21:59 -05:00
commit bf706de3d3
35 changed files with 2148 additions and 8 deletions

View file

@ -7,3 +7,8 @@ ADD_SUBDIRECTORY(disp_sheet_id)
ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(object_viewer)
ADD_SUBDIRECTORY(zone_painter) ADD_SUBDIRECTORY(zone_painter)
ADD_SUBDIRECTORY(georges_editor) ADD_SUBDIRECTORY(georges_editor)
# Ryzom Specific Plugins
IF(WITH_RYZOM AND WITH_RYZOM_TOOLS)
ADD_SUBDIRECTORY(mission_compiler)
ENDIF(WITH_RYZOM AND WITH_RYZOM_TOOLS)

View file

@ -92,6 +92,8 @@ const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char * const LEVELDESIGN_PATH = "LevelDesignPath"; const char * const LEVELDESIGN_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "AssetsPath"; const char * const ASSETS_PATH = "AssetsPath";
const char * const PRIMITIVES_PATH = "PrimitivesPath";
const char * const LIGOCONFIG_FILE = "LigoConfigFile";
const char * const REMAP_EXTENSIONS = "RemapExtensions"; const char * const REMAP_EXTENSIONS = "RemapExtensions";
const char * const LOG_SECTION = "LogSettings"; const char * const LOG_SECTION = "LogSettings";

View file

@ -82,6 +82,15 @@ void GeneralSettingsPage::applyGeneralSettings()
else else
QApplication::setPalette(m_originalPalette); QApplication::setPalette(m_originalPalette);
settings->endGroup(); settings->endGroup();
// Add primitives path and ligo config file to CPath
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
QString primitivePath = settings->value(Core::Constants::PRIMITIVES_PATH, "l:/primitives").toString();
QString ligoConfigFile = settings->value(Core::Constants::LIGOCONFIG_FILE, "l:/leveldesign/world_editor_files/world_editor_classes.xml").toString();
NLMISC::CPath::addSearchPath(primitivePath.toStdString(), true, false);
NLMISC::CPath::display();
NLMISC::CPath::addSearchFile(ligoConfigFile.toStdString());
settings->endGroup();
} }
QWidget *GeneralSettingsPage::createPage(QWidget *parent) QWidget *GeneralSettingsPage::createPage(QWidget *parent)
@ -94,6 +103,8 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath())); connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath()));
connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath())); connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath()));
connect(m_ui.assetsPathButton, SIGNAL(clicked()), this, SLOT(setAssetsPath())); connect(m_ui.assetsPathButton, SIGNAL(clicked()), this, SLOT(setAssetsPath()));
connect(m_ui.primitivesPathButton, SIGNAL(clicked()), this, SLOT(setPrimitivesPath()));
connect(m_ui.ligoConfigFileButton, SIGNAL(clicked()), this, SLOT(setLigoConfigFile()));
return m_page; return m_page;
} }
@ -135,6 +146,27 @@ void GeneralSettingsPage::setLevelDesignPath()
} }
} }
void GeneralSettingsPage::setPrimitivesPath()
{
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the primitives path"),
m_ui.primitivesPathLineEdit->text());
if (!newPath.isEmpty())
{
m_ui.primitivesPathLineEdit->setText(newPath);
}
}
void GeneralSettingsPage::setLigoConfigFile()
{
QString newFile = QFileDialog::getOpenFileName(0, tr("Set the ligo config file"),
m_ui.ligoConfigFileLineEdit->text());
if (!newFile.isEmpty())
{
m_ui.ligoConfigFileLineEdit->setText(newFile);
}
}
void GeneralSettingsPage::setAssetsPath() void GeneralSettingsPage::setAssetsPath()
{ {
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"), QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"),
@ -165,6 +197,8 @@ void GeneralSettingsPage::readSettings()
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
m_ui.leveldesignPathLineEdit->setText(settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString()); m_ui.leveldesignPathLineEdit->setText(settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString());
m_ui.assetsPathLineEdit->setText(settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString()); m_ui.assetsPathLineEdit->setText(settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString());
m_ui.primitivesPathLineEdit->setText(settings->value(Core::Constants::PRIMITIVES_PATH, "l:/primitives").toString());
m_ui.ligoConfigFileLineEdit->setText(settings->value(Core::Constants::LIGOCONFIG_FILE, "l:/leveldesign/world_editor_files/world_editor_classes.xml").toString());
settings->endGroup(); settings->endGroup();
} }
@ -185,6 +219,8 @@ void GeneralSettingsPage::writeSettings()
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->text()); settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->text());
settings->setValue(Core::Constants::ASSETS_PATH, m_ui.assetsPathLineEdit->text()); settings->setValue(Core::Constants::ASSETS_PATH, m_ui.assetsPathLineEdit->text());
settings->setValue(Core::Constants::PRIMITIVES_PATH, m_ui.primitivesPathLineEdit->text());
settings->setValue(Core::Constants::LIGOCONFIG_FILE, m_ui.ligoConfigFileLineEdit->text());
settings->endGroup(); settings->endGroup();
settings->sync(); settings->sync();
} }

View file

@ -57,6 +57,8 @@ private Q_SLOTS:
void setPluginsPath(); void setPluginsPath();
void setLevelDesignPath(); void setLevelDesignPath();
void setAssetsPath(); void setAssetsPath();
void setPrimitivesPath();
void setLigoConfigFile();
private: private:
void readSettings(); void readSettings();

View file

@ -105,7 +105,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="pluginsPathLabel"> <widget class="QLabel" name="pluginsPathLabel">
<property name="text"> <property name="text">
<string>Plugins path:</string> <string>Plugins</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -129,7 +129,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="leveldesignPathLabel"> <widget class="QLabel" name="leveldesignPathLabel">
<property name="text"> <property name="text">
<string>Level design path:</string> <string>Sheets</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -153,7 +153,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="assetsPathLabel"> <widget class="QLabel" name="assetsPathLabel">
<property name="text"> <property name="text">
<string>Assets path:</string> <string>Assets Database:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -174,6 +174,40 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="primitivesPathLabel">
<property name="text">
<string>Primitives</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="primitivesPathLineEdit"/>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="primitivesPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="ligoConfigFileLineEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ligoConfigFileLabel">
<property name="text">
<string>Ligo Config File</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="ligoConfigFileButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View file

@ -103,7 +103,7 @@ namespace Plugin
QString CLogPlugin::name() const QString CLogPlugin::name() const
{ {
return "NeL Log"; return "LogPlugin";
} }
QString CLogPlugin::version() const QString CLogPlugin::version() const

View file

@ -99,11 +99,14 @@ namespace Plugin
writeSettings(); writeSettings();
ExtensionSystem::IPluginManager *p = Core::ICore::instance()->pluginManager(); ExtensionSystem::IPluginManager *p = Core::ICore::instance()->pluginManager();
ExtensionSystem::IPlugin *plugin = p->pluginByName("LogPlugin")->plugin(); ExtensionSystem::IPluginSpec *spec = p->pluginByName("LogPlugin");
CLogPlugin* lp = dynamic_cast<CLogPlugin*>(plugin);
if (lp) if(spec)
{ {
lp->setDisplayers(); ExtensionSystem::IPlugin *plugin = spec->plugin();
CLogPlugin* lp = dynamic_cast<CLogPlugin*>(plugin);
if (lp)
lp->setDisplayers();
} }
} }

View file

@ -0,0 +1,49 @@
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_MISSION_COMPILER_HDR mission_compiler_plugin.h
mission_compiler_main_window.h
mission_compiler_settings_page.h
server_entry_dialog.h)
SET(OVQT_PLUG_MISSION_COMPILER_UIS mission_compiler_main_window.ui server_entry_dialog.ui mission_compiler_settings_page.ui)
SET(OVQT_PLUG_MISSION_COMPILER_RCS mission_compiler.qrc)
SET(QT_USE_QTGUI TRUE)
QT4_WRAP_CPP(OVQT_PLUG_MISSION_COMPILER_MOC_SRC ${OVQT_PLUG_MISSION_COMPILER_HDR})
QT4_ADD_RESOURCES( OVQT_PLUG_MISSION_COMPILER_RC_SRCS ${OVQT_PLUG_MISSION_COMPILER_RCS})
QT4_WRAP_UI(OVQT_PLUG_MISSION_COMPILER_UI_HDRS ${OVQT_PLUG_MISSION_COMPILER_UIS})
SOURCE_GROUP(QtResources FILES ${OVQT_PLUG_MISSION_COMPILER_UIS} ${OVQT_PLUG_MISSION_COMPILER_RCS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUG_MISSION_COMPILER_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_PLUG_MISSION_COMPILER_MOC_SRC} ${OVQT_PLUG_MISSION_COMPILER_RC_SRCS})
SOURCE_GROUP("Mission Compiler Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
# Mission Compiler Library
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ryzom/tools/leveldesign/mission_compiler_lib)
# Game Share Library
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/src)
ADD_LIBRARY(ovqt_plugin_mission_compiler MODULE ${SRC} ${OVQT_PLUG_MISSION_COMPILER_MOC_SRC} ${OVQT_PLUG_MISSION_COMPILER_RC_SRCS} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_MISSION_COMPILER_UI_HDRS})
TARGET_LINK_LIBRARIES(ovqt_plugin_mission_compiler ovqt_plugin_core nelmisc nelligo ryzom_mission_compiler_lib ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
NL_DEFAULT_PROPS(ovqt_plugin_mission_compiler "NeL, Tools, 3D: Object Viewer Qt Plugin: Mission Compiler")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_mission_compiler)
NL_ADD_LIB_SUFFIX(ovqt_plugin_mission_compiler)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
INSTALL(TARGETS ovqt_plugin_mission_compiler LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -0,0 +1,17 @@
<RCC>
<qresource prefix="buttons">
<file>images/ic_nel_reset_all.png</file>
<file>images/ic_nel_add_item.png</file>
<file>images/ic_nel_delete_item.png</file>
<file>images/ic_nel_down_item.png</file>
<file>images/ic_nel_generic_settings.png</file>
<file>images/ic_nel_up_item.png</file>
<file>images/arrow-left-2.png</file>
<file>images/arrow-left-double-2.png</file>
<file>images/arrow-right-2.png</file>
<file>images/arrow-right-double-2.png</file>
<file>images/document-export-4.png</file>
<file>images/news-subscribe-2.png</file>
<file>images/run-build-2.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,390 @@
#include "mission_compiler_main_window.h"
#include "ui_mission_compiler_main_window.h"
#include "validation_file.h"
#include "mission_compiler.h"
#include <QMenu>
#include <QSignalMapper>
#include <QColor>
#include <QColorDialog>
#include <QSettings>
#include <QTextStream>
#include <QFileDialog>
#include <QDirIterator>
#include "../core/icore.h"
#include "../core/imenu_manager.h"
#include "../core/core_constants.h"
#include <nel/misc/common.h>
#include <nel/misc/path.h>
#include <nel/ligo/primitive_utils.h>
#include <nel/ligo/primitive.h>
#include <nel/ligo/ligo_config.h>
MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MissionCompilerMainWindow)
{
ui->setupUi(this);
m_lastDir = ".";
m_compileLog = "";
updateCompileLog();
// Load the settings.
loadConfig();
m_undoStack = new QUndoStack(this);
m_regexpFilter = new QRegExp();
m_regexpFilter->setPatternSyntax(QRegExp::FixedString);
m_regexpFilter->setCaseSensitivity(Qt::CaseInsensitive);
m_allPrimitivesModel = new QStringListModel(this);
m_filteredProxyModel = new QSortFilterProxyModel(this);
m_filteredProxyModel->setSourceModel(m_allPrimitivesModel);
m_filteredProxyModel->setDynamicSortFilter(true);
m_filteredProxyModel->setFilterRegExp(*m_regexpFilter);
ui->allPrimitivesList->setModel(m_filteredProxyModel);
m_selectedPrimitivesModel = new QStringListModel(this);
ui->selectedPrimitivesList->setModel(m_selectedPrimitivesModel);
// Connections for toolbar buttons.
connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation()));
connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile()));
connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish()));
// Connections for selected item moves.
connect(ui->allPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleAllDoubleClick(const QModelIndex &)));
connect(ui->selectedPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleSelDoubleClick(const QModelIndex &)));
connect(ui->addSelectedButton, SIGNAL(clicked()), this, SLOT(handleMoveSelectedRight()));
connect(ui->removeSelectedButton, SIGNAL(clicked()), this, SLOT(handleMoveSelectedLeft()));
connect(ui->addAllButton, SIGNAL(clicked()), this, SLOT(handleMoveAllRight()));
connect(ui->removeAllButton, SIGNAL(clicked()), this, SLOT(handleMoveAllLeft()));
// Connections for the filter group box.
connect(ui->dataDirButton, SIGNAL(clicked()), this, SLOT(handleDataDirButton()));
connect(ui->dataDirEdit, SIGNAL(textChanged(const QString &)), this, SLOT(handleDataDirChanged(const QString &)));
connect(ui->filterEdit, SIGNAL(textEdited(const QString&)), this, SLOT(handleFilterChanged(const QString&)));
connect(ui->resetFiltersButton, SIGNAL(clicked()), this, SLOT(handleResetFiltersButton()));
// Set the default data dir to the primitives path.
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
m_lastDir = settings->value(Core::Constants::PRIMITIVES_PATH).toString();
ui->dataDirEdit->setText(m_lastDir);
populateAllPrimitives(m_lastDir);
settings->endGroup();
NLLIGO::Register();
// TODO try/catch exception. Crashes if path invalid.
m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false);
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
}
void MissionCompilerMainWindow::populateAllPrimitives(const QString &dataDir)
{
// First we need to clear out the models entirely.
QStringList emptyList;
m_selectedPrimitivesModel->setStringList(emptyList);
m_allPrimitivesModel->setStringList(emptyList);
// Populate the "all" primitives box.
QStringList list;
// Filter for only primitive files.
QStringList filters;
filters << "*.primitive";
QDirIterator it(dataDir, filters, QDir::Files, QDirIterator::Subdirectories|QDirIterator::FollowSymlinks);
while(it.hasNext())
{
it.next();
list << it.fileName();
}
m_allPrimitivesModel->setStringList(list);
}
void MissionCompilerMainWindow::handleResetFiltersButton()
{
handleDataDirChanged(m_lastDir);
ui->filterEdit->setText("");
handleFilterChanged("");
}
void MissionCompilerMainWindow::handleDataDirChanged(const QString &text)
{
populateAllPrimitives(text);
}
void MissionCompilerMainWindow::handleDataDirButton()
{
QString newPath = QFileDialog::getExistingDirectory(this, "", m_lastDir);
if(!newPath.isEmpty())
{
ui->dataDirEdit->setText(newPath);
m_lastDir = newPath;
populateAllPrimitives(newPath);
}
}
void MissionCompilerMainWindow::handleFilterChanged(const QString &text)
{
m_regexpFilter->setPattern(text);
m_filteredProxyModel->setFilterRegExp(*m_regexpFilter);
}
void MissionCompilerMainWindow::handleCompile()
{
compileMission();
}
void MissionCompilerMainWindow::handlePublish()
{
compileMission(true);
}
void MissionCompilerMainWindow::handleMoveSelectedRight()
{
QModelIndexList indexes = ui->allPrimitivesList->selectionModel()->selectedIndexes();
while(!indexes.isEmpty())
{
const QModelIndex index = indexes.takeFirst();
moveSelectedItem(index, m_allPrimitivesModel, m_selectedPrimitivesModel);
indexes = ui->allPrimitivesList->selectionModel()->selectedIndexes();
}
}
void MissionCompilerMainWindow::handleMoveAllRight()
{
ui->allPrimitivesList->selectAll();
handleMoveSelectedRight();
}
void MissionCompilerMainWindow::handleMoveSelectedLeft()
{
QModelIndexList indexes = ui->selectedPrimitivesList->selectionModel()->selectedIndexes();
while(!indexes.isEmpty())
{
const QModelIndex index = indexes.takeFirst();
moveSelectedItem(index, m_selectedPrimitivesModel, m_allPrimitivesModel);
indexes = ui->selectedPrimitivesList->selectionModel()->selectedIndexes();
}
}
void MissionCompilerMainWindow::handleMoveAllLeft()
{
ui->selectedPrimitivesList->selectAll();
handleMoveSelectedLeft();
}
void MissionCompilerMainWindow::moveSelectedItem(const QModelIndex &index, QStringListModel *from, QStringListModel *to)
{
QString item = from->data(index, Qt::DisplayRole).toString();
from->removeRows(index.row(),1);
QStringList list = to->stringList();
list << item;
to->setStringList(list);
}
void MissionCompilerMainWindow::handleAllDoubleClick(const QModelIndex &index)
{
moveSelectedItem(index, m_allPrimitivesModel, m_selectedPrimitivesModel);
}
void MissionCompilerMainWindow::handleSelDoubleClick(const QModelIndex &index)
{
moveSelectedItem(index, m_selectedPrimitivesModel, m_allPrimitivesModel);
}
void MissionCompilerMainWindow::compileMission(bool publish)
{
uint nbMission = 0;
// First switch toolbox pages to show the compilation output.
ui->toolBox->setCurrentIndex(2);
m_compileLog.append("Begin mission compilation.\n");
updateCompileLog();
// Go through each file.
QStringList list = m_selectedPrimitivesModel->stringList();
QStringListIterator itr(list);
while(itr.hasNext())
{
QString filename = itr.next();
m_compileLog.append("Compiling '"+filename+"'...\n");
updateCompileLog();
NLLIGO::CPrimitives primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::loadXmlPrimitiveFile(primDoc, NLMISC::CPath::lookup(filename.toAscii().data(), false), m_ligoConfig);
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
try
{
CMissionCompiler mc;
mc.compileMissions(primDoc.RootNode, filename.toStdString());
m_compileLog.append("Found "+QString::number(mc.getMissionsCount())+" valid missions\n");
updateCompileLog();
mc.installCompiledMission(m_ligoConfig, filename.toStdString());
nbMission += mc.getMissionsCount();
// publish files to selected servers
//if (publish)
//for (uint i=0 ; i<ServerPathPrim.size() ; i++)
//{
// if (IsDlgButtonChecked(IDC_CHECK_SRV1 + i) != BST_CHECKED)
// continue;
// compileLog += toString("\r\nPublishing to %s ...\r\n", ServerName[i].c_str());
// for (uint j=0 ; j<mc.getFileToPublishCount() ; j++)
// compileLog += toString(" %s\r\n", (NLMISC::CFile::getFilename(mc.getFileToPublish(j))).c_str());
// mc.publishFiles(ServerPathPrim[i], ServerPathText[i], LocalTextPath);
//}
}
catch(const EParseException &e)
{
if (e.Primitive != NULL)
m_compileLog.append("In '"+QString(buildPrimPath(e.Primitive).c_str())+"'\n");
m_compileLog.append("Error while compiling '"+filename+"' :\n"+QString(e.Why.c_str())+"\n");
updateCompileLog();
break;
}
}
m_compileLog.append("Mission compilation complete.\n");
updateCompileLog();
}
void MissionCompilerMainWindow::handleValidation()
{
// First switch toolbox pages to show the compilation output.
ui->toolBox->setCurrentIndex(2);
m_compileLog.append("Begin mission validation.\n");
updateCompileLog();
// Load existing validation
CValidationFile validation;
validation.loadMissionValidationFile("mission_validation.cfg");
// Go through each file.
QStringList list = m_selectedPrimitivesModel->stringList();
QStringListIterator itr(list);
while(itr.hasNext())
{
QString filename = itr.next();
m_compileLog.append("Parsing '"+filename+"'...\n");
updateCompileLog();
TMissionContainer missions;
NLLIGO::CPrimitives primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::loadXmlPrimitiveFile(primDoc, NLMISC::CPath::lookup(filename.toAscii().data(), false), m_ligoConfig);
parsePrimForMissions(primDoc.RootNode, missions);
// Parse missions to check modification
std::map<std::string, CMission>::iterator itMission, itMissionEnd = missions.end();
for (itMission=missions.begin(); itMission!=itMissionEnd; ++itMission)
{
CValidationFile::TMissionStateContainer::iterator itMissionValidation = validation._MissionStates.find(itMission->first);
if (itMissionValidation!=validation._MissionStates.end())
{
// Mission already registered, check hash key
if (itMissionValidation->second.hashKey!=itMission->second.hashKey)
{
itMissionValidation->second.hashKey = itMission->second.hashKey;
itMissionValidation->second.state = validation.defaultState();
}
}
else
{
// New mission
validation.insertMission(itMission->first, itMission->second.hashKey);
}
m_compileLog.append("Mission: '"+QString(itMission->first.c_str())+"->"+QString(itMission->second.hashKey.c_str())+"\n");
updateCompileLog();
}
}
validation.saveMissionValidationFile("mission_validation.cfg");
m_compileLog.append("Validation finished");
updateCompileLog();
}
bool MissionCompilerMainWindow::parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions)
{
std::string value;
// if the node is a mission parse it
if (prim->getPropertyByName("class",value) && !stricmp(value.c_str(),"mission") )
{
std::string name;
prim->getPropertyByName("name",name);
m_compileLog.append(" ** Parsing mission '"+QString(name.c_str())+"'\n");
updateCompileLog();
// parse the mission and put it in our manager
CMission mission(value, "");
if (!mission.parsePrim(prim) )
{
m_compileLog.append(" ** Previous errors in mission '"+QString(name.c_str())+"'");
updateCompileLog();
return false;
}
missions.insert(make_pair(name, mission));
return true;
}
else
{
//this is not a mission node, so lookup recursively in the children
bool ok = true;
for (uint i=0;i<prim->getNumChildren();++i)
{
const NLLIGO::IPrimitive *child;
if ( !prim->getChild(child,i) || !parsePrimForMissions(child, missions) )
ok = false;
}
return ok;
}
}
void MissionCompilerMainWindow::updateCompileLog()
{
ui->compileOutputText->setPlainText(m_compileLog);
QCoreApplication::processEvents();
}
void MissionCompilerMainWindow::loadConfig() {
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("MissionCompiler");
//QColor color;
//color = settings->value("BackgroundColor", QColor(80, 80, 80)).value<QColor>();
//m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha()));
}
void MissionCompilerMainWindow::saveConfig() {
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("MissionCompiler" );
//QColor color(m_nelWidget->backgroundColor().R, m_nelWidget->backgroundColor().G, m_nelWidget->backgroundColor().B, m_nelWidget->backgroundColor().A);
//settings->setValue("BackgroundColor", color);
settings->endGroup();
settings->sync();
}
MissionCompilerMainWindow::~MissionCompilerMainWindow()
{
delete ui;
}

View file

@ -0,0 +1,72 @@
#ifndef MISSION_COMPILER_MAIN_WINDOW_H
#define MISSION_COMPILER_MAIN_WINDOW_H
#include <QMainWindow>
#include <QTimer>
#include <QLabel>
#include <QAction>
#include <QtGui/QUndoStack>
#include <QStringListModel>
#include <QSortFilterProxyModel>
#include <QRegExp>
#include <nel/ligo/ligo_config.h>
#include <nel/ligo/primitive.h>
namespace Ui {
class MissionCompilerMainWindow;
}
struct CMission;
class MissionCompilerMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MissionCompilerMainWindow(QWidget *parent = 0);
~MissionCompilerMainWindow();
void loadConfig();
void saveConfig();
QUndoStack *getUndoStack() { return m_undoStack; }
typedef std::map<std::string, CMission> TMissionContainer;
public Q_SLOTS:
void handleFilterChanged(const QString &text);
void handleValidation();
void handleCompile();
void handlePublish();
void handleAllDoubleClick(const QModelIndex &index);
void handleSelDoubleClick(const QModelIndex &index);
void handleMoveSelectedRight();
void handleMoveSelectedLeft();
void handleMoveAllRight();
void handleMoveAllLeft();
void handleDataDirButton();
void handleDataDirChanged(const QString &text);
void handleResetFiltersButton();
private:
Ui::MissionCompilerMainWindow *ui;
void updateCompileLog();
void populateAllPrimitives(const QString &dataDir = QString());
bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions);
void compileMission(bool publish=false);
void moveSelectedItem(const QModelIndex &index, QStringListModel *from, QStringListModel *to);
QMenu *_toolModeMenu;
QUndoStack *m_undoStack;
QStringListModel *m_allPrimitivesModel;
QStringListModel *m_selectedPrimitivesModel;
QSortFilterProxyModel *m_filteredProxyModel;
QRegExp *m_regexpFilter;
QString m_compileLog;
QString m_lastDir;
NLLIGO::CLigoConfig m_ligoConfig;
};
#endif // MISSION_COMPILER_MAIN_WINDOW_H

View file

@ -0,0 +1,373 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MissionCompilerMainWindow</class>
<widget class="QMainWindow" name="MissionCompilerMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>794</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="compileOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>776</width>
<height>426</height>
</rect>
</property>
<attribute name="label">
<string>Mission Compiler Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="4">
<layout class="QVBoxLayout" name="addRemoveLayout">
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addSelectedButton">
<property name="toolTip">
<string>Add Selected</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/arrow-right-2.png</normaloff>:/buttons/images/arrow-right-2.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addAllButton">
<property name="toolTip">
<string>Add All</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/arrow-right-double-2.png</normaloff>:/buttons/images/arrow-right-double-2.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="removeAllButton">
<property name="toolTip">
<string>Remove All</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/arrow-left-double-2.png</normaloff>:/buttons/images/arrow-left-double-2.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeSelectedButton">
<property name="toolTip">
<string>Remove Selected</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/arrow-left-2.png</normaloff>:/buttons/images/arrow-left-2.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="3">
<widget class="QListView" name="allPrimitivesList">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QListView" name="selectedPrimitivesList">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="allPrimitivesLabel">
<property name="text">
<string>All Primitives</string>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QLabel" name="selectedPrimitivesLabel">
<property name="text">
<string>Selected Primitives</string>
</property>
</widget>
</item>
<item row="0" column="3" colspan="3">
<widget class="QGroupBox" name="filterGroupBox">
<property name="title">
<string>Filter Criteria</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QHBoxLayout" name="dataDirLayout">
<item>
<widget class="QLabel" name="dataDirLabel">
<property name="text">
<string>Data Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="dataDirEdit"/>
</item>
<item>
<widget class="QToolButton" name="dataDirButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="filterLayout">
<item>
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filterEdit">
<property name="placeholderText">
<string>type filter here</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetFiltersButton">
<property name="toolTip">
<string>Blanks out the filter and reloads all files from the data directory.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder>horizontalLayoutWidget</zorder>
<zorder>dataDirLabel</zorder>
<zorder>horizontalLayoutWidget</zorder>
<zorder></zorder>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="publishOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>776</width>
<height>426</height>
</rect>
</property>
<attribute name="label">
<string>Publish Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QListWidget" name="publishServersList"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="compilationOutputPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>776</width>
<height>426</height>
</rect>
</property>
<attribute name="label">
<string>Compilation Output</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPlainTextEdit" name="compileOutputText">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>794</width>
<height>21</height>
</rect>
</property>
</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="actionValidate"/>
<addaction name="actionCompile"/>
<addaction name="actionPublish"/>
</widget>
<action name="actionCompile">
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/run-build-2.png</normaloff>:/buttons/images/run-build-2.png</iconset>
</property>
<property name="text">
<string>Compile</string>
</property>
<property name="toolTip">
<string>Compile</string>
</property>
</action>
<action name="actionValidate">
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/news-subscribe-2.png</normaloff>:/buttons/images/news-subscribe-2.png</iconset>
</property>
<property name="text">
<string>Validate</string>
</property>
<property name="toolTip">
<string>Validate</string>
</property>
</action>
<action name="actionPublish">
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/document-export-4.png</normaloff>:/buttons/images/document-export-4.png</iconset>
</property>
<property name="text">
<string>Publish</string>
</property>
<property name="toolTip">
<string>Compile and Publish</string>
</property>
</action>
</widget>
<resources>
<include location="mission_compiler.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,131 @@
// Project includes
#include "mission_compiler_plugin.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/imenu_manager.h"
#include "../../extension_system/iplugin_spec.h"
// NeL includes
#include <nel/misc/debug.h>
#include <nel/misc/path.h>
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtGui/QMenuBar>
#include "mission_compiler_settings_page.h"
namespace Plugin
{
MissionCompilerPlugin::~MissionCompilerPlugin()
{
Q_FOREACH(QObject *obj, _autoReleaseObjects)
{
_plugMan->removeObject(obj);
}
qDeleteAll(_autoReleaseObjects);
_autoReleaseObjects.clear();
}
bool MissionCompilerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
_plugMan = pluginManager;
addAutoReleasedObject(new MissionCompilerSettingsPage(this));
addAutoReleasedObject(new CMissionCompilerContext(this));
//addAutoReleasedObject(new CCoreListener(this));
return true;
}
void MissionCompilerPlugin::extensionsInitialized()
{
Core::ICore *core = Core::ICore::instance();
QSettings *settings = Core::ICore::instance()->settings();
Core::IMenuManager *menuManager = core->menuManager();
//menuManager = _plugMan->getObject<Core::IMenuManager>();
//QAction *exampleAction1 = new QAction("Zone1", this);
//QAction *exampleAction2 = new QAction("Zone2", this);
//QMenu *toolsMenu = menuManager->menu(Core::Constants::M_TOOLS);
//helpMenu->insertAction(aboutQtAction, exampleAction1);
//helpMenu->addSeparator();
//helpMenu->addAction(exampleAction2);
//QMenu *zoneMenu = menuManager->menuBar()->addMenu("ZoneMenu");
//zoneMenu->insertAction(aboutQtAction, exampleAction1);
//zoneMenu->addSeparator();
//zoneMenu->addAction(exampleAction2);
// Initialize Ligo.
//settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
//QString ligoConfigFile = settings->value(Core::Constants::DATA_PATH_SECTION).toString();
//settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
}
void MissionCompilerPlugin::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
_LibContext = new NLMISC::CLibraryContext(*nelContext);
}
QString MissionCompilerPlugin::name() const
{
return "MissionCompilerPlugin";
}
QString MissionCompilerPlugin::version() const
{
return "0.1";
}
QString MissionCompilerPlugin::vendor() const
{
return "Ryzom Core";
}
QString MissionCompilerPlugin::description() const
{
return "Mission Compiler Plugin";
}
QStringList MissionCompilerPlugin::dependencies() const
{
QStringList list;
list.append(Core::Constants::OVQT_CORE_PLUGIN);
//list.append("ObjectViewer");
return list;
}
void MissionCompilerPlugin::addAutoReleasedObject(QObject *obj)
{
_plugMan->addObject(obj);
_autoReleaseObjects.prepend(obj);
}
QObject* MissionCompilerPlugin::objectByName(const QString &name) const
{
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
if (qobj->objectName() == name)
return qobj;
return 0;
}
ExtensionSystem::IPluginSpec *MissionCompilerPlugin::pluginByName(const QString &name) const
{
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
if (spec->name() == name)
return spec;
return 0;
}
}
Q_EXPORT_PLUGIN(Plugin::MissionCompilerPlugin)

View file

@ -0,0 +1,101 @@
#ifndef MISSION_COMPILER_PLUGIN_H
#define MISSION_COMPILER_PLUGIN_H
// Project includes
#include "../../extension_system/iplugin.h"
#include "../core/icontext.h"
#include "mission_compiler_main_window.h"
// NeL includes
#include <nel/misc/app_context.h>
#include <nel/misc/singleton.h>
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace NLMISC
{
class CLibraryContext;
}
namespace ExtensionSystem
{
class IPluginSpec;
}
namespace Plugin
{
class MissionCompilerPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
virtual ~MissionCompilerPlugin();
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized();
void setNelContext(NLMISC::INelContext *nelContext);
QString name() const;
QString version() const;
QString vendor() const;
QString description() const;
QStringList dependencies() const;
void addAutoReleasedObject(QObject *obj);
QObject *objectByName(const QString &name) const;
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
protected:
NLMISC::CLibraryContext *_LibContext;
private:
ExtensionSystem::IPluginManager *_plugMan;
QList<QObject *> _autoReleaseObjects;
};
class CMissionCompilerContext: public Core::IContext
{
Q_OBJECT
public:
CMissionCompilerContext(QObject *parent = 0): IContext(parent)
{
m_missionCompilerMainWindow = new MissionCompilerMainWindow();
}
virtual ~CMissionCompilerContext() {}
virtual QString id() const
{
return QLatin1String("MissionCompilerContext");
}
virtual QString trName() const
{
return tr("Mission Compiler");
}
virtual QIcon icon() const
{
return QIcon();
}
virtual QWidget *widget()
{
return m_missionCompilerMainWindow;
}
virtual QUndoStack *undoStack()
{
return m_missionCompilerMainWindow->getUndoStack();
}
virtual void open() {}
MissionCompilerMainWindow *m_missionCompilerMainWindow;
};
} // namespace Plugin
#endif // MISSION_COMPILER_PLUGIN_H

View file

@ -0,0 +1,185 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "mission_compiler_settings_page.h"
#include "../core/core_constants.h"
#include "../core/icore.h"
#include "server_entry_dialog.h"
// NeL includes
#include <nel/misc/path.h>
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QFileDialog>
#include <QtGui/QTreeWidgetItem>
namespace Plugin
{
QString lastDir = ".";
MissionCompilerSettingsPage::MissionCompilerSettingsPage(QObject *parent)
: IOptionsPage(parent),
m_page(0)
{
}
MissionCompilerSettingsPage::~MissionCompilerSettingsPage()
{
}
QString MissionCompilerSettingsPage::id() const
{
return QLatin1String("mission_compiler_settings");
}
QString MissionCompilerSettingsPage::trName() const
{
return tr("Mission Compiler Settings");
}
QString MissionCompilerSettingsPage::category() const
{
return QLatin1String("Mission Compiler");
}
QString MissionCompilerSettingsPage::trCategory() const
{
return tr("Mission Compiler");
}
QIcon MissionCompilerSettingsPage::categoryIcon() const
{
return QIcon();
}
QWidget *MissionCompilerSettingsPage::createPage(QWidget *parent)
{
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
readSettings();
connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addServer()));
connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delServer()));
connect(m_ui.serversTableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(editServer(int,int)));
return m_page;
}
void MissionCompilerSettingsPage::apply()
{
writeSettings();
}
void MissionCompilerSettingsPage::finish()
{
delete m_page;
m_page = 0;
}
void MissionCompilerSettingsPage::editServer(int row, int column)
{
ServerEntryDialog serverEntryDialog;
serverEntryDialog.setModal(true);
serverEntryDialog.show();
// Copy the values from the row to the dialog.
QTableWidgetItem *item1 = m_ui.serversTableWidget->item(row,0);
QTableWidgetItem *item2 = m_ui.serversTableWidget->item(row,1);
QTableWidgetItem *item3 = m_ui.serversTableWidget->item(row,2);
serverEntryDialog.setServerName(item1->text());
serverEntryDialog.setTextPath(item2->text());
serverEntryDialog.setPrimPath(item3->text());
if(serverEntryDialog.exec())
{
item1->setText(serverEntryDialog.getServerName());
item2->setText(serverEntryDialog.getTextPath());
item3->setText(serverEntryDialog.getPrimPath());
}
}
void MissionCompilerSettingsPage::addServer()
{
ServerEntryDialog serverEntryDialog;
serverEntryDialog.setModal(true);
serverEntryDialog.show();
if(serverEntryDialog.exec())
{
int row = m_ui.serversTableWidget->rowCount();
m_ui.serversTableWidget->insertRow(row);
QTableWidgetItem *item1 = new QTableWidgetItem(serverEntryDialog.getServerName());
QTableWidgetItem *item2 = new QTableWidgetItem(serverEntryDialog.getTextPath());
QTableWidgetItem *item3 = new QTableWidgetItem(serverEntryDialog.getPrimPath());
m_ui.serversTableWidget->setItem(row, 0, item1);
m_ui.serversTableWidget->setItem(row, 1, item2);
m_ui.serversTableWidget->setItem(row, 2, item3);
}
}
void MissionCompilerSettingsPage::delServer()
{
QList<QTableWidgetItem*> selectedItems = m_ui.serversTableWidget->selectedItems();
while(selectedItems.size() > 0)
{
m_ui.serversTableWidget->removeRow(selectedItems.back()->row());
selectedItems = m_ui.serversTableWidget->selectedItems();
}
}
void MissionCompilerSettingsPage::readSettings()
{
//QStringList paths;
//QSettings *settings = Core::ICore::instance()->settings();
//settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
//if (m_recurse)
// paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
//else
// paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
//settings->endGroup();
//Q_FOREACH(QString path, paths)
//{
// QListWidgetItem *newItem = new QListWidgetItem;
// newItem->setText(path);
// newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
// m_ui.serversTreeWidget->addItem(newItem);
//}
}
void MissionCompilerSettingsPage::writeSettings()
{
//QStringList paths;
//for (int i = 0; i < m_ui.serversTreeWidget->count(); ++i)
// paths << m_ui.serversTreeWidget->item(i)->text();
//QSettings *settings = Core::ICore::instance()->settings();
//settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
//if (m_recurse)
// settings->setValue(Core::Constants::RECURSIVE_SEARCH_PATHS, paths);
//else
// settings->setValue(Core::Constants::SEARCH_PATHS, paths);
//settings->endGroup();
//settings->sync();
}
} /* namespace Plugin */

View file

@ -0,0 +1,68 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 MISSION_COMPILER_SETTINGS_PAGE_H
#define MISSION_COMPILER_SETTINGS_PAGE_H
#include <QtCore/QObject>
#include "../core/ioptions_page.h"
#include "ui_mission_compiler_settings_page.h"
class QWidget;
namespace Plugin
{
/**
@class MissionCompilerSettingsPage
*/
class MissionCompilerSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
MissionCompilerSettingsPage(QObject *parent = 0);
~MissionCompilerSettingsPage();
QString id() const;
QString trName() const;
QString category() const;
QString trCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
private Q_SLOTS:
void addServer();
void delServer();
void editServer(int row, int column);
private:
void readSettings();
void writeSettings();
QWidget *m_page;
Ui::MissionCompilerSettingsPage m_ui;
};
} // namespace Plugin
#endif // MISSION_COMPILER_SETTINGS_PAGE_H

View file

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MissionCompilerSettingsPage</class>
<widget class="QWidget" name="MissionCompilerSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>544</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="publicationGroupBox">
<property name="title">
<string>Publication Servers</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="removeToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_delete_item.png</normaloff>:/buttons/images/ic_nel_delete_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="addToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_add_item.png</normaloff>:/buttons/images/ic_nel_add_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetToolButton">
<property name="toolTip">
<string>Reset</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_reset_all.png</normaloff>:/buttons/images/ic_nel_reset_all.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<spacer name="publishHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTableWidget" name="serversTableWidget">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Server Name</string>
</property>
</column>
<column>
<property name="text">
<string>Server Text Path</string>
</property>
</column>
<column>
<property name="text">
<string>Server Primitive Path</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="localPathLabel">
<property name="text">
<string>Local Text Path</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="localPathEdit">
<property name="toolTip">
<string>Local path for compiled mission texts.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="localPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="mission_compiler.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,89 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "server_entry_dialog.h"
#include "ui_server_entry_dialog.h"
// NeL includes
// Qt includes
#include <QFileDialog>
namespace Plugin
{
ServerEntryDialog::ServerEntryDialog(QWidget *parent)
: QDialog(parent),
m_ui(new Ui::ServerEntryDialog)
{
m_ui->setupUi(this);
connect(m_ui->serverTextPathButton, SIGNAL(clicked()), this, SLOT(lookupTextPath()));
connect(m_ui->serverPrimPathButton, SIGNAL(clicked()), this, SLOT(lookupPrimPath()));
}
ServerEntryDialog::~ServerEntryDialog()
{
delete m_ui;
}
QString ServerEntryDialog::getServerName()
{
return m_ui->serverNameEdit->text();
}
QString ServerEntryDialog::getTextPath()
{
return m_ui->serverTextPathEdit->text();
}
QString ServerEntryDialog::getPrimPath()
{
return m_ui->serverPrimPathEdit->text();
}
void ServerEntryDialog::setServerName(QString name)
{
m_ui->serverNameEdit->setText(name);
}
void ServerEntryDialog::setTextPath(QString path)
{
m_ui->serverTextPathEdit->setText(path);
}
void ServerEntryDialog::setPrimPath(QString path)
{
m_ui->serverPrimPathEdit->setText(path);
}
void ServerEntryDialog::lookupTextPath()
{
QString curPath = m_ui->serverTextPathEdit->text();
QString path = QFileDialog::getExistingDirectory(this, "", curPath);
m_ui->serverTextPathEdit->setText(path);
}
void ServerEntryDialog::lookupPrimPath()
{
QString curPath = m_ui->serverPrimPathEdit->text();
QString path = QFileDialog::getExistingDirectory(this, "", curPath);
m_ui->serverPrimPathEdit->setText(path);
}
} /* namespace Plugin */

View file

@ -0,0 +1,59 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 SERVER_ENTRY_DIALOG_H
#define SERVER_ENTRY_DIALOG_H
#include <QDialog>
namespace Ui {
class ServerEntryDialog;
}
namespace Plugin
{
/**
@class ServerEntryDialog
*/
class ServerEntryDialog : public QDialog
{
Q_OBJECT
public:
explicit ServerEntryDialog(QWidget *parent = 0);
~ServerEntryDialog();
QString getServerName();
QString getTextPath();
QString getPrimPath();
void setServerName(QString name);
void setTextPath(QString path);
void setPrimPath(QString path);
public Q_SLOTS:
void lookupTextPath();
void lookupPrimPath();
private:
Ui::ServerEntryDialog *m_ui;
};
} // namespace Plugin
#endif // SERVER_ENTRY_DIALOG_H

View file

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServerEntryDialog</class>
<widget class="QDialog" name="ServerEntryDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>175</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="serverSettingsBox">
<property name="title">
<string>Server Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="serverNameLabel">
<property name="text">
<string>Server Name</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="serverNameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="serverTextPathLabel">
<property name="text">
<string>Server Text Path</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="serverTextPathEdit"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="serverTextPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverPrimPathLabel">
<property name="text">
<string>Server Primitive Path</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="serverPrimPathEdit"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="serverPrimPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ServerEntryDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ServerEntryDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -0,0 +1,133 @@
#include "validation_file.h"
#include <nel/misc/config_file.h>
#include <nel/misc/path.h>
void CValidationFile::loadMissionValidationFile(std::string filename)
{
// load the configuration file
NLMISC::CConfigFile cf;
std::string pathName = NLMISC::CPath::lookup(filename, false);
if (pathName.empty())
{
nlwarning("Can't find index file '%s' in search path, no mission will be valid", filename.c_str());
return;
}
cf.load(pathName);
// get the variable
NLMISC::CConfigFile::CVar* var = cf.getVarPtr("AuthorizedStates");
if (var)
{
for (uint i=0; i<var->size(); ++i)
_AuthorizedStates.push_back(var->asString(i));
}
int missionStatesFields = 3;
var = cf.getVarPtr("MissionStatesFields");
if (var)
missionStatesFields = var->asInt();
else
nlwarning("Mission validation file does not contain MissionStatesFields variable. Parsing may fail and corrupt data.");
var = cf.getVarPtr("MissionStates");
if (var)
{
for (uint i=0; i<var->size()/missionStatesFields; ++i)
{
std::string mission = var->asString(i*missionStatesFields);
std::string stateName = var->asString(i*missionStatesFields+1);
std::string hashKey = var->asString(i*missionStatesFields+2);
_MissionStates.insert(std::make_pair(mission, CMissionState(mission, stateName, hashKey)));
}
}
}
void CValidationFile::saveMissionValidationFile(std::string filename)
{
// load the configuration file
std::string pathName = NLMISC::CPath::lookup(filename, false);
if (pathName.empty())
{
nlwarning("Can't find index file '%s' in search path, no mission will be valid", filename.c_str());
return;
}
FILE* file = fopen(pathName.c_str(), "w");
nlassert(file!=NULL);
// AuthorizedStates
fprintf(file, "%s",
"// AuthorizedStates contains the list of authorized states. EGS mission\n"
"// manager can accept any number of states. Default state is the first one.\n"
"AuthorizedStates = {\n");
std::deque<std::string>::iterator itAuth, itAuthEnd = _AuthorizedStates.end();
for (itAuth=_AuthorizedStates.begin(); itAuth!=itAuthEnd; ++itAuth)
fprintf(file, "\t\"%s\",\n", itAuth->c_str());
fprintf(file, "%s", "};\n\n");
// MissionStatesFields
fprintf(file, "%s",
"// MissionStatesFields contains the number of fields in MissionStates, for\n"
"// future compatibility purpose.\n"
"MissionStatesFields = ");
fprintf(file, "%d", 3); // 3 fields: name, state, hash key
fprintf(file, "%s", ";\n\n");
// MissionStates
fprintf(file, "%s",
"// MissionStates contains a list of mission with for each the state of the\n"
"// mission and its hash key. The tool will add new missions with the default\n"
"// state. It will flag missions with a modified hash key with default state to\n"
"// prevent untested modified missions to be published.\n"
"// :NOTE: You can add a field to this structure without the need to modify EGS\n"
"// code. Simply update MissionStatesFields.\n"
"MissionStates = {\n");
TMissionStateContainer::iterator itMission, itMissionEnd = _MissionStates.end();
for (itMission=_MissionStates.begin(); itMission!=itMissionEnd; ++itMission)
fprintf(file, "\t%-42s %-12s \"%s\",\n", ("\""+itMission->second.name+"\",").c_str(), ("\""+itMission->second.state+"\",").c_str(), itMission->second.hashKey.c_str());
fprintf(file, "};\n\n");
fclose(file);
}
// :NOTE: This function exists in mission_template.cpp. If you change it here modify the other file.
std::string buildHashKey(std::string const& content)
{
uint32 sum = 0;
size_t size = content.length()/4;
for (size_t i=0; i<size; ++i)
{
uint32 val = 0;
for (int j=0; j<4; ++j)
val += content[4*i+j]<<8*j;
sum += val;
if (sum&1)
sum = sum>>1 | 0x80000000;
else
sum = sum>>1;
}
return NLMISC::toString("0x%08X", sum);
}
bool CMission::parsePrim(NLLIGO::IPrimitive const* prim)
{
// init default values
std::vector<std::string>* params;
// get the mission script
if (!prim->getPropertyByName("script", params) || !params)
{
nlwarning("ERROR : cant find mission script!!!!!!");
return false;
}
// parse them
std::string content;
std::vector<std::string>::iterator itParam, itParamEnd = params->end();
for (itParam=params->begin(); itParam!=itParamEnd; ++itParam)
{
content += *itParam + "\n";
}
hashKey = buildHashKey(content);
return true;
}

View file

@ -0,0 +1,51 @@
#ifndef VALIDATION_FILE_H
#define VALIDATION_FILE_H
#include <deque>
#include <map>
#include <string>
#include <nel/ligo/primitive.h>
struct CMissionState
{
std::string name;
std::string state;
std::string hashKey;
CMissionState(std::string _name, std::string _state, std::string _hashKey)
: name(_name), state(_state), hashKey(_hashKey) { }
};
struct CMission
{
std::string name;
std::string hashKey;
CMission(std::string _name, std::string _hashKey)
: name(_name), hashKey(_hashKey) { }
bool parsePrim(NLLIGO::IPrimitive const* prim);
};
class CValidationFile
{
public:
typedef std::map<std::string, CMissionState> TMissionStateContainer;
std::deque<std::string> _AuthorizedStates;
TMissionStateContainer _MissionStates;
public:
// CValidationFile() { }
void loadMissionValidationFile(std::string filename);
void saveMissionValidationFile(std::string filename);
void insertMission(std::string const& mission, std::string const& hashKey)
{
_MissionStates.insert(std::make_pair(mission, CMissionState(mission, defaultState(), hashKey)));
}
std::string defaultState()
{
if (!_AuthorizedStates.empty())
return _AuthorizedStates.front();
else
return "";
}
};
#endif // VALIDATION_FILE_H