From bccf9e45cb70d91a8ce6742fe941101fe755abd3 Mon Sep 17 00:00:00 2001 From: aquiles Date: Fri, 4 Mar 2011 20:52:53 +0100 Subject: [PATCH] Changed: #1150 Added splash screen & new dialog + minor changes --- .../3d/object_viewer_widget/src/interfaces.h | 3 +- .../src/object_viewer_widget.cpp | 144 +++--- .../src/object_viewer_widget.h | 5 +- .../georges_editor_qt/src/CMakeLists.txt | 24 +- .../src/completer_line_edit.cpp | 150 ++++++ .../src/completer_line_edit.h | 39 ++ .../georges_editor_qt/src/configuration.cpp | 378 ++++++++-------- .../georges_editor_qt/src/configuration.h | 100 ++-- .../georges_editor_qt/src/entity.cpp | 8 +- .../georges_editor_qt/src/formdelegate.cpp | 56 ++- .../georges_editor_qt/src/formdelegate.h | 4 +- .../georges_editor_qt/src/formitem.cpp | 54 ++- .../georges_editor_qt/src/georges.cpp | 15 + .../georges_editor_qt/src/georges.h | 6 + .../src/georges_dirtree_dialog.h | 2 +- .../src/georges_editor_qt.qrc | 2 + .../georges_editor_qt/src/georges_splash.cpp | 73 +++ .../georges_editor_qt/src/georges_splash.h | 56 +++ .../src/georges_treeview_dialog.cpp | 83 +++- .../src/georges_treeview_dialog.h | 9 +- .../src/georgesform_model.cpp | 37 +- .../src/images/mp_generic.png | Bin 0 -> 2414 bytes .../georges_editor_qt/src/main.cpp | 10 +- .../georges_editor_qt/src/main_window.cpp | 136 +++--- .../georges_editor_qt/src/main_window.h | 9 +- .../georges_editor_qt/src/modules.cpp | 9 +- .../georges_editor_qt/src/modules.h | 8 +- .../georges_editor_qt/src/new_dialog.cpp | 341 ++++++++++++++ .../georges_editor_qt/src/new_dialog.h | 88 ++++ .../georges_editor_qt/src/new_form.ui | 428 ++++++++++++++++++ .../src/objectviewer_dialog.cpp | 19 +- .../georges_editor_qt/src/progress_dialog.cpp | 2 + .../georges_editor_qt/src/splash.ui | 76 ++++ 33 files changed, 1939 insertions(+), 435 deletions(-) create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/images/mp_generic.png create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/new_form.ui create mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/splash.ui diff --git a/code/nel/tools/3d/object_viewer_widget/src/interfaces.h b/code/nel/tools/3d/object_viewer_widget/src/interfaces.h index 1924ed33d..990df2e0a 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/interfaces.h +++ b/code/nel/tools/3d/object_viewer_widget/src/interfaces.h @@ -67,11 +67,12 @@ namespace NLQT virtual NL3D::UDriver *getDriver() = 0; virtual NL3D::UScene *getScene() = 0; virtual NL3D::UPlayListManager *getPlayListManager() = 0; - virtual void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z) = 0; + virtual void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z) = 0; virtual bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction) = 0; virtual void setVisible(bool visible) = 0; virtual QWidget* getWidget() = 0; virtual void setNelContext(NLMISC::INelContext &nelContext) = 0; + virtual QIcon* saveOneImage(std::string shapename) = 0; }; diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index cf71ed01b..4c6d25b3a 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -41,6 +41,9 @@ along with this program. If not, see . #include #include +// Qt includes +#include + // Project includes Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) @@ -432,7 +435,7 @@ namespace NLQT CAABBox bbox; Entity.getShapeAABBox(bbox); - setCamera(bbox , Entity, true); + setCamera(_Scene, bbox , Entity, true); _MouseListener->setMatrix(_Scene->getCam().getMatrix()); @@ -576,7 +579,7 @@ namespace NLQT _Entities.clear(); } - void CObjectViewerWidget::setCamera(CAABBox &bbox, UTransform &entity, bool high_z) + void CObjectViewerWidget::setCamera(NL3D::UScene *scene, CAABBox &bbox, UTransform &entity, bool high_z) { CVector pos(0.f, 0.f, 0.f); CQuat quat(0.f, 0.f, 0.f, 0.f); @@ -586,87 +589,29 @@ namespace NLQT { inst.getDefaultPos(pos); inst.getDefaultRotQuat(quat); - /* - if (quat.getAxis().isNull()) - { - quat.set(0, 0, 0, 0); - inst.setRotQuat(quat); - } - */ - // quat.set(1.f, 1.f, 0.f, 0.f); - - // inst.setRotQuat(quat); - // inst.getRotQuat(quat); - - // check for presence of all textures from each sets - //bool allGood = true; - - //for(uint s = 0; s < 5; ++s) - //{ - // inst.selectTextureSet(s); - - // uint numMat = inst.getNumMaterials(); - - // // by default, all textures are present - // allGood = true; - - // for(uint i = 0; i < numMat; ++i) - // { - // UInstanceMaterial mat = inst.getMaterial(i); - - // for(sint j = 0; j <= mat.getLastTextureStage(); ++j) - // { - // // if a texture is missing - // if (mat.isTextureFile(j) && mat.getTextureFileName(j) == "CTextureMultiFile:Dummy") - // allGood = false; - // } - // } - - // // if all textures have been found for this set, skip other sets - // if (allGood) - // break; - //} } // fix scale (some shapes have a different value) entity.setScale(1.f, 1.f, 1.f); - UCamera Camera = _Scene->getCam(); + UCamera Camera = scene->getCam(); CVector max_radius = bbox.getHalfSize(); CVector center = bbox.getCenter(); entity.setPivot(center); center += pos; - //_Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); + //scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); float fov = float(_CameraFocal * (float)Pi/180.0); //Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f); float radius = max(max(max_radius.x, max_radius.y), max_radius.z); if (radius == 0.f) radius = 1.f; float left, right, bottom, top, znear, zfar; Camera.getFrustum(left, right, bottom, top, znear, zfar); - float dist = radius / (tan(fov/2)); + float dist = (radius / (tan(fov/2))) * 0.2; CVector eye(center); - /* if (axis == CVector::I) - eye.y -= dist+radius; - else if (axis == CVector::J) - eye.x += dist+radius; - */ - // quat.normalize(); - CVector ax(quat.getAxis()); - // float angle = quat.getAngle(); - /* - if (ax.isNull()) - { - if (int(angle*100.f) == int(NLMISC::Pi * 200.f)) - { - ax = CVector::J; - } - } - else - */ if (ax.isNull() || ax == CVector::I) { ax = CVector::J; @@ -675,12 +620,6 @@ namespace NLQT { ax = -CVector::J; } - /* else if (ax.x < -0.9f && ax.y == 0.f && ax.z == 0.f) - { - ax = -CVector::J ; - } - */ - // ax.normalize(); eye -= ax * (dist+radius); if (high_z) @@ -713,6 +652,73 @@ namespace NLQT return true; } + QIcon* CObjectViewerWidget::saveOneImage(string shapename) + { + int output_width = 128; + int output_height = 128; + + // Create a scene + NL3D::UScene* Scene = _Driver->createScene(true); + if (!Scene) return 0; + + // get scene camera + if (Scene->getCam().empty()) + { + nlwarning("can't get camera from scene"); + return 0; + } + + // add an entity to the scene + UInstance Entity = Scene->createInstance(shapename.c_str()); + + // if we can't create entity, skip it + if (Entity.empty()) + { + nlwarning("can't create instance from %s", shapename.c_str()); + return 0; + } + + // get AABox of Entity + CAABBox bbox; + Entity.getShapeAABBox(bbox); + setCamera(Scene, bbox , Entity, true); + Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)output_width/output_height, 0.1f, 1000); + + string filename = CPath::standardizePath("") + toString("%s.%s", shapename.c_str(), "png"); + + // the background is white + _Driver->clearBuffers(); + + // render the scene + Scene->render(); + + CBitmap btm; + _Driver->getBuffer(btm); + + btm.resample(output_width, output_height); + + COFile fs; + + if (fs.open(filename)) + { + if (!btm.writePNG(fs, 24)) + { + nlwarning("can't save image to PNG"); + return 0; + } + } + else + { + nlwarning("can't create %s", "test.png"); + return 0; + } + fs.close(); + + QIcon *icon = new QIcon(QString(filename.c_str())); + //CFile::deleteFile(filename); + return icon; + } + #if defined(NL_OS_WINDOWS) typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index fd358f482..82bf26f92 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -45,6 +45,7 @@ namespace NL3D class U3dMouseListener; } +class QIcon; /** namespace NLQT @brief namespace NLQT @@ -153,9 +154,11 @@ namespace NLQT /// @return pointer to the UPlayListManager inline NL3D::UPlayListManager *getPlayListManager() { return _PlayListManager; } - void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z); + void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false); bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction); + QIcon* saveOneImage(std::string shapename); + virtual void setVisible(bool visible); QWidget* getWidget() {return this;} diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt index f24f2570b..869d9d1c4 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt @@ -8,9 +8,27 @@ INCLUDE_DIRECTORIES( INCLUDE( ${QT_USE_FILE} ) FILE(GLOB GEORGES_EDITOR_SRC *.cpp *.h) -SET(GEORGES_EDITOR_HDR georges_dirtree_dialog.h georges_treeview_dialog.h main_window.h - objectviewer_dialog.h settings_dialog.h progress_dialog.h) -SET(GEORGES_EDITOR_UIS settings_form.ui objectviewer_form.ui log_form.ui georges_treeview_form.ui georges_dirtree_form.ui) + +SET(GEORGES_EDITOR_HDR + georges_dirtree_dialog.h + georges_treeview_dialog.h + main_window.h + objectviewer_dialog.h + settings_dialog.h + progress_dialog.h + new_dialog.h + completer_line_edit.h + georges_splash.h) + +SET(GEORGES_EDITOR_UIS + settings_form.ui + objectviewer_form.ui + log_form.ui + georges_treeview_form.ui + georges_dirtree_form.ui + new_form.ui + splash.ui) + SET(GEORGES_EDITOR_RCS georges_editor_qt.qrc) SET(QT_USE_QTGUI TRUE) diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp new file mode 100644 index 000000000..abb7b09c7 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp @@ -0,0 +1,150 @@ + + +#include "completer_line_edit.h" + +#include +#include +#include +#include +#include +#include + +CompleteLineEdit::CompleteLineEdit(QWidget *parent, QStringList words) + : QLineEdit(parent), _words(words) +{ + listView = new QListView(this); + model = new QStringListModel(this); + listView->setModel(model); + listView->setWindowFlags(Qt::ToolTip); + listView->setUniformItemSizes(true); + + connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(setCompleter(const QString &))); + connect(listView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(completeText(const QModelIndex &))); +} + +void CompleteLineEdit::setStringList(QStringList list) +{ + _words = list; +} + +//void CompleteLineEdit::focusOutEvent(QFocusEvent *e) +//{ +// listView->hide(); +//} + +void CompleteLineEdit::keyPressEvent(QKeyEvent *e) +{ + if (!listView->isHidden()) + { + int key = e->key(); + int count = listView->model()->rowCount(); + QModelIndex currentIndex = listView->currentIndex(); + + if (Qt::Key_Down == key) + { + int row = currentIndex.row() + 1; + if (row >= count) + { + row = 0; + } + + QModelIndex index = listView->model()->index(row, 0); + listView->setCurrentIndex(index); + } + else if (Qt::Key_Up == key) + { + int row = currentIndex.row() - 1; + if (row < 0) + { + row = count - 1; + } + + QModelIndex index = listView->model()->index(row, 0); + listView->setCurrentIndex(index); + } + else if (Qt::Key_Escape == key) + { + listView->hide(); + } + else if (Qt::Key_Enter == key || Qt::Key_Return == key) + { + if (currentIndex.isValid()) + { + QString text = listView->currentIndex().data().toString(); + setText(text); + } + + listView->hide(); + } + else + { + //listView->hide(); + QLineEdit::keyPressEvent(e); + } + } + else + { + QLineEdit::keyPressEvent(e); + } +} + +void CompleteLineEdit::setCompleter(const QString &text) +{ + if (text.isEmpty()) + { + listView->hide(); + return; + } + + if ((text.length() > 1) && (!listView->isHidden())) + { + //return; + } + + QStringList sl; + Q_FOREACH(QString word, _words) + { + if (word.contains(text)) + { + sl << word; + } + } + + if (sl.isEmpty()) + { + if (_words.isEmpty()) + { + setText(tr("No files found")); + setEnabled(false); + return; + } + else + { + model->setStringList(_words); + } + } + else + { + model->setStringList(sl); + } + + // Position the text edit + listView->setMinimumWidth(width()); + listView->setMaximumWidth(width()); + //listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QPoint p(0, height()); + int x = mapToGlobal(p).x(); + int y = mapToGlobal(p).y() + 1; + + listView->move(x, y); + if(!listView->isVisible()) + listView->show(); +} + +void CompleteLineEdit::completeText(const QModelIndex &index) +{ + QString text = index.data().toString(); + setText(text); + listView->hide(); +} \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h new file mode 100644 index 000000000..30876a78b --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h @@ -0,0 +1,39 @@ +#ifndef COMPLETELINEEDIT_H +#define COMPLETELINEEDIT_H + + +// code from +// http://www.cppblog.com/biao/archive/2009/10/31/99873.html +// there was no license attached + +#include +#include + +class QListView; +class QStringListModel; +class QModelIndex; + +class CompleteLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + CompleteLineEdit(QWidget *parent = 0, QStringList words = QStringList()); + + void setStringList(QStringList list); + +public Q_SLOTS: + void setCompleter(const QString &text); + void completeText(const QModelIndex &index); + +protected: + virtual void keyPressEvent(QKeyEvent *e); + //virtual void focusOutEvent(QFocusEvent *e); + +private: + QStringList _words; + QListView *listView; + QStringListModel *model; +}; + +#endif // COMPLETELINEEDIT_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp index a9c770386..233e0c939 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp @@ -1,19 +1,19 @@ /* - Georges Editor Qt - Copyright (C) 2010 Adrian Jaekel +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. +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 General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ @@ -38,188 +38,200 @@ using namespace std; using namespace NLMISC; namespace NLQT { - -CConfiguration::CConfiguration() -{ - -} -CConfiguration::~CConfiguration() -{ - -} - -void CConfiguration::init() -{ - // load config - QFile file(NLQT_CONFIG_FILE); - if (!file.exists()) { - file.open( QIODevice::WriteOnly | QIODevice::Text ); - file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); - file.write("\nSearchPaths = {\"\"};"); - file.write("\nRemapExtensions = { \"png\", \"tga\" };"); - file.write("\nBackgroundColor = { 0, 0, 0 };"); - //file.write("\nQtStyle = \"\";"); - //file.write("\nQtPalette = \"\";"); - file.close(); - } - - try { - ConfigFile.load(NLQT_CONFIG_FILE); - } catch(...) { - } - - addLeveldesignPath(); - addSearchPaths(); - configRemapExtensions(); -} - -void CConfiguration::release() -{ - //Modules::config().dropCallback("SearchPaths"); - - // save and release the config file - if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) + CConfiguration::CConfiguration() : _progressCB(0) { - ConfigFile.save(); + } - ConfigFile.clear(); - - // release the search paths etc - CPath::releaseInstance(); -} - -void CConfiguration::updateUtilities() -{ - //H_AUTO2 - CConfigFile::checkConfigFiles(); -} -void CConfiguration::addLeveldesignPath() -{ - std::vector list; - list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString())); - addSearchPaths(&list); -} - -void CConfiguration::configRemapExtensions() -{ - CConfigFile::CVar *var; - var = ConfigFile.getVarPtr("RemapExtensions"); - uint varsize = var->size(); - for (uint i = 0; i < varsize; i += 2) - CPath::remapExtension(var->asString(i), var->asString(i + 1), true); -} - -float CConfiguration::getValue(const string &varName, float defaultValue) -{ - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble((double)defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -double CConfiguration::getValue(const string &varName, double defaultValue) -{ - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -int CConfiguration::getValue(const string &varName, int defaultValue) -{ - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -string CConfiguration::getValue(const string &varName, const string &defaultValue) -{ - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsString(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue) -{ - if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString()); - CConfigFile::CVar varToCopy; - varToCopy.forceAsString(defaultValue.toUtf8()); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -bool CConfiguration::getValue(const string &varName, bool defaultValue) -{ - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue ? 1 : 0); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; -} - -CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) -{ - if (ConfigFile.exists(varName)) + CConfiguration::~CConfiguration() { - return getValue(ConfigFile.getVar(varName), defaultValue); + } - else - { - // create a new value only if one doesn't exist - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue.R); - varToCopy.setAsInt(defaultValue.G, 1); - varToCopy.setAsInt(defaultValue.B, 2); - varToCopy.setAsInt(defaultValue.A, 3); - ConfigFile.insertVar(varName, varToCopy); - } - return defaultValue; -} -CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue) -{ - if (var.size() >= 3) - { - if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); - return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); - } - nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); - return defaultValue; -} - -void CConfiguration::addSearchPaths(std::vector* list) -{ - //Modules::config().getConfigFile().getVar("SearchPaths"); - - std::vector *tmpList = list; - if (!tmpList) - { - NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths"); - tmpList = new std::vector(); - for (uint i = 0; i < v.size(); ++i) - { - tmpList->push_back(v.asString(i)); + void CConfiguration::init() + { + // load config + QFile file(NLQT_CONFIG_FILE); + if (!file.exists()) { + file.open( QIODevice::WriteOnly | QIODevice::Text ); + file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); + file.write("\nSearchPaths = {\"\"};"); + file.write("\nRemapExtensions = { \"png\", \"tga\" };"); + file.write("\nBackgroundColor = { 0, 0, 0 };"); + //file.write("\nQtStyle = \"\";"); + //file.write("\nQtPalette = \"\";"); + file.close(); } + + try { + ConfigFile.load(NLQT_CONFIG_FILE); + } catch(...) { + } + + addLeveldesignPath(); + addSearchPaths(); + configRemapExtensions(); } - uint listsize = tmpList->size(); - for (uint i = 0; i < listsize; ++i) + void CConfiguration::release() { - CProgressDialog pcb; - pcb.DisplayString = tmpList->at(i); - pcb.show(); - CPath::addSearchPath(tmpList->at(i), true, false, &pcb); + //Modules::config().dropCallback("SearchPaths"); + + // save and release the config file + if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) + { + ConfigFile.save(); + } + ConfigFile.clear(); + + // release the search paths etc + CPath::releaseInstance(); + } + + void CConfiguration::updateUtilities() + { + //H_AUTO2 + CConfigFile::checkConfigFiles(); + } + + void CConfiguration::addLeveldesignPath() + { + std::vector list; + list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString())); + addSearchPaths(&list); + } + + void CConfiguration::configRemapExtensions() + { + CConfigFile::CVar *var; + var = ConfigFile.getVarPtr("RemapExtensions"); + uint varsize = var->size(); + for (uint i = 0; i < varsize; i += 2) + CPath::remapExtension(var->asString(i), var->asString(i + 1), true); + } + + float CConfiguration::getValue(const string &varName, float defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsDouble((double)defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + double CConfiguration::getValue(const string &varName, double defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsDouble(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + int CConfiguration::getValue(const string &varName, int defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + string CConfiguration::getValue(const string &varName, const string &defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsString(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue) + { + if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString()); + CConfigFile::CVar varToCopy; + varToCopy.forceAsString(defaultValue.toUtf8()); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + bool CConfiguration::getValue(const string &varName, bool defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue ? 1 : 0); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) + { + if (ConfigFile.exists(varName)) + { + return getValue(ConfigFile.getVar(varName), defaultValue); + } + else + { + // create a new value only if one doesn't exist + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue.R); + varToCopy.setAsInt(defaultValue.G, 1); + varToCopy.setAsInt(defaultValue.B, 2); + varToCopy.setAsInt(defaultValue.A, 3); + ConfigFile.insertVar(varName, varToCopy); + } + return defaultValue; + } + + CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue) + { + if (var.size() >= 3) + { + if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); + return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); + } + nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); + return defaultValue; + } + + void CConfiguration::addSearchPaths(std::vector* list) + { + //Modules::config().getConfigFile().getVar("SearchPaths"); + + std::vector *tmpList = list; + if (!tmpList) + { + NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths"); + tmpList = new std::vector(); + for (uint i = 0; i < v.size(); ++i) + { + tmpList->push_back(v.asString(i)); + } + } + + uint listsize = tmpList->size(); + for (uint i = 0; i < listsize; ++i) + { + if(_progressCB) { + _progressCB->DisplayString = tmpList->at(i); + CPath::addSearchPath(tmpList->at(i), true, false, _progressCB); + } + else + { + CProgressDialog pcb; + pcb.DisplayString = tmpList->at(i); + pcb.show(); + CPath::addSearchPath(tmpList->at(i), true, false, &pcb); + } + } + if (!list) + delete tmpList; + } + + void CConfiguration::setProgressCallback(NLMISC::IProgressCallback *cb) + { + _progressCB = cb; } - if (!list) - delete tmpList; -} } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h index dc5bd0f4b..f701cd9fb 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h @@ -1,19 +1,19 @@ /* - Georges Editor Qt - Copyright (C) 2010 Adrian Jaekel +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. +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 General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ @@ -34,46 +34,54 @@ #define NLQT_CONFIG_FILE "georges_editor.cfg" +namespace NLMISC { + class IProgressCallback; +} + namespace NLQT { -/** - * CConfiguration - * \brief CConfiguration - * \date 2010-02-05 15:44GMT - * \author Jan Boon (Kaetemi) - */ -class CConfiguration -{ -public: - CConfiguration(); - virtual ~CConfiguration(); + /** + * CConfiguration + * \brief CConfiguration + * \date 2010-02-05 15:44GMT + * \author Jan Boon (Kaetemi) + */ + class CConfiguration + { + public: + CConfiguration(); + virtual ~CConfiguration(); - void init(); - void release(); - - void updateUtilities(); - void configRemapExtensions(); - void addSearchPaths(std::vector* list = 0); - void addLeveldesignPath(); + void init(); + void release(); - float getValue(const std::string &varName, float defaultValue); - double getValue(const std::string &varName, double defaultValue); - int getValue(const std::string &varName, int defaultValue); - std::string getValue(const std::string &varName, const std::string &defaultValue); - ucstring getValue(const std::string &varName, const ucstring &defaultValue); - bool getValue(const std::string &varName, bool defaultValue); - NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); - NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); - - inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } + void updateUtilities(); + void configRemapExtensions(); + void addSearchPaths(std::vector* list = 0); + void addLeveldesignPath(); -private: - CConfiguration(const CConfiguration &); - CConfiguration &operator=(const CConfiguration &); + void setProgressCallback(NLMISC::IProgressCallback *_progressCB); - NLMISC::CConfigFile ConfigFile; - -};/* class CConfiguration */ + float getValue(const std::string &varName, float defaultValue); + double getValue(const std::string &varName, double defaultValue); + int getValue(const std::string &varName, int defaultValue); + std::string getValue(const std::string &varName, const std::string &defaultValue); + ucstring getValue(const std::string &varName, const ucstring &defaultValue); + bool getValue(const std::string &varName, bool defaultValue); + NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); + NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); + + inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } + + private: + CConfiguration(const CConfiguration &); + CConfiguration &operator=(const CConfiguration &); + + NLMISC::CConfigFile ConfigFile; + + NLMISC::IProgressCallback *_progressCB; + + };/* class CConfiguration */ } /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp index 934bb4d64..d23939fd0 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp @@ -76,23 +76,23 @@ CEntity::~CEntity(void) if (_PlayList != NULL) { _PlayList->resetAllChannels(); - Modules::objViewInt().getPlayListManager()->deletePlayList (_PlayList); + Modules::objViewInt()->getPlayListManager()->deletePlayList (_PlayList); _PlayList = NULL; } if (_AnimationSet != NULL) { - Modules::objViewInt().getDriver()->deleteAnimationSet(_AnimationSet); + Modules::objViewInt()->getDriver()->deleteAnimationSet(_AnimationSet); _AnimationSet = NULL; } if (!_Skeleton.empty()) { _Skeleton.detachSkeletonSon(_Instance); - Modules::objViewInt().getScene()->deleteSkeleton(_Skeleton); + Modules::objViewInt()->getScene()->deleteSkeleton(_Skeleton); _Skeleton = NULL; } if (!_Instance.empty()) { - Modules::objViewInt().getScene()->deleteInstance(_Instance); + Modules::objViewInt()->getScene()->deleteInstance(_Instance); _Instance = NULL; } } diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp index f5ce78726..fc634d322 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp @@ -58,7 +58,13 @@ namespace NLQT if (value.isEmpty() || !mp || !m) return 0; - const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); + CFormItem* curItem = m->getItem(mp->mapToSource(index)); + NLGEORGES::UFormElm *curElm = curItem->getFormElm(); + if (!curElm) { + // TODO: create new Element + return 0; + } + const NLGEORGES::UType *type = curElm->getType(); if(type) { int numDefinitions = type->getNumDefinition(); @@ -273,36 +279,36 @@ namespace NLQT //option.decorationAlignment = QStyleOptionViewItem::Right; } - void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const - { - QStyleOptionViewItemV4 optionV4 = option; - optionV4.decorationPosition = QStyleOptionViewItem::Right; - //optionV4.decorationSize = QSize(32,32); - initStyleOption(&optionV4, index); + //void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + //{ + // QStyleOptionViewItemV4 optionV4 = option; + // optionV4.decorationPosition = QStyleOptionViewItem::Right; + // //optionV4.decorationSize = QSize(32,32); + // initStyleOption(&optionV4, index); - QStyledItemDelegate::paint(painter,optionV4,index); + // QStyledItemDelegate::paint(painter,optionV4,index); - //QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); + // //QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); - //QTextDocument doc; - //doc.setHtml(optionV4.text); + // //QTextDocument doc; + // //doc.setHtml(optionV4.text); - ///// Painting item without text - //optionV4.text = QString(); - //style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); + // ///// Painting item without text + // //optionV4.text = QString(); + // //style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); - //QAbstractTextDocumentLayout::PaintContext ctx; + // //QAbstractTextDocumentLayout::PaintContext ctx; - //// Highlighting text if item is selected - //if (optionV4.state & QStyle::State_Selected) - // ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); + // //// Highlighting text if item is selected + // //if (optionV4.state & QStyle::State_Selected) + // // ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); - //QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); - //painter->save(); - //painter->translate(textRect.topLeft()); - //painter->setClipRect(textRect.translated(-textRect.topLeft())); - //doc.documentLayout()->draw(painter, ctx); - //painter->restore(); - } + // //QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); + // //painter->save(); + // //painter->translate(textRect.topLeft()); + // //painter->setClipRect(textRect.translated(-textRect.topLeft())); + // //doc.documentLayout()->draw(painter, ctx); + // //painter->restore(); + //} } /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h index 589ebad64..1263ab58d 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h @@ -37,8 +37,8 @@ namespace NLQT const QModelIndex &index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; - void paint ( QPainter * painter, const QStyleOptionViewItem & option, - const QModelIndex & index ) const; + //void paint ( QPainter * painter, const QStyleOptionViewItem & option, + // const QModelIndex & index ) const; }; } diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp index 3ec84e4e1..55e34f95c 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp @@ -22,7 +22,9 @@ along with this program. If not, see . // NeL includes +#include #include +#include namespace NLQT { @@ -101,19 +103,61 @@ namespace NLQT case NLGEORGES::UType::SignedInt: case NLGEORGES::UType::Double: case NLGEORGES::UType::String: - nldebug(QString("string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - parentItem->formElm->setValueByName( - value.toString().toStdString().c_str(),itemData[0].toString().toStdString().c_str()); + if (parentItem->formElm->isArray()) + { + //((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName( + //if(parentItem->formElm->getArrayNode(elmName, num)) + //{ + //} + + bool ok; + // TODO: the node can be renamed from eg "#0" to "foobar" + int arrayIndex = itemData[0].toString().remove("#").toInt(&ok); + if(ok) + { + NLGEORGES::UFormElm *elmt = 0; + if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt) + { + if (elmt->isAtom()) + { + ((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toStdString().c_str()); + nldebug(QString("array element string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + } + } + } + else + { + if(parentItem->formElm->setValueByName( + value.toString().toStdString().c_str(), + itemData[0].toString().toStdString().c_str())) + { + nldebug(QString("string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + else + { + nldebug(QString("FAILED string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + } break; case NLGEORGES::UType::Color: + nldebug("Color is TODO"); break; default: break; } } } + else + { + nldebug("setting sth other than Atom"); + } //formElm->setValueByName(); return true; } diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp index 854ebe3a7..369c62d90 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . // NeL includes #include #include +#include // Project includes @@ -48,4 +49,18 @@ namespace NLQT return form; } + UFormDfn *CGeorges::loadFormDfn(std::string formName) + { + UFormDfn *formdfn = FormLoader->loadFormDfn(formName.c_str()); + + return formdfn; + } + + UType *CGeorges::loadFormType(std::string formName) + { + UType *type = FormLoader->loadFormType(formName.c_str()); + + return type; + } + } /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h index 6303bf13a..64dd61679 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h @@ -32,7 +32,9 @@ along with this program. If not, see . namespace NLGEORGES { + class UType; class UForm; + class UFormDfn; class UFormLoader; } @@ -54,6 +56,10 @@ namespace NLQT // Load the given form root UForm* loadForm(std::string formName); + // Load a dfn + UFormDfn* loadFormDfn(std::string formName); + // Load a type + UType *loadFormType (std::string formName); // A form loader UFormLoader *FormLoader; diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h index 60c42321b..1c476350a 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h @@ -48,7 +48,7 @@ namespace NLQT QString _ldPath; Q_SIGNALS: - void selectedForm(QString); + void selectedForm(const QString); public Q_SLOTS: void ldPathChanged(QString path); diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_editor_qt.qrc b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_editor_qt.qrc index 58efbb3a0..9e752618e 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_editor_qt.qrc +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_editor_qt.qrc @@ -9,5 +9,7 @@ images/preferences.png images/pqrticles.png images/khead.png + images/georges_logo.png + images/mp_generic.png diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp new file mode 100644 index 000000000..b28dfc3d8 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp @@ -0,0 +1,73 @@ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "georges_splash.h" + +// Qt includes +#include +#include +#include + +// NeL includes + +// Project includes + +namespace NLMISC { + class IProgressCallback; +} + +namespace NLQT +{ + + CGeorgesSplash::CGeorgesSplash(QWidget *parent) + : QWidget(parent) + { + _ui.setupUi(this); + + setWindowFlags(Qt::SplashScreen); + _ui.imageLabel->setPixmap( + QPixmap(":/images/georges_logo.png"). + scaledToHeight(_ui.imageLabel->height(),Qt::SmoothTransformation)); + //setWindowIcon(QIcon(":/images/georges_logo.png")); + } + + CGeorgesSplash::~CGeorgesSplash() + { + + } + + void CGeorgesSplash::progress (float progressValue) + { + QString display = DisplayString.c_str(); + + // UNCOMMENT if shorter strings are needed + //QFileInfo info(display); + //display = info.filePath(); + //QString sec = display.section("/",-2,-1, + // QString::SectionSkipEmpty | + // QString::SectionIncludeTrailingSep | + // QString::SectionIncludeLeadingSep); + //if(display != sec) + // display = sec.prepend("..."); + + _ui.splashLabel->setText(QString(tr("Adding Folder:\n%1")).arg(display)); + _ui.progressBar->setValue(getCropedValue(progressValue) * 100); + QApplication::processEvents(); + } +} /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h new file mode 100644 index 000000000..336dab431 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h @@ -0,0 +1,56 @@ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef GEORGES_SPLASH_H +#define GEORGES_SPLASH_H + +// Qt includes +#include + +// STL includes + +// NeL includes + +// NeL includes +#include + +// Project includes +#include "ui_splash.h" + +namespace NLMISC { + class IProgressCallback; +} + +namespace NLQT +{ + class CGeorgesSplash: public QWidget, public NLMISC::IProgressCallback + { + Q_OBJECT + + Ui::CGeorgesSplash _ui; + + void progress (float progressValue); + + public: + CGeorgesSplash(QWidget *parent = 0); + ~CGeorgesSplash(); + }; /* CGeorgesSplash */ + +} /* namespace NLQT */ + +#endif // GEORGES_SPLASH_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp index 12b814cdc..dea8d8ce7 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp @@ -25,10 +25,10 @@ along with this program. If not, see . #include // NeL includes -#include #include #include #include +#include // Project includes #include "modules.h" @@ -47,7 +47,7 @@ namespace NLQT CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/, bool emptyView /*= false*/) : QDockWidget(parent) { - _georges = new NLQT::CGeorges; + _georges = new NLQT::CGeorges; loadedForm = ""; _modified = false; @@ -80,14 +80,65 @@ namespace NLQT CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog() { delete _ui.treeView->itemDelegateForColumn(1); + delete _form; deleteLater(); //QSettings settings("RyzomCore", "GeorgesQt"); //settings.setValue("dirViewGeometry", saveGeometry()); } - void CGeorgesTreeViewDialog::selectedForm(QString formName) + void CGeorgesTreeViewDialog::setForm(const CForm *form) { - _form = _georges->loadForm(formName.toStdString()); + _form = (UForm*)form; + } + + CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName) + { + if(NLMISC::CPath::exists(formName.toStdString())) + { + return (CForm*)_georges->loadForm(formName.toStdString()); + } + else + { + CForm *form = 0; + // Load the DFN + std::string extStr = NLMISC::CFile::getExtension( formName.toStdString() ); + QString dfnName = QString("%1.dfn").arg(extStr.c_str()); + UFormDfn *formdfn; + if (NLMISC::CPath::exists(dfnName.toStdString())) + { + formdfn = _georges->loadFormDfn (dfnName.toStdString()); + if (!formdfn) + { + nlwarning("Failed to load dfn: %s", dfnName.toStdString().c_str()); + return 0; + } + } + else + { + nlwarning("Cannot find dfn: %s", dfnName.toStdString().c_str()); + return 0; + } + + form = new CForm; + + // Build the root element + ((CFormElmStruct*)&form->getRootNode())->build((CFormDfn*)formdfn); + + uint i; + for (i=0; iHeldElements[i]))->build ((CFormDfn*)formdfn); + } + return form; + } + return 0; + } + + void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form) + { + + if(form) + _form = form; if (_form) { @@ -118,7 +169,7 @@ namespace NLQT Q_FOREACH(std::string str, dependencies) { QString file = str.c_str(); - if (file == formName) continue; + if (str == _form->getFilename()) continue; deps[file.remove(0,file.indexOf(".")+1)] << str.c_str(); } nlinfo("typ's %d",deps["typ"].count()); @@ -127,7 +178,7 @@ namespace NLQT //nlwarning(strList.join(";").toStdString().c_str()); if (root) { - loadedForm = formName; + loadedForm = _form->getFilename().c_str(); CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents); CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); @@ -145,12 +196,17 @@ namespace NLQT connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), this, SLOT(modifiedFile())); - Modules::mainWin().setWindowTitle("Qt Georges Editor - " + formName); + Modules::mainWin().setWindowTitle("Qt Georges Editor - " + loadedForm); //Modules::mainWin().getTabBar(); } } } + void CGeorgesTreeViewDialog::addParentForm(CForm *form) + { + ((CForm*)_form)->insertParent(((CForm*)_form)->getParentCount(), form->getFilename().c_str(), form); + } + void CGeorgesTreeViewDialog::modifiedFile( ) { if (!_modified) @@ -249,7 +305,7 @@ namespace NLQT CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); QModelIndex in = mp->mapToSource(index); - + // col containing additional stuff like icons if (index.column() == 2) { @@ -279,9 +335,12 @@ namespace NLQT { if (path.contains(".shape")) { - Modules::objViewInt().resetScene(); - //Modules::config().configRemapExtensions(); - Modules::objViewInt().loadMesh(path.toStdString(),""); + if (Modules::objViewInt()) + { + Modules::objViewInt()->resetScene(); + //Modules::config().configRemapExtensions(); + Modules::objViewInt()->loadMesh(path.toStdString(),""); + } return; } } @@ -289,7 +348,7 @@ namespace NLQT // open eg parent files if (!path.isEmpty()) Q_EMIT changeFile(path); - + } } diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h index b514cd3b9..af17ba1df 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h @@ -33,6 +33,7 @@ along with this program. If not, see . namespace NLGEORGES { class UForm; + class CForm; } using namespace NLGEORGES; @@ -53,6 +54,9 @@ namespace NLQT bool modified() {return _modified;} void setModified(bool m) {_modified = m;} + CForm* getFormByName(const QString); + void addParentForm(CForm *form); + void write ( ); QString loadedForm; @@ -64,10 +68,11 @@ namespace NLQT void changeFile(QString); void modified(bool); public Q_SLOTS: - void selectedForm(QString); + void setForm(const CForm*); + void loadFormIntoDialog(CForm *form = 0); + void modifiedFile( ); private Q_SLOTS: void doubleClicked ( const QModelIndex & index ); - void modifiedFile( ); void filterRows(); private: diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp index 515fc12c5..ab3092455 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp @@ -35,6 +35,7 @@ along with this program. If not, see . // project includes #include "formitem.h" +#include "modules.h" using namespace NLGEORGES; @@ -141,7 +142,21 @@ namespace NLQT if (value.contains(".shape")) { - return QIcon(":/images/pqrticles.png"); + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon) + { + if(icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } + else + { + return QIcon(); + } + } } else if(value.contains(".tga") || value.contains(".png")) { @@ -166,7 +181,14 @@ namespace NLQT if (value.contains(".shape")) { - return QIcon(":/images/pqrticles.png"); + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } } else if(value.contains(".tga") || value.contains(".png")) { @@ -218,6 +240,7 @@ namespace NLQT if (result) Q_EMIT dataChanged(index, this->index(index.row(),index.column()+1,index.parent())); + setupModelData(); return result; } @@ -385,6 +408,10 @@ namespace NLQT elmtType.append("_unknownType"); } } + else + { + elmtType.append("_noType"); + } if (numDefinitions) { @@ -485,9 +512,6 @@ namespace NLQT columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - - //columnData << QString(elmName.c_str()) << QString("default") << QString("default"); - //parent->appendChild(new CFormItem(elmt, columnData, parent, UFormElm::ValueDefaultDfn, UFormElm::NodeDfn)); } } else @@ -510,7 +534,6 @@ namespace NLQT QList columnData; std::string value; QString elmtType = ""; - //root->getValueByName(value, elmName.c_str()); UFormElm *elmt = 0; if(root->getArrayNode(&elmt,0) && elmt) @@ -527,6 +550,8 @@ namespace NLQT } if (elmt->isVirtualStruct()) elmtType = "VirtualStruct"; + + elmtType.append("_arrayValue"); columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; parent->appendChild(new CFormItem(elmt, columnData, parent)); loadFormData(elmt, parent->child(parent->childCount()-1)); diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/images/mp_generic.png b/code/ryzom/tools/leveldesign/georges_editor_qt/src/images/mp_generic.png new file mode 100644 index 0000000000000000000000000000000000000000..a566c8b520efec65a4fa0dba7c55dbb5b7e28b54 GIT binary patch literal 2414 zcmV-!36b`RP)bcX? zw_igGLP}MsGIi=Zzle;8OnL9U_xS&8`hN}ZJoB&VxpHCHh4Iq%Islb5j0g6B8885+ zo6r0*4|^SeTh#{O2sj7!H@}C?niqzA9e`KF%06(q-GH)~!S;5OhLYt{7$*h=7iwf--=^Lu~brGLvy`>vyW zD-+%ol0&2A?MXC35#z=7k}WKTdh6+YJe_C z_lLWB_UC&$a_6+0RKrlR^`|VFp^7g15R|vBPk7@?HUIvz1&4cq;FM~rO#4jN!O$C{ z7-leu%AzTFlWXHR1`)wI_ey{wu% z3G7dV!(HWIzhZad@!oN5ueK|Dfx2?M{go-|z=@E0W7Q`}M)05*?O4bKLKSUH_O6-z zo|!$`gqkuSRyK%C)_~v~uiB9f!Mt!~Gx!Gsod9vRiv%P%SQ$fS>m4SD3cm(?Lqz;Wy{Ag}B;acc+m0D-4%;fV$~&@zM#P2 zOfUmWt(B5zrIahI_rg;Ze5(J=43%6&L`yb)dE9d_^_(tx?mZf~b*)CdQj&51xaW;8 z)iix(Ooe7J&fCPJ)1H1Xe)LI?Ve|>EUkT)#@M@$~oTWaLQtz5s5Rs8ji@>u1L9ENw zV&PUO*f$8;(jFTv+DEu~C0F{pgnhAB{<2KZQBQTHIF z@ZoY*uD8v|;cftdrpp}9N8b7Jgu|KRbXoGra`atas3YuThjTFG!m=B2PMA$SH?Btd zF_TiE6mWu?<(p=<%V+C5toz0uK3|L1`&|SxONLE`X8zlYW}LQtA!h?Ka)E9r?9V)4 z_REtIRiqR+Uyc0iZbK=Bu|ORiHxE2_Zcdo52HL(bq(VCw;wP;O^^d*xKT*}?rY;NX zF1+7L`MCfDP}QvJ|5oDe51ncn#&zYGM8}t}R~+s|j?OZVP6iDQ?Z-k&g{Cb`q7uB| z5ca2zH?G$VxtOq4c1VVZXhCOBcy8O)#mi!F3!Oy-QFknU`uEY3r1|nwY3Yc%zx&Yc- zgn3fE$Iv2TPW4|GtF){uVZU~qtwx%*a4>az^+wIF+^E5XekjZ;A!p-sk?1y6V^#@m z8kw&~&YF>agr+yt1uLd!BC-^bET0x*W8Ku+Wq|GiAkNv5nWZs9mkMgayh)ra6KAWQ zrX9I`)gw-27z=$WoG%mISP*9%oew-bNq~_vwB5QM_oeEcbH}QBzR7_X^WWp|PrA6U zK8;;86Twm{jHz(mX4E-8dD!yt-Im#o<6!3KyUdUZqR@?ni7CrfqS-`M?UX(h9-d`F zbS2^EmG{TaxkgnppN+#y0k`yz7ZqG5BFAlCZueu}yhWyMU^a1>38(YKkTPQ`)(=Iz z6Y^-B_qN_F3g_d<>Aav$sC;FLUwZFX&bcHap7rVPGwMAJ&_2J&omN%&&y>^GmtAo~ z5~`T+j&;YF5~_kB3<*hD%rr_;82X-+AeTbQ5Q7ryNLMNe(XYJsk5qLfB9|VbE>m!= zwFo9I)w6>ixbgJcR&1vqGiS@f-o)XYkkx4W!lEr4%`@Vv)TU5|!C9!LHss{g6%&tT z)6^DkKExbjyt~PNk9fu@@3}5kRU38h`$_CxwAHT$MwvIpkTMR)W-MCabY=9pS|p1< z4IzB!y}vIah_h)aWkM<0iJUvnBw z25<|xRi&`*c9s|B1*rLKY_(q$4qomOy==xd1zj}Hx(m*mH79&py1tOT$_?w&R7tGe gxt;&Q%5Cj`0LJmKzH3{ULI3~&07*qoM6N<$g45Hm@c;k- literal 0 HcmV?d00001 diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp index bbd2a4007..d877de075 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include // NeL includes #include @@ -18,6 +19,7 @@ // Project includes #include "modules.h" +#include "georges_splash.h" // nel_qt log file name #define NLQT_LOG_FILE "nel_qt.log" @@ -84,6 +86,11 @@ void messageHandler(QtMsgType p_type, const char* p_msg) sint main(int argc, char **argv) { QApplication app(argc, argv); + QPixmap pixmap(":/images/georges_logo.png"); + NLQT::CGeorgesSplash splash; + splash.show(); + app.processEvents(); + NLMISC::CApplicationContext myApplicationContext; #if defined(NL_OS_MAC) @@ -120,9 +127,10 @@ sint main(int argc, char **argv) NLMISC::CPath::remapExtension("tga", "png", true); } - Modules::init(); + Modules::init(&splash); //Modules::mainWin().resize(800,600); Modules::mainWin().show(); + splash.close(); int result = app.exec(); Modules::release(); return result; diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp index 318272e01..b9c105615 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp @@ -24,11 +24,13 @@ along with this program. If not, see . #include // NeL includes +#include // Project includes #include "modules.h" #include "settings_dialog.h" #include "log_dialog.h" +#include "new_dialog.h" #include "objectviewer_dialog.h" #include "georges_dirtree_dialog.h" #include "georges_treeview_dialog.h" @@ -60,16 +62,16 @@ namespace NLQT _currentView = 0; // load and set leveldesign path from config - QString ldPath = Modules::config(). + _leveldesignPath = Modules::config(). getValue("LeveldesignPath", QString("").toStdString()).c_str(); - QFileInfo info(ldPath); + QFileInfo info(_leveldesignPath); if (!info.isDir()) - ldPath = ""; + _leveldesignPath = ""; // create georges dir dock widget - _GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(ldPath, this); + _GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(_leveldesignPath, this); addDockWidget(Qt::LeftDockWidgetArea, _GeorgesDirTreeDialog); - if (ldPath == "") + if (_leveldesignPath == "") { if (QMessageBox::information(this, tr("Missing leveldesign path"), tr("Your leveldesign path seems to be empty or incorrect.\nDo you want to set it now?"), @@ -101,8 +103,8 @@ namespace NLQT connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); _statusBarTimer->start(5000); - connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(QString)), - this, SLOT(openTreeView(QString))); + connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(const QString)), + this, SLOT(loadFile(const QString))); } CMainWindow::~CMainWindow() @@ -135,11 +137,11 @@ namespace NLQT event->accept(); } - void CMainWindow::openTreeView(QString file) + CGeorgesTreeViewDialog * CMainWindow::createTreeView(QString file) { // create or/and raise tree view dock widget for current file - setCurrentFile(file); + //setCurrentFile(file); CGeorgesTreeViewDialog *newView = 0; @@ -172,7 +174,9 @@ namespace NLQT } _treeViewList.append(newView); - newView->selectedForm(file); + + //newView->selectedForm(file); + _currentView = newView; connect(newView, SIGNAL(changeFile(QString)), @@ -182,6 +186,8 @@ namespace NLQT } QApplication::processEvents(); newView->raise(); + + return newView; } void CMainWindow::settings() @@ -210,33 +216,9 @@ namespace NLQT void CMainWindow::open() { - /*QStringList fileNames = QFileDialog::getOpenFileNames(this, - tr("Open NeL data file"), _lastDir, - tr("All NeL files (*.shape *.ps);;" - "NeL shape files (*.shape);;" - "NeL particle system files (*.ps)")); - - setCursor(Qt::WaitCursor); - if (!fileNames.isEmpty()) - { - QStringList list = fileNames; - QStringList::Iterator it = list.begin(); - _lastDir = QFileInfo(*it).absolutePath(); - - QString skelFileName = QFileDialog::getOpenFileName(this, - tr("Open skeleton file"), _lastDir, - tr("NeL skeleton file (*.skel)")); - - while(it != list.end()) - { - loadFile(*it, skelFileName); - ++it; - } - _AnimationSetDialog->updateListObject(); - _AnimationSetDialog->updateListAnim(); - _SlotManagerDialog->updateUiSlots(); - } - setCursor(Qt::ArrowCursor);*/ + // TODO: FileDialog & loadFile(); + QString fileName = QFileDialog::getOpenFileName(); + loadFile(fileName); } void CMainWindow::save() @@ -246,6 +228,21 @@ namespace NLQT setCursor(Qt::WaitCursor); + //TODO: if not exists open FileDialog SaveAs... + if(!CPath::exists(_currentView->loadedForm.toStdString())) + { + QString fileName = QFileDialog::getSaveFileName( + this, + QString(), + _currentView->loadedForm + ); + QFile file(fileName); + file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); + file.close(); + CPath::addSearchFile(fileName.toStdString()); + //QFileInfo info = QFileInfo(file); + //m->setData(in2, info.fileName()); + } _currentView->write(); setWindowTitle(windowTitle().remove("*")); _saveAction->setEnabled(false); @@ -255,6 +252,31 @@ namespace NLQT void CMainWindow::create() { + QStringList lst; + CGeorgesNewDialog dlg(lst); + dlg.exec(); + qDebug() << lst; + if (!lst.isEmpty() && !lst.at(0).isEmpty()) + { + QString formName = lst.takeFirst(); + CGeorgesTreeViewDialog * newView = 0; + newView = createTreeView(formName); + CForm* form = newView->getFormByName(formName); + newView->setForm(form); + + Q_FOREACH(QString dep, lst) + { + newView->addParentForm(newView->getFormByName(dep)); + } + newView->loadFormIntoDialog(); + //TODO: look into setFilename for new Form object + if(newView->loadedForm.isEmpty()) + { + newView->loadedForm = formName; + setWindowTitle("Qt Georges Editor - " + formName); + } + newView->modifiedFile(); + } } void CMainWindow::createEmptyView(QDockWidget* w) @@ -442,6 +464,24 @@ namespace NLQT } } + void CMainWindow::loadFile(QString fileName){ + QFileInfo info(fileName); + fileName = info.fileName(); + // TODO: make georges static and stuff + CGeorgesTreeViewDialog *newView = new CGeorgesTreeViewDialog; + CForm *form = newView->getFormByName(fileName); + if (form) + { + delete newView; + newView = createTreeView(fileName); + newView->setForm(form); + newView->loadFormIntoDialog(form); + setCurrentFile(fileName); + return; + } + delete newView; + } + void CMainWindow::openRecentFile() { QAction *action = qobject_cast(sender()); @@ -496,28 +536,6 @@ namespace NLQT _separatorAction->setVisible(numRecentFiles > 0); } - - void CMainWindow::loadFile(const QString &fileName) - { - /*QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Recent Files"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream in(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - textEdit->setPlainText(in.readAll()); - QApplication::restoreOverrideCursor();*/ - - openTreeView(fileName); - setCurrentFile(fileName); - //statusBar()->showMessage(tr("File loaded"), 2000); - } - } /* namespace NLQT */ /* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h index 7f56503cf..05fdb928a 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h @@ -60,6 +60,8 @@ namespace NLQT void createEmptyView(QDockWidget* w = 0); void closeEvent(QCloseEvent *event); + QString leveldesignPath() { return _leveldesignPath; } + private Q_SLOTS: void open(); void create(); @@ -67,9 +69,10 @@ namespace NLQT void settings(); void about(); void updateStatusBar(); - void openTreeView(QString); + CGeorgesTreeViewDialog * createTreeView(QString); void tabChanged(int); void openRecentFile(); + void loadFile(QString fileName); private: void createActions(); @@ -77,8 +80,7 @@ namespace NLQT void createToolBars(); void createStatusBar(); void createDialogs(); - - void loadFile(const QString &fileName); + void updateRecentFileActions(); void setCurrentFile(const QString &fileName); @@ -113,6 +115,7 @@ namespace NLQT QAction *_aboutQtAction; QAction *_separatorAction; + QString _leveldesignPath; enum { MaxRecentFiles = 5 }; QAction *recentFileActs[MaxRecentFiles]; diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp index aa651becd..59f596f51 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp @@ -29,14 +29,17 @@ NLQT::CConfiguration *Modules::_configuration = NULL; NLQT::IObjectViewer *Modules::_objViewerInterface = NULL; NLQT::CMainWindow *Modules::_mainWindow = NULL; -void Modules::init() +void Modules::init(NLMISC::IProgressCallback *cb) { - loadPlugin(); - + if (loadPlugin()) + { _objViewerInterface->setNelContext(NLMISC::INelContext::getInstance()); + } if (_configuration == NULL) _configuration = new NLQT::CConfiguration; + _configuration->setProgressCallback(cb); config().init(); + _configuration->setProgressCallback(0); if (_mainWindow == NULL) _mainWindow = new NLQT::CMainWindow; } diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h index 302955253..3718d6733 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h @@ -23,14 +23,18 @@ #include "main_window.h" #include "interfaces.h" +namespace NLMISC { + class IProgressCallback; +} + class Modules { public: - static void init(); + static void init(NLMISC::IProgressCallback *cb); static void release(); static NLQT::CConfiguration &config() { return *_configuration; } - static NLQT::IObjectViewer &objViewInt() { return *_objViewerInterface; } + static NLQT::IObjectViewer* objViewInt() { return _objViewerInterface; } static NLQT::CMainWindow &mainWin() { return *_mainWindow; } private: static bool loadPlugin(); diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp new file mode 100644 index 000000000..a89e292ef --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp @@ -0,0 +1,341 @@ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "new_dialog.h" + +// Qt includes +#include +#include +#include +#include +#include + +#include + +// NeL includes +#include + +// Project includes +#include "modules.h" +#include "completer_line_edit.h" + +namespace NLQT +{ + + CGeorgesNewDialog::CGeorgesNewDialog(QStringList& result, QWidget *parent) + : QDialog(parent), + _result(result), + _descriptionTemplate(QString()) + { + _ui.setupUi(this); + + setWindowIcon(QIcon(":/images/georges_logo.png")); + + _ui.parentLineEdit->setEnabled(false); + _ui.addParentButton->setEnabled(true); + + // wizard page + connect(_ui.wizardBtn, SIGNAL(clicked(bool)), + this, SLOT(wizardBtnClicked(bool))); + connect(_ui.wizardList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(wizardItemActivated(QListWidgetItem *))); + + // form page + connect(_ui.formBtn, SIGNAL(clicked(bool)), + this, SLOT(formBtnClicked(bool))); + connect(_ui.addParentButton, SIGNAL(clicked()), + this, SLOT(addParentClicked())); + connect(_ui.deleteParentButton, SIGNAL(clicked()), + this, SLOT(deleteParentClicked())); + connect(_ui.formList, SIGNAL(itemActivated(QListWidgetItem*)), + this, SLOT(formItemActivated(QListWidgetItem *))); + connect(_ui.formList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(formItemActivated(QListWidgetItem *))); + connect(_ui.parentLineEdit, SIGNAL(editingFinished()), + this, SLOT(validateParentCombo())); + + // dfn page + connect(_ui.dfnTypeBtn, SIGNAL(clicked(bool)), + this, SLOT(dfnTypeClicked(bool))); + + connect(_ui.buttonBox, SIGNAL(accepted()), + this, SLOT(buttonBoxAccepted())); + connect(_ui.buttonBox, SIGNAL(rejected()), + this, SLOT(buttonBoxRejected())); + + // wizard list + QListWidgetItem *mpWiz = new QListWidgetItem(QIcon(":/images/mp_generic.png"),tr("Raw Material Generator")); + _ui.wizardList->addItem(mpWiz); + + // form list + QString path = Modules::mainWin().leveldesignPath(); + QStringList typelist; + //nlinfo ("Searching files in directory '%s'...", dir.c_str()); + NLMISC::CPath::getPathContent(path.toStdString(),true,false,true,_files); + + getTypes(path.toStdString()); + //nlinfo ("%d supported file types :",FileTypeToId.size()); + for ( std::map::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it ) + { + typelist.append(QString((*it).first.c_str())); + //nlinfo("%s",(*it).first.c_str()); + } + _ui.formList->addItems(typelist); + + for(uint i = 0; i < _files.size(); i++) + { + std::string extStr = NLMISC::CFile::getExtension( _files[i] ); + + // filter files without existing dfn + if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString()) && + !NLMISC::CPath::exists(QString("%1.typ").arg(extStr.c_str()).toStdString())) + { + continue; + } + _filelist.append(QString(NLMISC::CFile::getFilename(_files[i]).c_str())); + } + + _ui.parentFrame->hide(); + + // replace "Heading" and "Descriptive Text" with your string + _descriptionTemplate = + "" + "\n" + "" + "" + "\n

