ADDED: #1471 My work on the link editor so far. Not yet fully implemented.

This commit is contained in:
dfighter1985 2012-07-25 09:09:12 +02:00
parent f3abf43368
commit 5817e07468
14 changed files with 391 additions and 53 deletions

View file

@ -27,6 +27,7 @@
#include "nel/gui/lua_helper.h"
#include "nel/gui/proc.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/link_data.h"
namespace NLGUI
{
@ -324,6 +325,11 @@ namespace NLGUI
bool luaInitialized;
ISetupOptionCallbackClass *setupCallback;
uint32 linkId;
std::map< uint32, SLinkData > links;
bool editorMode;
public:
void initLUA();
void uninitLUA();
@ -340,6 +346,11 @@ namespace NLGUI
bool hasProc( const std::string &name ) const;
bool addProc( const std::string &name );
bool removeProc( const std::string &name );
const std::map< uint32, SLinkData >& getLinkMap() const{ return links; }
void addLinkData( const SLinkData &linkData );
void setEditorMode( bool b ){ editorMode = b; }
};
}

View file

@ -0,0 +1,40 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef LINKDATA_H
#define LINKDATA_H
#include <string>
namespace NLGUI
{
struct SLinkData
{
public:
std::string parent;
std::string expr;
std::string target;
std::string action;
std::string params;
std::string cond;
};
}
#endif

View file

@ -22,6 +22,7 @@
#include <vector>
#include "nel/misc/types_nl.h"
#include "nel/gui/proc.h"
#include "nel/gui/link_data.h"
namespace NLGUI
{
@ -71,6 +72,9 @@ namespace NLGUI
virtual bool hasProc( const std::string &name ) const = 0;
virtual bool addProc( const std::string &name ) = 0;
virtual bool removeProc( const std::string &name ) = 0;
virtual void setEditorMode( bool b ) = 0;
virtual const std::map< uint32, SLinkData >& getLinkMap() const = 0;
virtual void addLinkData( const SLinkData &linkData ) = 0;
};
}

View file

@ -200,6 +200,8 @@ namespace NLGUI
{
luaInitialized = false;
cacheUIParsing = false;
linkId = 0;
editorMode = false;
setupCallback = NULL;
}
@ -991,6 +993,7 @@ namespace NLGUI
std::vector<CInterfaceLink::CTargetInfo> targets;
ptr = (char*) xmlGetProp (cur, (xmlChar*)"target");
std::string target = ptr;
if (ptr)
{
CInterfaceLink::splitLinkTargets(std::string((const char*)ptr), parentGroup, targets);
@ -1009,6 +1012,20 @@ namespace NLGUI
// create the link
CInterfaceLink *il = new CInterfaceLink;
il->init(targets, expr, action, params, cond, parentGroup); // init will add 'il' in the list of link present in 'elm'
if( editorMode )
{
SLinkData linkData;
linkData.parent = parentGroup->getId();
linkData.expr = expr;
linkData.target = target;
linkData.action = action;
linkData.cond = cond;
linkData.params = params;
addLinkData( linkData );
}
return true;
}
@ -2814,5 +2831,10 @@ namespace NLGUI
_ProcedureMap.erase( itr );
return true;
}
void CInterfaceParser::addLinkData( const SLinkData &linkData )
{
links[ ++linkId ] = linkData;
}
}

View file

@ -15,6 +15,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
gui_editor_context.h
widget_properties.h
widget_hierarchy.h
link_list.h
link_editor.h
proc_list.h
proc_editor.h
@ -29,6 +30,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
gui_editor_window.ui
widget_properties.ui
widget_hierarchy.ui
link_list.ui
link_editor.ui
proc_list.ui
proc_editor.ui

View file

