From b300bb1ee7e47906b7e77d55939dd9783190c393 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 12 Sep 2014 19:19:51 +0200 Subject: [PATCH 01/43] Added GUI for expression editor. --- .../src/plugins/gui_editor/CMakeLists.txt | 2 + .../plugins/gui_editor/expression_editor.cpp | 88 +++++++++++++++++++ .../plugins/gui_editor/expression_editor.h | 51 +++++++++++ .../plugins/gui_editor/expression_editor.ui | 34 +++++++ .../plugins/gui_editor/gui_editor_window.cpp | 14 +++ .../plugins/gui_editor/gui_editor_window.h | 3 + 6 files changed, 192 insertions(+) create mode 100644 code/studio/src/plugins/gui_editor/expression_editor.cpp create mode 100644 code/studio/src/plugins/gui_editor/expression_editor.h create mode 100644 code/studio/src/plugins/gui_editor/expression_editor.ui diff --git a/code/studio/src/plugins/gui_editor/CMakeLists.txt b/code/studio/src/plugins/gui_editor/CMakeLists.txt index 4b50ec8d1..77ca5a335 100644 --- a/code/studio/src/plugins/gui_editor/CMakeLists.txt +++ b/code/studio/src/plugins/gui_editor/CMakeLists.txt @@ -34,6 +34,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR texture_chooser.h action_property_manager.h texture_property_manager.h + expression_editor.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -51,6 +52,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS add_widget_widget.ui action_list.ui texture_chooser.ui + expression_editor.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp new file mode 100644 index 000000000..81ea74941 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -0,0 +1,88 @@ +// Ryzom Core Studio - Georges 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 "expression_editor.h" +#include +#include +#include +#include + +ExpressionEditor::ExpressionEditor( QWidget *parent ) : +QWidget( parent ) +{ + m_ui.setupUi( this ); + + m_selection = NULL; + + m_scene = new QGraphicsScene( this ); + m_ui.view->setScene( m_scene ); + + m_scene->addSimpleText( "Hello" ); + + connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); +} + +ExpressionEditor::~ExpressionEditor() +{ + m_scene = NULL; +} + +void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) +{ + QMenu menu; + + QAction *a = NULL; + a = menu.addAction( "Add rect" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) ); + + if( m_selection != NULL ) + { + a = menu.addAction( "Remove" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) ); + } + + menu.exec( e->globalPos() ); +} + +void ExpressionEditor::onAddRect() +{ + QGraphicsRectItem *item = new QGraphicsRectItem( 0, 0, 100, 100 ); + item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_scene->addItem( item ); +} + +void ExpressionEditor::onDeleteSelection() +{ + m_scene->removeItem( m_selection ); +} + +void ExpressionEditor::onSelectionChanged() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + if( l.isEmpty() ) + { + m_selection = NULL; + return; + } + + m_selection = l[ 0 ]; +} + + + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h new file mode 100644 index 000000000..31fb64d73 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -0,0 +1,51 @@ +// Ryzom Core Studio - Georges 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 EXPRESSION_EDITOR +#define EXPRESSION_EDITOR + +#include "ui_expression_editor.h" + +class QGraphicsScene; +class QGraphicsItem; + +class ExpressionEditor : public QWidget +{ + Q_OBJECT +public: + ExpressionEditor( QWidget *parent = NULL ); + ~ExpressionEditor(); + +protected: + void contextMenuEvent( QContextMenuEvent *e ); + +private Q_SLOTS: + void onAddRect(); + void onDeleteSelection(); + void onSelectionChanged(); + +private: + Ui::ExpressionEditor m_ui; + QGraphicsScene *m_scene; + + QGraphicsItem *m_selection; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui new file mode 100644 index 000000000..80480ad39 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -0,0 +1,34 @@ + + + ExpressionEditor + + + Qt::ApplicationModal + + + + 0 + 0 + 724 + 522 + + + + Expression Editor + + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOn + + + + + + + + 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 3f4e318db..f6adacc8a 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -46,6 +46,8 @@ #include "add_widget_widget.h" #include "texture_chooser.h" +#include "expression_editor.h" + namespace GUIEditor { QString _lastDir; @@ -72,6 +74,7 @@ namespace GUIEditor widgetInfoTree = new CWidgetInfoTree; tc = new TextureChooser(); + ee = new ExpressionEditor(); createMenus(); readSettings(); @@ -120,6 +123,8 @@ namespace GUIEditor delete tc; tc = NULL; + delete ee; + ee = NULL; delete messageProcessor; messageProcessor = NULL; @@ -365,6 +370,11 @@ namespace GUIEditor tc->exec(); } + void GUIEditorWindow::onEEClicked() + { + ee->show(); + } + void GUIEditorWindow::createMenus() { Core::MenuManager *mm = Core::ICore::instance()->menuManager(); @@ -415,6 +425,10 @@ namespace GUIEditor connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) ); m->addAction( a ); + a = new QAction( "Expression Editor", this ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onEEClicked() ) ); + m->addAction( a ); + menu = m; } } 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 d18a24813..d0dbe628e 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -29,6 +29,7 @@ class QtTreePropertyBrowser; class QMenu; class TextureChooser; +class ExpressionEditor; namespace GUIEditor { @@ -68,6 +69,7 @@ private Q_SLOTS: void onAddWidgetClicked(); void onTreeChanged(); void onTCClicked(); + void onEEClicked(); protected: @@ -103,6 +105,7 @@ private: QMenu *menu; TextureChooser *tc; + ExpressionEditor *ee; }; } From 8f72f2d12f533b1d5285110ea443e556302e00ac Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 12 Sep 2014 19:47:28 +0200 Subject: [PATCH 02/43] We can select multiple items --- .../plugins/gui_editor/expression_editor.cpp | 18 +++++++++--------- .../src/plugins/gui_editor/expression_editor.h | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 81ea74941..e4d749dcd 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -28,7 +28,7 @@ QWidget( parent ) { m_ui.setupUi( this ); - m_selection = NULL; + m_hasSelection = false; m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); @@ -51,7 +51,7 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Add rect" ); connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) ); - if( m_selection != NULL ) + if( m_hasSelection ) { a = menu.addAction( "Remove" ); connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) ); @@ -69,19 +69,19 @@ void ExpressionEditor::onAddRect() void ExpressionEditor::onDeleteSelection() { - m_scene->removeItem( m_selection ); + QList< QGraphicsItem* > l = m_scene->selectedItems(); + QListIterator< QGraphicsItem* > itr( l ); + while( itr.hasNext() ) + m_scene->removeItem( itr.next() ); } void ExpressionEditor::onSelectionChanged() { QList< QGraphicsItem* > l = m_scene->selectedItems(); if( l.isEmpty() ) - { - m_selection = NULL; - return; - } - - m_selection = l[ 0 ]; + m_hasSelection = false; + else + m_hasSelection = true; } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 31fb64d73..b73f8029f 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -23,7 +23,6 @@ #include "ui_expression_editor.h" class QGraphicsScene; -class QGraphicsItem; class ExpressionEditor : public QWidget { @@ -44,7 +43,7 @@ private: Ui::ExpressionEditor m_ui; QGraphicsScene *m_scene; - QGraphicsItem *m_selection; + bool m_hasSelection; }; #endif From 475bd91a0c6e6fbcae538db21e2d35d2316c1311 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 12 Sep 2014 21:01:29 +0200 Subject: [PATCH 03/43] Added link action. --- .../plugins/gui_editor/expression_editor.cpp | 28 ++++++++++++++----- .../plugins/gui_editor/expression_editor.h | 4 ++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index e4d749dcd..2909b0835 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -28,7 +28,7 @@ QWidget( parent ) { m_ui.setupUi( this ); - m_hasSelection = false; + m_selectionCount = 0; m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); @@ -51,10 +51,16 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Add rect" ); connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) ); - if( m_hasSelection ) + if( m_selectionCount > 0 ) { a = menu.addAction( "Remove" ); connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) ); + + if( m_selectionCount == 2 ) + { + a = menu.addAction( "Link" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onLinkItems() ) ); + } } menu.exec( e->globalPos() ); @@ -78,11 +84,19 @@ void ExpressionEditor::onDeleteSelection() void ExpressionEditor::onSelectionChanged() { QList< QGraphicsItem* > l = m_scene->selectedItems(); - if( l.isEmpty() ) - m_hasSelection = false; - else - m_hasSelection = true; + m_selectionCount = l.count(); +} + +void ExpressionEditor::onLinkItems() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + QGraphicsItem *from = l[ 0 ]; + QGraphicsItem *to = l[ 1 ]; + + QGraphicsLineItem *line = new QGraphicsLineItem(); + line->setLine( QLineF( from->pos(), to->pos() ) ); + line->setPen( QPen( Qt::darkRed, 1.0 ) ); + m_scene->addItem( line ); } - diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index b73f8029f..70d2ad572 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -38,12 +38,14 @@ private Q_SLOTS: void onAddRect(); void onDeleteSelection(); void onSelectionChanged(); + void onLinkItems(); private: + Ui::ExpressionEditor m_ui; QGraphicsScene *m_scene; - bool m_hasSelection; + int m_selectionCount; }; #endif From f7b360f1cbf32d5bc140918bef50da8c618d53eb Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 12 Sep 2014 23:45:57 +0200 Subject: [PATCH 04/43] Subclassed QGraphicsItem and QGraphicsItemLine. --- .../plugins/gui_editor/expression_editor.cpp | 12 +++-- .../plugins/gui_editor/expression_link.cpp | 44 ++++++++++++++++ .../src/plugins/gui_editor/expression_link.h | 44 ++++++++++++++++ .../plugins/gui_editor/expression_node.cpp | 50 +++++++++++++++++++ .../src/plugins/gui_editor/expression_node.h | 37 ++++++++++++++ 5 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 code/studio/src/plugins/gui_editor/expression_link.cpp create mode 100644 code/studio/src/plugins/gui_editor/expression_link.h create mode 100644 code/studio/src/plugins/gui_editor/expression_node.cpp create mode 100644 code/studio/src/plugins/gui_editor/expression_node.h diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 2909b0835..5fad4f054 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -23,6 +23,9 @@ #include #include +#include "expression_node.h" +#include "expression_link.h" + ExpressionEditor::ExpressionEditor( QWidget *parent ) : QWidget( parent ) { @@ -68,7 +71,7 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) void ExpressionEditor::onAddRect() { - QGraphicsRectItem *item = new QGraphicsRectItem( 0, 0, 100, 100 ); + QGraphicsItem *item = new ExpressionNode(); item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); m_scene->addItem( item ); } @@ -93,10 +96,9 @@ void ExpressionEditor::onLinkItems() QGraphicsItem *from = l[ 0 ]; QGraphicsItem *to = l[ 1 ]; - QGraphicsLineItem *line = new QGraphicsLineItem(); - line->setLine( QLineF( from->pos(), to->pos() ) ); - line->setPen( QPen( Qt::darkRed, 1.0 ) ); - m_scene->addItem( line ); + ExpressionLink *link = new ExpressionLink(); + link->link( from, to ); + m_scene->addItem( link ); } diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp new file mode 100644 index 000000000..55f0f8421 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -0,0 +1,44 @@ +// Ryzom Core Studio - Georges 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 "expression_link.h" +#include +#include + +ExpressionLink::ExpressionLink( QGraphicsItem *parent ) : +QGraphicsLineItem( parent ) +{ + m_from = NULL; + m_to = NULL; +} + +ExpressionLink::~ExpressionLink() +{ +} + +void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) +{ + if( m_from != NULL ) + setLine( QLineF( m_from->pos(), m_to->pos() ) ); + + setPen( QPen( Qt::darkRed ) ); + + QGraphicsLineItem::paint( painter, option, widget ); +} + + diff --git a/code/studio/src/plugins/gui_editor/expression_link.h b/code/studio/src/plugins/gui_editor/expression_link.h new file mode 100644 index 000000000..d45900691 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_link.h @@ -0,0 +1,44 @@ +// Ryzom Core Studio - Georges 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 EXPRESSION_LINK +#define EXPRESSION_LINK + +#include + +class ExpressionLink : public QGraphicsLineItem +{ +public: + ExpressionLink( QGraphicsItem *parent = NULL ); + ~ExpressionLink(); + + void link( QGraphicsItem *from, QGraphicsItem *to ){ + m_from = from; + m_to = to; + } + + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + +private: + QGraphicsItem *m_from; + QGraphicsItem *m_to; + +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp new file mode 100644 index 000000000..3fc0d7d2b --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -0,0 +1,50 @@ +// Ryzom Core Studio - Georges 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 "expression_node.h" +#include +#include + +ExpressionNode::ExpressionNode( QGraphicsItem *parent ) : +QGraphicsItem( parent ) +{ +} + +ExpressionNode::~ExpressionNode() +{ +} + +QRectF ExpressionNode::boundingRect() const +{ + return QRectF( 0, 0, 100, 100 ); +} + +void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) +{ + if( option->state & QStyle::State_Selected ) + { + QPen outline; + outline.setStyle( Qt::DotLine ); + painter->setPen( outline ); + + } + + painter->drawRect( boundingRect() ); +} + diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h new file mode 100644 index 000000000..354905c3e --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -0,0 +1,37 @@ +// Ryzom Core Studio - Georges 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 EXPRESSION_NODE +#define EXPRESSION_NODE + +#include + +class ExpressionNode : public QGraphicsItem +{ +public: + ExpressionNode( QGraphicsItem *parent = NULL ); + ~ExpressionNode(); + + QRectF boundingRect() const; + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + +}; + +#endif + From a6e5f52e17159cf2e5225d1024ff3350ed0166df Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 00:43:00 +0200 Subject: [PATCH 05/43] Link nodes and remove and delete the link too when deleting one of the nodes. --- .../plugins/gui_editor/expression_editor.cpp | 24 ++++++++++++++-- .../plugins/gui_editor/expression_link.cpp | 28 +++++++++++++++++-- .../src/plugins/gui_editor/expression_link.h | 14 ++++++---- .../plugins/gui_editor/expression_node.cpp | 12 ++++++++ .../src/plugins/gui_editor/expression_node.h | 11 ++++++++ 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 5fad4f054..48f807696 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -81,7 +81,24 @@ void ExpressionEditor::onDeleteSelection() QList< QGraphicsItem* > l = m_scene->selectedItems(); QListIterator< QGraphicsItem* > itr( l ); while( itr.hasNext() ) - m_scene->removeItem( itr.next() ); + { + QGraphicsItem *item = itr.next(); + + ExpressionNode *node = dynamic_cast< ExpressionNode* >( item ); + if( node != NULL ) + { + ExpressionLink *link = node->link(); + if( link != NULL ) + { + link->unlink(); + m_scene->removeItem( link ); + delete link; + } + } + + m_scene->removeItem( item ); + delete item; + } } void ExpressionEditor::onSelectionChanged() @@ -93,11 +110,12 @@ void ExpressionEditor::onSelectionChanged() void ExpressionEditor::onLinkItems() { QList< QGraphicsItem* > l = m_scene->selectedItems(); - QGraphicsItem *from = l[ 0 ]; - QGraphicsItem *to = l[ 1 ]; + ExpressionNode *from = static_cast< ExpressionNode* >( l[ 0 ] ); + ExpressionNode *to = static_cast< ExpressionNode* >( l[ 1 ] ); ExpressionLink *link = new ExpressionLink(); link->link( from, to ); + m_scene->addItem( link ); } diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 55f0f8421..9fa6aa536 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -17,6 +17,7 @@ // along with this program. If not, see . #include "expression_link.h" +#include "expression_node.h" #include #include @@ -25,17 +26,38 @@ QGraphicsLineItem( parent ) { m_from = NULL; m_to = NULL; + + setFlags( QGraphicsItem::ItemIsSelectable ); } ExpressionLink::~ExpressionLink() { + unlink(); +} + +void ExpressionLink::link( ExpressionNode *from, ExpressionNode *to ) +{ + m_from = from; + m_to = to; + m_from->setLink( this ); + m_to->setLink( this ); + + nodeMoved(); +} + +void ExpressionLink::unlink() +{ + m_from->setLink( NULL ); + m_to->setLink( NULL ); +} + +void ExpressionLink::nodeMoved() +{ + setLine( QLineF( m_from->pos(), m_to->pos() ) ); } void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { - if( m_from != NULL ) - setLine( QLineF( m_from->pos(), m_to->pos() ) ); - setPen( QPen( Qt::darkRed ) ); QGraphicsLineItem::paint( painter, option, widget ); diff --git a/code/studio/src/plugins/gui_editor/expression_link.h b/code/studio/src/plugins/gui_editor/expression_link.h index d45900691..59644980a 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.h +++ b/code/studio/src/plugins/gui_editor/expression_link.h @@ -21,22 +21,24 @@ #include +class ExpressionNode; + class ExpressionLink : public QGraphicsLineItem { public: ExpressionLink( QGraphicsItem *parent = NULL ); ~ExpressionLink(); - void link( QGraphicsItem *from, QGraphicsItem *to ){ - m_from = from; - m_to = to; - } + void link( ExpressionNode *from, ExpressionNode *to ); + void unlink(); + + void nodeMoved(); void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); private: - QGraphicsItem *m_from; - QGraphicsItem *m_to; + ExpressionNode *m_from; + ExpressionNode *m_to; }; diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 3fc0d7d2b..8e92b6705 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -18,12 +18,14 @@ #include "expression_node.h" +#include "expression_link.h" #include #include ExpressionNode::ExpressionNode( QGraphicsItem *parent ) : QGraphicsItem( parent ) { + m_link = NULL; } ExpressionNode::~ExpressionNode() @@ -48,3 +50,13 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o painter->drawRect( boundingRect() ); } + +void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) +{ + if( m_link != NULL ) + m_link->nodeMoved(); + + QGraphicsItem::mouseMoveEvent( e ); +} + + diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 354905c3e..a3bf701fd 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -22,6 +22,8 @@ #include +class ExpressionLink; + class ExpressionNode : public QGraphicsItem { public: @@ -31,6 +33,15 @@ public: QRectF boundingRect() const; void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + void setLink( ExpressionLink *link ){ m_link = link; } + ExpressionLink* link() const{ return m_link; } + +protected: + void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); + +private: + ExpressionLink *m_link; + }; #endif From ac9dc5638ce2fa2b335c5c4a7ca90009f6bccbb6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 00:54:37 +0200 Subject: [PATCH 06/43] Throw an error message when trying to link nodes that are already linked. --- .../src/plugins/gui_editor/expression_editor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 48f807696..d942623ba 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -26,6 +26,8 @@ #include "expression_node.h" #include "expression_link.h" +#include + ExpressionEditor::ExpressionEditor( QWidget *parent ) : QWidget( parent ) { @@ -113,6 +115,14 @@ void ExpressionEditor::onLinkItems() ExpressionNode *from = static_cast< ExpressionNode* >( l[ 0 ] ); ExpressionNode *to = static_cast< ExpressionNode* >( l[ 1 ] ); + if( ( from->link() != NULL ) || ( to->link() != NULL ) ) + { + QMessageBox::information( this, + tr( "Failed to link nodes" ), + tr( "Unfortunately those nodes are already linked." ) ); + return; + } + ExpressionLink *link = new ExpressionLink(); link->link( from, to ); From f170d8854b64d4b9102257e4cbe532b5ffdcef62 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 18:03:02 +0200 Subject: [PATCH 07/43] Add a little style. --- .../plugins/gui_editor/expression_link.cpp | 2 +- .../plugins/gui_editor/expression_node.cpp | 35 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 9fa6aa536..c17ad8b30 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -58,7 +58,7 @@ void ExpressionLink::nodeMoved() void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { - setPen( QPen( Qt::darkRed ) ); + setPen( QPen( Qt::black ) ); QGraphicsLineItem::paint( painter, option, widget ); } diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 8e92b6705..334fd3042 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -39,15 +39,40 @@ QRectF ExpressionNode::boundingRect() const void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { + QBrush br; + QPen p; + QColor c; + + QRectF rect = boundingRect(); + QRectF header = rect; + header.setHeight( header.height() * 0.2 ); + + // Draw filled rectangle, header + c.setRed( 44 ); + c.setGreen( 169 ); + c.setBlue( 232 ); + br.setColor( c ); + br.setStyle( Qt::SolidPattern ); + p.setColor( c ); + painter->setPen( p ); + painter->fillRect( header, br ); + + // Draw header text + p.setColor( Qt::black ); + painter->setPen( p ); + painter->drawText( header, Qt::AlignCenter, "Something" ); + + if( option->state & QStyle::State_Selected ) { - QPen outline; - outline.setStyle( Qt::DotLine ); - painter->setPen( outline ); - + p.setStyle( Qt::DotLine ); + p.setColor( Qt::red ); } - painter->drawRect( boundingRect() ); + // Draw outline of the entire thing + header + painter->setPen( p ); + painter->drawRect( rect ); + painter->drawRect( header ); } From cf42655519174dee2a2457f8962b23a444340d73 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 21:34:47 +0200 Subject: [PATCH 08/43] Paint the connection text, boxes separately. --- .../plugins/gui_editor/expression_editor.cpp | 2 - .../plugins/gui_editor/expression_link.cpp | 5 +- .../plugins/gui_editor/expression_node.cpp | 55 ++++++++++++++++++- .../src/plugins/gui_editor/expression_node.h | 2 + 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index d942623ba..313af23b5 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -38,8 +38,6 @@ QWidget( parent ) m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); - m_scene->addSimpleText( "Hello" ); - connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); } diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index c17ad8b30..1e7f7cf5f 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -58,7 +58,10 @@ void ExpressionLink::nodeMoved() void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { - setPen( QPen( Qt::black ) ); + QPen p; + p.setColor( Qt::black ); + p.setWidth( 5 ); + setPen( p ); QGraphicsLineItem::paint( painter, option, widget ); } diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 334fd3042..fae024096 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -40,6 +40,7 @@ QRectF ExpressionNode::boundingRect() const void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { QBrush br; + QBrush boxBrush; QPen p; QColor c; @@ -62,7 +63,6 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o painter->setPen( p ); painter->drawText( header, Qt::AlignCenter, "Something" ); - if( option->state & QStyle::State_Selected ) { p.setStyle( Qt::DotLine ); @@ -73,6 +73,8 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o painter->setPen( p ); painter->drawRect( rect ); painter->drawRect( header ); + + paintConnections( painter ); } @@ -84,4 +86,55 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) QGraphicsItem::mouseMoveEvent( e ); } +void ExpressionNode::paintConnections( QPainter *painter ) +{ + QRectF rect = boundingRect(); + QBrush boxBrush; + QPen p; + + boxBrush.setColor( Qt::black ); + boxBrush.setStyle( Qt::SolidPattern ); + p.setColor( Qt::black ); + + QRectF box = rect; + QRectF tbox = rect; + qreal wh = 10.0; + qreal tw = 25.0; + qreal th = 12.0; + + box.setTopLeft( QPoint( 0, rect.height() * 0.5 ) ); + box.setHeight( wh ); + box.setWidth( wh ); + + painter->fillRect( box, boxBrush ); + + tbox.setTopLeft( QPoint( 15, rect.height() * 0.50 ) ); + tbox.setHeight( th ); + tbox.setWidth( tw ); + painter->setPen( p ); + painter->drawText( tbox, Qt::AlignCenter, "Out" ); + + + for( int i = 0; i < 3; i++ ) + { + qreal x = rect.width() - wh; + qreal y = 30 + i * 20; + qreal tx = x - 5 - tw; + qreal ty = y - 2; + + box.setTopLeft( QPoint( x, y ) ); + box.setHeight( wh ); + box.setWidth( wh ); + + painter->fillRect( box, boxBrush ); + + tbox.setTopLeft( QPoint( tx, ty ) ); + tbox.setHeight( th ); + tbox.setWidth( tw ); + + QString text = 'A' + i; + painter->drawText( tbox, Qt::AlignRight, text ); + } +} + diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index a3bf701fd..6eebcb8a4 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -40,6 +40,8 @@ protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); private: + void paintConnections( QPainter *painter ); + ExpressionLink *m_link; }; From 1d1660c27bf9ad64598596ea1b2ea418bb832b08 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 22:26:11 +0200 Subject: [PATCH 09/43] Connection slots are now managed by their own object, and linking is now done to their positions. --- .../plugins/gui_editor/expression_link.cpp | 2 +- .../plugins/gui_editor/expression_node.cpp | 150 +++++++++++++----- .../src/plugins/gui_editor/expression_node.h | 11 +- 3 files changed, 117 insertions(+), 46 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 1e7f7cf5f..5050a9339 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -53,7 +53,7 @@ void ExpressionLink::unlink() void ExpressionLink::nodeMoved() { - setLine( QLineF( m_from->pos(), m_to->pos() ) ); + setLine( QLineF( m_from->slotPos( 0 ), m_to->slotPos( 0 ) ) ); } void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index fae024096..06616c1db 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -22,19 +22,92 @@ #include #include + + +class NodeSlot +{ +public: + NodeSlot( const QPoint &tl, const QPoint &ttl, const QString &text ) + { + m_tl = tl; + m_ttl = ttl; + m_text = text; + + m_tw = 25.0; + m_th = 12.0; + m_wh = 10.0; + } + + ~NodeSlot() + { + } + + QPointF pos() const{ + QPointF p; + p.setX( m_tl.x() + m_wh / 2.0 ); + p.setY( m_tl.y() + m_wh / 2.0 ); + + return p; + } + + void paint( QPainter *painter ) + { + QBrush boxBrush; + QPen p; + + boxBrush.setColor( Qt::black ); + boxBrush.setStyle( Qt::SolidPattern ); + p.setColor( Qt::black ); + painter->setPen( p ); + + QRectF box; + QRectF tbox; + + box.setTopLeft( m_tl ); + box.setHeight( m_wh ); + box.setWidth( m_wh ); + + painter->fillRect( box, boxBrush ); + + tbox.setTopLeft( m_ttl ); + tbox.setHeight( m_th ); + tbox.setWidth( m_tw ); + + painter->drawText( tbox, Qt::AlignRight, m_text ); + } + +private: + QPoint m_tl; + QPoint m_ttl; + QString m_text; + + qreal m_th; + qreal m_tw; + qreal m_wh; +}; + + + ExpressionNode::ExpressionNode( QGraphicsItem *parent ) : QGraphicsItem( parent ) { m_link = NULL; + + m_w = 100; + m_h = 100; + + createSlots(); } ExpressionNode::~ExpressionNode() { + qDeleteAll( m_slots ); + m_slots.clear(); } QRectF ExpressionNode::boundingRect() const { - return QRectF( 0, 0, 100, 100 ); + return QRectF( 0, 0, m_w, m_h ); } void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) @@ -74,10 +147,20 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o painter->drawRect( rect ); painter->drawRect( header ); - paintConnections( painter ); + paintSlots( painter ); } +QPointF ExpressionNode::slotPos( int slot ) const +{ + const NodeSlot *s = m_slots[ slot ]; + QPointF sp = s->pos(); + QPointF mp = pos(); + + mp += sp; + return mp; +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { if( m_link != NULL ) @@ -86,54 +169,33 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) QGraphicsItem::mouseMoveEvent( e ); } -void ExpressionNode::paintConnections( QPainter *painter ) +void ExpressionNode::createSlots() { - QRectF rect = boundingRect(); - QBrush boxBrush; - QPen p; - - boxBrush.setColor( Qt::black ); - boxBrush.setStyle( Qt::SolidPattern ); - p.setColor( Qt::black ); - - QRectF box = rect; - QRectF tbox = rect; - qreal wh = 10.0; - qreal tw = 25.0; - qreal th = 12.0; - - box.setTopLeft( QPoint( 0, rect.height() * 0.5 ) ); - box.setHeight( wh ); - box.setWidth( wh ); - - painter->fillRect( box, boxBrush ); - - tbox.setTopLeft( QPoint( 15, rect.height() * 0.50 ) ); - tbox.setHeight( th ); - tbox.setWidth( tw ); - painter->setPen( p ); - painter->drawText( tbox, Qt::AlignCenter, "Out" ); - + // First create the "Out" slot + qreal x = 0.0; + qreal y = m_h * 0.5; + qreal tx = 10; + qreal ty = m_h * 0.5 - 2; + m_slots.push_back( new NodeSlot( QPoint( x, y ), QPoint( tx, ty ), "Out" ) ); + // Then the rest of them for( int i = 0; i < 3; i++ ) { - qreal x = rect.width() - wh; - qreal y = 30 + i * 20; - qreal tx = x - 5 - tw; - qreal ty = y - 2; - - box.setTopLeft( QPoint( x, y ) ); - box.setHeight( wh ); - box.setWidth( wh ); + x = m_w - 10; + y = 30 + i * 20.0; + tx = x - 5 - 25.0; + ty = y - 2; - painter->fillRect( box, boxBrush ); + m_slots.push_back( new NodeSlot( QPoint( x, y ), QPoint( tx, ty ), QString( 'A' + i ) ) ); + } +} - tbox.setTopLeft( QPoint( tx, ty ) ); - tbox.setHeight( th ); - tbox.setWidth( tw ); - - QString text = 'A' + i; - painter->drawText( tbox, Qt::AlignRight, text ); +void ExpressionNode::paintSlots( QPainter *painter ) +{ + for( int i = 0; i < 4; i++ ) + { + NodeSlot *slot = m_slots[ i ]; + slot->paint( painter ); } } diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 6eebcb8a4..c189bd0fc 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -21,8 +21,10 @@ #define EXPRESSION_NODE #include +#include class ExpressionLink; +class NodeSlot; class ExpressionNode : public QGraphicsItem { @@ -36,14 +38,21 @@ public: void setLink( ExpressionLink *link ){ m_link = link; } ExpressionLink* link() const{ return m_link; } + QPointF slotPos( int slot ) const; + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); private: - void paintConnections( QPainter *painter ); + void createSlots(); + void paintSlots( QPainter *painter ); ExpressionLink *m_link; + qreal m_w; + qreal m_h; + + QList< NodeSlot* > m_slots; }; #endif From cce08a691417d0a3774202ec60656cb726257a23 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 22:31:48 +0200 Subject: [PATCH 10/43] Refactoring --- .../plugins/gui_editor/expression_node.cpp | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 06616c1db..e59db6a3c 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -22,16 +22,21 @@ #include #include - +struct NodeSlotInfo +{ + QPoint tl; + QPoint ttl; + QString text; +}; class NodeSlot { public: - NodeSlot( const QPoint &tl, const QPoint &ttl, const QString &text ) + NodeSlot( const NodeSlotInfo &info ) { - m_tl = tl; - m_ttl = ttl; - m_text = text; + m_tl = info.tl; + m_ttl = info.ttl; + m_text = info.text; m_tw = 25.0; m_th = 12.0; @@ -176,7 +181,13 @@ void ExpressionNode::createSlots() qreal y = m_h * 0.5; qreal tx = 10; qreal ty = m_h * 0.5 - 2; - m_slots.push_back( new NodeSlot( QPoint( x, y ), QPoint( tx, ty ), "Out" ) ); + + NodeSlotInfo info; + info.tl = QPoint( x, y ); + info.ttl = QPoint( tx, ty ); + info.text = "Out"; + + m_slots.push_back( new NodeSlot( info ) ); // Then the rest of them for( int i = 0; i < 3; i++ ) @@ -186,7 +197,11 @@ void ExpressionNode::createSlots() tx = x - 5 - 25.0; ty = y - 2; - m_slots.push_back( new NodeSlot( QPoint( x, y ), QPoint( tx, ty ), QString( 'A' + i ) ) ); + info.tl = QPoint( x, y ); + info.ttl = QPoint( tx, ty ); + info.text = QString( 'A' + i ); + + m_slots.push_back( new NodeSlot( info ) ); } } From 2f92e69e9d5665d7720563ee6f94ff9db6f454ef Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 22:39:00 +0200 Subject: [PATCH 11/43] More refactoring. --- .../plugins/gui_editor/expression_node.cpp | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index e59db6a3c..72f77f4dd 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -24,9 +24,23 @@ struct NodeSlotInfo { + // top-left QPoint tl; + + // text top-left QPoint ttl; + + // The text displayed QString text; + + // text width + qreal tw; + + // text height + qreal th; + + // width-height of the box + qreal wh; }; class NodeSlot @@ -38,9 +52,9 @@ public: m_ttl = info.ttl; m_text = info.text; - m_tw = 25.0; - m_th = 12.0; - m_wh = 10.0; + m_tw = info.tw; + m_th = info.th; + m_wh = info.wh; } ~NodeSlot() @@ -177,12 +191,17 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) void ExpressionNode::createSlots() { // First create the "Out" slot - qreal x = 0.0; - qreal y = m_h * 0.5; - qreal tx = 10; - qreal ty = m_h * 0.5 - 2; NodeSlotInfo info; + info.tw = 25.0; + info.th = 12.0; + info.wh = 10.0; + + qreal x = 0.0; + qreal y = m_h * 0.5; + qreal tx = info.wh; + qreal ty = m_h * 0.5 - 2; + info.tl = QPoint( x, y ); info.ttl = QPoint( tx, ty ); info.text = "Out"; @@ -192,9 +211,9 @@ void ExpressionNode::createSlots() // Then the rest of them for( int i = 0; i < 3; i++ ) { - x = m_w - 10; + x = m_w - info.wh; y = 30 + i * 20.0; - tx = x - 5 - 25.0; + tx = x - 5 - info.tw; ty = y - 2; info.tl = QPoint( x, y ); From 594443ce3b9032184c983e1b4328a62af65e6e75 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 22:54:50 +0200 Subject: [PATCH 12/43] More refactoring. --- .../plugins/gui_editor/expression_node.cpp | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 72f77f4dd..95c2830f1 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -48,13 +48,7 @@ class NodeSlot public: NodeSlot( const NodeSlotInfo &info ) { - m_tl = info.tl; - m_ttl = info.ttl; - m_text = info.text; - - m_tw = info.tw; - m_th = info.th; - m_wh = info.wh; + m_info = info; } ~NodeSlot() @@ -63,8 +57,8 @@ public: QPointF pos() const{ QPointF p; - p.setX( m_tl.x() + m_wh / 2.0 ); - p.setY( m_tl.y() + m_wh / 2.0 ); + p.setX( m_info.tl.x() + m_info.wh / 2.0 ); + p.setY( m_info.tl.y() + m_info.wh / 2.0 ); return p; } @@ -82,27 +76,21 @@ public: QRectF box; QRectF tbox; - box.setTopLeft( m_tl ); - box.setHeight( m_wh ); - box.setWidth( m_wh ); + box.setTopLeft( m_info.tl ); + box.setHeight( m_info.wh ); + box.setWidth( m_info.wh ); painter->fillRect( box, boxBrush ); - tbox.setTopLeft( m_ttl ); - tbox.setHeight( m_th ); - tbox.setWidth( m_tw ); + tbox.setTopLeft( m_info.ttl ); + tbox.setHeight( m_info.th ); + tbox.setWidth( m_info.tw ); - painter->drawText( tbox, Qt::AlignRight, m_text ); + painter->drawText( tbox, Qt::AlignRight, m_info.text ); } private: - QPoint m_tl; - QPoint m_ttl; - QString m_text; - - qreal m_th; - qreal m_tw; - qreal m_wh; + NodeSlotInfo m_info; }; From dfe108cb828e040a8513f35fad98de46bdfce03a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 13 Sep 2014 23:54:25 +0200 Subject: [PATCH 13/43] There are more than 1 slots available now. --- .../plugins/gui_editor/expression_editor.cpp | 20 +++++++++------ .../plugins/gui_editor/expression_link.cpp | 13 ++++++---- .../src/plugins/gui_editor/expression_link.h | 4 ++- .../plugins/gui_editor/expression_node.cpp | 25 ++++++++++++++++--- .../src/plugins/gui_editor/expression_node.h | 9 ++++--- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 313af23b5..cca3b29ae 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -87,12 +87,18 @@ void ExpressionEditor::onDeleteSelection() ExpressionNode *node = dynamic_cast< ExpressionNode* >( item ); if( node != NULL ) { - ExpressionLink *link = node->link(); - if( link != NULL ) + ExpressionLink *link = NULL; + + int c = node->slotCount(); + for( int i = 0; i < c; i++ ) { - link->unlink(); - m_scene->removeItem( link ); - delete link; + link = node->link( i ); + if( link != NULL ) + { + link->unlink(); + m_scene->removeItem( link ); + delete link; + } } } @@ -113,7 +119,7 @@ void ExpressionEditor::onLinkItems() ExpressionNode *from = static_cast< ExpressionNode* >( l[ 0 ] ); ExpressionNode *to = static_cast< ExpressionNode* >( l[ 1 ] ); - if( ( from->link() != NULL ) || ( to->link() != NULL ) ) + if( ( from->link( 0 ) != NULL ) || ( to->link( 0 ) != NULL ) ) { QMessageBox::information( this, tr( "Failed to link nodes" ), @@ -122,7 +128,7 @@ void ExpressionEditor::onLinkItems() } ExpressionLink *link = new ExpressionLink(); - link->link( from, to ); + link->link( from, to, 0, 0 ); m_scene->addItem( link ); } diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 5050a9339..8e461960e 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -35,20 +35,23 @@ ExpressionLink::~ExpressionLink() unlink(); } -void ExpressionLink::link( ExpressionNode *from, ExpressionNode *to ) +void ExpressionLink::link( ExpressionNode *from, ExpressionNode *to, int fromSlot, int toSlot ) { m_from = from; m_to = to; - m_from->setLink( this ); - m_to->setLink( this ); + m_from->setLink( this, fromSlot ); + m_to->setLink( this, toSlot ); + + m_fromSlot = fromSlot; + m_toSlot = toSlot; nodeMoved(); } void ExpressionLink::unlink() { - m_from->setLink( NULL ); - m_to->setLink( NULL ); + m_from->setLink( NULL, m_fromSlot ); + m_to->setLink( NULL, m_toSlot ); } void ExpressionLink::nodeMoved() diff --git a/code/studio/src/plugins/gui_editor/expression_link.h b/code/studio/src/plugins/gui_editor/expression_link.h index 59644980a..a5235737c 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.h +++ b/code/studio/src/plugins/gui_editor/expression_link.h @@ -29,7 +29,7 @@ public: ExpressionLink( QGraphicsItem *parent = NULL ); ~ExpressionLink(); - void link( ExpressionNode *from, ExpressionNode *to ); + void link( ExpressionNode *from, ExpressionNode *to, int fromSlot, int toSlot ); void unlink(); void nodeMoved(); @@ -40,6 +40,8 @@ private: ExpressionNode *m_from; ExpressionNode *m_to; + int m_fromSlot; + int m_toSlot; }; #endif diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 95c2830f1..bcde92423 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -98,12 +98,13 @@ private: ExpressionNode::ExpressionNode( QGraphicsItem *parent ) : QGraphicsItem( parent ) { - m_link = NULL; - m_w = 100; m_h = 100; createSlots(); + + for( int i = 0; i < 4; i++ ) + m_links.push_back( NULL ); } ExpressionNode::~ExpressionNode() @@ -168,10 +169,26 @@ QPointF ExpressionNode::slotPos( int slot ) const return mp; } +void ExpressionNode::setLink( ExpressionLink *link, int slot ) +{ + m_links[ slot ] = link; +} + +ExpressionLink* ExpressionNode::link( int slot ) const +{ + return m_links[ slot ]; +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { - if( m_link != NULL ) - m_link->nodeMoved(); + for( int i = 0; i < 4; i++ ) + { + ExpressionLink *link = m_links[ i ]; + if( link == NULL ) + continue; + + link->nodeMoved(); + } QGraphicsItem::mouseMoveEvent( e ); } diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index c189bd0fc..991057731 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -35,11 +35,13 @@ public: QRectF boundingRect() const; void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); - void setLink( ExpressionLink *link ){ m_link = link; } - ExpressionLink* link() const{ return m_link; } + void setLink( ExpressionLink *link, int slot ); + ExpressionLink* link( int slot ) const; QPointF slotPos( int slot ) const; + int slotCount() const{ return m_slots.count(); } + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); @@ -47,12 +49,11 @@ private: void createSlots(); void paintSlots( QPainter *painter ); - ExpressionLink *m_link; - qreal m_w; qreal m_h; QList< NodeSlot* > m_slots; + QList< ExpressionLink* > m_links; }; #endif From 8513711d667be1c13ab05744d9d59b6208c572f8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 15:15:20 +0200 Subject: [PATCH 14/43] Improved linking --- .../src/plugins/gui_editor/CMakeLists.txt | 2 + .../src/plugins/gui_editor/expr_link_dlg.cpp | 122 ++++++++++++++++++ .../src/plugins/gui_editor/expr_link_dlg.h | 49 +++++++ .../src/plugins/gui_editor/expr_link_dlg.ui | 58 +++++++++ .../src/plugins/gui_editor/expr_slot_info.h | 32 +++++ .../plugins/gui_editor/expression_editor.cpp | 23 +++- .../plugins/gui_editor/expression_link.cpp | 8 +- .../plugins/gui_editor/expression_node.cpp | 39 ++++++ .../src/plugins/gui_editor/expression_node.h | 6 + 9 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 code/studio/src/plugins/gui_editor/expr_link_dlg.cpp create mode 100644 code/studio/src/plugins/gui_editor/expr_link_dlg.h create mode 100644 code/studio/src/plugins/gui_editor/expr_link_dlg.ui create mode 100644 code/studio/src/plugins/gui_editor/expr_slot_info.h diff --git a/code/studio/src/plugins/gui_editor/CMakeLists.txt b/code/studio/src/plugins/gui_editor/CMakeLists.txt index 77ca5a335..2b46e2cdc 100644 --- a/code/studio/src/plugins/gui_editor/CMakeLists.txt +++ b/code/studio/src/plugins/gui_editor/CMakeLists.txt @@ -35,6 +35,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR action_property_manager.h texture_property_manager.h expression_editor.h + expr_link_dlg.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -53,6 +54,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS action_list.ui texture_chooser.ui expression_editor.ui + expr_link_dlg.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp new file mode 100644 index 000000000..44cf29d74 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp @@ -0,0 +1,122 @@ +// Ryzom Core Studio - Georges 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 "expr_link_dlg.h" +#include + +ExprLinkDlg::ExprLinkDlg( 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() ) ); +} + +ExprLinkDlg::~ExprLinkDlg() +{ +} + +void ExprLinkDlg::load( const QList< SlotInfo > &a, const QList< SlotInfo > &b ) +{ + QListIterator< SlotInfo > itra( a ); + QListIterator< SlotInfo > itrb( b ); + + while( itra.hasNext() ) + { + const SlotInfo &info = itra.next(); + + QListWidgetItem *item = new QListWidgetItem(); + item->setText( info.name ); + item->setData( Qt::UserRole, info.slot ); + + m_ui.list1->addItem( item ); + } + + while( itrb.hasNext() ) + { + const SlotInfo &info = itrb.next(); + + QListWidgetItem *item = new QListWidgetItem(); + item->setText( info.name ); + item->setData( Qt::UserRole, info.slot ); + + m_ui.list2->addItem( item ); + } + +} + +int ExprLinkDlg::getSlotA() const +{ + QListWidgetItem *item = m_ui.list1->currentItem(); + if( item == NULL ) + return -1; + + int slot = item->data( Qt::UserRole ).toInt(); + return slot; +} + +int ExprLinkDlg::getSlotB() const +{ + QListWidgetItem *item = m_ui.list2->currentItem(); + if( item == NULL ) + return -1; + + int slot = item->data( Qt::UserRole ).toInt(); + return slot; +} + +void ExprLinkDlg::onOKClicked() +{ + int slotA = getSlotA(); + int slotB = getSlotB(); + + if( ( slotA == -1 ) || ( slotB == -1 ) ) + { + QMessageBox::information( this, + tr( "No slots selected" ), + tr( "You need to select a slot on both sides." ) ); + return; + } + + if( ( slotA == 0 ) && ( slotB == 0 ) ) + { + QMessageBox::information( this, + tr( "Wrong slots selected" ), + tr( "You can only select the 'Out' slot on one of the sides." ) ); + return; + } + + if( ( slotA != 0 ) && ( slotB != 0 ) ) + { + QMessageBox::information( this, + tr( "Wrong slots selected" ), + tr( "One of the slots selected must be the 'Out' slot!" ) ); + return; + } + + accept(); +} + +void ExprLinkDlg::onCancelClicked() +{ + reject(); +} + + diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.h b/code/studio/src/plugins/gui_editor/expr_link_dlg.h new file mode 100644 index 000000000..d53d528c5 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.h @@ -0,0 +1,49 @@ +// Ryzom Core Studio - Georges 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 EXPR_LINK_DLG +#define EXPR_LINK_DLG + +#include +#include +#include "ui_expr_link_dlg.h" +#include "expr_slot_info.h" + +class ExprLinkDlg : public QDialog +{ + Q_OBJECT +public: + ExprLinkDlg( QWidget *parent = NULL ); + ~ExprLinkDlg(); + + void load( const QList< SlotInfo > &a, const QList< SlotInfo > &b ); + + int getSlotA() const; + int getSlotB() const; + +private Q_SLOTS: + void onOKClicked(); + void onCancelClicked(); + +private: + Ui::ExprLinkDialog m_ui; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.ui b/code/studio/src/plugins/gui_editor/expr_link_dlg.ui new file mode 100644 index 000000000..32e610352 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.ui @@ -0,0 +1,58 @@ + + + ExprLinkDialog + + + + 0 + 0 + 581 + 388 + + + + Linking nodes + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 398 + 20 + + + + + + + + Ok + + + + + + + Cancel + + + + + + + + diff --git a/code/studio/src/plugins/gui_editor/expr_slot_info.h b/code/studio/src/plugins/gui_editor/expr_slot_info.h new file mode 100644 index 000000000..9614cd96a --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expr_slot_info.h @@ -0,0 +1,32 @@ +// Ryzom Core Studio - Georges 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 EXPR_SLOT_INFO +#define EXPR_SLOT_INFO + +#include + +struct SlotInfo +{ + QString name; + int slot; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index cca3b29ae..c4d5c1948 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -25,6 +25,7 @@ #include "expression_node.h" #include "expression_link.h" +#include "expr_link_dlg.h" #include @@ -119,16 +120,32 @@ void ExpressionEditor::onLinkItems() ExpressionNode *from = static_cast< ExpressionNode* >( l[ 0 ] ); ExpressionNode *to = static_cast< ExpressionNode* >( l[ 1 ] ); - if( ( from->link( 0 ) != NULL ) || ( to->link( 0 ) != NULL ) ) + QList< SlotInfo > froml; + QList< SlotInfo > tol; + + from->getSlots( froml ); + to->getSlots( tol ); + + // If there are no free slots, or both "Out" slots are taken we can't link + if( froml.isEmpty() || tol.isEmpty() || ( !from->slotEmpty( 0 ) && !to->slotEmpty( 0 ) ) ) { QMessageBox::information( this, tr( "Failed to link nodes" ), - tr( "Unfortunately those nodes are already linked." ) ); + tr( "Unfortunately those nodes are full." ) ); return; } + ExprLinkDlg d; + d.load( froml, tol ); + int result = d.exec(); + if( result == QDialog::Rejected ) + return; + + int slotA = d.getSlotA(); + int slotB = d.getSlotB(); + ExpressionLink *link = new ExpressionLink(); - link->link( from, to, 0, 0 ); + link->link( from, to, slotA, slotB ); m_scene->addItem( link ); } diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 8e461960e..66ddffd7f 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -50,13 +50,19 @@ void ExpressionLink::link( ExpressionNode *from, ExpressionNode *to, int fromSlo void ExpressionLink::unlink() { + if( m_from == NULL ) + return; + m_from->setLink( NULL, m_fromSlot ); m_to->setLink( NULL, m_toSlot ); + + m_from = NULL; + m_to = NULL; } void ExpressionLink::nodeMoved() { - setLine( QLineF( m_from->slotPos( 0 ), m_to->slotPos( 0 ) ) ); + setLine( QLineF( m_from->slotPos( m_fromSlot ), m_to->slotPos( m_toSlot ) ) ); } void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index bcde92423..90d132d91 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -89,6 +89,8 @@ public: painter->drawText( tbox, Qt::AlignRight, m_info.text ); } + QString text() const{ return m_info.text; } + private: NodeSlotInfo m_info; }; @@ -109,6 +111,8 @@ QGraphicsItem( parent ) ExpressionNode::~ExpressionNode() { + clearLinks(); + qDeleteAll( m_slots ); m_slots.clear(); } @@ -169,6 +173,29 @@ QPointF ExpressionNode::slotPos( int slot ) const return mp; } +bool ExpressionNode::slotEmpty( int slot ) const +{ + if( m_links[ 0 ] == NULL ) + return true; + else + return false; +} + +void ExpressionNode::getSlots( QList< SlotInfo > &l ) +{ + SlotInfo info; + + for( int i = 0; i < m_slots.count(); i++ ) + { + if( m_links[ i ] != NULL ) + continue; + + info.name = m_slots[ i ]->text(); + info.slot = i; + l.push_back( info ); + } +} + void ExpressionNode::setLink( ExpressionLink *link, int slot ) { m_links[ slot ] = link; @@ -239,3 +266,15 @@ void ExpressionNode::paintSlots( QPainter *painter ) } +void ExpressionNode::clearLinks() +{ + for( int i = 0; i < m_links.count(); i++ ) + { + ExpressionLink *link = m_links[ i ]; + if( link == NULL ) + continue; + + link->unlink(); + } +} + diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 991057731..704804b55 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -22,6 +22,7 @@ #include #include +#include "expr_slot_info.h" class ExpressionLink; class NodeSlot; @@ -42,12 +43,17 @@ public: int slotCount() const{ return m_slots.count(); } + bool slotEmpty( int slot ) const; + + void getSlots( QList< SlotInfo > &l ); + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); private: void createSlots(); void paintSlots( QPainter *painter ); + void clearLinks(); qreal m_w; qreal m_h; From 624578c02469d1b426bee80969cdfd1f2ced1db2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 15:36:41 +0200 Subject: [PATCH 15/43] Added unlinking support. --- .../plugins/gui_editor/expression_editor.cpp | 17 +++++++++++++++++ .../src/plugins/gui_editor/expression_editor.h | 1 + .../src/plugins/gui_editor/expression_link.cpp | 2 ++ .../src/plugins/gui_editor/expression_node.h | 3 ++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index c4d5c1948..1c4a1ecda 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -65,6 +65,9 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Link" ); connect( a, SIGNAL( triggered() ), this, SLOT( onLinkItems() ) ); } + + a = menu.addAction( "Unlink" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onUnLinkItems() ) ); } menu.exec( e->globalPos() ); @@ -150,4 +153,18 @@ void ExpressionEditor::onLinkItems() m_scene->addItem( link ); } +void ExpressionEditor::onUnLinkItems() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + + for( int i = 0; i < l.count(); i++ ) + { + ExpressionNode *node = dynamic_cast< ExpressionNode* >( l[ i ] ); + if( node == NULL ) + continue; + + node->clearLinks(); + } +} + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 70d2ad572..00d347993 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -39,6 +39,7 @@ private Q_SLOTS: void onDeleteSelection(); void onSelectionChanged(); void onLinkItems(); + void onUnLinkItems(); private: diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 66ddffd7f..537d4891f 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -58,6 +58,8 @@ void ExpressionLink::unlink() m_from = NULL; m_to = NULL; + + delete this; } void ExpressionLink::nodeMoved() diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 704804b55..4fb92cbf4 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -47,13 +47,14 @@ public: void getSlots( QList< SlotInfo > &l ); + void clearLinks(); + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); private: void createSlots(); void paintSlots( QPainter *painter ); - void clearLinks(); qreal m_w; qreal m_h; From 892ca16ae3c719419d6cf9ffd3440ba3e31859cd Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 16:37:17 +0200 Subject: [PATCH 16/43] Support for adding nodes with different slot count. --- .../plugins/gui_editor/expression_editor.cpp | 39 ++++++++++++++----- .../plugins/gui_editor/expression_editor.h | 4 +- .../plugins/gui_editor/expression_node.cpp | 19 +++++---- .../src/plugins/gui_editor/expression_node.h | 2 +- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 1c4a1ecda..14bf69600 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -52,8 +52,15 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) QMenu menu; QAction *a = NULL; - a = menu.addAction( "Add rect" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) ); + QMenu *mm = menu.addMenu( "Add node" ); + a = mm->addAction( "1 slot" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode1() ) ); + + a = mm->addAction( "2 slots" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode2() ) ); + + a = mm->addAction( "3 slots" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode3() ) ); if( m_selectionCount > 0 ) { @@ -73,13 +80,6 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) menu.exec( e->globalPos() ); } -void ExpressionEditor::onAddRect() -{ - QGraphicsItem *item = new ExpressionNode(); - item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); - m_scene->addItem( item ); -} - void ExpressionEditor::onDeleteSelection() { QList< QGraphicsItem* > l = m_scene->selectedItems(); @@ -168,3 +168,24 @@ void ExpressionEditor::onUnLinkItems() } +void ExpressionEditor::onAddNode1() +{ + QGraphicsItem *item = new ExpressionNode( 1 ); + item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_scene->addItem( item ); +} + +void ExpressionEditor::onAddNode2() +{ + QGraphicsItem *item = new ExpressionNode( 2 ); + item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_scene->addItem( item ); +} + +void ExpressionEditor::onAddNode3() +{ + QGraphicsItem *item = new ExpressionNode( 3 ); + item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_scene->addItem( item ); +} + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 00d347993..2346f42cf 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -35,11 +35,13 @@ protected: void contextMenuEvent( QContextMenuEvent *e ); private Q_SLOTS: - void onAddRect(); void onDeleteSelection(); void onSelectionChanged(); void onLinkItems(); void onUnLinkItems(); + void onAddNode1(); + void onAddNode2(); + void onAddNode3(); private: diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 90d132d91..049acfbb9 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -97,16 +97,19 @@ private: -ExpressionNode::ExpressionNode( QGraphicsItem *parent ) : +ExpressionNode::ExpressionNode( int nodes, QGraphicsItem *parent ) : QGraphicsItem( parent ) { m_w = 100; m_h = 100; - createSlots(); + // Out nodes + m_links.push_back( NULL ); - for( int i = 0; i < 4; i++ ) + for( int i = 0; i < nodes; i++ ) m_links.push_back( NULL ); + + createSlots(); } ExpressionNode::~ExpressionNode() @@ -208,7 +211,7 @@ ExpressionLink* ExpressionNode::link( int slot ) const void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { - for( int i = 0; i < 4; i++ ) + for( int i = 0; i < m_links.count(); i++ ) { ExpressionLink *link = m_links[ i ]; if( link == NULL ) @@ -222,8 +225,9 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) void ExpressionNode::createSlots() { - // First create the "Out" slot + int nodes = m_links.count(); + // First create the "Out" slot NodeSlotInfo info; info.tw = 25.0; info.th = 12.0; @@ -239,9 +243,10 @@ void ExpressionNode::createSlots() info.text = "Out"; m_slots.push_back( new NodeSlot( info ) ); + nodes--; // Then the rest of them - for( int i = 0; i < 3; i++ ) + for( int i = 0; i < nodes; i++ ) { x = m_w - info.wh; y = 30 + i * 20.0; @@ -258,7 +263,7 @@ void ExpressionNode::createSlots() void ExpressionNode::paintSlots( QPainter *painter ) { - for( int i = 0; i < 4; i++ ) + for( int i = 0; i < m_slots.count(); i++ ) { NodeSlot *slot = m_slots[ i ]; slot->paint( painter ); diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 4fb92cbf4..efecea818 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -30,7 +30,7 @@ class NodeSlot; class ExpressionNode : public QGraphicsItem { public: - ExpressionNode( QGraphicsItem *parent = NULL ); + ExpressionNode( int nodes = 3, QGraphicsItem *parent = NULL ); ~ExpressionNode(); QRectF boundingRect() const; From eb70ac61990ac2016d8fc407b06e18b33963d7c2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 16:43:45 +0200 Subject: [PATCH 17/43] A little refactoring. --- .../plugins/gui_editor/expression_editor.cpp | 18 ++++++++-------- .../plugins/gui_editor/expression_editor.h | 1 + .../plugins/gui_editor/expression_node.cpp | 21 ++++++++----------- .../src/plugins/gui_editor/expression_node.h | 4 ++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 14bf69600..c821ceb6d 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -167,25 +167,25 @@ void ExpressionEditor::onUnLinkItems() } } +void ExpressionEditor::addNode( int slotCount ) +{ + QGraphicsItem *item = new ExpressionNode( slotCount ); + item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_scene->addItem( item ); +} void ExpressionEditor::onAddNode1() { - QGraphicsItem *item = new ExpressionNode( 1 ); - item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); - m_scene->addItem( item ); + addNode( 1 ); } void ExpressionEditor::onAddNode2() { - QGraphicsItem *item = new ExpressionNode( 2 ); - item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); - m_scene->addItem( item ); + addNode( 2 ); } void ExpressionEditor::onAddNode3() { - QGraphicsItem *item = new ExpressionNode( 3 ); - item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); - m_scene->addItem( item ); + addNode( 3 ); } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 2346f42cf..91bb5d851 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -39,6 +39,7 @@ private Q_SLOTS: void onSelectionChanged(); void onLinkItems(); void onUnLinkItems(); + void addNode( int slotCount ); void onAddNode1(); void onAddNode2(); void onAddNode3(); diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 049acfbb9..86469314a 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -97,19 +97,13 @@ private: -ExpressionNode::ExpressionNode( int nodes, QGraphicsItem *parent ) : +ExpressionNode::ExpressionNode( int slotCount, QGraphicsItem *parent ) : QGraphicsItem( parent ) { m_w = 100; m_h = 100; - // Out nodes - m_links.push_back( NULL ); - - for( int i = 0; i < nodes; i++ ) - m_links.push_back( NULL ); - - createSlots(); + createSlots( slotCount ); } ExpressionNode::~ExpressionNode() @@ -223,10 +217,14 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) QGraphicsItem::mouseMoveEvent( e ); } -void ExpressionNode::createSlots() +void ExpressionNode::createSlots( int count) { - int nodes = m_links.count(); + // Out nodes + m_links.push_back( NULL ); + for( int i = 0; i < count; i++ ) + m_links.push_back( NULL ); + // First create the "Out" slot NodeSlotInfo info; info.tw = 25.0; @@ -243,10 +241,9 @@ void ExpressionNode::createSlots() info.text = "Out"; m_slots.push_back( new NodeSlot( info ) ); - nodes--; // Then the rest of them - for( int i = 0; i < nodes; i++ ) + for( int i = 0; i < count; i++ ) { x = m_w - info.wh; y = 30 + i * 20.0; diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index efecea818..654329dd5 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -30,7 +30,7 @@ class NodeSlot; class ExpressionNode : public QGraphicsItem { public: - ExpressionNode( int nodes = 3, QGraphicsItem *parent = NULL ); + ExpressionNode( int slotCount = 3, QGraphicsItem *parent = NULL ); ~ExpressionNode(); QRectF boundingRect() const; @@ -53,7 +53,7 @@ protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); private: - void createSlots(); + void createSlots( int count = 3 ); void paintSlots( QPainter *painter ); qreal m_w; From c404e0e59055b942762c7907836858ad09e22a2d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 16:57:56 +0200 Subject: [PATCH 18/43] Allow painting of arbitrary number of connection slots. --- code/studio/src/plugins/gui_editor/expression_node.cpp | 6 +++++- code/studio/src/plugins/gui_editor/expression_node.h | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 86469314a..c12ca3ea5 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -102,6 +102,10 @@ QGraphicsItem( parent ) { m_w = 100; m_h = 100; + m_hh = 20.0; + + if( slotCount > 3 ) + m_h = m_h + 20.0 * ( slotCount - 3 ); createSlots( slotCount ); } @@ -128,7 +132,7 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o QRectF rect = boundingRect(); QRectF header = rect; - header.setHeight( header.height() * 0.2 ); + header.setHeight( m_hh ); // Draw filled rectangle, header c.setRed( 44 ); diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 654329dd5..6df38d583 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -56,8 +56,9 @@ private: void createSlots( int count = 3 ); void paintSlots( QPainter *painter ); - qreal m_w; - qreal m_h; + qreal m_w; // node width + qreal m_h; // node height + qreal m_hh; // header height QList< NodeSlot* > m_slots; QList< ExpressionLink* > m_links; From e37394ae207354e798edd8643620300ae1925bdf Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 17:04:42 +0200 Subject: [PATCH 19/43] Add serial number to nodes. --- code/studio/src/plugins/gui_editor/expression_editor.cpp | 9 ++++++++- code/studio/src/plugins/gui_editor/expression_editor.h | 1 + code/studio/src/plugins/gui_editor/expression_node.cpp | 6 ++++-- code/studio/src/plugins/gui_editor/expression_node.h | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index c821ceb6d..dc164d361 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -40,6 +40,8 @@ QWidget( parent ) m_ui.view->setScene( m_scene ); connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); + + m_nodeCount = 0; } ExpressionEditor::~ExpressionEditor() @@ -169,7 +171,12 @@ void ExpressionEditor::onUnLinkItems() void ExpressionEditor::addNode( int slotCount ) { - QGraphicsItem *item = new ExpressionNode( slotCount ); + QString name; + name = "node #"; + name += QString::number( m_nodeCount ); + m_nodeCount++; + + QGraphicsItem *item = new ExpressionNode( name, slotCount ); item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); m_scene->addItem( item ); } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 91bb5d851..553f8efd3 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -50,6 +50,7 @@ private: QGraphicsScene *m_scene; int m_selectionCount; + int m_nodeCount; }; #endif diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index c12ca3ea5..3098c6290 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -97,13 +97,15 @@ private: -ExpressionNode::ExpressionNode( int slotCount, QGraphicsItem *parent ) : +ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) : QGraphicsItem( parent ) { m_w = 100; m_h = 100; m_hh = 20.0; + m_name = name; + if( slotCount > 3 ) m_h = m_h + 20.0 * ( slotCount - 3 ); @@ -147,7 +149,7 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o // Draw header text p.setColor( Qt::black ); painter->setPen( p ); - painter->drawText( header, Qt::AlignCenter, "Something" ); + painter->drawText( header, Qt::AlignCenter, m_name ); if( option->state & QStyle::State_Selected ) { diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 6df38d583..0b7242f5d 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -30,7 +30,7 @@ class NodeSlot; class ExpressionNode : public QGraphicsItem { public: - ExpressionNode( int slotCount = 3, QGraphicsItem *parent = NULL ); + ExpressionNode( const QString &name, int slotCount = 3, QGraphicsItem *parent = NULL ); ~ExpressionNode(); QRectF boundingRect() const; @@ -62,6 +62,8 @@ private: QList< NodeSlot* > m_slots; QList< ExpressionLink* > m_links; + + QString m_name; }; #endif From 1b913a76c1d6190620b5a5fe7d95eab62d652c3f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 17:19:11 +0200 Subject: [PATCH 20/43] Show the node names as title, in the link dialog. --- .../src/plugins/gui_editor/expr_link_dlg.cpp | 4 ++- .../src/plugins/gui_editor/expr_link_dlg.h | 2 +- .../src/plugins/gui_editor/expr_link_dlg.ui | 28 +++++++++++++++---- .../plugins/gui_editor/expression_editor.cpp | 2 +- .../src/plugins/gui_editor/expression_node.h | 2 ++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp index 44cf29d74..9a91e5f21 100644 --- a/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp @@ -33,7 +33,7 @@ ExprLinkDlg::~ExprLinkDlg() { } -void ExprLinkDlg::load( const QList< SlotInfo > &a, const QList< SlotInfo > &b ) +void ExprLinkDlg::load( const QList< SlotInfo > &a, const QList< SlotInfo > &b, const QString &aname, const QString &bname ) { QListIterator< SlotInfo > itra( a ); QListIterator< SlotInfo > itrb( b ); @@ -60,6 +60,8 @@ void ExprLinkDlg::load( const QList< SlotInfo > &a, const QList< SlotInfo > &b ) m_ui.list2->addItem( item ); } + m_ui.groupBox1->setTitle( aname ); + m_ui.groupBox2->setTitle( bname ); } int ExprLinkDlg::getSlotA() const diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.h b/code/studio/src/plugins/gui_editor/expr_link_dlg.h index d53d528c5..267787cf3 100644 --- a/code/studio/src/plugins/gui_editor/expr_link_dlg.h +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.h @@ -32,7 +32,7 @@ public: ExprLinkDlg( QWidget *parent = NULL ); ~ExprLinkDlg(); - void load( const QList< SlotInfo > &a, const QList< SlotInfo > &b ); + void load( const QList< SlotInfo > &a, const QList< SlotInfo > &b, const QString &aname, const QString &bname ); int getSlotA() const; int getSlotB() const; diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.ui b/code/studio/src/plugins/gui_editor/expr_link_dlg.ui index 32e610352..d6fdf9d7d 100644 --- a/code/studio/src/plugins/gui_editor/expr_link_dlg.ui +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.ui @@ -6,21 +6,39 @@ 0 0 - 581 - 388 + 641 + 334 Linking nodes - + - + + + GroupBox + + + + + + + - + + + GroupBox + + + + + + + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index dc164d361..62e034255 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -141,7 +141,7 @@ void ExpressionEditor::onLinkItems() } ExprLinkDlg d; - d.load( froml, tol ); + d.load( froml, tol, from->name(), to->name() ); int result = d.exec(); if( result == QDialog::Rejected ) return; diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 0b7242f5d..7d236475a 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -49,6 +49,8 @@ public: void clearLinks(); + QString name() const{ return m_name; } + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); From 79e205c6d83daa6c855c52806c5d213f09f97df8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 21:00:40 +0200 Subject: [PATCH 21/43] Expression Editor is now a QMainWindow subclass. Also added an expression tree, with some sample nodes. --- .../plugins/gui_editor/expression_editor.cpp | 28 +++-- .../plugins/gui_editor/expression_editor.h | 5 +- .../plugins/gui_editor/expression_editor.ui | 107 +++++++++++++++--- 3 files changed, 110 insertions(+), 30 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 62e034255..54f878afa 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -30,16 +30,17 @@ #include ExpressionEditor::ExpressionEditor( QWidget *parent ) : -QWidget( parent ) +QMainWindow( parent ) { m_ui.setupUi( this ); - + m_selectionCount = 0; m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect( m_ui.tree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) ); m_nodeCount = 0; } @@ -169,30 +170,37 @@ void ExpressionEditor::onUnLinkItems() } } -void ExpressionEditor::addNode( int slotCount ) +void ExpressionEditor::addNode( const QString &name, int slotCount ) { - QString name; - name = "node #"; - name += QString::number( m_nodeCount ); + QString n = name; + n += " #"; + n += QString::number( m_nodeCount ); m_nodeCount++; - QGraphicsItem *item = new ExpressionNode( name, slotCount ); + QGraphicsItem *item = new ExpressionNode( n, slotCount ); item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); m_scene->addItem( item ); } void ExpressionEditor::onAddNode1() { - addNode( 1 ); + addNode( "node", 1 ); } void ExpressionEditor::onAddNode2() { - addNode( 2 ); + addNode( "node", 2 ); } void ExpressionEditor::onAddNode3() { - addNode( 3 ); + addNode( "node", 3 ); } +void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) +{ + QString name = item->text( 0 ); + addNode( name, 3 ); +} + + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 553f8efd3..5b17d091d 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -24,7 +24,7 @@ class QGraphicsScene; -class ExpressionEditor : public QWidget +class ExpressionEditor : public QMainWindow { Q_OBJECT public: @@ -39,10 +39,11 @@ private Q_SLOTS: void onSelectionChanged(); void onLinkItems(); void onUnLinkItems(); - void addNode( int slotCount ); + void addNode( const QString &name, int slotCount ); void onAddNode1(); void onAddNode2(); void onAddNode3(); + void onItemDblClicked( QTreeWidgetItem *item ); private: diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui index 80480ad39..db71014bf 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.ui +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -1,33 +1,104 @@ ExpressionEditor - - - Qt::ApplicationModal - + 0 0 - 724 - 522 + 800 + 600 Expression Editor - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOn - - - - + + + + + + + + + + + 0 + 0 + 800 + 21 + + + + + + + 1 + + + + + + + + Expressions + + + + + Logical + + + + and + + + + + or + + + + + + Mathematical + + + + add + + + + + sub + + + + + + Value + + + + integer + + + + + string + + + + + boolean + + + + + + + + From 8314fd5c6b5c7127d578ceded23d17a74e745e34 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 15 Sep 2014 01:25:01 +0200 Subject: [PATCH 22/43] Slot count can now be changed. --- .../plugins/gui_editor/expression_editor.cpp | 25 ++++++++++++++++++ .../plugins/gui_editor/expression_editor.h | 1 + .../plugins/gui_editor/expression_node.cpp | 26 ++++++++++++++++--- .../src/plugins/gui_editor/expression_node.h | 2 ++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 54f878afa..45cd9c2d6 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -28,6 +28,7 @@ #include "expr_link_dlg.h" #include +#include ExpressionEditor::ExpressionEditor( QWidget *parent ) : QMainWindow( parent ) @@ -70,6 +71,12 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Remove" ); connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) ); + if( m_selectionCount == 1 ) + { + a = menu.addAction( "Change slot count" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); + } + else if( m_selectionCount == 2 ) { a = menu.addAction( "Link" ); @@ -203,4 +210,22 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) addNode( name, 3 ); } +void ExpressionEditor::onChangeSlotCount() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + ExpressionNode *node = static_cast< ExpressionNode* >( l[ 0 ] ); + int oldc = node->slotCount(); + + int c = QInputDialog::getInt( this, + tr( "Change slot count" ), + tr( "Enter new slot count" ), + oldc, + 1, + 26 ); + + if( oldc == c ) + return; + + node->changeSlotCount( c ); +} diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 5b17d091d..26493b8a0 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -44,6 +44,7 @@ private Q_SLOTS: void onAddNode2(); void onAddNode3(); void onItemDblClicked( QTreeWidgetItem *item ); + void onChangeSlotCount(); private: diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 3098c6290..026857ee3 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -115,9 +115,7 @@ QGraphicsItem( parent ) ExpressionNode::~ExpressionNode() { clearLinks(); - - qDeleteAll( m_slots ); - m_slots.clear(); + clearSlots(); } QRectF ExpressionNode::boundingRect() const @@ -176,6 +174,28 @@ QPointF ExpressionNode::slotPos( int slot ) const return mp; } +void ExpressionNode::changeSlotCount( int count ) +{ + clearSlots(); + clearLinks(); + m_links.clear(); + + if( count <= 3 ) + m_h = 100.0; + else + m_h = 100.0 + 20.0 * ( count - 3 ); + + createSlots( count ); + + update(); +} + +void ExpressionNode::clearSlots() +{ + qDeleteAll( m_slots ); + m_slots.clear(); +} + bool ExpressionNode::slotEmpty( int slot ) const { if( m_links[ 0 ] == NULL ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 7d236475a..cf49c212f 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -42,6 +42,8 @@ public: QPointF slotPos( int slot ) const; int slotCount() const{ return m_slots.count(); } + void changeSlotCount( int count ); + void clearSlots(); bool slotEmpty( int slot ) const; From 8b0f7ddeaf7b5e09c9ee818299dfb8d09276af19 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 02:32:10 +0200 Subject: [PATCH 23/43] Parse expression files, and build the expression tree from the expressions parsed from these files. --- .../plugins/gui_editor/expression_editor.cpp | 56 +++++ .../plugins/gui_editor/expression_editor.h | 8 + .../plugins/gui_editor/expression_editor.ui | 50 ----- .../src/plugins/gui_editor/expression_info.h | 34 +++ .../plugins/gui_editor/expression_loader.cpp | 203 ++++++++++++++++++ .../plugins/gui_editor/expression_loader.h | 39 ++++ .../plugins/gui_editor/expression_store.cpp | 105 +++++++++ .../src/plugins/gui_editor/expression_store.h | 46 ++++ .../plugins/gui_editor/gui_editor_window.cpp | 1 + 9 files changed, 492 insertions(+), 50 deletions(-) create mode 100644 code/studio/src/plugins/gui_editor/expression_info.h create mode 100644 code/studio/src/plugins/gui_editor/expression_loader.cpp create mode 100644 code/studio/src/plugins/gui_editor/expression_loader.h create mode 100644 code/studio/src/plugins/gui_editor/expression_store.cpp create mode 100644 code/studio/src/plugins/gui_editor/expression_store.h diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 45cd9c2d6..773191afc 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -26,14 +26,24 @@ #include "expression_node.h" #include "expression_link.h" #include "expr_link_dlg.h" +#include "expression_store.h" +#include "expression_info.h" #include #include +class ExpressionEditorPvt +{ +public: + ExpressionStore store; +}; + ExpressionEditor::ExpressionEditor( QWidget *parent ) : QMainWindow( parent ) { m_ui.setupUi( this ); + + m_pvt = new ExpressionEditorPvt(); m_selectionCount = 0; @@ -48,9 +58,27 @@ QMainWindow( parent ) ExpressionEditor::~ExpressionEditor() { + delete m_pvt; + m_pvt = NULL; m_scene = NULL; } +void ExpressionEditor::load() +{ + m_pvt->store.load(); + + QList< const ExpressionInfo* > l; + m_pvt->store.getExpressions( l ); + + QListIterator< const ExpressionInfo* > itr( l ); + while( itr.hasNext() ) + { + addExpression( itr.next() ); + } + + l.clear(); +} + void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) { QMenu menu; @@ -229,3 +257,31 @@ void ExpressionEditor::onChangeSlotCount() node->changeSlotCount( c ); } +void ExpressionEditor::addExpression( const ExpressionInfo *info ) +{ + QTreeWidgetItem *item = findTopLevelItem( info->category ); + if( item == NULL ) + { + item = new QTreeWidgetItem(); + item->setText( 0, info->category ); + m_ui.tree->addTopLevelItem( item ); + } + + QTreeWidgetItem *citem = new QTreeWidgetItem(); + citem->setText( 0, info->name ); + item->addChild( citem ); +} + +QTreeWidgetItem* ExpressionEditor::findTopLevelItem( const QString &text ) +{ + int c = m_ui.tree->topLevelItemCount(); + for( int i = 0; i < c; i++ ) + { + QTreeWidgetItem *item = m_ui.tree->topLevelItem( i ); + if( item->text( 0 ) == text ) + return item; + } + + return NULL; +} + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 26493b8a0..21f247249 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -23,6 +23,8 @@ #include "ui_expression_editor.h" class QGraphicsScene; +class ExpressionEditorPvt; +class ExpressionInfo; class ExpressionEditor : public QMainWindow { @@ -31,6 +33,8 @@ public: ExpressionEditor( QWidget *parent = NULL ); ~ExpressionEditor(); + void load(); + protected: void contextMenuEvent( QContextMenuEvent *e ); @@ -47,12 +51,16 @@ private Q_SLOTS: void onChangeSlotCount(); private: + void addExpression( const ExpressionInfo *info ); + QTreeWidgetItem* findTopLevelItem( const QString &text ); Ui::ExpressionEditor m_ui; QGraphicsScene *m_scene; int m_selectionCount; int m_nodeCount; + + ExpressionEditorPvt *m_pvt; }; #endif diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui index db71014bf..342b2b5f1 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.ui +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -44,56 +44,6 @@ Expressions - - - Logical - - - - and - - - - - or - - - - - - Mathematical - - - - add - - - - - sub - - - - - - Value - - - - integer - - - - - string - - - - - boolean - - - diff --git a/code/studio/src/plugins/gui_editor/expression_info.h b/code/studio/src/plugins/gui_editor/expression_info.h new file mode 100644 index 000000000..854ea12c1 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_info.h @@ -0,0 +1,34 @@ +// 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 EXPRESSION_INFO +#define EXPRESSION_INFO + +#include +#include + +struct ExpressionInfo +{ + QString name; + QString category; + bool variable; + QStringList slotNames; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expression_loader.cpp b/code/studio/src/plugins/gui_editor/expression_loader.cpp new file mode 100644 index 000000000..ee3346a0c --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_loader.cpp @@ -0,0 +1,203 @@ +// 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 "expression_loader.h" +#include "expression_info.h" + +#include +#include + +class ExpressionLoaderPvt +{ +public: + + bool parseName() + { + QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + if( reader.hasError() ) + return false; + + m_info->name = text; + + return true; + } + + bool parseCategory() + { + QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + if( reader.hasError() ) + return false; + + m_info->category = text; + + return true; + } + + bool parseVariable() + { + QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + if( reader.hasError() ) + return false; + + if( text.toLower() == "true" ) + m_info->variable = true; + else + m_info->variable = false; + + return true; + } + + bool parseSlot() + { + QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + if( reader.hasError() ) + return false; + + m_info->slotNames.push_back( text ); + + return true; + } + + bool parseSlots() + { + bool error = false; + + while( !reader.atEnd() ) + { + reader.readNext(); + + if( reader.isStartElement() ) + { + QString name = reader.name().toString(); + if( name == "slot" ) + error = !parseSlot(); + } + else + if( reader.isEndElement() ) + { + if( reader.name() == "slots" ) + break; + } + } + + if( reader.atEnd() ) + return false; + + return true; + } + + bool load( QFile *f ) + { + reader.clear(); + reader.setDevice( f ); + + bool error = false; + + // start of document + reader.readNext(); + if( reader.atEnd() ) + return false; + + // root node + reader.readNext(); + if( reader.atEnd() ) + return false; + + if( reader.isStartElement() ) + { + // Not an expression file? + if( reader.name() != "expression" ) + return false; + } + + while( !reader.atEnd() ) + { + reader.readNext(); + + if( reader.isStartElement() ) + { + QString name = reader.name().toString(); + + if( name == "name" ) + error = !parseName(); + else + if( name == "category" ) + error = !parseCategory(); + else + if( name == "variable" ) + error = !parseVariable(); + else + if( name == "slots" ) + error = !parseSlots(); + } + + if( error ) + break; + } + + if( error || reader.hasError() ) + { + return false; + } + + return true; + } + + void setInfo( ExpressionInfo *info ){ m_info = info; } + +private: + QXmlStreamReader reader; + ExpressionInfo *m_info; +}; + +ExpressionLoader::ExpressionLoader() +{ + m_pvt = new ExpressionLoaderPvt; +} + +ExpressionLoader::~ExpressionLoader() +{ + delete m_pvt; + m_pvt = NULL; +} + +ExpressionInfo* ExpressionLoader::load( const QString &filename ) +{ + ExpressionInfo *info = NULL; + bool ok = false; + + QFile f( filename ); + if( !f.open( QIODevice::ReadOnly | QIODevice::Text ) ) + return NULL; + + info = new ExpressionInfo(); + m_pvt->setInfo( info ); + ok = m_pvt->load( &f ); + + f.close(); + + if( !ok ) + { + delete info; + info = NULL; + } + + return info; +} + + diff --git a/code/studio/src/plugins/gui_editor/expression_loader.h b/code/studio/src/plugins/gui_editor/expression_loader.h new file mode 100644 index 000000000..f315fcdcd --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_loader.h @@ -0,0 +1,39 @@ +// 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 EXPRESSION_LOADER +#define EXPRESSION_LOADER + +struct ExpressionInfo; +class QString; +class ExpressionLoaderPvt; + +class ExpressionLoader +{ +public: + ExpressionLoader(); + ~ExpressionLoader(); + + ExpressionInfo* load( const QString &filename ); + +private: + ExpressionLoaderPvt *m_pvt; +}; + +#endif + diff --git a/code/studio/src/plugins/gui_editor/expression_store.cpp b/code/studio/src/plugins/gui_editor/expression_store.cpp new file mode 100644 index 000000000..9f2218b4e --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_store.cpp @@ -0,0 +1,105 @@ +// 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 "expression_store.h" +#include "expression_info.h" +#include "expression_loader.h" +#include +#include + +class ExpressionStorePvt +{ +public: + + ~ExpressionStorePvt() + { + qDeleteAll( expressions ); + expressions.clear(); + } + + + QMap< QString, ExpressionInfo* > expressions; +}; + +ExpressionStore::ExpressionStore() +{ + m_pvt = new ExpressionStorePvt(); +} + +ExpressionStore::~ExpressionStore() +{ + delete m_pvt; + m_pvt = NULL; +} + + +bool ExpressionStore::load() +{ + QDir d( "expressions" ); + if( !d.exists() ) + return false; + + QFileInfoList l = d.entryInfoList(); + QListIterator< QFileInfo > itr( l ); + if( !itr.hasNext() ) + return false; + + ExpressionLoader loader; + + while( itr.hasNext() ) + { + const QFileInfo &info = itr.next(); + if( !info.isFile() ) + continue; + + if( info.suffix() != "xml" ) + continue; + + ExpressionInfo *expr = loader.load( info.absoluteFilePath() ); + if( expr == NULL ) + continue; + + m_pvt->expressions[ expr->name ] = expr; + } + + return false; +} + +void ExpressionStore::getExpressions( QList< const ExpressionInfo* > &l ) const +{ + l.clear(); + + QMap< QString, ExpressionInfo* >::const_iterator itr = m_pvt->expressions.constBegin(); + while( itr != m_pvt->expressions.constEnd() ) + { + l.push_back( itr.value() ); + ++itr; + } +} + +const ExpressionInfo* ExpressionStore::getInfo( const QString &name ) +{ + QMap< QString, ExpressionInfo* >::const_iterator itr = m_pvt->expressions.find( name ); + if( itr == m_pvt->expressions.end() ) + return NULL; + else + return itr.value(); +} + + + diff --git a/code/studio/src/plugins/gui_editor/expression_store.h b/code/studio/src/plugins/gui_editor/expression_store.h new file mode 100644 index 000000000..9c29fa0f6 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_store.h @@ -0,0 +1,46 @@ +// 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 EXPRESSION_STORE +#define EXPRESSION_STORE + +#include +#include +#include "expression_info.h" + +//struct ExpressionInfo; +class ExpressionStorePvt; + +class ExpressionStore +{ +public: + ExpressionStore(); + ~ExpressionStore(); + + bool load(); + + void getExpressions( QList< const ExpressionInfo* > &l ) const; + + const ExpressionInfo* getInfo( const QString &name ); + +private: + ExpressionStorePvt *m_pvt; +}; + +#endif + 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 f6adacc8a..2447ac0af 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -75,6 +75,7 @@ namespace GUIEditor tc = new TextureChooser(); ee = new ExpressionEditor(); + ee->load(); createMenus(); readSettings(); From cce83f371d846918cd7d53ae03d08ec43291b222 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 03:38:21 +0200 Subject: [PATCH 24/43] Set the number of slots and their names from the data loaded from XMLs. --- .../plugins/gui_editor/expression_editor.cpp | 34 +++++-------------- .../plugins/gui_editor/expression_editor.h | 5 +-- .../plugins/gui_editor/expression_node.cpp | 11 ++++++ .../src/plugins/gui_editor/expression_node.h | 2 ++ 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 773191afc..81bd22373 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -205,37 +205,21 @@ void ExpressionEditor::onUnLinkItems() } } -void ExpressionEditor::addNode( const QString &name, int slotCount ) +void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) { + QString name = item->text( 0 ); + + const ExpressionInfo *info = m_pvt->store.getInfo( name ); + QString n = name; n += " #"; n += QString::number( m_nodeCount ); m_nodeCount++; - QGraphicsItem *item = new ExpressionNode( n, slotCount ); - item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); - m_scene->addItem( item ); -} - -void ExpressionEditor::onAddNode1() -{ - addNode( "node", 1 ); -} - -void ExpressionEditor::onAddNode2() -{ - addNode( "node", 2 ); -} - -void ExpressionEditor::onAddNode3() -{ - addNode( "node", 3 ); -} - -void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) -{ - QString name = item->text( 0 ); - addNode( name, 3 ); + ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() ); + node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + node->setSlotNames( info->slotNames ); + m_scene->addItem( node ); } void ExpressionEditor::onChangeSlotCount() diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 21f247249..79ff908f1 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -23,6 +23,7 @@ #include "ui_expression_editor.h" class QGraphicsScene; +class QGraphicsItem; class ExpressionEditorPvt; class ExpressionInfo; @@ -43,10 +44,6 @@ private Q_SLOTS: void onSelectionChanged(); void onLinkItems(); void onUnLinkItems(); - void addNode( const QString &name, int slotCount ); - void onAddNode1(); - void onAddNode2(); - void onAddNode3(); void onItemDblClicked( QTreeWidgetItem *item ); void onChangeSlotCount(); diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 026857ee3..bb2eb451f 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -90,6 +90,7 @@ public: } QString text() const{ return m_info.text; } + void setText( const QString &text ){ m_info.text = text; } private: NodeSlotInfo m_info; @@ -229,6 +230,16 @@ ExpressionLink* ExpressionNode::link( int slot ) const return m_links[ slot ]; } +void ExpressionNode::setSlotNames( const QList< QString > &l ) +{ + int c = l.count(); + for( int i = 0; i < c; i++ ) + { + // "Out" slot is at position 0, so set the names with an offset of 1 + m_slots[ i + 1 ]->setText( l[ i ] ); + } +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { for( int i = 0; i < m_links.count(); i++ ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index cf49c212f..e43e717bb 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -53,6 +53,8 @@ public: QString name() const{ return m_name; } + void setSlotNames( const QList< QString > &l ); + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); From 52fa0b4fa9650683820e4173dc1a4a548b9e671d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 03:45:26 +0200 Subject: [PATCH 25/43] Only allow variable nodes to have their number of slots changed. --- .../plugins/gui_editor/expression_editor.cpp | 22 +++++++++---------- .../plugins/gui_editor/expression_node.cpp | 2 ++ .../src/plugins/gui_editor/expression_node.h | 5 +++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 81bd22373..df83a6732 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -84,15 +84,6 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) QMenu menu; QAction *a = NULL; - QMenu *mm = menu.addMenu( "Add node" ); - a = mm->addAction( "1 slot" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode1() ) ); - - a = mm->addAction( "2 slots" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode2() ) ); - - a = mm->addAction( "3 slots" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode3() ) ); if( m_selectionCount > 0 ) { @@ -101,8 +92,16 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) if( m_selectionCount == 1 ) { - a = menu.addAction( "Change slot count" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); + QList< QGraphicsItem* > l = m_scene->selectedItems(); + ExpressionNode *node = dynamic_cast< ExpressionNode* >( l[ 0 ] ); + if( node != NULL ) + { + if( node->variable() ) + { + a = menu.addAction( "Change slot count" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); + } + } } else if( m_selectionCount == 2 ) @@ -219,6 +218,7 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() ); node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); node->setSlotNames( info->slotNames ); + node->setVariable( info->variable ); m_scene->addItem( node ); } diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index bb2eb451f..8c736c919 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -105,6 +105,8 @@ QGraphicsItem( parent ) m_h = 100; m_hh = 20.0; + m_variable = false; + m_name = name; if( slotCount > 3 ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index e43e717bb..ebf2c9fd5 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -55,6 +55,9 @@ public: void setSlotNames( const QList< QString > &l ); + void setVariable( bool b ){ m_variable = b; } + bool variable() const{ return m_variable; } + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); @@ -70,6 +73,8 @@ private: QList< ExpressionLink* > m_links; QString m_name; + + bool m_variable; }; #endif From 535e0474ad278e3c98fcf87c02d643cb249c9fe1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 15:15:31 +0200 Subject: [PATCH 26/43] Allow to set and change values of value nodes. --- .../plugins/gui_editor/expression_editor.cpp | 33 +++++++++++++++++++ .../plugins/gui_editor/expression_editor.h | 1 + .../src/plugins/gui_editor/expression_info.h | 7 ++++ .../plugins/gui_editor/expression_loader.cpp | 17 ++++++++++ .../plugins/gui_editor/expression_node.cpp | 15 +++++++++ .../src/plugins/gui_editor/expression_node.h | 9 +++++ 6 files changed, 82 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index df83a6732..502c135e1 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -101,6 +101,12 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Change slot count" ); connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); } + + if( node->isValue() ) + { + a = menu.addAction( "Change value" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onChangeValue() ) ); + } } } else @@ -219,6 +225,11 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); node->setSlotNames( info->slotNames ); node->setVariable( info->variable ); + node->setIsValue( info->value ); + if( node->isValue() ) + { + node->setValue( "Value" ); + } m_scene->addItem( node ); } @@ -241,6 +252,28 @@ void ExpressionEditor::onChangeSlotCount() node->changeSlotCount( c ); } +void ExpressionEditor::onChangeValue() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + ExpressionNode *node = static_cast< ExpressionNode* >( l[ 0 ] ); + + QString oldValue = node->getValue(); + + QString newValue = QInputDialog::getText( this, + tr( "Change value" ), + tr( "Enter new value" ), + QLineEdit::Normal, + oldValue ); + + if( newValue.isEmpty() ) + return; + if( newValue == oldValue ) + return; + + node->setValue( newValue ); + node->update(); +} + void ExpressionEditor::addExpression( const ExpressionInfo *info ) { QTreeWidgetItem *item = findTopLevelItem( info->category ); diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 79ff908f1..9380c6b29 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -46,6 +46,7 @@ private Q_SLOTS: void onUnLinkItems(); void onItemDblClicked( QTreeWidgetItem *item ); void onChangeSlotCount(); + void onChangeValue(); private: void addExpression( const ExpressionInfo *info ); diff --git a/code/studio/src/plugins/gui_editor/expression_info.h b/code/studio/src/plugins/gui_editor/expression_info.h index 854ea12c1..86218b6af 100644 --- a/code/studio/src/plugins/gui_editor/expression_info.h +++ b/code/studio/src/plugins/gui_editor/expression_info.h @@ -25,9 +25,16 @@ struct ExpressionInfo { QString name; + bool value; QString category; bool variable; QStringList slotNames; + + ExpressionInfo() + { + value = false; + variable = false; + } }; #endif diff --git a/code/studio/src/plugins/gui_editor/expression_loader.cpp b/code/studio/src/plugins/gui_editor/expression_loader.cpp index ee3346a0c..07db432e0 100644 --- a/code/studio/src/plugins/gui_editor/expression_loader.cpp +++ b/code/studio/src/plugins/gui_editor/expression_loader.cpp @@ -37,6 +37,20 @@ public: return true; } + bool parseValue() + { + QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + if( reader.hasError() ) + return false; + + if( text.toLower() == "true" ) + m_info->value = true; + else + m_info->value = false; + + return true; + } + bool parseCategory() { QString text = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); @@ -136,6 +150,9 @@ public: if( name == "name" ) error = !parseName(); else + if( name == "value" ) + error = !parseValue(); + else if( name == "category" ) error = !parseCategory(); else diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 8c736c919..3a67a2d8d 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -106,6 +106,7 @@ QGraphicsItem( parent ) m_hh = 20.0; m_variable = false; + m_isValue = false; m_name = name; @@ -152,6 +153,20 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o painter->setPen( p ); painter->drawText( header, Qt::AlignCenter, m_name ); + // Draw value if applicable + if( m_isValue ) + { + QRectF vbox; + vbox.setTopLeft( QPoint( 0.0, 20.0 ) ); + vbox.setWidth( header.width() ); + vbox.setHeight( header.height() ); + QPen vpen; + vpen.setColor( Qt::red ); + painter->setPen( vpen ); + painter->drawText( vbox, Qt::AlignCenter, m_value ); + painter->setPen( p ); + } + if( option->state & QStyle::State_Selected ) { p.setStyle( Qt::DotLine ); diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index ebf2c9fd5..52d515bbb 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -58,6 +58,12 @@ public: void setVariable( bool b ){ m_variable = b; } bool variable() const{ return m_variable; } + void setValue( const QString &value ){ m_value = value; } + QString getValue() const{ return m_value; } + + bool isValue() const{ return m_isValue; } + void setIsValue( bool b ){ m_isValue = b; } + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); @@ -75,6 +81,9 @@ private: QString m_name; bool m_variable; + + QString m_value; + bool m_isValue; }; #endif From 1e91e006c4b40c5d17c75d036ed908b3aa09549e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 15:31:06 +0200 Subject: [PATCH 27/43] When changing the value of a node, change the size the node if needed. --- .../src/plugins/gui_editor/expression_editor.cpp | 1 - .../src/plugins/gui_editor/expression_node.cpp | 13 +++++++++++++ .../studio/src/plugins/gui_editor/expression_node.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 502c135e1..1a16762e7 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -271,7 +271,6 @@ void ExpressionEditor::onChangeValue() return; node->setValue( newValue ); - node->update(); } void ExpressionEditor::addExpression( const ExpressionInfo *info ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 3a67a2d8d..d7a548dc4 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -257,6 +257,19 @@ void ExpressionNode::setSlotNames( const QList< QString > &l ) } } +void ExpressionNode::setValue( const QString &value ) +{ + m_value = value; + + int c = m_value.count(); + if( c < 15 ) + m_w = 100.0; + else + m_w = m_w + ( 100.0 / 15.0 ) * ( c - 15.0 ); + + update(); +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { for( int i = 0; i < m_links.count(); i++ ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 52d515bbb..f4b75ca1a 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -58,7 +58,7 @@ public: void setVariable( bool b ){ m_variable = b; } bool variable() const{ return m_variable; } - void setValue( const QString &value ){ m_value = value; } + void setValue( const QString &value ); QString getValue() const{ return m_value; } bool isValue() const{ return m_isValue; } From 4fe0b030f5c4ec3a43ad9688402918bbecc21d60 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 15:54:53 +0200 Subject: [PATCH 28/43] Added sample expression files. --- code/studio/src/plugins/gui_editor/expressions/add.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/and.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/div.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/eq.xml | 9 +++++++++ .../src/plugins/gui_editor/expressions/ifthenelse.xml | 10 ++++++++++ code/studio/src/plugins/gui_editor/expressions/mul.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/ne.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/not.xml | 8 ++++++++ code/studio/src/plugins/gui_editor/expressions/or.xml | 9 +++++++++ code/studio/src/plugins/gui_editor/expressions/sub.xml | 9 +++++++++ .../src/plugins/gui_editor/expressions/value.xml | 6 ++++++ 11 files changed, 96 insertions(+) create mode 100644 code/studio/src/plugins/gui_editor/expressions/add.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/and.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/div.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/eq.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/ifthenelse.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/mul.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/ne.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/not.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/or.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/sub.xml create mode 100644 code/studio/src/plugins/gui_editor/expressions/value.xml diff --git a/code/studio/src/plugins/gui_editor/expressions/add.xml b/code/studio/src/plugins/gui_editor/expressions/add.xml new file mode 100644 index 000000000..62cec88af --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/add.xml @@ -0,0 +1,9 @@ + +Mathematical +add +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/and.xml b/code/studio/src/plugins/gui_editor/expressions/and.xml new file mode 100644 index 000000000..cc8c05c6e --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/and.xml @@ -0,0 +1,9 @@ + +Logical +and +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/div.xml b/code/studio/src/plugins/gui_editor/expressions/div.xml new file mode 100644 index 000000000..aba3faffc --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/div.xml @@ -0,0 +1,9 @@ + +Mathematical +div +false + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/eq.xml b/code/studio/src/plugins/gui_editor/expressions/eq.xml new file mode 100644 index 000000000..77b7041cc --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/eq.xml @@ -0,0 +1,9 @@ + +Logical +eq +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/ifthenelse.xml b/code/studio/src/plugins/gui_editor/expressions/ifthenelse.xml new file mode 100644 index 000000000..248a68332 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/ifthenelse.xml @@ -0,0 +1,10 @@ + +Logical +ifthenelse +false + +if +then +else + + diff --git a/code/studio/src/plugins/gui_editor/expressions/mul.xml b/code/studio/src/plugins/gui_editor/expressions/mul.xml new file mode 100644 index 000000000..54d03b025 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/mul.xml @@ -0,0 +1,9 @@ + +Mathematical +mul +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/ne.xml b/code/studio/src/plugins/gui_editor/expressions/ne.xml new file mode 100644 index 000000000..31d62af02 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/ne.xml @@ -0,0 +1,9 @@ + +Logical +ne +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/not.xml b/code/studio/src/plugins/gui_editor/expressions/not.xml new file mode 100644 index 000000000..872b9b7a4 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/not.xml @@ -0,0 +1,8 @@ + +Logical +not +false + +A + + diff --git a/code/studio/src/plugins/gui_editor/expressions/or.xml b/code/studio/src/plugins/gui_editor/expressions/or.xml new file mode 100644 index 000000000..2d977267c --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/or.xml @@ -0,0 +1,9 @@ + +Logical +or +true + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/sub.xml b/code/studio/src/plugins/gui_editor/expressions/sub.xml new file mode 100644 index 000000000..5f35c2895 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/sub.xml @@ -0,0 +1,9 @@ + +Mathematical +sub +false + +A +B + + diff --git a/code/studio/src/plugins/gui_editor/expressions/value.xml b/code/studio/src/plugins/gui_editor/expressions/value.xml new file mode 100644 index 000000000..9bd57fc95 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expressions/value.xml @@ -0,0 +1,6 @@ + +Value +value +true +false + From aa1ac95aae4e3849a250352169793c31b9bb5223 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 14:41:57 +0200 Subject: [PATCH 29/43] A root node can now be set. The root node is where the evaluation will start. --- .../plugins/gui_editor/expression_editor.cpp | 25 ++++++++++++++++++- .../plugins/gui_editor/expression_editor.h | 1 + .../plugins/gui_editor/expression_node.cpp | 22 +++++++++++++--- .../src/plugins/gui_editor/expression_node.h | 2 ++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 1a16762e7..0967b33e1 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -35,7 +35,14 @@ class ExpressionEditorPvt { public: + + ExpressionEditorPvt() + { + m_root = NULL; + } + ExpressionStore store; + ExpressionNode *m_root; }; ExpressionEditor::ExpressionEditor( QWidget *parent ) : @@ -101,12 +108,15 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Change slot count" ); connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); } - + else if( node->isValue() ) { a = menu.addAction( "Change value" ); connect( a, SIGNAL( triggered() ), this, SLOT( onChangeValue() ) ); } + + a = menu.addAction( "Set as root" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onSetRoot() ) ); } } else @@ -273,6 +283,19 @@ void ExpressionEditor::onChangeValue() node->setValue( newValue ); } +void ExpressionEditor::onSetRoot() +{ + QList< QGraphicsItem* > l = m_scene->selectedItems(); + ExpressionNode *node = static_cast< ExpressionNode* >( l[ 0 ] ); + + if( m_pvt->m_root != NULL ) + m_pvt->m_root->setRoot( false ); + + m_pvt->m_root = node; + node->setRoot( true ); +} + + void ExpressionEditor::addExpression( const ExpressionInfo *info ) { QTreeWidgetItem *item = findTopLevelItem( info->category ); diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 9380c6b29..448ac536c 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -47,6 +47,7 @@ private Q_SLOTS: void onItemDblClicked( QTreeWidgetItem *item ); void onChangeSlotCount(); void onChangeValue(); + void onSetRoot(); private: void addExpression( const ExpressionInfo *info ); diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index d7a548dc4..17343c11c 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -107,6 +107,7 @@ QGraphicsItem( parent ) m_variable = false; m_isValue = false; + m_isRoot = false; m_name = name; @@ -139,9 +140,18 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o header.setHeight( m_hh ); // Draw filled rectangle, header - c.setRed( 44 ); - c.setGreen( 169 ); - c.setBlue( 232 ); + if( !m_isRoot ) + { + c.setRed( 44 ); + c.setGreen( 169 ); + c.setBlue( 232 ); + } + else + { + c.setRed( 255 ); + c.setGreen( 0 ); + c.setBlue( 0 ); + } br.setColor( c ); br.setStyle( Qt::SolidPattern ); p.setColor( c ); @@ -270,6 +280,12 @@ void ExpressionNode::setValue( const QString &value ) update(); } +void ExpressionNode::setRoot( bool b ) +{ + m_isRoot = b; + update(); +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { for( int i = 0; i < m_links.count(); i++ ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index f4b75ca1a..ec1fb9c67 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -63,6 +63,7 @@ public: bool isValue() const{ return m_isValue; } void setIsValue( bool b ){ m_isValue = b; } + void setRoot( bool b ); protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); @@ -84,6 +85,7 @@ private: QString m_value; bool m_isValue; + bool m_isRoot; }; #endif From f3fbfdcb83073555ce6273f8beb069de3166b7aa Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 15:31:54 +0200 Subject: [PATCH 30/43] Expression can now be built. --- .../plugins/gui_editor/expression_editor.cpp | 22 +++++++++++- .../plugins/gui_editor/expression_editor.h | 1 + .../src/plugins/gui_editor/expression_link.h | 3 ++ .../plugins/gui_editor/expression_node.cpp | 35 +++++++++++++++++++ .../src/plugins/gui_editor/expression_node.h | 2 ++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 0967b33e1..a1c35e892 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -89,7 +89,6 @@ void ExpressionEditor::load() void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) { QMenu menu; - QAction *a = NULL; if( m_selectionCount > 0 ) @@ -129,6 +128,11 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Unlink" ); connect( a, SIGNAL( triggered() ), this, SLOT( onUnLinkItems() ) ); } + else + { + a = menu.addAction( "Build expression" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onBuildExpression() ) ); + } menu.exec( e->globalPos() ); } @@ -295,6 +299,22 @@ void ExpressionEditor::onSetRoot() node->setRoot( true ); } +void ExpressionEditor::onBuildExpression() +{ + if( m_pvt->m_root == NULL ) + { + QMessageBox::information( this, + tr( "Building expression" ), + tr( "Failed to build expression: You must set a root node." ) ); + return; + } + + QString result = m_pvt->m_root->build(); + QMessageBox::information( this, + tr( "Building expression" ), + tr( "The result is\n" ) + result ); +} + void ExpressionEditor::addExpression( const ExpressionInfo *info ) { diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 448ac536c..700813618 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -48,6 +48,7 @@ private Q_SLOTS: void onChangeSlotCount(); void onChangeValue(); void onSetRoot(); + void onBuildExpression(); private: void addExpression( const ExpressionInfo *info ); diff --git a/code/studio/src/plugins/gui_editor/expression_link.h b/code/studio/src/plugins/gui_editor/expression_link.h index a5235737c..4e6df90dd 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.h +++ b/code/studio/src/plugins/gui_editor/expression_link.h @@ -36,6 +36,9 @@ public: void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + ExpressionNode* from() const{ return m_from; } + ExpressionNode* to() const{ return m_to; } + private: ExpressionNode *m_from; ExpressionNode *m_to; diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 17343c11c..8316d8901 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -286,6 +286,41 @@ void ExpressionNode::setRoot( bool b ) update(); } +QString ExpressionNode::build() const +{ + QString result; + + if( isValue() ) + return m_value; + + QStringList l = m_name.split( ' ' ); + result = l[ 0 ]; + result += "( "; + + int c = m_links.count(); + for( int i = 1; i < c; i++ ) + { + ExpressionLink *link = m_links[ i ]; + if( link == NULL ) + continue; + + ExpressionNode *node = NULL; + + if( link->from() == this ) + node = link->to(); + else + node = link->from(); + + result += node->build(); + + if( i != ( c - 1 ) ) + result += ", "; + } + + result += " )"; + return result; +} + void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) { for( int i = 0; i < m_links.count(); i++ ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index ec1fb9c67..101a6ebf8 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -65,6 +65,8 @@ public: void setIsValue( bool b ){ m_isValue = b; } void setRoot( bool b ); + QString build() const; + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); From 814fedbc4ac6bc8459aff02721509c6466e62853 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 15:47:49 +0200 Subject: [PATCH 31/43] Save expression. --- .../src/plugins/gui_editor/expression_editor.cpp | 13 +++++++++++++ .../src/plugins/gui_editor/expression_editor.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index a1c35e892..db77d18f6 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -132,6 +132,9 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) { a = menu.addAction( "Build expression" ); connect( a, SIGNAL( triggered() ), this, SLOT( onBuildExpression() ) ); + + a = menu.addAction( "Save" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onSave() ) ); } menu.exec( e->globalPos() ); @@ -315,6 +318,16 @@ void ExpressionEditor::onBuildExpression() tr( "The result is\n" ) + result ); } +void ExpressionEditor::onSave() +{ + if( m_pvt->m_root != NULL ) + { + m_result = m_pvt->m_root->build(); + } + + hide(); +} + void ExpressionEditor::addExpression( const ExpressionInfo *info ) { diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 700813618..02db8e06b 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -35,6 +35,7 @@ public: ~ExpressionEditor(); void load(); + QString result() const{ return m_result; } protected: void contextMenuEvent( QContextMenuEvent *e ); @@ -49,6 +50,7 @@ private Q_SLOTS: void onChangeValue(); void onSetRoot(); void onBuildExpression(); + void onSave(); private: void addExpression( const ExpressionInfo *info ); @@ -61,6 +63,7 @@ private: int m_nodeCount; ExpressionEditorPvt *m_pvt; + QString m_result; }; #endif From a7b3b0f985b444a1a4d3c7e83341d3855dd16830 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 15:50:12 +0200 Subject: [PATCH 32/43] This is the GUI Editor not Georges... --- code/studio/src/plugins/gui_editor/expr_link_dlg.cpp | 2 +- code/studio/src/plugins/gui_editor/expr_link_dlg.h | 2 +- code/studio/src/plugins/gui_editor/expr_slot_info.h | 2 +- code/studio/src/plugins/gui_editor/expression_editor.cpp | 2 +- code/studio/src/plugins/gui_editor/expression_editor.h | 2 +- code/studio/src/plugins/gui_editor/expression_link.cpp | 2 +- code/studio/src/plugins/gui_editor/expression_link.h | 2 +- code/studio/src/plugins/gui_editor/expression_node.cpp | 2 +- code/studio/src/plugins/gui_editor/expression_node.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp index 9a91e5f21..e8d01af85 100644 --- a/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.cpp @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expr_link_dlg.h b/code/studio/src/plugins/gui_editor/expr_link_dlg.h index 267787cf3..3f3ba97c0 100644 --- a/code/studio/src/plugins/gui_editor/expr_link_dlg.h +++ b/code/studio/src/plugins/gui_editor/expr_link_dlg.h @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expr_slot_info.h b/code/studio/src/plugins/gui_editor/expr_slot_info.h index 9614cd96a..470edf68d 100644 --- a/code/studio/src/plugins/gui_editor/expr_slot_info.h +++ b/code/studio/src/plugins/gui_editor/expr_slot_info.h @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index db77d18f6..32eefbf08 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 02db8e06b..9f7bd6101 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 537d4891f..f946c10f2 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_link.h b/code/studio/src/plugins/gui_editor/expression_link.h index 4e6df90dd..a0e699451 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.h +++ b/code/studio/src/plugins/gui_editor/expression_link.h @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 8316d8901..2dc9cf4fb 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 101a6ebf8..c2fa739de 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -1,4 +1,4 @@ -// Ryzom Core Studio - Georges Editor Plugin +// Ryzom Core Studio - GUI Editor Plugin // // Copyright (C) 2014 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core From 55264978ad64feefd6368862844ce65f8bb87e53 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 16:01:23 +0200 Subject: [PATCH 33/43] Links shouldn't be selectable. --- code/studio/src/plugins/gui_editor/expression_link.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index f946c10f2..54c7734b0 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -26,8 +26,6 @@ QGraphicsLineItem( parent ) { m_from = NULL; m_to = NULL; - - setFlags( QGraphicsItem::ItemIsSelectable ); } ExpressionLink::~ExpressionLink() From e18e3ac358741a239b4deab820399c8c1e511be9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 16:02:28 +0200 Subject: [PATCH 34/43] ExpressionNode flags are now set in it's constructor. --- code/studio/src/plugins/gui_editor/expression_editor.cpp | 1 - code/studio/src/plugins/gui_editor/expression_node.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 32eefbf08..4aba6c4a5 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -239,7 +239,6 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) m_nodeCount++; ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() ); - node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); node->setSlotNames( info->slotNames ); node->setVariable( info->variable ); node->setIsValue( info->value ); diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 2dc9cf4fb..8f3425a37 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -101,6 +101,8 @@ private: ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) : QGraphicsItem( parent ) { + setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + m_w = 100; m_h = 100; m_hh = 20.0; From e7f9487800ec05f42da40f5c70dddc64b0aa8e94 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 16:17:41 +0200 Subject: [PATCH 35/43] Instead of mouse move event, use the itemChange handler to move the links. --- .../src/plugins/gui_editor/expression_node.cpp | 16 ++++++++++++---- .../src/plugins/gui_editor/expression_node.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 8f3425a37..8a0ef774b 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -101,7 +101,7 @@ private: ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) : QGraphicsItem( parent ) { - setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsScenePositionChanges ); m_w = 100; m_h = 100; @@ -323,7 +323,17 @@ QString ExpressionNode::build() const return result; } -void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) +QVariant ExpressionNode::itemChange( GraphicsItemChange change, const QVariant &value ) +{ + if( change == ItemScenePositionHasChanged ) + { + onNodeMove(); + } + + return QGraphicsItem::itemChange( change, value ); +} + +void ExpressionNode::onNodeMove() { for( int i = 0; i < m_links.count(); i++ ) { @@ -333,8 +343,6 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) link->nodeMoved(); } - - QGraphicsItem::mouseMoveEvent( e ); } void ExpressionNode::createSlots( int count) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index c2fa739de..1e0290344 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -68,9 +68,10 @@ public: QString build() const; protected: - void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); + QVariant itemChange( GraphicsItemChange change, const QVariant &value ); private: + void onNodeMove(); void createSlots( int count = 3 ); void paintSlots( QPainter *painter ); From 8ca98c91e9e71b413d6512454a0f228bcc0c1e76 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 19:19:43 +0200 Subject: [PATCH 36/43] Moved the Expression Editor to it's right place. --- .../plugins/gui_editor/expression_editor.cpp | 9 +++- .../plugins/gui_editor/expression_editor.h | 4 ++ .../plugins/gui_editor/expression_editor.ui | 3 ++ .../plugins/gui_editor/gui_editor_window.cpp | 15 ------ .../plugins/gui_editor/gui_editor_window.h | 4 -- .../src/plugins/gui_editor/link_editor.cpp | 48 +++++++++++++++++++ .../src/plugins/gui_editor/link_editor.h | 8 +++- .../src/plugins/gui_editor/link_editor.ui | 3 ++ 8 files changed, 73 insertions(+), 21 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 4aba6c4a5..5be3939fd 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -140,6 +140,13 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) menu.exec( e->globalPos() ); } +void ExpressionEditor::closeEvent( QCloseEvent *e ) +{ + QMainWindow::closeEvent( e ); + + Q_EMIT closing(); +} + void ExpressionEditor::onDeleteSelection() { QList< QGraphicsItem* > l = m_scene->selectedItems(); @@ -324,7 +331,7 @@ void ExpressionEditor::onSave() m_result = m_pvt->m_root->build(); } - hide(); + close(); } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 9f7bd6101..ce13ff58e 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -37,8 +37,12 @@ public: void load(); QString result() const{ return m_result; } +Q_SIGNALS: + void closing(); + protected: void contextMenuEvent( QContextMenuEvent *e ); + void closeEvent( QCloseEvent *e ); private Q_SLOTS: void onDeleteSelection(); diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui index 342b2b5f1..fa21420a2 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.ui +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -2,6 +2,9 @@ ExpressionEditor + + Qt::ApplicationModal + 0 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 2447ac0af..3f4e318db 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -46,8 +46,6 @@ #include "add_widget_widget.h" #include "texture_chooser.h" -#include "expression_editor.h" - namespace GUIEditor { QString _lastDir; @@ -74,8 +72,6 @@ namespace GUIEditor widgetInfoTree = new CWidgetInfoTree; tc = new TextureChooser(); - ee = new ExpressionEditor(); - ee->load(); createMenus(); readSettings(); @@ -124,8 +120,6 @@ namespace GUIEditor delete tc; tc = NULL; - delete ee; - ee = NULL; delete messageProcessor; messageProcessor = NULL; @@ -371,11 +365,6 @@ namespace GUIEditor tc->exec(); } - void GUIEditorWindow::onEEClicked() - { - ee->show(); - } - void GUIEditorWindow::createMenus() { Core::MenuManager *mm = Core::ICore::instance()->menuManager(); @@ -426,10 +415,6 @@ namespace GUIEditor connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) ); m->addAction( a ); - a = new QAction( "Expression Editor", this ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onEEClicked() ) ); - m->addAction( a ); - menu = m; } } 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 d0dbe628e..978a8df72 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -29,7 +29,6 @@ class QtTreePropertyBrowser; class QMenu; class TextureChooser; -class ExpressionEditor; namespace GUIEditor { @@ -69,8 +68,6 @@ private Q_SLOTS: void onAddWidgetClicked(); void onTreeChanged(); void onTCClicked(); - void onEEClicked(); - protected: void hideEvent( QHideEvent *evnt ); @@ -105,7 +102,6 @@ private: QMenu *menu; TextureChooser *tc; - ExpressionEditor *ee; }; } diff --git a/code/studio/src/plugins/gui_editor/link_editor.cpp b/code/studio/src/plugins/gui_editor/link_editor.cpp index c57a6cd09..3cb49f37a 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.cpp +++ b/code/studio/src/plugins/gui_editor/link_editor.cpp @@ -18,20 +18,49 @@ #include "link_editor.h" #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" +#include "expression_editor.h" +#include namespace GUIEditor { + class LinkEditorPvt + { + public: + + LinkEditorPvt() + { + ee = new ExpressionEditor(); + ee->load(); + } + + ~LinkEditorPvt() + { + delete ee; + ee = NULL; + } + + ExpressionEditor *ee; + }; + + LinkEditor::LinkEditor( QWidget *parent ) : QWidget( parent ) { setupUi( this ); setup(); + + m_pvt = new LinkEditorPvt(); + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKButtonClicked() ) ); connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( expressionEdit, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( onTextEditContextMenu( const QPoint& ) ) ); + connect( m_pvt->ee, SIGNAL( closing() ), this, SLOT( onEEClosing() ) ); } LinkEditor::~LinkEditor() { + delete m_pvt; + m_pvt = NULL; } void LinkEditor::setup() @@ -89,4 +118,23 @@ namespace GUIEditor hide(); } + + void LinkEditor::onTextEditContextMenu( const QPoint &pos ) + { + QMenu *menu = expressionEdit->createStandardContextMenu(); + QAction *a = menu->addAction( "Expression Editor" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onEE() ) ); + + menu->exec( mapToGlobal( pos ) ); + } + + void LinkEditor::onEE() + { + m_pvt->ee->show(); + } + + void LinkEditor::onEEClosing() + { + expressionEdit->setPlainText( m_pvt->ee->result() ); + } } diff --git a/code/studio/src/plugins/gui_editor/link_editor.h b/code/studio/src/plugins/gui_editor/link_editor.h index b70019d20..f5617982e 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.h +++ b/code/studio/src/plugins/gui_editor/link_editor.h @@ -23,6 +23,8 @@ namespace GUIEditor { + class LinkEditorPvt; + class LinkEditor : public QWidget, public Ui::LinkEditor { Q_OBJECT @@ -35,12 +37,16 @@ namespace GUIEditor Q_SIGNALS: void okClicked(); - + private Q_SLOTS: void onOKButtonClicked(); + void onTextEditContextMenu( const QPoint &pos ); + void onEE(); + void onEEClosing(); private: uint32 currentLinkId; + LinkEditorPvt *m_pvt; }; } diff --git a/code/studio/src/plugins/gui_editor/link_editor.ui b/code/studio/src/plugins/gui_editor/link_editor.ui index 13a6e7d7e..657b0eabc 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.ui +++ b/code/studio/src/plugins/gui_editor/link_editor.ui @@ -26,6 +26,9 @@ + + Qt::CustomContextMenu + From 49e83433452094d5c6e0e381404efdba598265cd Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 19:21:39 +0200 Subject: [PATCH 37/43] Texture Chooser shouldn't have been left in the main menu... --- .../src/plugins/gui_editor/gui_editor_window.cpp | 16 ---------------- .../src/plugins/gui_editor/gui_editor_window.h | 6 ------ 2 files changed, 22 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 3f4e318db..9f6568936 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -44,7 +44,6 @@ #include "editor_selection_watcher.h" #include "editor_message_processor.h" #include "add_widget_widget.h" -#include "texture_chooser.h" namespace GUIEditor { @@ -71,8 +70,6 @@ namespace GUIEditor widgetInfoTree = new CWidgetInfoTree; - tc = new TextureChooser(); - createMenus(); readSettings(); @@ -118,9 +115,6 @@ namespace GUIEditor removeMenus(); - delete tc; - tc = NULL; - delete messageProcessor; messageProcessor = NULL; @@ -359,12 +353,6 @@ namespace GUIEditor GUICtrl->show(); } - void GUIEditorWindow::onTCClicked() - { - tc->load(); - tc->exec(); - } - void GUIEditorWindow::createMenus() { Core::MenuManager *mm = Core::ICore::instance()->menuManager(); @@ -411,10 +399,6 @@ namespace GUIEditor connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) ); m->addAction( a ); - a = new QAction( "Texture Chooser", this ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) ); - m->addAction( a ); - menu = m; } } 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 978a8df72..cc2dfbc65 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -25,11 +25,8 @@ #include "property_browser_ctrl.h" class QtTreePropertyBrowser; - class QMenu; -class TextureChooser; - namespace GUIEditor { @@ -67,7 +64,6 @@ private Q_SLOTS: void onGUILoaded(); void onAddWidgetClicked(); void onTreeChanged(); - void onTCClicked(); protected: void hideEvent( QHideEvent *evnt ); @@ -100,8 +96,6 @@ private: QString currentProjectFile; QMenu *menu; - - TextureChooser *tc; }; } From 6badbe5112e7e7329faefcae872aa97e51392275 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 19:27:06 +0200 Subject: [PATCH 38/43] Added support for clearing the Expression Editor scene. --- .../src/plugins/gui_editor/expression_editor.cpp | 12 ++++++++++++ .../src/plugins/gui_editor/expression_editor.h | 1 + 2 files changed, 13 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 5be3939fd..392bdca41 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -135,6 +135,9 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Save" ); connect( a, SIGNAL( triggered() ), this, SLOT( onSave() ) ); + + a = menu.addAction( "Clear" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onClear() ) ); } menu.exec( e->globalPos() ); @@ -334,6 +337,15 @@ void ExpressionEditor::onSave() close(); } +void ExpressionEditor::onClear() +{ + m_scene->clear(); + m_pvt->m_root = NULL; + m_nodeCount = 0; + m_selectionCount = 0; + m_result = ""; +} + void ExpressionEditor::addExpression( const ExpressionInfo *info ) { diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index ce13ff58e..92cc959bd 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -55,6 +55,7 @@ private Q_SLOTS: void onSetRoot(); void onBuildExpression(); void onSave(); + void onClear(); private: void addExpression( const ExpressionInfo *info ); From 3731f2889228a84193b6b5ec7bb73fbca37cbfa2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 18 Sep 2014 11:31:19 +0200 Subject: [PATCH 39/43] Backed out incomplete changes to GL driver --- .../src/3d/driver/opengl/driver_opengl.cpp | 4 - code/nel/src/3d/driver/opengl/driver_opengl.h | 6 - .../3d/driver/opengl/driver_opengl_window.cpp | 141 ++---------------- 3 files changed, 14 insertions(+), 137 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index e9965e0f1..ce60d7f42 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -234,10 +234,6 @@ CDriverGL::CDriverGL() _CursorScale = 1.f; _MouseCaptured = false; -#if defined(NL_OS_WINDOWS) - _BorderlessFullscreen = false; -#endif - _NeedToRestaureGammaRamp = false; _win = EmptyWindow; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index fb6069447..c4540b9da 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -996,12 +996,6 @@ private: EWindowStyle getWindowStyle() const; bool setWindowStyle(EWindowStyle windowStyle); -#if defined(NL_OS_WINDOWS) - static BOOL CALLBACK monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData); - bool _BorderlessFullscreen; -#endif - std::string _CurrentDisplayDevice; - // Methods to manage screen resolutions bool restoreScreenMode(); bool saveScreenMode(); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 4e08884b0..751e72149 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -1271,86 +1271,10 @@ static sint modeInfoToFrequency(XF86VidModeModeInfo *info) // *************************************************************************** -#if defined(NL_OS_WINDOWS) - -struct CMonitorEnumParams -{ -public: - CDriverGL *Driver; - const char *DeviceName; - bool Success; -}; - -BOOL CALLBACK CDriverGL::monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData) -{ - CMonitorEnumParams *p = reinterpret_cast(dwData); - - MONITORINFOEXA monitorInfo; - memset(&monitorInfo, 0, sizeof(monitorInfo)); - monitorInfo.cbSize = sizeof(monitorInfo); - GetMonitorInfoA(hMonitor, &monitorInfo); - nldebug("3D: Monitor: '%s'", monitorInfo.szDevice); - - size_t devLen = strlen(monitorInfo.szDevice); - size_t targetLen = strlen(p->DeviceName); - - nlassert(devLen < 32); - size_t minLen = min(devLen, targetLen); - if (!memcmp(monitorInfo.szDevice, p->DeviceName, minLen)) - { - if (devLen == targetLen - || (devLen < targetLen && (p->DeviceName[minLen] == '\\')) - || (devLen > targetLen && (monitorInfo.szDevice[minLen] == '\\'))) - { - nldebug("3D: Remapping '%s' to '%s'", p->DeviceName, monitorInfo.szDevice); - nldebug("3D: Found requested monitor at %i, %i", monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top); - p->Driver->_CurrentMode.Windowed = false; - p->Driver->setWindowStyle(CDriverGL::EWSWindowed); - p->Driver->setWindowSize(monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top); - LONG dwStyle = GetWindowLong(p->Driver->_win, GWL_STYLE); - SetWindowLong(p->Driver->_win, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); - SetWindowPos(p->Driver->_win, NULL, - monitorInfo.rcMonitor.left, - monitorInfo.rcMonitor.top, - monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, - monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top, - SWP_FRAMECHANGED); - p->Driver->_WindowX = monitorInfo.rcMonitor.left; - p->Driver->_WindowY = monitorInfo.rcMonitor.top; - p->Driver->_CurrentDisplayDevice = std::string(p->DeviceName); - p->Driver->_BorderlessFullscreen = true; - p->Driver->_CurrentMode.Windowed = false; - p->Success = true; - return FALSE; - } - } - p->Success = false; - return TRUE; // continue -}; - -#endif - -// *************************************************************************** - bool CDriverGL::setScreenMode(const GfxMode &mode) { H_AUTO_OGL(CDriverGL_setScreenMode) - nldebug("3D: setScreenMode"); - -#if defined(NL_OS_WINDOWS) - if (_BorderlessFullscreen) - { - _BorderlessFullscreen = false; - LONG dwStyle = GetWindowLong(_win, GWL_STYLE); - dwStyle |= WS_OVERLAPPEDWINDOW; - if (!_Resizable) dwStyle ^= WS_MAXIMIZEBOX|WS_THICKFRAME; - SetWindowLong(_win, GWL_STYLE, dwStyle); - SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - _CurrentMode.Windowed = true; - } -#endif - if (mode.Windowed) { // if fullscreen, switch back to desktop screen mode @@ -1360,17 +1284,13 @@ bool CDriverGL::setScreenMode(const GfxMode &mode) return true; } - if (_CurrentDisplayDevice != mode.DisplayDevice) - restoreScreenMode(); - // save previous screen mode only if switching from windowed to fullscreen if (_CurrentMode.Windowed) saveScreenMode(); // if switching exactly to the same screen mode, doesn't change it GfxMode previousMode; - if (_CurrentDisplayDevice == mode.DisplayDevice - && getCurrentScreenMode(previousMode) + if (getCurrentScreenMode(previousMode) && mode.Width == previousMode.Width && mode.Height == previousMode.Height && mode.Depth == previousMode.Depth @@ -1379,9 +1299,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode) #if defined(NL_OS_WINDOWS) - const char *deviceName = mode.DisplayDevice.c_str(); - - DEVMODEA devMode; + DEVMODE devMode; memset(&devMode, 0, sizeof(DEVMODE)); devMode.dmSize = sizeof(DEVMODE); devMode.dmDriverExtra = 0; @@ -1389,42 +1307,22 @@ bool CDriverGL::setScreenMode(const GfxMode &mode) devMode.dmPelsWidth = mode.Width; devMode.dmPelsHeight = mode.Height; - if (mode.Depth > 0) + if(mode.Depth > 0) { devMode.dmBitsPerPel = mode.Depth; devMode.dmFields |= DM_BITSPERPEL; } - if (mode.Frequency > 0) + if(mode.Frequency > 0) { devMode.dmDisplayFrequency = mode.Frequency; devMode.dmFields |= DM_DISPLAYFREQUENCY; } - - if (deviceName[0]) + + if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { - // First attempt exclusive fullscreen - nldebug("3D: ChangeDisplaySettingsEx"); - LONG resex; - if ((resex = ChangeDisplaySettingsExA(deviceName, &devMode, NULL, CDS_FULLSCREEN, NULL)) != DISP_CHANGE_SUCCESSFUL) - { - nlwarning("3D: Fullscreen mode switch failed (%i)", (sint)resex); - // Workaround, resize to monitor and make borderless - CMonitorEnumParams p; - p.DeviceName = deviceName; - p.Driver = this; - EnumDisplayMonitors(NULL, NULL, monitorEnumProcFullscreen, (LPARAM)&p); - return p.Success; - } - } - else - { - nldebug("3D: ChangeDisplaySettings"); - if (ChangeDisplaySettingsA(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - { - nlwarning("3D: Fullscreen mode switch failed"); - return false; - } + nlwarning("3D: Fullscreen mode switch failed"); + return false; } #elif defined(NL_OS_MAC) @@ -1830,11 +1728,7 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle) dwNewStyle |= WS_VISIBLE; if (dwStyle != dwNewStyle) - { SetWindowLong(_win, GWL_STYLE, dwNewStyle); - if (windowStyle == EWSWindowed) - SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } // if (windowStyle == EWSMaximized && isVisible && !isMaximized) // ShowWindow(_hWnd, SW_SHOWMAXIMIZED); @@ -1962,24 +1856,19 @@ bool CDriverGL::setMode(const GfxMode& mode) && ScreenToClient(_win, &cursorPos); sint curX = (sint)cursorPos.x * (sint)mode.Width; sint curY = (sint)cursorPos.y * (sint)mode.Height; - if (_BorderlessFullscreen) - ReleaseCapture(); #endif if (!setScreenMode(mode)) return false; - if (!_BorderlessFullscreen) - { - // when changing window style, it's possible system change window size too - setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen); + // when changing window style, it's possible system change window size too + setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen); - if (!mode.Windowed) - _CurrentMode.Depth = mode.Depth; + if (!mode.Windowed) + _CurrentMode.Depth = mode.Depth; - setWindowSize(mode.Width, mode.Height); - setWindowPos(_WindowX, _WindowY); - } + setWindowSize(mode.Width, mode.Height); + setWindowPos(_WindowX, _WindowY); switch (_CurrentMode.Depth) { @@ -1996,8 +1885,6 @@ bool CDriverGL::setMode(const GfxMode& mode) cursorPos.y = curY / (sint)mode.Height; ClientToScreen(_win, &cursorPos); SetCursorPos(cursorPos.x, cursorPos.y); - if (_BorderlessFullscreen) - SetCapture(_win); } #endif From 7fdcf203c5396ecdaeb4f9fb290cce64f241cc13 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 18 Sep 2014 13:02:32 +0200 Subject: [PATCH 40/43] Fix missing include --- code/ryzom/client/src/release.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 4e712a10d..f88849197 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -27,6 +27,7 @@ #include "nel/misc/system_utils.h" // 3D Interface. #include "nel/3d/bloom_effect.h" +#include "nel/3d/fxaa.h" #include "nel/3d/fasthls_modifier.h" #include "nel/3d/particle_system_manager.h" #include "nel/3d/particle_system.h" @@ -661,7 +662,7 @@ void release() delete &CLuaManager::getInstance(); NLGUI::CDBManager::release(); CWidgetManager::release(); - + From b9b58bd7dceed47cf557b9180534cef19d472fdf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 18 Sep 2014 14:10:03 +0200 Subject: [PATCH 41/43] Add particle system path fixing script --- .../scripts/nel_assets_ps_batched.ms | 378 ++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms new file mode 100644 index 000000000..f8165e25e --- /dev/null +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms @@ -0,0 +1,378 @@ + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +fn findFile dir fileName = +( + if (doesFileExist (dir + "\\" + fileName)) then + ( + return (dir + "\\" + fileName) + ) + + dirArr = GetDirectories (dir + "\\*") + + for d in dirArr do + ( + local fileFound = findFile d fileName + if (fileFound != "") then + return fileFound + ) + + return "" +) + +fn getFixedPath ps = +( + if not (doesFileExist ps) then + ( + local fileName = filenameFromPath ps + local fileFound = findFile "W:\\database\\sfx" fileName + if (fileFound != "") then + return fileFound + else + return fileName + ) + else + ( + return ps + ) +) + +fn renameParticleSystem ps = +( + local newFileName = getFixedPath ps.ps_file_name + if (newFileName != ps.ps_file_name) then + ( + ps.ps_file_name = newFileName + return 1 + ) + else + ( + return 0 + ) +) + + +rollout assets_ps_rollout "Properties" +( + fn do_it = + ( + local result = 0 + + for m in getClassInstances nel_ps do + ( + if (renameParticleSystem m) == 1 then + result = 1 + ) + + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return result + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- To use this script + -- Include it in your script into the rollout at the beginning. + -- Implement a do_it function to do the job in your rollout. + -- The function should retun -1 if an arror occured, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Open the max project + if loadMaxFile file quiet:true == true then + ( + objXRefMgr.UpdateAllRecords() + + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_ps_floater = newRolloutFloater "NeL Assets PS Database" 550 400 +addrollout assets_ps_rollout assets_ps_floater rolledUp:false + + From 9d161fddf50d0820296a3993aa84d6d8649c18b8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 18 Sep 2014 17:40:07 +0200 Subject: [PATCH 42/43] Add resave scripts --- .../plugin_max/scripts/nel_assets_resave.ms | 329 ++++++++++++++++++ .../scripts/nel_assets_resave_hard.ms | 316 +++++++++++++++++ 2 files changed, 645 insertions(+) create mode 100644 code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms create mode 100644 code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms new file mode 100644 index 000000000..ab9e45325 --- /dev/null +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms @@ -0,0 +1,329 @@ + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +rollout assets_resave_rollout "Properties" +( + fn do_it = + ( + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return 1 + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- To use this script + -- Include it in your script into the rollout at the beginning. + -- Implement a do_it function to do the job in your rollout. + -- The function should retun -1 if an arror occured, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Open the max project + if loadMaxFile file quiet:true == true then + ( + origAnimStart = animationRange.start + origAnimEnd = animationRange.end + origFrameRate = frameRate + + resetMAXFile #noprompt + + animationRange = interval origAnimStart origAnimEnd + frameRate = origFrameRate + + -- Merge the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_resave_floater = newRolloutFloater "NeL Assets Resave Database" 550 874 +addrollout assets_resave_rollout assets_resave_floater rolledUp:false + diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms new file mode 100644 index 000000000..05220c7a5 --- /dev/null +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms @@ -0,0 +1,316 @@ + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +rollout assets_resave_rollout "Properties" +( + fn do_it = + ( + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return 1 + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- To use this script + -- Include it in your script into the rollout at the beginning. + -- Implement a do_it function to do the job in your rollout. + -- The function should retun -1 if an arror occured, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Merge the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_resave_floater = newRolloutFloater "NeL Assets Resave Database Hard" 550 874 +addrollout assets_resave_rollout assets_resave_floater rolledUp:false + From 5165f74aae473129ea905b0af3151e21b9526e07 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 18 Sep 2014 21:02:14 +0200 Subject: [PATCH 43/43] It works on my machine --- code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp index 5cb7c6922..a15f8c6d3 100644 --- a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp +++ b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp @@ -27,7 +27,7 @@ #include "nel/misc/file.h" // Game share -#include "server_share/bmp4image.h" +#include "game_share/bmp4image.h" // AI share #include "ai_share/world_map.h"