" + "Heading

" + "\n

" + "Descriptive Text

"; + } + + CGeorgesNewDialog::~CGeorgesNewDialog() + { + + } + + void CGeorgesNewDialog::wizardBtnClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.wizardPage); + else + _ui.wizardBtn->setChecked(true); + } + + void CGeorgesNewDialog::formBtnClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.formPage); + else + _ui.formBtn->setChecked(true); + } + + void CGeorgesNewDialog::dfnTypeClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.dfnTypePage); + else + _ui.dfnTypeBtn->setChecked(true); + } + + void CGeorgesNewDialog::addParentClicked() + { + if (!_filelist.contains(_ui.parentLineEdit->text())) + { + _ui.parentLineEdit->clear(); + return; + } + + _ui.parentFrame->show(); + + QList itemList = _ui.parentList-> + findItems(_ui.parentLineEdit->text(), Qt::MatchFixedString); + if ((itemList.count() == 0) && (!_ui.parentLineEdit->text().isEmpty())) + { + _ui.parentList->insertItem(_ui.parentList->count(), _ui.parentLineEdit->text()); + } + _ui.parentLineEdit->clear(); + } + + void CGeorgesNewDialog::deleteParentClicked() + { + _ui.parentList->takeItem(_ui.parentList->currentRow()); + + if (_ui.parentList->count() == 0) + { + _ui.parentFrame->hide(); + } + } + + void CGeorgesNewDialog::buttonBoxAccepted() + { + if (_ui.stackedWidget->currentWidget() == _ui.formPage) + { + _result << _ui.formFileNameEdit->text(); + for (int i = 0; i < _ui.parentList->count(); i++) + { + _result << _ui.parentList->item(i)->text(); + } + } + else + { + QMessageBox::information(this,"Information","Not yet included.\nSoon to come! :)"); + } + } + + void CGeorgesNewDialog::buttonBoxRejected() + { + // TODO + } + + void CGeorgesNewDialog::formItemActivated(QListWidgetItem *item) + { + _ui.formFileNameEdit->setText(QString(tr("newfile.%1").arg(item->text()))); + _ui.parentLineEdit->setEnabled(true); + _ui.parentLineEdit->setText(""); + //_ui.addParentButton->setEnabled(false); + + QStringList list = _filelist.filter(item->text()); + _ui.parentLineEdit->setStringList(list); + _ui.formFileNameEdit->setFocus(); + _ui.formFileNameEdit->setSelection(0, tr("newfile").size()); + } + + void CGeorgesNewDialog::wizardItemActivated(QListWidgetItem *item) + { + QString myDescription = _descriptionTemplate; + myDescription = myDescription.replace("Heading", item->text()); + + if (item->text() == tr("Raw Material Generator")) + { + myDescription = myDescription.replace("Descriptive Text", + tr("Automatically creates MP (resources) for every creature in the assets.")); + } + + _ui.wizDescLabel->setText(myDescription); + } + + void CGeorgesNewDialog::getTypes( std::string& dir ) + { + //nlinfo ("Found %d files in directory '%s'", files.size(), dir.c_str()); + for(uint i = 0; i < _files.size(); i++) + { + addType(NLMISC::CFile::getFilename(_files[i])); + QApplication::processEvents(); + } + } + + void CGeorgesNewDialog::addType( std::string fileName ) + { + if(fileName.empty() || fileName=="." || fileName==".." || fileName[0]=='_' || fileName.find(".#")==0) + { + //nlinfo("Discarding file '%s'", fileName.c_str()); + return; + } + else + { + std::string extStr = NLMISC::CFile::getExtension( fileName ); + + if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString())) + { + return; + } + } + + // if the file is new + std::map::iterator itFI = FormToId.find( fileName ); + if( itFI == FormToId.end() ) + { + // double check : if file not found we check with lower case version of filename + std::map::iterator itFILwr = FormToId.find( NLMISC::toLower(fileName) ); + if( itFILwr != FormToId.end() ) + { + nlwarning("Trying to add %s but the file %s is already known ! be careful with lower case and upper case.", fileName.c_str(), NLMISC::toLower(fileName).c_str()); + return; + } + + std::string fileType; + if( getFileType( fileName, fileType ) ) + { + std::map::iterator itFTI = FileTypeToId.find( fileType ); + TFormId fid; + memset( &fid, 0, sizeof(TFormId) ); + + // if the type of this file is a new type + if( itFTI == FileTypeToId.end() ) + { + sint16 firstFreeFileTypeId = getFirstFreeFileTypeId(); + if( firstFreeFileTypeId == -1 ) + { + nlwarning("MORE THAN 256 FILE TYPES!!!!"); + } + else + { + FileTypeToId.insert( std::make_pair(fileType,(uint8)firstFreeFileTypeId) ); + IdToFileType.insert( std::make_pair((uint8)firstFreeFileTypeId,fileType) ); + + fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId; + fid.FormIDInfos.Id = 0; + + //nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId); + } + } + else + { + return; + } + FormToId.insert( make_pair(fileName,fid) ); + //nlinfo("Adding file '%s' id %d with type '%s' id %d", fileName.c_str(), fid.FormIDInfos.Id, fileType.c_str(), fid.FormIDInfos.Type); + } + else + { + nlinfo("Unknown file type for the file : '%s' --> not added",fileName.c_str()); + } + } + else + { + nlinfo("Skipping file '%s', already in the file", fileName.c_str()); + } + } + + bool CGeorgesNewDialog::getFileType( std::string& fileName, std::string& fileType ) + { + fileType = NLMISC::CFile::getExtension(NLMISC::CFile::getFilename(fileName)); + return !fileType.empty(); + } + + sint16 CGeorgesNewDialog::getFirstFreeFileTypeId() + { + for( sint16 id=0; id<256; ++id ) + { + if( IdToFileType.find((uint8)id) == IdToFileType.end() ) + { + return id; + } + } + return -1; + } + + void CGeorgesNewDialog::validateParentCombo() { + // TODO: clear if no valid text + //if (!_filelist.contains(_ui.parentLineEdit->text())) + // _ui.parentLineEdit->clear(); + } +} /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h new file mode 100644 index 000000000..c06824ada --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h @@ -0,0 +1,88 @@ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef NEW_DIALOG_H +#define NEW_DIALOG_H + +// Qt includes +#include + +// STL includes + +// NeL includes +#include +#include + +// Project includes +#include "ui_new_form.h" + +namespace NLQT +{ + class CGeorgesNewDialog: public QDialog + { + Q_OBJECT + + union TFormId + { + uint32 Id; + struct + { + uint32 Type : 8; + uint32 Id : 24; + } FormIDInfos; + void serial(NLMISC::IStream &f) { f.serial(Id); }; + }; + + Ui::CGeorgesNewDialog _ui; + QStringList _filelist; + QStringList &_result; + QString _descriptionTemplate; + + std::map FormToId; + std::map FileTypeToId; + std::map IdToFileType; + + std::vector _files; + + void getTypes( std::string& dir ); + void addType( std::string fileName ); + bool getFileType( std::string& fileName, std::string& fileType ); + sint16 getFirstFreeFileTypeId(); + + public: + CGeorgesNewDialog(QStringList& result, QWidget *parent = 0); + ~CGeorgesNewDialog(); + + private Q_SLOTS: + void wizardBtnClicked(bool checked); + void formBtnClicked (bool checked); + void dfnTypeClicked (bool p_checked); + void addParentClicked(); + void deleteParentClicked(); + void formItemActivated(QListWidgetItem *); + void wizardItemActivated(QListWidgetItem *); + void validateParentCombo(); + void buttonBoxAccepted(); + void buttonBoxRejected(); + + friend class CMainWindow; + }; /* CGeorgesNewDialog */ + +} /* namespace NLQT */ + +#endif // NEW_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_form.ui b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_form.ui new file mode 100644 index 000000000..65e9e6214 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_form.ui @@ -0,0 +1,428 @@ + + + CGeorgesNewDialog + + + + 0 + 0 + 885 + 520 + + + + + 0 + 0 + + + + Create new form ... + + + true + + + + + + Qt::Vertical + + + + + + + 0 + + + + + 0 + + + + + Choose a wizard ... + + + + + + QListView::IconMode + + + + + + + Description + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + + + + + + + + + + + + + 0 + + + + + Choose type of form ... + + + + + + Qt::Vertical + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + 0 + 0 + + + + + 0 + 55 + + + + + 16777215 + 55 + + + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 55 + + + + + + + + Delete + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Add Parent + + + + + + + + + + Add + + + + + + + Filename + + + + + + + + + + + + + + + 0 + + + + + Create a new dfn or typ file ... + + + + + + DFN + + + true + + + + + + + Type + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 0 + + + 6 + + + 0 + + + + + + 0 + 0 + + + + Wizards ... + + + true + + + true + + + true + + + true + + + + + + + + 0 + 0 + + + + Create New Form ... + + + true + + + true + + + true + + + + + + + Create DFN or Type ... + + + true + + + true + + + true + + + + + + + Qt::Vertical + + + + 169 + 308 + + + + + + + + + + + + CompleteLineEdit + QLineEdit +
completer_line_edit.h
+
+
+ + wizardBtn + formBtn + dfnTypeBtn + wizardList + formList + parentList + formFileNameEdit + dfnRadioButton + typeRadioButton + filenameLineEdit + buttonBox + + + + + buttonBox + accepted() + CGeorgesNewDialog + accept() + + + 350 + 598 + + + 157 + 274 + + + + + buttonBox + rejected() + CGeorgesNewDialog + reject() + + + 418 + 598 + + + 286 + 274 + + + + +
diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp index b7be551df..ebe725b24 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp @@ -41,14 +41,17 @@ using namespace NL3D; namespace NLQT { - CObjectViewerDialog::CObjectViewerDialog(QWidget *parent) - : QDockWidget(parent) + CObjectViewerDialog::CObjectViewerDialog(QWidget *parent) :QDockWidget(parent), + _nlw(0) { _ui.setupUi(this); - _nlw = dynamic_cast(Modules::objViewInt().getWidget()); - //_nlw->setObjectName(QString::fromUtf8("nlwidget")); - _ui.gridLayout->addWidget(_nlw, 0, 0); + if (Modules::objViewInt()) + { + _nlw = dynamic_cast(Modules::objViewInt()->getWidget()); + //_nlw->setObjectName(QString::fromUtf8("nlwidget")); + _ui.gridLayout->addWidget(_nlw, 0, 0); + } } CObjectViewerDialog::~CObjectViewerDialog() @@ -97,8 +100,10 @@ namespace NLQT { //nldebug("%d %d",_nlw->width(), _nlw->height()); QDockWidget::resizeEvent(resizeEvent); - if (Modules::objViewInt().getDriver()) - Modules::objViewInt().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); + if (Modules::objViewInt()) { + if (Modules::objViewInt()->getDriver()) + Modules::objViewInt()->setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); + } // The OpenGL driver does not resize automatically. // The Direct3D driver breaks the window mode to include window borders when calling setMode windowed. diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp index 369eb576b..6d98b9d97 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include #include #include +#include // STL includes // NeL includes @@ -47,6 +48,7 @@ namespace NLQT resize(250, 100); _progressBar->setMinimum(0); _progressBar->setMaximum(100); + setWindowIcon(QIcon(":/images/georges_logo.png")); } CProgressDialog::~CProgressDialog() diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/splash.ui b/code/ryzom/tools/leveldesign/georges_editor_qt/src/splash.ui new file mode 100644 index 000000000..8043acb91 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/splash.ui @@ -0,0 +1,76 @@ + + + CGeorgesSplash + + + + 0 + 0 + 337 + 214 + + + + + + + + + + 24 + + + + + + + + 0 + 0 + + + + Initializing ... + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">Georges Editor Qt</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">for</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Ryzom Core</span></p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">by</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">aquiles</span></p></body></html> + + + + + + + + 150 + 150 + + + + + 150 + 150 + + + + + + + + + + + +