@ -33,7 +33,7 @@
#include "widget_properties.h"
#include "widget_properties_parser.h"
#include "widget_hierarchy.h"
#include "link_editor.h"
#include "link_list.h"
#include "proc_list.h"
#include "project_file_parser.h"
#include "project_window.h"
@ -51,7 +51,7 @@ namespace GUIEditor
m_ui.setupUi(this);
m_undoStack = new QUndoStack(this);
widgetProps = new CWidgetProperties;
linkEditor = new LinkEditor;
linkList = new LinkList;
procList = new ProcList;
projectWindow = new ProjectWindow;
connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) );
@ -85,6 +85,7 @@ namespace GUIEditor
connect( viewPort, SIGNAL( guiLoadComplete() ), hierarchyView, SLOT( onGUILoaded() ) );
connect( viewPort, SIGNAL( guiLoadComplete() ), procList, SLOT( onGUILoaded() ) );
connect( viewPort, SIGNAL( guiLoadComplete() ), linkList, SLOT( onGUILoaded() ) );
}
GUIEditorWindow::~GUIEditorWindow()
@ -94,8 +95,8 @@ namespace GUIEditor
delete widgetProps;
widgetProps = NULL;
delete linkEditor;
linkEditor = NULL;
delete linkList;
linkList = NULL;
delete procList;
procList = NULL;
@ -194,7 +195,7 @@ namespace GUIEditor
m->addAction( a );
a = new QAction( "Link Editor", this );
connect( a, SIGNAL( triggered( bool ) ), linkEditor, SLOT( show() ) );
connect( a, SIGNAL( triggered( bool ) ), linkList, SLOT( show() ) );
m->addAction( a );
a = new QAction( "Procedure Editor", this );
@ -204,10 +205,6 @@ namespace GUIEditor
a = new QAction( "Project Window", this );
connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) );
m->addAction( a );
a = new QAction( "Clear Viewport", this );
connect( a, SIGNAL( triggered( bool ) ), viewPort, SLOT( clear() ) );
m->addAction( a );
}
}

View file

@ -31,7 +31,7 @@ namespace GUIEditor
class CWidgetProperties;
class WidgetHierarchy;
class LinkEditor;
class LinkList;
class ProcList;
class ProjectWindow;
class NelGUIWidget;
@ -67,7 +67,7 @@ private:
CWidgetProperties *widgetProps;
WidgetHierarchy *hierarchyView;
QtTreePropertyBrowser *propBrowser;
LinkEditor *linkEditor;
LinkList *linkList;
ProcList *procList;
ProjectWindow *projectWindow;
NelGUIWidget *viewPort;

View file

@ -16,6 +16,8 @@
#include "link_editor.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
namespace GUIEditor
{
@ -23,6 +25,7 @@ namespace GUIEditor
QWidget( parent )
{
setupUi( this );
setup();
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
}
@ -30,4 +33,50 @@ namespace GUIEditor
LinkEditor::~LinkEditor()
{
}
void LinkEditor::setup()
{
expressionEdit->clear();
groupCB->setCheckable( true );
groupCB->setChecked( false );
groupCB->setDisabled( true );
ahCB->setCheckable( true );
ahCB->setChecked( false );
ahCB->setDisabled( true );
ahEdit->clear();
ahParamEdit->clear();
ahParamEdit->setDisabled( true );
}
void LinkEditor::setLinkId( uint32 linkId )
{
setup();
currentLinkId = linkId;
const std::map< uint32, SLinkData > &linkMap =
CWidgetManager::getInstance()->getParser()->getLinkMap();
std::map< uint32, SLinkData >::const_iterator itr =
linkMap.find( currentLinkId );
if( itr == linkMap.end() )
return;
SLinkData data = itr->second;
expressionEdit->setPlainText( data.expr.c_str() );
if( !data.target.empty() )
{
groupCB->setEnabled( true );
groupCB->setChecked( true );
ahEdit->setText( data.target.c_str() );
}
else
{
ahCB->setEnabled( true );
ahCB->setChecked( true );
ahEdit->setText( data.action.c_str() );
ahParamEdit->setEnabled( true );
ahParamEdit->setText( data.params.c_str() );
}
}
}

View file

@ -19,6 +19,7 @@
#define LINK_EDITOR_H
#include "ui_link_editor.h"
#include "nel/misc/types_nl.h"
namespace GUIEditor
{
@ -28,6 +29,11 @@ namespace GUIEditor
public:
LinkEditor( QWidget *parent = NULL );
~LinkEditor();
void setup();
void setLinkId( uint32 linkId );
private:
uint32 currentLinkId;
};
}

