From 99a3b93703f4c651605f5179d7f88ae61bb8a0c2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 14:44:16 +0200 Subject: [PATCH 01/18] Restored lost class names --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml | 1 + code/studio/src/plugins/gui_editor/widgets/CtrlColPick.xml | 1 + code/studio/src/plugins/gui_editor/widgets/CtrlScroll.xml | 1 + .../src/plugins/gui_editor/widgets/DBGroupSelectNumber.xml | 1 + code/studio/src/plugins/gui_editor/widgets/DBViewBar.xml | 1 + code/studio/src/plugins/gui_editor/widgets/DBViewBar3.xml | 1 + code/studio/src/plugins/gui_editor/widgets/DBViewDigit.xml | 1 + code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml | 1 + code/studio/src/plugins/gui_editor/widgets/DBViewQuantity.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupContainer.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupEditBox.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupHTML.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupHeader.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupList.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupMenu.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupModal.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupScrollText.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupTab.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupTable.xml | 1 + code/studio/src/plugins/gui_editor/widgets/GroupTree.xml | 1 + code/studio/src/plugins/gui_editor/widgets/InterfaceGroup.xml | 1 + .../src/plugins/gui_editor/widgets/InterfaceGroupWheel.xml | 1 + code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml | 1 + code/studio/src/plugins/gui_editor/widgets/ViewBitmapCombo.xml | 1 + code/studio/src/plugins/gui_editor/widgets/ViewText.xml | 1 + code/studio/src/plugins/gui_editor/widgets/ViewTextFormated.xml | 1 + code/studio/src/plugins/gui_editor/widgets/ViewTextID.xml | 1 + .../studio/src/plugins/gui_editor/widgets/ViewTextIDFormated.xml | 1 + 28 files changed, 28 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml index 12b82e7f6..c081f3dae 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml @@ -2,6 +2,7 @@
CtrlButton CCtrlButton + button CtrlBaseButton false diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlColPick.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlColPick.xml index ea2ba6171..7ab3e2f48 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlColPick.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlColPick.xml @@ -2,6 +2,7 @@
CtrlColPick CCtrlColPick + colpick CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlScroll.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlScroll.xml index 1ad970f31..9f5fcfc60 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlScroll.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlScroll.xml @@ -2,6 +2,7 @@
CtrlScroll CCtrlScroll + scroll CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBGroupSelectNumber.xml b/code/studio/src/plugins/gui_editor/widgets/DBGroupSelectNumber.xml index 624ded887..7d78fc6b9 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBGroupSelectNumber.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBGroupSelectNumber.xml @@ -2,6 +2,7 @@
DBGroupSelectNumber CDBGroupSelectNumber + select_number InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewBar.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewBar.xml index c7f644fa4..878f9b563 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewBar.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewBar.xml @@ -2,6 +2,7 @@
DBViewBar CDBViewBar + bar ViewBitmap false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewBar3.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewBar3.xml index 8295c5f30..db635eb27 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewBar3.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewBar3.xml @@ -2,6 +2,7 @@
DBViewBar3 CDBViewBar3 + bar3 ViewBitmap false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewDigit.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewDigit.xml index 0c12445f9..1a659fd91 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewDigit.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewDigit.xml @@ -2,6 +2,7 @@
DBViewDigit CDBViewDigit + digit CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml index c1861df61..36a7d23ce 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml @@ -2,6 +2,7 @@
DBViewNumber CDBViewNumber + text_number ViewText false diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewQuantity.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewQuantity.xml index c24379c96..c11c1a4cc 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewQuantity.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewQuantity.xml @@ -2,6 +2,7 @@
DBViewQuantity CDBViewQuantity + text_quantity ViewText false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupContainer.xml b/code/studio/src/plugins/gui_editor/widgets/GroupContainer.xml index 3d879a150..a3c9aade7 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupContainer.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupContainer.xml @@ -2,6 +2,7 @@
GroupContainer CGroupContainer + container InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupEditBox.xml b/code/studio/src/plugins/gui_editor/widgets/GroupEditBox.xml index 31ca205c7..578262a20 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupEditBox.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupEditBox.xml @@ -2,6 +2,7 @@
GroupEditBox CGroupEditBox + edit_box InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupHTML.xml b/code/studio/src/plugins/gui_editor/widgets/GroupHTML.xml index 5f0521be8..894580734 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupHTML.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupHTML.xml @@ -2,6 +2,7 @@
GroupHTML CGroupHTML + html GroupScrollText false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupHeader.xml b/code/studio/src/plugins/gui_editor/widgets/GroupHeader.xml index cc96fd742..91dd73e36 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupHeader.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupHeader.xml @@ -2,6 +2,7 @@
GroupHeader CGroupHeader + header GroupList false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupList.xml b/code/studio/src/plugins/gui_editor/widgets/GroupList.xml index 3ca2db95c..569aa8d9d 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupList.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupList.xml @@ -2,6 +2,7 @@
GroupList CGroupList + list InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupMenu.xml b/code/studio/src/plugins/gui_editor/widgets/GroupMenu.xml index cdd42ba95..3bd0c5506 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupMenu.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupMenu.xml @@ -2,6 +2,7 @@
GroupMenu CGroupMenu + menu GroupModal false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupModal.xml b/code/studio/src/plugins/gui_editor/widgets/GroupModal.xml index 034e3025e..33bd6fd08 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupModal.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupModal.xml @@ -2,6 +2,7 @@
GroupModal CGroupModal + modal GroupFrame false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupScrollText.xml b/code/studio/src/plugins/gui_editor/widgets/GroupScrollText.xml index 95719398d..53092a456 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupScrollText.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupScrollText.xml @@ -2,6 +2,7 @@
GroupScrollText CGroupScrollText + scroll_text InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupTab.xml b/code/studio/src/plugins/gui_editor/widgets/GroupTab.xml index df148a0a3..e2e1a8bf1 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupTab.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupTab.xml @@ -2,6 +2,7 @@
GroupTab CGroupTab + tab InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupTable.xml b/code/studio/src/plugins/gui_editor/widgets/GroupTable.xml index 9fa957741..dfbc4e2a8 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupTable.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupTable.xml @@ -2,6 +2,7 @@
GroupTable CGroupTable + table InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupTree.xml b/code/studio/src/plugins/gui_editor/widgets/GroupTree.xml index 73b1dea3b..b20c74733 100644 --- a/code/studio/src/plugins/gui_editor/widgets/GroupTree.xml +++ b/code/studio/src/plugins/gui_editor/widgets/GroupTree.xml @@ -2,6 +2,7 @@
GroupTree CGroupTree + tree InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/InterfaceGroup.xml b/code/studio/src/plugins/gui_editor/widgets/InterfaceGroup.xml index ddcdf01e6..50f7c3e83 100644 --- a/code/studio/src/plugins/gui_editor/widgets/InterfaceGroup.xml +++ b/code/studio/src/plugins/gui_editor/widgets/InterfaceGroup.xml @@ -2,6 +2,7 @@
InterfaceGroup CInterfaceGroup + interface_group CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/InterfaceGroupWheel.xml b/code/studio/src/plugins/gui_editor/widgets/InterfaceGroupWheel.xml index b095ecac5..6a35671cd 100644 --- a/code/studio/src/plugins/gui_editor/widgets/InterfaceGroupWheel.xml +++ b/code/studio/src/plugins/gui_editor/widgets/InterfaceGroupWheel.xml @@ -2,6 +2,7 @@
InterfaceGroupWheel CInterfaceGroupWheel + group_wheel InterfaceGroup false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml index 21ef7daff..7d78f6c40 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml @@ -2,6 +2,7 @@
ViewBitmap CViewBitmap + bitmap CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewBitmapCombo.xml b/code/studio/src/plugins/gui_editor/widgets/ViewBitmapCombo.xml index 8fc579675..461f69c55 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewBitmapCombo.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewBitmapCombo.xml @@ -2,6 +2,7 @@
ViewBitmapCombo CViewBitmapCombo + bitmap_combo CtrlBase false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewText.xml b/code/studio/src/plugins/gui_editor/widgets/ViewText.xml index 415c3167e..f515f7b3d 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewText.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewText.xml @@ -2,6 +2,7 @@
ViewText CViewText + text InterfaceElement false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewTextFormated.xml b/code/studio/src/plugins/gui_editor/widgets/ViewTextFormated.xml index cabd081f0..36aa68102 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewTextFormated.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewTextFormated.xml @@ -2,6 +2,7 @@
ViewTextFormated CViewTextFormated + text_formated ViewText false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewTextID.xml b/code/studio/src/plugins/gui_editor/widgets/ViewTextID.xml index 52e010ec6..43ac442c0 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewTextID.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewTextID.xml @@ -2,6 +2,7 @@
ViewTextID CViewTextID + text_id ViewText false diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewTextIDFormated.xml b/code/studio/src/plugins/gui_editor/widgets/ViewTextIDFormated.xml index af8dd54eb..32b08f156 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewTextIDFormated.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewTextIDFormated.xml @@ -2,6 +2,7 @@
ViewTextIDFormated CViewTextIDFormated + text_id_formated ViewTextID false From 7e16e95c3570dcfd28684703ff7a30a2d823560d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 16:26:38 +0200 Subject: [PATCH 02/18] CInterfaceParser in editor mode should look for files in the working directory first. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/interface_parser.h | 8 +++++++ code/nel/include/nel/gui/parser.h | 1 + code/nel/src/gui/interface_parser.cpp | 24 +++++++++++++++---- .../plugins/gui_editor/gui_editor_window.cpp | 2 ++ .../src/plugins/gui_editor/nelgui_ctrl.cpp | 6 +++++ .../src/plugins/gui_editor/nelgui_ctrl.h | 2 ++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 2bf1df9a8..c1b3fa109 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -353,7 +353,15 @@ namespace NLGUI std::map< std::string, std::string > pointerSettings; std::map< std::string, std::map< std::string, std::string > > keySettings; + std::string _WorkDir; + public: + /// Sets the working directory, where files should be looked for + void setWorkDir( const std::string &workdir ){ _WorkDir = workdir; } + + /// Looks up a file in either the working directory or using CPath::lookup + std::string lookup( const std::string &file ); + void initLUA(); void uninitLUA(); bool isLuaInitialized() const{ return luaInitialized; } diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index db868f70d..0378c22ec 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -88,6 +88,7 @@ namespace NLGUI virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0; virtual bool serializeKeySettings( xmlNodePtr parentNode ) const = 0; virtual CViewBase* createClass( const std::string &name ) = 0; + virtual void setWorkDir( const std::string &workdir ) = 0; }; } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index b26a403c4..f052224ff 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -233,6 +233,22 @@ namespace NLGUI destStream.seek(0, NLMISC::IStream::begin); } + std::string CInterfaceParser::lookup( const std::string &file ) + { + std::string filename; + + if( editorMode && !_WorkDir.empty() ) + { + std::string wdpath = CPath::standardizePath( _WorkDir ) + file; + if( CFile::fileExists( wdpath ) ) + filename = wdpath; + } + if( filename.empty() ) + filename = CPath::lookup( file ); + + return filename; + } + // ---------------------------------------------------------------------------- bool CInterfaceParser::parseInterface (const std::vector & strings, bool reload, bool isFilename, bool checkInData) { @@ -270,7 +286,7 @@ namespace NLGUI { //get the first file document pointer firstFileName = *it; - string filename = CPath::lookup(firstFileName); + string filename = lookup( firstFileName ); bool isInData = false; string::size_type pos = filename.find ("@"); if (pos != string::npos) @@ -283,7 +299,7 @@ namespace NLGUI isInData = true; } - if ((needCheck && !isInData) || !file.open (CPath::lookup(firstFileName))) + if ((needCheck && !isInData) || !file.open (lookup(firstFileName))) { // todo hulud interface syntax error nlwarning ("could not open file %s, skipping xml parsing",firstFileName.c_str()); @@ -331,7 +347,7 @@ namespace NLGUI { saveParseResult = true; std::string archive = CPath::lookup(nextFileName + "_compressed", false, false); - std::string current = CPath::lookup(nextFileName, false, false); + std::string current = lookup(nextFileName); if (!archive.empty() && !current.empty()) { if (CFile::getFileModificationDate(current) <= CFile::getFileModificationDate(archive)) @@ -351,7 +367,7 @@ namespace NLGUI { if (isFilename) { - if (!file.open(CPath::lookup(nextFileName, false, false))) + if (!file.open(lookup(nextFileName))) { // todo hulud interface syntax error nlwarning ("could not open file %s, skipping xml parsing",nextFileName.c_str()); diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index ca5e240e7..5b3d835a2 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -181,6 +181,8 @@ namespace GUIEditor currentProject = projectFiles.projectName.c_str(); currentProjectFile = fileName; projectWindow->setupFiles( projectFiles ); + GUICtrl->setWorkDir( _lastDir ); + if( GUICtrl->parse( projectFiles ) ) { hierarchyView->buildHierarchy( projectFiles.masterGroup ); diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp index 03f784944..8f0f56711 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp @@ -187,6 +187,12 @@ namespace GUIEditor } } + void NelGUICtrl::setWorkDir( const QString &dir ) + { + IParser *parser = CWidgetManager::getInstance()->getParser(); + parser->setWorkDir( std::string( dir.toUtf8().constData() ) ); + } + QWidget* NelGUICtrl::getViewPort() { return w; diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h index b3c68ff32..63118d947 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h @@ -52,6 +52,8 @@ namespace GUIEditor void show(); void hide(); + void setWorkDir( const QString &dir ); + Q_SIGNALS: void guiLoadComplete(); From 816e89c967874194b5f6c705a521af8024aa5403 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 16:40:41 +0200 Subject: [PATCH 03/18] Another classname. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml index ca66dbd62..6ad8334c5 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml @@ -2,6 +2,7 @@
CtrlTextButton CCtrlTextButton + text_button CtrlBaseButton false From 5217b38f58fd9e6e6b45ceb90386852bd430d400 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 16:47:39 +0200 Subject: [PATCH 04/18] Some defaults. --HG-- branch : dfighter-tools --- .../src/plugins/gui_editor/widgets/CtrlTextButton.xml | 10 +++++----- .../studio/src/plugins/gui_editor/widgets/ViewText.xml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml index 6ad8334c5..6afd06cdf 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlTextButton.xml @@ -12,22 +12,22 @@ tx_normal string - + but tx_pushed string - + but tx_over string - + but_over hardtext string - + push me wmargin @@ -157,7 +157,7 @@ line_maxw int - 0 + 100 multi_line_space diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewText.xml b/code/studio/src/plugins/gui_editor/widgets/ViewText.xml index f515f7b3d..4862517aa 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewText.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewText.xml @@ -47,7 +47,7 @@ line_maxw int - 0 + 100 multi_line_space @@ -102,7 +102,7 @@ hardtext string - + Some text hardtext_format From 03c041310ec73d37e3ac285dbf57189139ac039e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 18:56:24 +0200 Subject: [PATCH 05/18] Added dialog for the new GUI action. --HG-- branch : dfighter-tools --- .../src/plugins/gui_editor/CMakeLists.txt | 2 + .../plugins/gui_editor/gui_editor_window.cpp | 14 +++- .../src/plugins/gui_editor/new_gui_dlg.cpp | 72 ++++++++++++++++ .../src/plugins/gui_editor/new_gui_dlg.h | 44 ++++++++++ .../src/plugins/gui_editor/new_gui_dlg.ui | 84 +++++++++++++++++++ 5 files changed, 213 insertions(+), 3 deletions(-) create mode 100644 code/studio/src/plugins/gui_editor/new_gui_dlg.cpp create mode 100644 code/studio/src/plugins/gui_editor/new_gui_dlg.h create mode 100644 code/studio/src/plugins/gui_editor/new_gui_dlg.ui diff --git a/code/studio/src/plugins/gui_editor/CMakeLists.txt b/code/studio/src/plugins/gui_editor/CMakeLists.txt index 2b46e2cdc..e1e8b38be 100644 --- a/code/studio/src/plugins/gui_editor/CMakeLists.txt +++ b/code/studio/src/plugins/gui_editor/CMakeLists.txt @@ -36,6 +36,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR texture_property_manager.h expression_editor.h expr_link_dlg.h + new_gui_dlg.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -55,6 +56,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS texture_chooser.ui expression_editor.ui expr_link_dlg.ui + new_gui_dlg.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index 5b3d835a2..1f3c372c0 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -44,6 +44,7 @@ #include "editor_selection_watcher.h" #include "editor_message_processor.h" #include "add_widget_widget.h" +#include "new_gui_dlg.h" namespace GUIEditor { @@ -199,6 +200,13 @@ namespace GUIEditor void GUIEditorWindow::newDocument() { + NewGUIDlg d; + int result = d.exec(); + + if( result == QDialog::Rejected ) + return; + + close(); } void GUIEditorWindow::save() @@ -358,14 +366,14 @@ namespace GUIEditor void GUIEditorWindow::createMenus() { Core::MenuManager *mm = Core::ICore::instance()->menuManager(); - //QAction *newAction = mm->action( Core::Constants::NEW ); + QAction *newAction = mm->action( Core::Constants::NEW ); QAction *saveAction = mm->action( Core::Constants::SAVE ); QAction *saveAsAction = mm->action( Core::Constants::SAVE_AS ); QAction *closeAction = mm->action( Core::Constants::CLOSE ); QAction *delAction = mm->action( Core::Constants::DEL ); - //if( newAction != NULL ) - // newAction->setEnabled( true ); + if( newAction != NULL ) + newAction->setEnabled( true ); if( saveAction != NULL ) saveAction->setEnabled( true ); if( saveAsAction != NULL ) diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp new file mode 100644 index 000000000..8dc7abb1e --- /dev/null +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp @@ -0,0 +1,72 @@ +// Ryzom Core Studio - GUI Editor Plugin +// +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "new_gui_dlg.h" +#include + +NewGUIDlg::NewGUIDlg( QWidget *parent ) : +QDialog( parent ) +{ + m_ui.setupUi( this ); + + connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); + connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + +} + +NewGUIDlg::~NewGUIDlg() +{ +} + +QString NewGUIDlg::getProjectName() const +{ + return m_ui.projectEdit->text(); +} + +QString NewGUIDlg::getWindowName() const +{ + return m_ui.windowEdit->text(); +} + +void NewGUIDlg::onOKClicked() +{ + if( m_ui.projectEdit->text().isEmpty() ) + { + QMessageBox::information( this, + tr( "New project" ), + tr( "You must specify a project name!" ) ); + return; + } + + if( m_ui.windowEdit->text().isEmpty() ) + { + QMessageBox::information( this, + tr( "New project" ), + tr( "You must specify a window name!" ) ); + return; + } + + accept(); +} + +void NewGUIDlg::onCancelClicked() +{ + reject(); +} + + diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.h b/code/studio/src/plugins/gui_editor/new_gui_dlg.h new file mode 100644 index 000000000..3e290545c --- /dev/null +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.h @@ -0,0 +1,44 @@ +// Ryzom Core Studio - GUI Editor Plugin +// +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NEW_GUI_DLG_H +#define NEW_GUI_DLG_H + +#include "ui_new_gui_dlg.h" + +class NewGUIDlg : public QDialog +{ + Q_OBJECT + +public: + NewGUIDlg( QWidget *parent = NULL ); + ~NewGUIDlg(); + + QString getProjectName() const; + QString getWindowName() const; + +private Q_SLOTS: + void onOKClicked(); + void onCancelClicked(); + +private: + Ui::NewGUIDialog m_ui; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.ui b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui new file mode 100644 index 000000000..a144c58e8 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui @@ -0,0 +1,84 @@ + + + NewGUIDialog + + + + 0 + 0 + 292 + 95 + + + + New GUI + + + + + + Project name + + + + + + + + + + Window name + + + + + + + + + + Qt::Horizontal + + + + 107 + 20 + + + + + + + + + + + 0 + 0 + + + + OK + + + + + + + + 0 + 0 + + + + Cancel + + + + + + + + + + From e5d2e9293d1c2fe1e8fb1c4a447572257ce7b7a0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 19:30:30 +0200 Subject: [PATCH 06/18] Moved CRootGroup out of CInterfaceParser. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/root_group.h | 46 +++++++++++++ code/nel/src/gui/interface_parser.cpp | 81 +---------------------- code/nel/src/gui/root_group.cpp | 94 +++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 80 deletions(-) create mode 100644 code/nel/include/nel/gui/root_group.h create mode 100644 code/nel/src/gui/root_group.cpp diff --git a/code/nel/include/nel/gui/root_group.h b/code/nel/include/nel/gui/root_group.h new file mode 100644 index 000000000..58963a3b2 --- /dev/null +++ b/code/nel/include/nel/gui/root_group.h @@ -0,0 +1,46 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef ROOT_GROUP_H +#define ROOT_GROUP_H + +#include +#include + +#include "nel/gui/interface_group.h" + +namespace NLGUI +{ + + class CRootGroup : public CInterfaceGroup + { + public: + CRootGroup(const TCtorParam ¶m); + virtual ~CRootGroup(); + + virtual CInterfaceElement* getElement (const std::string &id); + virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1); + virtual bool delGroup (CInterfaceGroup *child, bool dontDelete = false); + + private: + std::map< std::string, CInterfaceGroup* > _Accel; + }; + +} + +#endif + diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index f052224ff..7bf44c6f6 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -37,6 +37,7 @@ #include "nel/gui/lua_helper.h" #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_manager.h" +#include "nel/gui/root_group.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -113,86 +114,6 @@ namespace NLGUI return node; } - - - // ---------------------------------------------------------------------------- - // CRootGroup - // ---------------------------------------------------------------------------- - - class CRootGroup : public CInterfaceGroup - { - public: - CRootGroup(const TCtorParam ¶m) - : CInterfaceGroup(param) - { } - - /// Destructor - virtual ~CRootGroup() { } - - virtual CInterfaceElement* getElement (const std::string &id) - { - if (_Id == id) - return this; - - if (id.substr(0, _Id.size()) != _Id) - return NULL; - - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - if (pVB->getId() == id) - return pVB; - } - - vector::const_iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase* ctrl = *itc; - if (ctrl->getId() == id) - return ctrl; - } - - // Accelerate - string sTmp = id; - sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); - string::size_type pos = sTmp.find(':'); - if (pos != string::npos) - sTmp = sTmp.substr(0,pos); - - map::iterator it = _Accel.find(sTmp); - if (it != _Accel.end()) - { - CInterfaceGroup *pIG = it->second; - return pIG->getElement(id); - } - return NULL; - } - - virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1) - { - string sTmp = child->getId(); - sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); - _Accel.insert(pair(sTmp, child)); - CInterfaceGroup::addGroup(child,eltOrder); - } - - virtual bool delGroup (CInterfaceGroup *child, bool dontDelete = false) - { - string sTmp = child->getId(); - sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); - map::iterator it = _Accel.find(sTmp); - if (it != _Accel.end()) - { - _Accel.erase(it); - } - return CInterfaceGroup::delGroup(child,dontDelete); - } - - private: - map _Accel; - }; - // ---------------------------------------------------------------------------- // CInterfaceParser // ---------------------------------------------------------------------------- diff --git a/code/nel/src/gui/root_group.cpp b/code/nel/src/gui/root_group.cpp new file mode 100644 index 000000000..bffdd5579 --- /dev/null +++ b/code/nel/src/gui/root_group.cpp @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "nel/gui/root_group.h" +#include + +namespace NLGUI +{ + + CRootGroup::CRootGroup(const TCtorParam ¶m) : + CInterfaceGroup(param) + { + } + + CRootGroup::~CRootGroup() + { + } + + CInterfaceElement* CRootGroup::getElement (const std::string &id) + { + if (_Id == id) + return this; + + if (id.substr(0, _Id.size()) != _Id) + return NULL; + + std::vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + if (pVB->getId() == id) + return pVB; + } + + std::vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase* ctrl = *itc; + if (ctrl->getId() == id) + return ctrl; + } + + // Accelerate + std::string sTmp = id; + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + std::string::size_type pos = sTmp.find(':'); + if (pos != std::string::npos) + sTmp = sTmp.substr(0,pos); + + std::map::iterator it = _Accel.find(sTmp); + if (it != _Accel.end()) + { + CInterfaceGroup *pIG = it->second; + return pIG->getElement(id); + } + return NULL; + } + + void CRootGroup::addGroup (CInterfaceGroup *child, sint eltOrder) + { + std::string sTmp = child->getId(); + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + _Accel.insert(std::pair(sTmp, child)); + CInterfaceGroup::addGroup(child,eltOrder); + } + + bool CRootGroup::delGroup (CInterfaceGroup *child, bool dontDelete) + { + std::string sTmp = child->getId(); + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + std::map::iterator it = _Accel.find(sTmp); + if (it != _Accel.end()) + { + _Accel.erase(it); + } + return CInterfaceGroup::delGroup(child,dontDelete); + } + +} + From ded18b266c1e4fe5579933c3b177880bc50e4934 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Oct 2014 21:43:28 +0200 Subject: [PATCH 07/18] Implemented new action. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/widget_manager.h | 2 + code/nel/src/gui/widget_manager.cpp | 45 +++++++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 40 ++++++++++++----- .../plugins/gui_editor/gui_editor_window.h | 1 + .../src/plugins/gui_editor/nelgui_ctrl.cpp | 35 +++++++++++++-- .../src/plugins/gui_editor/nelgui_ctrl.h | 3 ++ 6 files changed, 112 insertions(+), 14 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index d722a9165..6d2336047 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -528,6 +528,8 @@ namespace NLGUI bool groupSelection(); bool unGroupSelection(); void setMultiSelection( bool b ){ multiSelection = b; } + + bool createNewGUI( const std::string &project, const std::string &window ); private: CWidgetManager(); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index c68a2c963..803889a79 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -35,6 +35,7 @@ #include "nel/gui/reflect_register.h" #include "nel/gui/editor_selection_watcher.h" #include "nel/misc/events.h" +#include "nel/gui/root_group.h" namespace NLGUI { @@ -1041,6 +1042,8 @@ namespace NLGUI resetGlobalAlphasProps(); activeAnims.clear(); + + editorSelection.clear(); } @@ -3604,6 +3607,48 @@ namespace NLGUI } + bool CWidgetManager::createNewGUI( const std::string &project, const std::string &window ) + { + reset(); + + for( int i = 0; i < _MasterGroups.size(); i++ ) + delete _MasterGroups[i].Group; + _MasterGroups.clear(); + + // First create the master group + CRootGroup *root = new CRootGroup( CViewBase::TCtorParam() ); + + SMasterGroup mg; + mg.Group = root; + + root->setIdRecurse( project ); + root->setW( 1024 ); + root->setH( 768 ); + root->setActive( true ); + + // Create the first / main window + CInterfaceGroup *wnd = new CInterfaceGroup( CViewBase::TCtorParam() ); + wnd->setW( 1024 ); + wnd->setH( 768 ); + wnd->setParent( root ); + wnd->setParentPos( root ); + wnd->setParentSize( root ); + wnd->setPosRef( Hotspot_MM ); + wnd->setParentPosRef( Hotspot_MM ); + wnd->setIdRecurse( window ); + wnd->setActive( true ); + + // Add the window + root->addElement( wnd ); + mg.addWindow( wnd, wnd->getPriority() ); + _MasterGroups.push_back( mg ); + + _Pointer = new CViewPointer( CViewBase::TCtorParam() ); + + return true; + } + + CWidgetManager::CWidgetManager() { LinkHack(); diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index 1f3c372c0..aedeea5d6 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -207,6 +207,21 @@ namespace GUIEditor return; close(); + + std::string proj = d.getProjectName().toUtf8().constData(); + std::string wnd = d.getWindowName().toUtf8().constData(); + + bool b = GUICtrl->createNewGUI( proj, wnd ); + if( !b ) + { + QMessageBox::information( this, + tr( "Creating new GUI project" ), + tr( "Failed to create new GUI project :(" ) ); + reset(); + } + + std::string mg = std::string( "ui:" ) + proj; + hierarchyView->buildHierarchy( mg ); } void GUIEditorWindow::save() @@ -279,6 +294,20 @@ namespace GUIEditor } + void GUIEditorWindow::reset() + { + projectFiles.clearAll(); + projectWindow->clear(); + hierarchyView->clearHierarchy(); + GUICtrl->reset(); + browserCtrl.clear(); + linkList->clear(); + procList->clear(); + currentProject = ""; + currentProjectFile = ""; + projectParser.clear(); + } + bool GUIEditorWindow::close() { if( currentProject.isEmpty() ) @@ -296,16 +325,7 @@ namespace GUIEditor disconnect( w, SIGNAL( sgnSelectionChanged() ), hierarchyView, SLOT( onSelectionChanged() ) ); disconnect( w, SIGNAL( sgnSelectionChanged() ), &browserCtrl, SLOT( onSelectionChanged() ) ); - projectFiles.clearAll(); - projectWindow->clear(); - hierarchyView->clearHierarchy(); - GUICtrl->reset(); - browserCtrl.clear(); - linkList->clear(); - procList->clear(); - currentProject = ""; - currentProjectFile = ""; - projectParser.clear(); + reset(); return true; } diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.h b/code/studio/src/plugins/gui_editor/gui_editor_window.h index cc2dfbc65..4a0a919a4 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -70,6 +70,7 @@ protected: void showEvent( QShowEvent *evnt ); private: + void reset(); void createMenus(); void removeMenus(); diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp index 8f0f56711..c1e7af3df 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp @@ -114,11 +114,29 @@ namespace GUIEditor if( e != NULL ) e->setActive( true ); - timerID = startTimer( 200 ); - guiLoaded = true; - Q_EMIT guiLoadComplete(); + onGUILoaded(); - CWidgetManager::getInstance()->registerSelectionWatcher( watcher ); + return true; + } + + bool NelGUICtrl::createNewGUI( const std::string &project, const std::string &window ) + { + reset(); + bool ok = CWidgetManager::getInstance()->createNewGUI( project, window ); + if( !ok ) + return false; + + std::string mg = std::string( "ui:" ) + project; + std::string ag = mg + ":" + window; + + CWidgetManager::getInstance()->updateAllLocalisedElements(); + CWidgetManager::getInstance()->activateMasterGroup( mg, true ); + + CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( ag ); + if( e != NULL ) + e->setActive( true ); + + onGUILoaded(); return true; } @@ -160,6 +178,15 @@ namespace GUIEditor } } + void NelGUICtrl::onGUILoaded() + { + timerID = startTimer( 200 ); + guiLoaded = true; + Q_EMIT guiLoadComplete(); + + CWidgetManager::getInstance()->registerSelectionWatcher( watcher ); + } + void NelGUICtrl::show() { if( timerID == 0 ) diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h index 63118d947..d7d157ccf 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h @@ -43,6 +43,7 @@ namespace GUIEditor void init(); bool parse( SProjectFiles &files ); + bool createNewGUI( const std::string &project, const std::string &window ); void draw(); void reset(); CEditorSelectionWatcher* getWatcher(){ return watcher; } @@ -61,6 +62,8 @@ Q_SIGNALS: void timerEvent( QTimerEvent *evnt ); private: + void onGUILoaded(); + int timerID; bool guiLoaded; CEditorSelectionWatcher *watcher; From 2c5617cea7205510364137900ac649573ab4a957 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Oct 2014 20:09:42 +0200 Subject: [PATCH 08/18] When creating a new project, save it right away. --HG-- branch : dfighter-tools --- .../plugins/gui_editor/gui_editor_window.cpp | 38 ++++++++++++++++++- .../src/plugins/gui_editor/new_gui_dlg.cpp | 26 +++++++++++++ .../src/plugins/gui_editor/new_gui_dlg.h | 2 + .../src/plugins/gui_editor/new_gui_dlg.ui | 23 +++++++++-- .../gui_editor/project_file_parser.cpp | 5 ++- 5 files changed, 89 insertions(+), 5 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index aedeea5d6..70f206b3b 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -210,6 +210,9 @@ namespace GUIEditor std::string proj = d.getProjectName().toUtf8().constData(); std::string wnd = d.getWindowName().toUtf8().constData(); + std::string mg = std::string( "ui:" ) + proj; + std::string dir = d.getProjectDirectory().toUtf8().constData(); + std::string uiFile = "ui_" + proj + ".xml"; bool b = GUICtrl->createNewGUI( proj, wnd ); if( !b ) @@ -220,8 +223,41 @@ namespace GUIEditor reset(); } - std::string mg = std::string( "ui:" ) + proj; hierarchyView->buildHierarchy( mg ); + + projectFiles.projectName = proj; + projectFiles.masterGroup = mg; + projectFiles.activeGroup = std::string( "ui:" ) + proj + ":" + wnd; + projectFiles.version = NEW; + projectFiles.guiFiles.push_back( uiFile ); + projectWindow->setupFiles( projectFiles ); + + currentProject = proj.c_str(); + currentProjectFile = std::string( dir + "/" + proj + ".xml" ).c_str(); + + + // Save the project file + CProjectFileSerializer serializer; + serializer.setFile( currentProjectFile.toUtf8().constData() ); + if( !serializer.serialize( projectFiles ) ) + { + QMessageBox::critical( this, + tr( "Failed to save project" ), + tr( "There was an error while trying to save the project." ) ); + return; + } + + // Save the GUI file + WidgetSerializer widgetSerializer; + widgetSerializer.setFile( dir + "/" + uiFile ); + widgetSerializer.setActiveGroup( projectFiles.activeGroup ); + if( !widgetSerializer.serialize( projectFiles.masterGroup ) ) + { + QMessageBox::critical( this, + tr( "Failed to save project" ), + tr( "There was an error while trying to save the project." ) ); + return; + } } void GUIEditorWindow::save() diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp index 8dc7abb1e..88d4a19fd 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp @@ -18,6 +18,7 @@ #include "new_gui_dlg.h" #include +#include NewGUIDlg::NewGUIDlg( QWidget *parent ) : QDialog( parent ) @@ -26,6 +27,7 @@ QDialog( parent ) connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + connect( m_ui.projectDirTB, SIGNAL( clicked( bool ) ), this, SLOT( onProjectDirTBClicked() ) ); } @@ -43,6 +45,11 @@ QString NewGUIDlg::getWindowName() const return m_ui.windowEdit->text(); } +QString NewGUIDlg::getProjectDirectory() const +{ + return m_ui.projectDirEdit->text(); +} + void NewGUIDlg::onOKClicked() { if( m_ui.projectEdit->text().isEmpty() ) @@ -61,6 +68,14 @@ void NewGUIDlg::onOKClicked() return; } + if( m_ui.projectDirEdit->text().isEmpty() ) + { + QMessageBox::information( this, + tr( "New project" ), + tr( "You must specify a project directory!" ) ); + return; + } + accept(); } @@ -69,4 +84,15 @@ void NewGUIDlg::onCancelClicked() reject(); } +void NewGUIDlg::onProjectDirTBClicked() +{ + QString dir = QFileDialog::getExistingDirectory( this, + tr( "Specify project directory" ), + "." ); + if( dir.isEmpty() ) + return; + + m_ui.projectDirEdit->setText( dir ); +} + diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.h b/code/studio/src/plugins/gui_editor/new_gui_dlg.h index 3e290545c..f4bf474f7 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.h +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.h @@ -31,10 +31,12 @@ public: QString getProjectName() const; QString getWindowName() const; + QString getProjectDirectory() const; private Q_SLOTS: void onOKClicked(); void onCancelClicked(); + void onProjectDirTBClicked(); private: Ui::NewGUIDialog m_ui; diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.ui b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui index a144c58e8..7dca6d2a3 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.ui +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui @@ -6,8 +6,8 @@ 0 0 - 292 - 95 + 332 + 125 @@ -35,6 +35,23 @@ + + + Project directory + + + + + + + + + + ... + + + + Qt::Horizontal @@ -47,7 +64,7 @@ - + diff --git a/code/studio/src/plugins/gui_editor/project_file_parser.cpp b/code/studio/src/plugins/gui_editor/project_file_parser.cpp index 7213b332a..a5646c963 100644 --- a/code/studio/src/plugins/gui_editor/project_file_parser.cpp +++ b/code/studio/src/plugins/gui_editor/project_file_parser.cpp @@ -16,6 +16,7 @@ #include "project_file_parser.h" +#include "nel/misc/debug.h" namespace GUIEditor { @@ -208,7 +209,9 @@ namespace GUIEditor reader.readNext(); } if( files.mapFiles.empty() ) - return false; + { + nlinfo( "No map file(s) specified in project file." ); + } return true; } From b587acb135fd2b9e671bddcd3abc6f22f14dac35 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Oct 2014 21:15:13 +0200 Subject: [PATCH 09/18] Some refactoring regarding saving. --HG-- branch : dfighter-tools --- .../plugins/gui_editor/gui_editor_window.cpp | 60 +++++++++---------- .../gui_editor/project_file_parser.cpp | 4 +- .../gui_editor/project_file_serializer.cpp | 2 +- .../src/plugins/gui_editor/project_files.h | 15 ++--- 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index 70f206b3b..aad19c2ac 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -212,6 +212,7 @@ namespace GUIEditor std::string wnd = d.getWindowName().toUtf8().constData(); std::string mg = std::string( "ui:" ) + proj; std::string dir = d.getProjectDirectory().toUtf8().constData(); + _lastDir = dir.c_str(); std::string uiFile = "ui_" + proj + ".xml"; bool b = GUICtrl->createNewGUI( proj, wnd ); @@ -228,7 +229,7 @@ namespace GUIEditor projectFiles.projectName = proj; projectFiles.masterGroup = mg; projectFiles.activeGroup = std::string( "ui:" ) + proj + ":" + wnd; - projectFiles.version = NEW; + projectFiles.version = SProjectFiles::NEW; projectFiles.guiFiles.push_back( uiFile ); projectWindow->setupFiles( projectFiles ); @@ -278,8 +279,23 @@ namespace GUIEditor // Can't save old projects any further, since the widgets are in multiple files in them // using templates, styles and whatnot. There's no way to restore the original XML structure // after it's loaded - if( projectParser.getProjectVersion() == OLD ) + if( projectFiles.version == SProjectFiles::OLD ) return; + + std::string f = _lastDir.toUtf8().constData(); + f += "/"; + f += projectFiles.guiFiles[ 0 ]; + + WidgetSerializer widgetSerializer; + widgetSerializer.setFile( f ); + widgetSerializer.setActiveGroup( projectFiles.activeGroup ); + if( !widgetSerializer.serialize( projectFiles.masterGroup ) ) + { + QMessageBox::critical( this, + tr( "Failed to save project" ), + tr( "There was an error while trying to save the project." ) ); + return; + } } void GUIEditorWindow::saveAs() @@ -292,42 +308,22 @@ namespace GUIEditor if( dir.isEmpty() ) return; + _lastDir = dir; - projectFiles.guiFiles.clear(); - projectFiles.guiFiles.push_back( "ui_" + projectFiles.projectName + ".xml" ); - projectFiles.version = NEW; - - QString newFile = - dir + "/" + projectFiles.projectName.c_str() + ".xml"; - - CProjectFileSerializer serializer; - serializer.setFile( newFile.toUtf8().constData() ); - if( !serializer.serialize( projectFiles ) ) + if( projectFiles.version == SProjectFiles::OLD ) { - QMessageBox::critical( this, - tr( "Failed to save project" ), - tr( "There was an error while trying to save the project." ) ); - return; - } - - std::string guiFile = - std::string( dir.toUtf8().constData() ) + "/" + "ui_" + projectFiles.projectName + ".xml"; + projectFiles.guiFiles.clear(); + projectFiles.guiFiles.push_back( "ui_" + projectFiles.projectName + ".xml" ); + projectFiles.version = SProjectFiles::NEW; - WidgetSerializer widgetSerializer; - widgetSerializer.setFile( guiFile ); - widgetSerializer.setActiveGroup( projectFiles.activeGroup ); - if( !widgetSerializer.serialize( projectFiles.masterGroup ) ) - { - QMessageBox::critical( this, - tr( "Failed to save project" ), - tr( "There was an error while trying to save the project." ) ); - return; } - QMessageBox::information( this, - tr( "Save successful" ), - tr( "Project saved successfully!" ) ); + currentProjectFile = _lastDir; + currentProjectFile += "/"; + currentProjectFile += projectFiles.projectName.c_str(); + currentProjectFile += ".xml"; + save(); } void GUIEditorWindow::reset() diff --git a/code/studio/src/plugins/gui_editor/project_file_parser.cpp b/code/studio/src/plugins/gui_editor/project_file_parser.cpp index a5646c963..a10f5d783 100644 --- a/code/studio/src/plugins/gui_editor/project_file_parser.cpp +++ b/code/studio/src/plugins/gui_editor/project_file_parser.cpp @@ -63,7 +63,7 @@ namespace GUIEditor unsigned long CProjectFileParser::getProjectVersion() const { if( !loaded ) - return OLD; + return SProjectFiles::OLD; return files.version; } @@ -71,7 +71,7 @@ namespace GUIEditor void CProjectFileParser::clear() { files.projectName = ""; - files.version = OLD; + files.version = SProjectFiles::OLD; files.activeGroup = ""; files.guiFiles.clear(); files.mapFiles.clear(); diff --git a/code/studio/src/plugins/gui_editor/project_file_serializer.cpp b/code/studio/src/plugins/gui_editor/project_file_serializer.cpp index 4eb442d3f..0b34f511b 100644 --- a/code/studio/src/plugins/gui_editor/project_file_serializer.cpp +++ b/code/studio/src/plugins/gui_editor/project_file_serializer.cpp @@ -25,7 +25,7 @@ namespace GUIEditor if( fileName.empty() ) return false; - if( project.version >= MAX_PROJECTFILE_VERSION ) + if( project.version >= SProjectFiles::MAX_PROJECTFILE_VERSION ) return false; out.open( fileName.c_str() ); diff --git a/code/studio/src/plugins/gui_editor/project_files.h b/code/studio/src/plugins/gui_editor/project_files.h index 4ae58493b..786bd22e4 100644 --- a/code/studio/src/plugins/gui_editor/project_files.h +++ b/code/studio/src/plugins/gui_editor/project_files.h @@ -23,16 +23,17 @@ namespace GUIEditor { - enum ProjectVersion - { - OLD = 0, - NEW = 1, - MAX_PROJECTFILE_VERSION - }; - struct SProjectFiles { public: + + enum ProjectVersion + { + OLD = 0, + NEW = 1, + MAX_PROJECTFILE_VERSION + }; + std::string projectName; unsigned long version; std::string masterGroup; From b3dd26e01cb968e0aee8eece958a77c3c82147e2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Oct 2014 23:05:22 +0200 Subject: [PATCH 10/18] Parent positions should now be saved right again. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/interface_element.h | 1 + code/nel/src/gui/interface_element.cpp | 36 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 0be4c02e3..a8a04b454 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -492,6 +492,7 @@ namespace NLGUI bool isEditorSelected() const{ return editorSelected; } void setPosParent( const std::string &id ); + void getPosParent( std::string &id ) const; void setSizeParent( const std::string &id ); void setSerializable( bool b ){ serializable = b; } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index c9b480516..e3928e85f 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -294,8 +294,10 @@ namespace NLGUI xmlNewProp( node, BAD_CAST "w", BAD_CAST toString( _W ).c_str() ); xmlNewProp( node, BAD_CAST "h", BAD_CAST toString( _H ).c_str() ); xmlNewProp( node, BAD_CAST "posref", BAD_CAST HotSpotCoupleToString( _ParentPosRef, _PosRef ).c_str() ); - xmlNewProp( node, BAD_CAST "posparent", - BAD_CAST CWidgetManager::getInstance()->getParser()->getParentPosAssociation( (CInterfaceElement*)this ).c_str() ); + + std::string pp; + getPosParent( pp ); + xmlNewProp( node, BAD_CAST "posparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "sizeref", BAD_CAST getSizeRefAsString().c_str() ); xmlNewProp( node, BAD_CAST "sizeparent", BAD_CAST CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ).c_str() ); @@ -1541,6 +1543,36 @@ namespace NLGUI } } + void CInterfaceElement::getPosParent( std::string &id ) const + { + + // If there's no pos parent set, then the parent group is the pos parent + if( getParentPos() == NULL ) + { + id = "parent"; + return; + } + + // If pos parent and parent are the same then ofc the parent group is the pos parent... + CInterfaceElement *p = getParent(); + if( getParentPos() == p ) + { + id = "parent"; + return; + } + + // If parent is in the same group, use the short id + p = getParentPos(); + if( p->isInGroup( getParent() ) ) + { + id = p->getShortId(); + return; + } + + // Otherwise use the full id + id = p->getId(); + } + void CInterfaceElement::setSizeParent( const std::string &id ) { std::string Id = stripId( id ); From 487c6a344019236b6decaeb3ec5acc2a60fef022 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Oct 2014 23:07:08 +0200 Subject: [PATCH 11/18] GUI Editor should show the right parent position. --HG-- branch : dfighter-tools --- code/nel/src/gui/interface_element.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index e3928e85f..0e7458f3a 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -147,7 +147,9 @@ namespace NLGUI } if( name == "posparent" ) { - return CWidgetManager::getInstance()->getParser()->getParentPosAssociation( (CInterfaceElement*)this ); + std::string pp; + getPosParent( pp ); + return pp; } else if( name == "sizeparent" ) From 2dd62787719d810f4f47963a0e7a9312fc7e7f55 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 15:26:47 +0200 Subject: [PATCH 12/18] Size parent is now queried directly from the widget. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/interface_element.h | 1 + code/nel/src/gui/interface_element.cpp | 37 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index a8a04b454..0f9b271ce 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -494,6 +494,7 @@ namespace NLGUI void setPosParent( const std::string &id ); void getPosParent( std::string &id ) const; void setSizeParent( const std::string &id ); + void getSizeParent( std::string &id ) const; void setSerializable( bool b ){ serializable = b; } bool IsSerializable() const{ return serializable; } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 0e7458f3a..a18b8e71d 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -154,7 +154,9 @@ namespace NLGUI else if( name == "sizeparent" ) { - return CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ); + std::string sp; + getSizeParent( sp ); + return sp; } else if( name == "global_color" ) @@ -301,8 +303,8 @@ namespace NLGUI getPosParent( pp ); xmlNewProp( node, BAD_CAST "posparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "sizeref", BAD_CAST getSizeRefAsString().c_str() ); - xmlNewProp( node, BAD_CAST "sizeparent", - BAD_CAST CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ).c_str() ); + getSizeParent( pp ); + xmlNewProp( node, BAD_CAST "sizeparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); xmlNewProp( node, BAD_CAST "render_layer", BAD_CAST toString( _RenderLayer ).c_str() ); @@ -1598,6 +1600,35 @@ namespace NLGUI } } + void CInterfaceElement::getSizeParent( std::string &id ) const + { + CInterfaceElement *p = getParentSize(); + + // If there's no parent set then the size parent is the parent + if( p == NULL ) + { + id = "parent"; + return; + } + + // If the size parent is the same as the group parent, then the size parent is the parent ofc + if( p == getParent() ) + { + id = "parent"; + return; + } + + // If the size parent is in the parent group, use the short Id + if( p->isInGroup( getParent() ) ) + { + id = p->getShortId(); + return; + } + + // Otherwise use the full Id + id = p->getId(); + } + void CInterfaceElement::registerDeletionWatcher( IDeletionWatcher *watcher ) { std::vector< IDeletionWatcher* >::iterator itr From 8066717aa22475ae2dd574ea9dd0178e4bb3598a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 15:43:10 +0200 Subject: [PATCH 13/18] Pos and Size parent setters should now use the widget directly as well. --HG-- branch : dfighter-tools --- code/nel/src/gui/interface_element.cpp | 71 ++++++++++++++++++-------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index a18b8e71d..620e7dbdb 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -1534,17 +1534,36 @@ namespace NLGUI void CInterfaceElement::setPosParent( const std::string &id ) { - std::string Id = stripId( id ); + // Parent or empty id simply means the group parent + if( ( id == "parent" ) || ( id.empty() ) ) + { + setParentPos( getParent() ); + return; + } + + CInterfaceElement *pp = NULL; - if( Id != "parent" ) + // Check if it's a short Id + std::string::size_type idx = id.find( "ui:" ); + if( idx == std::string::npos ) { - std::string idParent; - if( _Parent != NULL ) - idParent = _Parent->getId() + ":"; - else - idParent = "ui:"; - CWidgetManager::getInstance()->getParser()->addParentPositionAssociation( this, idParent + Id ); + // If it is, find the widget in the parent group and set as posparent + CInterfaceGroup *p = getParent(); + if( p != NULL ) + { + pp = p->findFromShortId( id ); + } + } + else + { + // If it is not, find using the widgetmanager + // TODO: refactor, shouldn't use a singleton + pp = CWidgetManager::getInstance()->getElementFromId( id ); } + + if( pp != NULL ) + setParentPos( pp ); + } void CInterfaceElement::getPosParent( std::string &id ) const @@ -1579,25 +1598,35 @@ namespace NLGUI void CInterfaceElement::setSizeParent( const std::string &id ) { - std::string Id = stripId( id ); - std::string idParent; - - if( Id != "parent" ) + // Parent or empty id simply means the group parent + if( ( id == "parent" ) || ( id.empty() ) ) { - if( _Parent != NULL ) - idParent = _Parent->getId() + ":"; - else - idParent = "ui:"; - CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent + Id ); + setParentSize( getParent() ); + return; } - else + + CInterfaceElement *pp = NULL; + + // Check if it's a short Id + std::string::size_type idx = id.find( "ui:" ); + if( idx == std::string::npos ) { - if( _Parent != NULL ) + // If it is, find the widget in the parent group and set as posparent + CInterfaceGroup *p = getParent(); + if( p != NULL ) { - idParent = _Parent->getId(); - CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent ); + pp = p->findFromShortId( id ); } } + else + { + // If it is not, find using the widgetmanager + // TODO: refactor, shouldn't use a singleton + pp = CWidgetManager::getInstance()->getElementFromId( id ); + } + + if( pp != NULL ) + setParentSize( pp ); } void CInterfaceElement::getSizeParent( std::string &id ) const From c5cd6990fe808fef6fc38bc126ccd449e49908a2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 17:47:42 +0200 Subject: [PATCH 14/18] When creating a new GUI set the base color to white. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/interface_parser.h | 16 +------- code/nel/include/nel/gui/parser.h | 2 + code/nel/include/nel/gui/variable_data.h | 41 +++++++++++++++++++++ code/nel/src/gui/interface_parser.cpp | 28 ++++++++++++++ code/nel/src/gui/widget_manager.cpp | 20 ++++++++++ 5 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 code/nel/include/nel/gui/variable_data.h diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index c1b3fa109..18ec9045a 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -28,6 +28,7 @@ #include "nel/gui/proc.h" #include "nel/gui/widget_manager.h" #include "nel/gui/link_data.h" +#include "nel/gui/variable_data.h" namespace NLGUI { @@ -100,20 +101,6 @@ namespace NLGUI virtual void setupOptions() = 0; }; - - struct VariableData - { - std::string entry; - std::string type; - std::string value; - uint32 size; - - VariableData() - { - size = 0; - } - }; - CInterfaceParser(); virtual ~CInterfaceParser(); @@ -386,6 +373,7 @@ namespace NLGUI void setEditorMode( bool b ){ editorMode = b; } + void setVariable( const VariableData &v ); bool serializeVariables( xmlNodePtr parentNode ) const; bool serializeProcs( xmlNodePtr parentNode ) const; bool serializePointerSettings( xmlNodePtr parentNode ) const; diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index 0378c22ec..bc53e402d 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -23,6 +23,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/proc.h" #include "nel/gui/link_data.h" +#include "nel/gui/variable_data.h" namespace NLGUI { @@ -83,6 +84,7 @@ namespace NLGUI virtual void removeLinkData( uint32 id ) = 0; virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0; virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0; + virtual void setVariable( const VariableData &v ) = 0; virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0; virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0; virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0; diff --git a/code/nel/include/nel/gui/variable_data.h b/code/nel/include/nel/gui/variable_data.h new file mode 100644 index 000000000..cffba2bce --- /dev/null +++ b/code/nel/include/nel/gui/variable_data.h @@ -0,0 +1,41 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef VARIABLE_DATA_H +#define VARIABLE_DATA_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + struct VariableData + { + std::string entry; + std::string type; + std::string value; + uint32 size; + + VariableData() + { + size = 0; + } + }; + +} + + +#endif + diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 7bf44c6f6..096c001ae 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -2951,6 +2951,34 @@ namespace NLGUI itr->second = linkData; } + void CInterfaceParser::setVariable( const VariableData &v ) + { + CInterfaceProperty prop; + const std::string &type = v.type; + const std::string &value = v.value; + const std::string &entry = v.entry; + + if( type == "sint64" ) + prop.readSInt64( value.c_str(), entry ); + else + if( type == "sint32" ) + prop.readSInt32( value.c_str(), entry ); + else + if( type == "float" || type == "double" ) + prop.readDouble( value.c_str(), entry ); + else + if( type == "bool" ) + prop.readBool( value.c_str(), entry ); + else + if( type == "rgba" ) + prop.readRGBA( value.c_str(), entry ); + else + if( type == "hotspot" ) + prop.readHotSpot( value.c_str(), entry ); + + variableCache[ entry ] = v; + } + bool CInterfaceParser::serializeVariables( xmlNodePtr parentNode ) const { diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 803889a79..81fbaf28b 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3645,6 +3645,26 @@ namespace NLGUI _Pointer = new CViewPointer( CViewBase::TCtorParam() ); + IParser *parser = getParser(); + + + // Set base color to white + VariableData v; + v.type = "sint32"; + v.value = "255"; + + v.entry = "UI:SAVE:COLOR:R"; + parser->setVariable( v ); + + v.entry = "UI:SAVE:COLOR:G"; + parser->setVariable( v ); + + v.entry = "UI:SAVE:COLOR:B"; + parser->setVariable( v ); + + v.entry = "UI:SAVE:COLOR:A"; + parser->setVariable( v ); + return true; } From 22a1d39ac7bf42ed4d8cdaffcf474c22bc89210e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 18:53:26 +0200 Subject: [PATCH 15/18] Map files can now be specified when creating a new GUI project. --HG-- branch : dfighter-tools --- .../plugins/gui_editor/gui_editor_window.cpp | 20 ++++++++ .../src/plugins/gui_editor/nelgui_ctrl.cpp | 36 ++++++++------ .../src/plugins/gui_editor/nelgui_ctrl.h | 1 + .../src/plugins/gui_editor/new_gui_dlg.cpp | 37 +++++++++++++++ .../src/plugins/gui_editor/new_gui_dlg.h | 4 ++ .../src/plugins/gui_editor/new_gui_dlg.ui | 47 +++++++++++++++---- 6 files changed, 122 insertions(+), 23 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index aad19c2ac..002002abd 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -215,6 +215,9 @@ namespace GUIEditor _lastDir = dir.c_str(); std::string uiFile = "ui_" + proj + ".xml"; + QList< QString > mapList; + d.getMapList( mapList ); + bool b = GUICtrl->createNewGUI( proj, wnd ); if( !b ) { @@ -222,6 +225,7 @@ namespace GUIEditor tr( "Creating new GUI project" ), tr( "Failed to create new GUI project :(" ) ); reset(); + return; } hierarchyView->buildHierarchy( mg ); @@ -231,6 +235,22 @@ namespace GUIEditor projectFiles.activeGroup = std::string( "ui:" ) + proj + ":" + wnd; projectFiles.version = SProjectFiles::NEW; projectFiles.guiFiles.push_back( uiFile ); + + for( int i = 0; i < mapList.size(); i++ ) + { + projectFiles.mapFiles.push_back( mapList[ i ].toUtf8().constData() ); + } + + b = GUICtrl->loadMapFiles( projectFiles.mapFiles ); + if( !b ) + { + QMessageBox::information( this, + tr( "Creating new GUI project" ), + tr( "Failed to create new GUI project: Couldn't load map files. " ) ); + reset(); + return; + } + projectWindow->setupFiles( projectFiles ); currentProject = proj.c_str(); diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp index c1e7af3df..e9712ce4e 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp @@ -89,20 +89,8 @@ namespace GUIEditor reset(); IParser *parser = CWidgetManager::getInstance()->getParser(); - std::vector< std::string >::iterator itr; - for( itr = files.mapFiles.begin(); itr != files.mapFiles.end(); ++itr ) - { - std::string &file = *itr; - std::string::size_type i = file.find_last_of( '.' ); - std::string mapFile = file.substr( 0, i ); - mapFile.append( ".txt" ); - - if( !CViewRenderer::getInstance()->loadTextures( file, mapFile, false ) ) - { - CViewRenderer::getInstance()->reset(); - return false; - } - } + if( !loadMapFiles( files.mapFiles ) ) + return false; if( !parser->parseInterface( files.guiFiles, false ) ) return false; @@ -119,6 +107,26 @@ namespace GUIEditor return true; } + bool NelGUICtrl::loadMapFiles( const std::vector< std::string > &v ) + { + std::vector< std::string >::const_iterator itr; + for( itr = v.begin(); itr != v.end(); ++itr ) + { + const std::string &file = *itr; + std::string::size_type i = file.find_last_of( '.' ); + std::string mapFile = file.substr( 0, i ); + mapFile.append( ".txt" ); + + if( !CViewRenderer::getInstance()->loadTextures( file, mapFile, false ) ) + { + CViewRenderer::getInstance()->reset(); + return false; + } + } + + return true; + } + bool NelGUICtrl::createNewGUI( const std::string &project, const std::string &window ) { reset(); diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h index d7d157ccf..d54c78c7a 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.h +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.h @@ -43,6 +43,7 @@ namespace GUIEditor void init(); bool parse( SProjectFiles &files ); + bool loadMapFiles( const std::vector< std::string > &v ); bool createNewGUI( const std::string &project, const std::string &window ); void draw(); void reset(); diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp index 88d4a19fd..3c9208dfc 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp @@ -28,6 +28,8 @@ QDialog( parent ) connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.projectDirTB, SIGNAL( clicked( bool ) ), this, SLOT( onProjectDirTBClicked() ) ); + connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); + connect( m_ui.removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); } @@ -50,6 +52,16 @@ QString NewGUIDlg::getProjectDirectory() const return m_ui.projectDirEdit->text(); } +void NewGUIDlg::getMapList( QList< QString > &l ) +{ + l.clear(); + + for( int i = 0; i < m_ui.mapList->count(); i++ ) + { + l.push_back( m_ui.mapList->item( i )->text() ); + } +} + void NewGUIDlg::onOKClicked() { if( m_ui.projectEdit->text().isEmpty() ) @@ -95,4 +107,29 @@ void NewGUIDlg::onProjectDirTBClicked() m_ui.projectDirEdit->setText( dir ); } +void NewGUIDlg::onAddClicked() +{ + if( m_ui.mapEdit->text().isEmpty() ) + return; + + QList< QListWidgetItem* > l = m_ui.mapList->findItems( m_ui.mapEdit->text(), Qt::MatchContains ); + if( !l.isEmpty() ) + { + return; + } + + m_ui.mapList->addItem( m_ui.mapEdit->text() ); + m_ui.mapEdit->clear(); +} + +void NewGUIDlg::onRemoveClicked() +{ + QListWidgetItem *item = m_ui.mapList->currentItem(); + if( item == NULL ) + return; + + delete item; +} + + diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.h b/code/studio/src/plugins/gui_editor/new_gui_dlg.h index f4bf474f7..0d878461c 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.h +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.h @@ -20,6 +20,7 @@ #define NEW_GUI_DLG_H #include "ui_new_gui_dlg.h" +#include class NewGUIDlg : public QDialog { @@ -32,11 +33,14 @@ public: QString getProjectName() const; QString getWindowName() const; QString getProjectDirectory() const; + void getMapList( QList< QString > &l ); private Q_SLOTS: void onOKClicked(); void onCancelClicked(); void onProjectDirTBClicked(); + void onAddClicked(); + void onRemoveClicked(); private: Ui::NewGUIDialog m_ui; diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.ui b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui index 7dca6d2a3..bf22e8c6b 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.ui +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.ui @@ -6,14 +6,14 @@ 0 0 - 332 - 125 + 399 + 354 New GUI - + @@ -21,7 +21,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -41,17 +41,46 @@ - + - + ... - + + + + Map files + + + + + + Add + + + + + + + + + + Remove + + + + + + + + + + Qt::Horizontal @@ -64,7 +93,7 @@ - + From fae1e39039dc9d0b7e69c124b73bc22a6875b4f0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 18:55:17 +0200 Subject: [PATCH 16/18] Don't reject an action property just because it's empty... --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp index 84302bcf0..c518d7acc 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -728,9 +728,6 @@ namespace GUIEditor { std::string j = element->getProperty( prop.propName ); - if( j.empty() ) - return; - QtProperty *pp = actionMgr->addProperty( prop.propName.c_str() ); if( pp == NULL ) return; From ab76b7ed85630c41abe00f84ffc6ecfa9ca6ab84 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 19:15:59 +0200 Subject: [PATCH 17/18] It's not a bad idea to actually retrieve the version if we load it... --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/project_file_parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/studio/src/plugins/gui_editor/project_file_parser.cpp b/code/studio/src/plugins/gui_editor/project_file_parser.cpp index a10f5d783..856b3c164 100644 --- a/code/studio/src/plugins/gui_editor/project_file_parser.cpp +++ b/code/studio/src/plugins/gui_editor/project_file_parser.cpp @@ -58,6 +58,7 @@ namespace GUIEditor projectFiles.projectName = files.projectName; projectFiles.masterGroup = files.masterGroup; projectFiles.activeGroup = files.activeGroup; + projectFiles.version = files.version; } unsigned long CProjectFileParser::getProjectVersion() const From 2b5898565f4ec153c71b8b42fc65dd285c9c25a5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 20:15:41 +0200 Subject: [PATCH 18/18] Don't disable the active group before serializing. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widget_serializer.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widget_serializer.cpp b/code/studio/src/plugins/gui_editor/widget_serializer.cpp index fd4e7cfbe..8006a6b50 100644 --- a/code/studio/src/plugins/gui_editor/widget_serializer.cpp +++ b/code/studio/src/plugins/gui_editor/widget_serializer.cpp @@ -93,8 +93,6 @@ namespace GUIEditor return false; } - ag->setActive( false ); - if( mg->serializeSubGroups( root ) == NULL ) { ag->setActive( true ); @@ -103,8 +101,6 @@ namespace GUIEditor return false; } - ag->setActive( true ); - if( !mg->serializeLinks( root ) ) { xmlFreeNode( root );