From 2038260b3c69627a18be8f5467fed77524db9655 Mon Sep 17 00:00:00 2001 From: aquiles Date: Sun, 21 Nov 2010 17:40:58 +0100 Subject: [PATCH] Changed: #1150 added progress dialog to show CPath progress and changed config behaviour --- .../georges_editor_qt/src/CMakeLists.txt | 2 +- .../georges_editor_qt/src/callback.cpp | 27 -- .../georges_editor_qt/src/callback.h | 326 ------------------ .../georges_editor_qt/src/configuration.cpp | 87 ++--- .../georges_editor_qt/src/configuration.h | 16 +- .../georges_editor_qt/src/main_window.cpp | 6 +- .../georges_editor_qt/src/object_viewer.cpp | 36 +- .../georges_editor_qt/src/object_viewer.h | 4 - .../georges_editor_qt/src/settings_dialog.cpp | 108 +++--- .../georges_editor_qt/src/settings_dialog.h | 4 - 10 files changed, 109 insertions(+), 507 deletions(-) delete mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.cpp delete mode 100644 code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.h 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 c0eae2e2b..7919ed9fa 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt @@ -3,7 +3,7 @@ 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) + 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_RCS georges_editor_qt.qrc) diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.cpp deleted file mode 100644 index c09c6e357..000000000 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010 by authors - * - * This file is part of NEL QT. - * NEL QT 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 2 of the License, or - * (at your option) any later version. - * - * NEL QT 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 NEL QT; see the file COPYING. If not, see - * . - */ - -#include -#include "callback.h" - -namespace NLQT { - -} /* namespace NLQT */ - -/* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.h deleted file mode 100644 index 822b1ee99..000000000 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.h +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright (C) 2010 by authors - * - * This file is part of NEL QT. - * NEL QT 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 2 of the License, or - * (at your option) any later version. - * - * NEL QT 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 NEL QT; see the file COPYING. If not, see - * . - */ - -#ifndef NLQT_CALLBACK_H -#define NLQT_CALLBACK_H -#include - -// STL includes - -// NeL includes -#ifdef NL_COMP_GCC -// temporary fix for GCC 4.4 segmentation fault -# undef nlassert -# define nlassert(x) -#else -# include -#endif // NL_COMP_GCC - -// Project includes - -namespace NLQT { - -#define NLQT_CALLBACK_TEMPLATE \ -/** \ - * \brief NLQT_CALLBACK_ARGS_CLASS \ - * \date 2009-03-03 18:09GMT \ - * \author Jan Boon (Kaetemi) \ - * Awesome callback template \ - */ \ -template \ -class NLQT_CALLBACK_ARGS_CLASS \ -{ \ - /* Very simple reference counting callback base */ \ - class CCallbackBase \ - { \ - public: \ - CCallbackBase() : m_RefCount(0) \ - { \ - \ - } \ - \ - virtual ~CCallbackBase() \ - { \ - nlassert(!m_RefCount); \ - } \ - \ - void refAdd() \ - { \ - ++m_RefCount; \ - } \ - \ - void refRemove() \ - { \ - --m_RefCount; \ - if (!m_RefCount) \ - delete this; \ - } \ - \ - virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) = 0; \ - \ - virtual bool equals(const CCallbackBase *callbackBase) = 0; \ - \ - /* disable copy */ \ - CCallbackBase(const CCallbackBase &); \ - CCallbackBase &operator=(const CCallbackBase &); \ - \ - private: \ - uint m_RefCount; \ - }; \ - \ - typedef TReturn TCallbackFunction(NLQT_CALLBACK_ARGS_DECL); \ - class CCallbackFunction : public CCallbackBase \ - { \ - public: \ - CCallbackFunction(TCallbackFunction *callbackFunction) : m_CallbackFunction(callbackFunction) \ - { \ - nlassert(m_CallbackFunction); \ - } \ - \ - virtual ~CCallbackFunction() \ - { \ - m_CallbackFunction = NULL; \ - } \ - \ - virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ - { \ - return m_CallbackFunction(NLQT_CALLBACK_ARGS_IMPL); \ - } \ - \ - virtual bool equals(const CCallbackBase *callbackBase) \ - { \ - const CCallbackFunction *callbackFunction = \ - dynamic_cast(callbackBase); \ - if (!callbackFunction) return false; \ - return m_CallbackFunction == callbackFunction->m_CallbackFunction; \ - } \ - \ - private: \ - TCallbackFunction *m_CallbackFunction; \ - }; \ - \ - template \ - class CCallbackMethod : public CCallbackBase \ - { \ - typedef TReturn (TClass::*TCallbackMethod)(NLQT_CALLBACK_ARGS_DECL); \ - public: \ - CCallbackMethod(TClass *callbackObject, TCallbackMethod callbackMethod) : m_CallbackObject(callbackObject), m_CallbackMethod(callbackMethod) \ - { \ - nlassert(m_CallbackObject); \ - nlassert(m_CallbackMethod); \ - } \ - \ - virtual ~CCallbackMethod() \ - { \ - m_CallbackObject = NULL; \ - m_CallbackMethod = NULL; \ - } \ - \ - virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ - { \ - return (m_CallbackObject->*m_CallbackMethod)(NLQT_CALLBACK_ARGS_IMPL); \ - } \ - \ - virtual bool equals(const CCallbackBase *callbackBase) \ - { \ - const CCallbackMethod *callbackMethod = \ - dynamic_cast(callbackBase); \ - if (!callbackMethod) return false; \ - return m_CallbackObject == callbackMethod->m_CallbackObject \ - && m_CallbackMethod == callbackMethod->m_CallbackMethod; \ - } \ - \ - private: \ - TClass *m_CallbackObject; \ - TCallbackMethod m_CallbackMethod; \ - }; \ - \ -public: \ - CCallback() : m_CallbackBase(NULL) \ - { \ - \ - } \ - \ - CCallback(TCallbackFunction *callbackFunction) : m_CallbackBase(new CCallbackFunction(callbackFunction)) \ - { \ - nlassert(m_CallbackBase); \ - m_CallbackBase->refAdd(); \ - } \ - \ - template \ - CCallback(TClass *callbackObject, TReturn (TClass::*callbackMethod)(NLQT_CALLBACK_ARGS_DECL)) : m_CallbackBase(new CCallbackMethod(callbackObject, callbackMethod)) \ - { \ - nlassert(m_CallbackBase); \ - m_CallbackBase->refAdd(); \ - } \ - \ - CCallback(const CCallback &callback) \ - { \ - m_CallbackBase = callback.m_CallbackBase; \ - if (m_CallbackBase) \ - m_CallbackBase->refAdd(); \ - } \ - \ - CCallback &operator=(const CCallback &callback) \ - { \ - if (m_CallbackBase != callback.m_CallbackBase) \ - { \ - if (m_CallbackBase) \ - m_CallbackBase->refRemove(); \ - m_CallbackBase = callback.m_CallbackBase; \ - if (m_CallbackBase) \ - m_CallbackBase->refAdd(); \ - } \ - return *this; \ - } \ - \ - ~CCallback() \ - { \ - if (m_CallbackBase) \ - { \ - m_CallbackBase->refRemove(); \ - m_CallbackBase = NULL; \ - } \ - } \ - \ - TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ - { \ - nlassert(m_CallbackBase); \ - return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \ - } \ - \ - TReturn operator()(NLQT_CALLBACK_ARGS_DECL) \ - { \ - nlassert(m_CallbackBase); \ - return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \ - } \ - \ - bool valid() const \ - { \ - return m_CallbackBase != NULL; \ - } \ - \ - operator bool() const \ - { \ - return m_CallbackBase != NULL; \ - } \ - \ - bool operator==(const CCallback &callback) \ - { \ - return m_CallbackBase->equals(callback.m_CallbackBase); \ - } \ - \ -private: \ - CCallbackBase *m_CallbackBase; \ - \ -}; /* class CCallback */ \ - -template -class CCallback; - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME -#define NLQT_CALLBACK_ARGS_DECL -#define NLQT_CALLBACK_ARGS_IMPL -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA -#define NLQT_CALLBACK_ARGS_IMPL argsA -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL - -#define NLQT_CALLBACK_ARGS_CLASS CCallback -#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF, typename TArgsG -#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF, TArgsG argsG -#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF, argsG -NLQT_CALLBACK_TEMPLATE -#undef NLQT_CALLBACK_ARGS_CLASS -#undef NLQT_CALLBACK_ARGS_TYPENAME -#undef NLQT_CALLBACK_ARGS_DECL -#undef NLQT_CALLBACK_ARGS_IMPL -#undef NLQT_CALLBACK_ARGS_CLASSNAME - -#undef NLQT_CALLBACK_TEMPLATE - -typedef CCallback CEmptyCallback; - -} /* namespace NLQT */ - -#endif /* #ifndef NLQT_CALLBACK_H */ - -/* 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 173b35cc2..a9c770386 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp @@ -30,9 +30,9 @@ #include #include +// Project includes #include "modules.h" - -#include +#include "progress_dialog.h" using namespace std; using namespace NLMISC; @@ -51,9 +51,6 @@ CConfiguration::~CConfiguration() void CConfiguration::init() { - // verify data - nlassert(!ConfigCallbacks.size()); - // load config QFile file(NLQT_CONFIG_FILE); if (!file.exists()) { @@ -62,8 +59,8 @@ void CConfiguration::init() file.write("\nSearchPaths = {\"\"};"); file.write("\nRemapExtensions = { \"png\", \"tga\" };"); file.write("\nBackgroundColor = { 0, 0, 0 };"); - file.write("\nQtStyle = \"\";"); - file.write("\nQtPalette = \"\";"); + //file.write("\nQtStyle = \"\";"); + //file.write("\nQtPalette = \"\";"); file.close(); } @@ -72,14 +69,14 @@ void CConfiguration::init() } catch(...) { } - // setup config file callback - Modules::config().setAndCallback("SearchPaths", CConfigCallback(this, &CConfiguration::cfcbSearchPaths)); - + addLeveldesignPath(); + addSearchPaths(); + configRemapExtensions(); } void CConfiguration::release() { - Modules::config().dropCallback("SearchPaths"); + //Modules::config().dropCallback("SearchPaths"); // save and release the config file if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) @@ -90,9 +87,6 @@ void CConfiguration::release() // release the search paths etc CPath::releaseInstance(); - - // verify data - nlassert(!ConfigCallbacks.size()); } void CConfiguration::updateUtilities() @@ -101,17 +95,11 @@ void CConfiguration::updateUtilities() CConfigFile::checkConfigFiles(); } -void CConfiguration::configSearchPaths() +void CConfiguration::addLeveldesignPath() { - cfcbSearchPaths(Modules::config().getConfigFile().getVar("SearchPaths")); -} - -std::string CConfiguration::configLeveldesignPath() -{ - std::string path = Modules::config().getValue("LeveldesignPath", QString("").toStdString()); - cfcbSearchPaths(Modules::config().getConfigFile().getVar("LeveldesignPath")); - - return path; + std::vector list; + list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString())); + addSearchPaths(&list); } void CConfiguration::configRemapExtensions() @@ -123,25 +111,6 @@ void CConfiguration::configRemapExtensions() CPath::remapExtension(var->asString(i), var->asString(i + 1), true); } -void CConfiguration::setAndCallback(const std::string &varName, CConfigCallback configCallback) -{ - ConfigCallbacks[varName] = configCallback; - ConfigFile.setCallback(varName, cbConfigCallback); - configCallback(*ConfigFile.getVarPtr(varName)); -} - -void CConfiguration::setCallback(const std::string &varName, CConfigCallback configCallback) -{ - ConfigCallbacks[varName] = configCallback; - ConfigFile.setCallback(varName, cbConfigCallback); -} - -void CConfiguration::dropCallback(const std::string &varName) -{ - ConfigFile.setCallback(varName, NULL); - ConfigCallbacks.erase(varName); -} - float CConfiguration::getValue(const string &varName, float defaultValue) { if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); @@ -226,17 +195,31 @@ CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaul return defaultValue; } -void CConfiguration::cbConfigCallback(NLMISC::CConfigFile::CVar &var) +void CConfiguration::addSearchPaths(std::vector* list) { - Modules::config().ConfigCallbacks[var.Name](var); -} + //Modules::config().getConfigFile().getVar("SearchPaths"); -void CConfiguration::cfcbSearchPaths(NLMISC::CConfigFile::CVar &var) -{ - uint varsize = var.size(); - //CPath::clearMap(); - for (uint i = 0; i < varsize; ++i) - CPath::addSearchPath(var.asString(i), true, false); + 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) + { + CProgressDialog pcb; + pcb.DisplayString = tmpList->at(i); + pcb.show(); + CPath::addSearchPath(tmpList->at(i), true, false, &pcb); + } + 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 5acedd7a5..dc5bd0f4b 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h @@ -31,14 +31,11 @@ #include // Project includes -#include "callback.h" #define NLQT_CONFIG_FILE "georges_editor.cfg" namespace NLQT { -typedef CCallback CConfigCallback; - /** * CConfiguration * \brief CConfiguration @@ -55,14 +52,10 @@ public: void release(); void updateUtilities(); - void configSearchPaths(); - std::string configLeveldesignPath(); void configRemapExtensions(); + void addSearchPaths(std::vector* list = 0); + void addLeveldesignPath(); - void setAndCallback(const std::string &varName, CConfigCallback configCallback); - void setCallback(const std::string &varName, CConfigCallback configCallback); - void dropCallback(const std::string &varName); - float getValue(const std::string &varName, float defaultValue); double getValue(const std::string &varName, double defaultValue); int getValue(const std::string &varName, int defaultValue); @@ -75,15 +68,10 @@ public: inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } private: - static void cbConfigCallback(NLMISC::CConfigFile::CVar &var); - - void cfcbSearchPaths(NLMISC::CConfigFile::CVar &var); - CConfiguration(const CConfiguration &); CConfiguration &operator=(const CConfiguration &); NLMISC::CConfigFile ConfigFile; - std::map ConfigCallbacks; };/* class CConfiguration */ 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 59fcd9ba8..e28948050 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 @@ -32,6 +32,7 @@ along with this program. If not, see . #include "objectviewer_dialog.h" #include "georges_dirtree_dialog.h" #include "georges_treeview_dialog.h" +#include "progress_dialog.h" using namespace std; using namespace NLMISC; @@ -59,7 +60,8 @@ namespace NLQT _currentView = 0; // load and set leveldesign path from config - QString ldPath = Modules::config().configLeveldesignPath().c_str(); + QString ldPath = Modules::config(). + getValue("LeveldesignPath", QString("").toStdString()).c_str(); QFileInfo info(ldPath); if (!info.isDir()) ldPath = ""; @@ -113,7 +115,7 @@ namespace NLQT delete _ObjectViewerDialog; delete _GeorgesDirTreeDialog; delete _GeorgesLogDialog; - delete _emptyView; + //delete _emptyView; } void CMainWindow::closeEvent(QCloseEvent *event) diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.cpp index 44e8b2e8d..aa95eb087 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.cpp @@ -86,10 +86,20 @@ namespace NLQT //Modules::config().configSearchPaths(); // set background color from config - Modules::config().setAndCallback("BackgroundColor", CConfigCallback(this, &CObjectViewer::cfcbBackgroundColor)); + NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("BackgroundColor"); + _BackgroundColor = CRGBA(v.asInt(0), v.asInt(1), v.asInt(2)); // set graphics driver from config - Modules::config().setAndCallback("GraphicsDriver",CConfigCallback(this,&CObjectViewer::cfcbGraphicsDriver)); + NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("GraphicsDriver"); + // Choose driver opengl to work correctly under Linux example + _Direct3D = false; //_Driver = OpenGL; + +#ifdef NL_OS_WINDOWS + std::string driver = v2.asString(); + if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; + else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; + else nlwarning("Invalid driver specified, defaulting to OpenGL"); +#endif // create the driver nlassert(!_Driver); @@ -146,9 +156,6 @@ namespace NLQT //H_AUTO2 nldebug("CObjectViewer::release"); - Modules::config().dropCallback("BackgroundColor"); - Modules::config().dropCallback("GraphicsDriver"); - _Driver->delete3dMouseListener(_MouseListener); // delete all entities @@ -390,23 +397,4 @@ namespace NLQT _Entities.clear(); } - void CObjectViewer::cfcbBackgroundColor(NLMISC::CConfigFile::CVar &var) - { - // read variable from config file - _BackgroundColor = CRGBA(var.asInt(0), var.asInt(1), var.asInt(2)); - } - - void CObjectViewer::cfcbGraphicsDriver(NLMISC::CConfigFile::CVar &var) - { - // Choose driver opengl to work correctly under Linux example - _Direct3D = false; //_Driver = OpenGL; - -#ifdef NL_OS_WINDOWS - std::string driver = var.asString(); - if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; - else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; - else nlwarning("Invalid driver specified, defaulting to OpenGL"); -#endif - } - } /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.h index 2a49f4862..4927e166d 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/object_viewer.h @@ -161,10 +161,6 @@ namespace NLQT /// Delete all entities void deleteEntities(); - /// Load background color from config file, intended for CConfiguration. - void cfcbBackgroundColor(NLMISC::CConfigFile::CVar &var); - void cfcbGraphicsDriver(NLMISC::CConfigFile::CVar &var); - NLMISC::CRGBA _BackgroundColor; NL3D::UDriver *_Driver; diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp index 13a2f8a00..a21629203 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp @@ -39,12 +39,38 @@ namespace NLQT { ui.setupUi(this); - // setup config file callbacks and initialize values - Modules::config().setAndCallback("GraphicsDrivers", CConfigCallback(this, &CSettingsDialog::cfcbGraphicsDrivers)); - Modules::config().setAndCallback("SearchPaths", CConfigCallback(this, &CSettingsDialog::cfcbSearchPaths)); - Modules::config().setAndCallback("LeveldesignPath", CConfigCallback(this, &CSettingsDialog::cfcbLeveldesignPath)); + while (ui.driverGraphComboBox->count()) + ui.driverGraphComboBox->removeItem(0); - // load settings from the config file + // load types graphics driver from the config file + NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("GraphicsDrivers"); + for (uint i = 0; i < v.size(); ++i) + ui.driverGraphComboBox->addItem(v.asString(i).c_str()); + + // set graphics driver from the config file + QString value = Modules::config().getValue("GraphicsDriver",std::string("OpenGL")).c_str(); + QString dn = value.toLower(); + for (sint i = 0; i < ui.driverGraphComboBox->count(); ++i) + { + if (dn == ui.driverGraphComboBox->itemText(i).toLower()) + { + ui.driverGraphComboBox->setCurrentIndex(i); + } + } + + // load leveldesign path from the config file + NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("LeveldesignPath"); + ui.leveldesignPath->setText(v2.asString().c_str()); + + // load search paths from the config file + NLMISC::CConfigFile::CVar v3 = Modules::config().getConfigFile().getVar("SearchPaths"); + ui.pathsListWidget->clear(); + + for (uint i = 0; i < v3.size(); ++i) + { + ui.pathsListWidget->addItem(v3.asString(i).c_str()); + ui.pathsListWidget->item(i)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + } connect(ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); connect(ui.removeToolButton, SIGNAL(clicked()), this, SLOT(removePath())); @@ -62,9 +88,6 @@ namespace NLQT CSettingsDialog::~CSettingsDialog() { - Modules::config().dropCallback("GraphicsDrivers"); - Modules::config().dropCallback("SearchPaths"); - Modules::config().dropCallback("LeveldesignPath"); } void CSettingsDialog::addPath() @@ -126,17 +149,37 @@ namespace NLQT Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString(ui.driverGraphComboBox->currentText().toStdString()); // save leveldesign path to config file - std::string ldPath = ui.leveldesignPath->text().toStdString(); - Modules::config().getConfigFile().getVar("LeveldesignPath").forceAsString(ldPath); - Q_EMIT ldPathChanged(ldPath.c_str()); + QString oldLdPath = Modules::config().getValue("LeveldesignPath", std::string("")).c_str(); + if (oldLdPath != ui.leveldesignPath->text()) + { + std::string ldPath = ui.leveldesignPath->text().toStdString(); + Modules::config().getConfigFile().getVar("LeveldesignPath").forceAsString(ldPath); + Q_EMIT ldPathChanged(ldPath.c_str()); + // TODO: remove old Path from CPath + Modules::config().addLeveldesignPath(); + } // save search paths to config file + NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("SearchPaths"); + QStringList sl; + for (uint i = 0; i < v.size(); ++i) + { + sl.append(v.asString(i).c_str()); + } + std::vector list; + std::vector addList; for (sint i = 0; i < ui.pathsListWidget->count(); ++i) { std::string str = ui.pathsListWidget->item(i)->text().toStdString(); if (str != "") + { list.push_back(str); + if (!sl.contains(str.c_str())) + { + addList.push_back(str); + } + } } if (list.empty()) @@ -153,48 +196,7 @@ namespace NLQT Modules::config().getConfigFile().save(); // reload search paths - Modules::config().configSearchPaths(); - Modules::config().configLeveldesignPath(); - } - - void CSettingsDialog::cfcbGraphicsDrivers(NLMISC::CConfigFile::CVar &var) - { - while (ui.driverGraphComboBox->count()) - ui.driverGraphComboBox->removeItem(0); - - // load types graphics driver from the config file - for (uint i = 0; i < var.size(); ++i) - ui.driverGraphComboBox->addItem(var.asString(i).c_str()); - - // set graphics driver from the config file - QString value = Modules::config().getValue("GraphicsDriver",std::string("OpenGL")).c_str(); - QString dn = value.toLower(); - for (sint i = 0; i < ui.driverGraphComboBox->count(); ++i) - { - if (dn == ui.driverGraphComboBox->itemText(i).toLower()) - { - ui.driverGraphComboBox->setCurrentIndex(i); - return; - } - } - } - - void CSettingsDialog::cfcbSearchPaths(NLMISC::CConfigFile::CVar &var) - { - ui.pathsListWidget->clear(); - - // load search paths from the config file - for (uint i = 0; i < var.size(); ++i) - { - ui.pathsListWidget->addItem(var.asString(i).c_str()); - ui.pathsListWidget->item(i)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - } - } - - void CSettingsDialog::cfcbLeveldesignPath(NLMISC::CConfigFile::CVar &var) - { - // load leveldesign path from the config file - ui.leveldesignPath->setText(var.asString().c_str()); + Modules::config().addSearchPaths(&addList); } void CSettingsDialog::browseLeveldesignPath() diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h index c1ebebc72..f0fba77b2 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h @@ -52,10 +52,6 @@ namespace NLQT void browseLeveldesignPath(); private: - void cfcbGraphicsDrivers(NLMISC::CConfigFile::CVar &var); - void cfcbSoundDrivers(NLMISC::CConfigFile::CVar &var); - void cfcbSearchPaths(NLMISC::CConfigFile::CVar &var); - void cfcbLeveldesignPath(NLMISC::CConfigFile::CVar &var); Ui::CSettingsDialog ui;