View file

@ -10,92 +10,88 @@
<x>0</x>
<y>0</y>
<width>545</width>
<height>340</height>
<height>348</height>
</rect>
</property>
<property name="windowTitle">
<string>Link Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Expression</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0" colspan="3">
<widget class="QPlainTextEdit" name="expressionEdit">
<property name="plainText">
<string>expression</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>When the condition is met</string>
<string>When the expression is evaluated</string>
</property>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QRadioButton" name="groupCB">
<property name="text">
<string>Activate group</string>
<string>Pass result to targeted group(s)</string>
</property>
</widget>
</item>
<item>
<item row="4" column="0">
<widget class="QRadioButton" name="ahCB">
<property name="text">
<string>Run Action Handler</string>
</property>
</widget>
</item>
<item>
<item row="5" column="0" colspan="3">
<widget class="QLineEdit" name="ahEdit">
<property name="text">
<string>Group or action handler</string>
<string>Targeted group(s) or action handler</string>
</property>
</widget>
</item>
<item>
<item row="6" column="0" colspan="3">
<widget class="QLineEdit" name="ahParamEdit">
<property name="text">
<string>Action Handler parameters</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>348</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
<item row="7" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>362</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>

View file

@ -0,0 +1,79 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "link_list.h"
#include "link_editor.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/link_data.h"
#include <map>
#include <string>
namespace GUIEditor
{
LinkList::LinkList( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
linkEditor = new LinkEditor();
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditButtonClicked() ) );
}
LinkList::~LinkList()
{
delete linkEditor;
}
void LinkList::onGUILoaded()
{
const std::map< uint32, SLinkData > &linkMap =
CWidgetManager::getInstance()->getParser()->getLinkMap();
std::map< uint32, SLinkData >::const_iterator itr;
for( itr = linkMap.begin(); itr != linkMap.end(); ++itr )
{
QTreeWidgetItem *item = new QTreeWidgetItem( linkTree );
item->setText( 0, itr->second.parent.c_str() );
item->setText( 1, itr->second.target.c_str() );
item->setText( 2, itr->second.action.c_str() );
item->setData( 3, Qt::UserRole, itr->first );
linkTree->addTopLevelItem( item );
}
linkTree->sortByColumn( 0 );
}
void LinkList::onEditButtonClicked()
{
QTreeWidgetItem *item =
linkTree->currentItem();
if( item == NULL )
return;
bool ok;
uint32 id = item->data( 3, Qt::UserRole ).toUInt( &ok );
if( !ok )
return;
linkEditor->setLinkId( id );
linkEditor->show();
}
}

View file

@ -0,0 +1,46 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef LINK_LIST_H
#define LINK_LIST_H
#include "ui_link_list.h"
namespace GUIEditor
{
class LinkEditor;
class LinkList : public QWidget, public Ui::LinkList
{
Q_OBJECT
public:
LinkList( QWidget *parent = NULL );
~LinkList();
public Q_SLOTS:
void onGUILoaded();
private Q_SLOTS:
void onEditButtonClicked();
private:
LinkEditor *linkEditor;
};
}
#endif

View file

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LinkList</class>
<widget class="QWidget" name="LinkList">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>353</height>
</rect>
</property>
<property name="windowTitle">
<string>LinkList</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
<widget class="QTreeWidget" name="linkTree">
<column>
<property name="text">
<string>parent</string>
</property>
</column>
<column>
<property name="text">
<string>target(s)</string>
</property>
</column>
<column>
<property name="text">
<string>action handler</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>273</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -68,6 +68,8 @@ namespace GUIEditor
NLGUI::CViewRenderer::setTextContext( getTextContext() );
NLGUI::CViewRenderer::hwCursors = &hwCursors;
NLGUI::CViewRenderer::getInstance()->init();
CWidgetManager::getInstance()->getParser()->setEditorMode( true );
}
bool NelGUIWidget::parse( SProjectFiles &files )