diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index bec71cf94..66cbdb188 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -7,3 +7,8 @@ ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(zone_painter) 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) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h index be6e666a7..65327ae38 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h @@ -92,6 +92,8 @@ const char * const SEARCH_PATHS = "SearchPaths"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char * const LEVELDESIGN_PATH = "LevelDesignPath"; 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 LOG_SECTION = "LogSettings"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp index 51da80f67..a050f4789 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp @@ -82,6 +82,15 @@ void GeneralSettingsPage::applyGeneralSettings() else QApplication::setPalette(m_originalPalette); 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) @@ -94,6 +103,8 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent) connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath())); connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath())); 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; } @@ -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() { QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"), @@ -165,6 +197,8 @@ void GeneralSettingsPage::readSettings() settings->beginGroup(Core::Constants::DATA_PATH_SECTION); 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.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(); } @@ -185,6 +219,8 @@ void GeneralSettingsPage::writeSettings() settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->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->sync(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h index 2fbcb842a..22ab30e45 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h @@ -57,6 +57,8 @@ private Q_SLOTS: void setPluginsPath(); void setLevelDesignPath(); void setAssetsPath(); + void setPrimitivesPath(); + void setLigoConfigFile(); private: void readSettings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui index d2aa042e3..7d40b65df 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui @@ -105,7 +105,7 @@ - Plugins path: + Plugins @@ -129,7 +129,7 @@ - Level design path: + Sheets @@ -153,7 +153,7 @@ - Assets path: + Assets Database: @@ -174,6 +174,40 @@ + + + + Primitives + + + + + + + + + + ... + + + + + + + + + + Ligo Config File + + + + + + + ... + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp index f31a63924..41ce39632 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp @@ -103,7 +103,7 @@ namespace Plugin QString CLogPlugin::name() const { - return "NeL Log"; + return "LogPlugin"; } QString CLogPlugin::version() const @@ -139,10 +139,10 @@ namespace Plugin QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Core::Constants::LOG_SECTION); - bool error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); - bool warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); - bool debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); - bool assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); + bool error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); + bool warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); + bool debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); + bool assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); bool info = settings->value(Core::Constants::LOG_INFO, true).toBool(); settings->endGroup(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp index 3aba359a5..d1e3d65fc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp @@ -28,8 +28,8 @@ #include #include -namespace ExtensionSystem -{ +namespace ExtensionSystem +{ class IPluginManager; } @@ -42,10 +42,10 @@ namespace Plugin : IOptionsPage(parent), m_logPlugin(logPlugin), m_currentPage(NULL), - m_error(true), - m_warning(true), - m_debug(true), - m_assert(true), + m_error(true), + m_warning(true), + m_debug(true), + m_assert(true), m_info(true) { } @@ -99,7 +99,16 @@ namespace Plugin m_info = m_ui.infoCheck->isChecked(); writeSettings(); - m_logPlugin->setDisplayers(); + ExtensionSystem::IPluginManager *p = Core::ICore::instance()->pluginManager(); + ExtensionSystem::IPluginSpec *spec = p->pluginByName("LogPlugin"); + + if(spec) + { + ExtensionSystem::IPlugin *plugin = spec->plugin(); + CLogPlugin* lp = dynamic_cast(plugin); + if (lp) + lp->setDisplayers(); + } } void CLogSettingsPage::readSettings() @@ -107,10 +116,10 @@ namespace Plugin QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Core::Constants::LOG_SECTION); - m_error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); - m_warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); - m_debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); - m_assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); + m_error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); + m_warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); + m_debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); + m_assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); m_info = settings->value(Core::Constants::LOG_INFO, true).toBool(); settings->endGroup(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt new file mode 100644 index 000000000..f277a4b14 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt @@ -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) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-2.png new file mode 100644 index 000000000..8f153292c Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-double-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-double-2.png new file mode 100644 index 000000000..8b6d62c7a Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-left-double-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-2.png new file mode 100644 index 000000000..d4016e2c7 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-double-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-double-2.png new file mode 100644 index 000000000..1fe9feb28 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/arrow-right-double-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/document-export-4.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/document-export-4.png new file mode 100644 index 000000000..bc7688858 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/document-export-4.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_add_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_add_item.png new file mode 100644 index 000000000..bde338f78 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_add_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_delete_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_delete_item.png new file mode 100644 index 000000000..a5a1787d5 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_delete_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_down_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_down_item.png new file mode 100644 index 000000000..fc86c4f6d Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_down_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_generic_settings.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_generic_settings.png new file mode 100644 index 000000000..799bacb28 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_generic_settings.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_reset_all.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_reset_all.png new file mode 100644 index 000000000..aea193c70 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_reset_all.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_up_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_up_item.png new file mode 100644 index 000000000..ee471023e Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/ic_nel_up_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/news-subscribe-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/news-subscribe-2.png new file mode 100644 index 000000000..d5259a76b Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/news-subscribe-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/run-build-2.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/run-build-2.png new file mode 100644 index 000000000..5fea6c540 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/images/run-build-2.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler.qrc new file mode 100644 index 000000000..eed07d969 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler.qrc @@ -0,0 +1,17 @@ + + + images/ic_nel_reset_all.png + images/ic_nel_add_item.png + images/ic_nel_delete_item.png + images/ic_nel_down_item.png + images/ic_nel_generic_settings.png + images/ic_nel_up_item.png + images/arrow-left-2.png + images/arrow-left-double-2.png + images/arrow-right-2.png + images/arrow-right-double-2.png + images/document-export-4.png + images/news-subscribe-2.png + images/run-build-2.png + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp new file mode 100644 index 000000000..bb4e783a7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp @@ -0,0 +1,508 @@ +#include "mission_compiler_main_window.h" +#include "ui_mission_compiler_main_window.h" +#include "validation_file.h" +#include "mission_compiler.h" +#include "mission_compiler_plugin_constants.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../core/icore.h" +#include "../core/imenu_manager.h" +#include "../core/core_constants.h" + +#include + +#include +#include +#include +#include + +using namespace MissionCompiler::Constants; + +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())); + + // Connect for settings changes. + connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(handleChangedSettings())); + + // 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) + { + m_compileLog.append("Begin publishing missions...\n"); + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(MISSION_COMPILER_SECTION); + + // Retrieve the local text path. + QString localPath = settings->value(SETTING_LOCAL_TEXT_PATH).toString(); + settings->endGroup(); + QStringList checkedServers; + for(int i = 0; ipublishServersList->count(); i++) + { + + // Retrieve each checked server. + QListWidgetItem *item = ui->publishServersList->item(i); + if(item->checkState() == Qt::Checked) + checkedServers << item->text(); + } + + Q_FOREACH(QString checkedServer, checkedServers) + { + m_compileLog.append("Processing publication configuration for '"+checkedServer+"'\n"); + QStringList items = settings->value(SETTING_SERVERS_TABLE_ITEMS).toStringList(); + int column = 0; + int row = 0; + QString servName; + QString primPath; + QString textPath; + Q_FOREACH(QString var, items) + { + // Check to see if we're starting a new row. + if(column > 2) + { + column = 0; + row++; + } + if(column == 0) + servName = var; + else if(column == 1) + textPath = var; + else if(column == 2) + { + primPath = var; + + m_compileLog.append("Publishing to "+servName+" ...\n"); + for (uint j=0 ; jtoolBox->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::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;igetNumChildren();++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(MISSION_COMPILER_SECTION); + + // Retrieve the local text path. + QString localPath = settings->value(SETTING_LOCAL_TEXT_PATH).toString(); + QListWidgetItem *item = new QListWidgetItem("Local"); + item->setForeground(Qt::blue); + item->setCheckState(Qt::Unchecked); + ui->publishServersList->addItem(item); + + QStringList items = settings->value(SETTING_SERVERS_TABLE_ITEMS).toStringList(); + int column = 0; + int row = 0; + Q_FOREACH(QString var, items) + { + // Check to see if we're starting a new row. + if(column > 2) + { + column = 0; + row++; + } + if(column == 0) + { + item = new QListWidgetItem(var); + item->setCheckState(Qt::Unchecked); + ui->publishServersList->addItem(item); + } + + column++; + } + + // Reapply the checkboxes for servers we had checked previously. + QStringList servers = settings->value(SETTING_PUBLISH_SERVER_CHECKS).toStringList(); + applyCheckboxes(servers); + + settings->endGroup(); +} + +void MissionCompilerMainWindow::saveConfig() { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(MISSION_COMPILER_SECTION); + + QStringList servers; + for(int row = 0; row < ui->publishServersList->count(); row++) + { + QListWidgetItem *item = ui->publishServersList->item(row); + if(item->checkState() == Qt::Checked) + servers << item->text(); + } + + settings->setValue(SETTING_PUBLISH_SERVER_CHECKS, servers); + + settings->endGroup(); + settings->sync(); +} + +void MissionCompilerMainWindow::handleChangedSettings() +{ + QStringList servers; + for(int row = 0; row < ui->publishServersList->count(); row++) + { + QListWidgetItem *item = ui->publishServersList->item(row); + if(item->checkState() == Qt::Checked) + servers << item->text(); + } + ui->publishServersList->clear(); + loadConfig(); + + applyCheckboxes(servers); +} + +void MissionCompilerMainWindow::applyCheckboxes(const QStringList &servers) +{ + Q_FOREACH(QString server, servers) + { + QList items = ui->publishServersList->findItems(server, Qt::MatchExactly); + if(items.size() != 1) + continue; + items.at(0)->setCheckState(Qt::Checked); + } +} + +MissionCompilerMainWindow::~MissionCompilerMainWindow() +{ + saveConfig(); + delete ui; +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h new file mode 100644 index 000000000..1dffea313 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h @@ -0,0 +1,75 @@ +#ifndef MISSION_COMPILER_MAIN_WINDOW_H +#define MISSION_COMPILER_MAIN_WINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +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 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(); + void handleChangedSettings(); + +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); + void applyCheckboxes(const QStringList &servers); + + + 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui new file mode 100644 index 000000000..d68b1a76d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui @@ -0,0 +1,373 @@ + + + MissionCompilerMainWindow + + + + 0 + 0 + 794 + 600 + + + + MainWindow + + + + + + + 0 + + + + + 0 + 0 + 776 + 426 + + + + Mission Compiler Options + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Add Selected + + + + + + + :/buttons/images/arrow-right-2.png:/buttons/images/arrow-right-2.png + + + + + + + Add All + + + + + + + :/buttons/images/arrow-right-double-2.png:/buttons/images/arrow-right-double-2.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Remove All + + + + + + + :/buttons/images/arrow-left-double-2.png:/buttons/images/arrow-left-double-2.png + + + + + + + Remove Selected + + + + + + + :/buttons/images/arrow-left-2.png:/buttons/images/arrow-left-2.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + true + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::DragDrop + + + Qt::MoveAction + + + true + + + QAbstractItemView::ExtendedSelection + + + + + + + true + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::DragDrop + + + Qt::MoveAction + + + true + + + QAbstractItemView::ExtendedSelection + + + + + + + All Primitives + + + + + + + Selected Primitives + + + + + + + Filter Criteria + + + + + + + + Data Directory + + + + + + + + + + ... + + + + + + + + + + + Filter + + + + + + + type filter here + + + + + + + Blanks out the filter and reloads all files from the data directory. + + + Reset + + + + + + + horizontalLayoutWidget + dataDirLabel + horizontalLayoutWidget + + + + + + + + + 0 + 0 + 776 + 426 + + + + Publish Options + + + + + + + + + + + 0 + 0 + 776 + 426 + + + + Compilation Output + + + + + + true + + + + + + + + + + + + + 0 + 0 + 794 + 21 + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + + :/buttons/images/run-build-2.png:/buttons/images/run-build-2.png + + + Compile + + + Compile + + + + + + :/buttons/images/news-subscribe-2.png:/buttons/images/news-subscribe-2.png + + + Validate + + + Validate + + + + + + :/buttons/images/document-export-4.png:/buttons/images/document-export-4.png + + + Publish + + + Compile and Publish + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp new file mode 100644 index 000000000..3b9eb3ead --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp @@ -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 +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +#include "mission_compiler_settings_page.h" + +namespace MissionCompiler +{ + +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(); + //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(MissionCompiler::MissionCompilerPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.h new file mode 100644 index 000000000..7f64465e7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.h @@ -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 +#include + +// Qt includes +#include +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace ExtensionSystem +{ +class IPluginSpec; +} + +namespace MissionCompiler +{ + +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 _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 MissionCompiler + +#endif // MISSION_COMPILER_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin_constants.h new file mode 100644 index 000000000..bfa71ceb1 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin_constants.h @@ -0,0 +1,17 @@ +#ifndef MISSION_COMPILER_PLUGIN_CONSTANTS_H +#define MISSION_COMPILER_PLUGIN_CONSTANTS_H + +namespace MissionCompiler +{ +namespace Constants +{ +//settings +const char * const MISSION_COMPILER_SECTION = "MissionCompiler"; +const char * const SETTING_LOCAL_TEXT_PATH = "LocalTextPath"; +const char * const SETTING_SERVERS_TABLE_ITEMS = "ServersTableItems"; +const char * const SETTING_PUBLISH_SERVER_CHECKS = "PublishServerChecks"; + +} // namespace Constants +} // namespace MissionCompiler + +#endif // MISSION_COMPILER_PLUGIN_CONSTANTS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp new file mode 100644 index 000000000..2f75aa4ab --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp @@ -0,0 +1,203 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "mission_compiler_settings_page.h" +#include "mission_compiler_plugin_constants.h" +#include "../core/core_constants.h" +#include "../core/icore.h" + +#include "server_entry_dialog.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace MissionCompiler +{ + +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 selectedItems = m_ui.serversTableWidget->selectedItems(); + while(selectedItems.size() > 0) + { + m_ui.serversTableWidget->removeRow(selectedItems.back()->row()); + selectedItems = m_ui.serversTableWidget->selectedItems(); + } +} + +void MissionCompilerSettingsPage::readSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::MISSION_COMPILER_SECTION); + + // Retrieve the local text path. + m_ui.localPathEdit->setText(settings->value(Constants::SETTING_LOCAL_TEXT_PATH).toString()); + + QStringList items = settings->value(Constants::SETTING_SERVERS_TABLE_ITEMS).toStringList(); + int column = 0; + int row = 0; + m_ui.serversTableWidget->insertRow(row); + Q_FOREACH(QString var, items) + { + // Check to see if we're starting a new row. + if(column > 2) + { + column = 0; + row++; + m_ui.serversTableWidget->insertRow(row); + } + + QTableWidgetItem *item = new QTableWidgetItem(var); + m_ui.serversTableWidget->setItem(row, column, item); + + column++; + } + settings->endGroup(); +} + +void MissionCompilerSettingsPage::writeSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::MISSION_COMPILER_SECTION); + + // Save the local text path. + settings->setValue(Constants::SETTING_LOCAL_TEXT_PATH, m_ui.localPathEdit->text()); + + QStringList items; + for(int row = 0; row < m_ui.serversTableWidget->rowCount(); row++) + { + for(int column = 0; column < m_ui.serversTableWidget->columnCount(); column++) + { + items << m_ui.serversTableWidget->item(row, column)->text(); + } + } + + settings->setValue(Constants::SETTING_SERVERS_TABLE_ITEMS, items); + settings->endGroup(); + settings->sync(); +} + +} /* namespace MissionCompiler */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h new file mode 100644 index 000000000..71996e442 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h @@ -0,0 +1,68 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + + +#ifndef MISSION_COMPILER_SETTINGS_PAGE_H +#define MISSION_COMPILER_SETTINGS_PAGE_H + +#include + +#include "../core/ioptions_page.h" + +#include "ui_mission_compiler_settings_page.h" + +class QWidget; + +namespace MissionCompiler +{ +/** +@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 MissionCompiler + +#endif // MISSION_COMPILER_SETTINGS_PAGE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui new file mode 100644 index 000000000..2ee2c2bce --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui @@ -0,0 +1,210 @@ + + + MissionCompilerSettingsPage + + + + 0 + 0 + 496 + 544 + + + + Form + + + + 6 + + + 3 + + + + + Publication Servers + + + + + + + + + 0 + 0 + + + + Delete + + + + + + + :/buttons/images/ic_nel_delete_item.png:/buttons/images/ic_nel_delete_item.png + + + + 20 + 20 + + + + true + + + + + + + + 0 + 0 + + + + Add + + + + + + + :/buttons/images/ic_nel_add_item.png:/buttons/images/ic_nel_add_item.png + + + + 20 + 20 + + + + true + + + + + + + Reset + + + + + + + :/buttons/images/ic_nel_reset_all.png:/buttons/images/ic_nel_reset_all.png + + + + 20 + 20 + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + 100 + + + true + + + + Server Name + + + + + Server Text Path + + + + + Server Primitive Path + + + + + + + + + + + General Settings + + + + + + Local Text Path + + + + + + + Local path for compiled mission texts. + + + + + + + ... + + + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp new file mode 100644 index 000000000..a9ef08f50 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp @@ -0,0 +1,89 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "server_entry_dialog.h" + +#include "ui_server_entry_dialog.h" + +// NeL includes + +// Qt includes +#include + +namespace MissionCompiler +{ + +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 MissionCompiler */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h new file mode 100644 index 000000000..98a086cd0 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h @@ -0,0 +1,59 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + + +#ifndef SERVER_ENTRY_DIALOG_H +#define SERVER_ENTRY_DIALOG_H + +#include + +namespace Ui { + class ServerEntryDialog; +} + +namespace MissionCompiler +{ +/** +@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 MissionCompiler + +#endif // SERVER_ENTRY_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui new file mode 100644 index 000000000..002af82eb --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui @@ -0,0 +1,130 @@ + + + ServerEntryDialog + + + + 0 + 0 + 488 + 175 + + + + Dialog + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Server Settings + + + + + + Server Name + + + + + + + + + + Server Text Path + + + + + + + + + + ... + + + + + + + Server Primitive Path + + + + + + + + + + ... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + buttonBox + accepted() + ServerEntryDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ServerEntryDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.cpp new file mode 100644 index 000000000..3e166da6b --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.cpp @@ -0,0 +1,133 @@ +#include "validation_file.h" + +#include +#include + +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; isize(); ++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; isize()/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::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>1 | 0x80000000; + else + sum = sum>>1; + } + return NLMISC::toString("0x%08X", sum); +} + +bool CMission::parsePrim(NLLIGO::IPrimitive const* prim) +{ + // init default values + std::vector* 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::iterator itParam, itParamEnd = params->end(); + for (itParam=params->begin(); itParam!=itParamEnd; ++itParam) + { + content += *itParam + "\n"; + } + hashKey = buildHashKey(content); + return true; +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.h new file mode 100644 index 000000000..73d661a26 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/validation_file.h @@ -0,0 +1,51 @@ +#ifndef VALIDATION_FILE_H +#define VALIDATION_FILE_H + +#include +#include +#include + +#include + +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 TMissionStateContainer; + std::deque _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 \ No newline at end of file