mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 20:00:54 +00:00
CHANGED: #1471 The procedure list window is now fully implemented ( can add/remove/edit procedures ).
This commit is contained in:
parent
92d74a2dbd
commit
0d52596ac2
8 changed files with 179 additions and 10 deletions
|
@ -233,6 +233,15 @@ namespace NLGUI
|
||||||
void removeAll();
|
void removeAll();
|
||||||
// @}
|
// @}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Procedure list
|
||||||
|
typedef TProcedureMap::iterator ItProcedureMap;
|
||||||
|
typedef TProcedureMap::const_iterator CstItProcedureMap;
|
||||||
|
TProcedureMap _ProcedureMap;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
// get info on procedure. return 0 if procedure not found
|
// get info on procedure. return 0 if procedure not found
|
||||||
uint getProcedureNumActions( const std::string &procName ) const;
|
uint getProcedureNumActions( const std::string &procName ) const;
|
||||||
|
|
||||||
|
@ -245,6 +254,8 @@ namespace NLGUI
|
||||||
|
|
||||||
CProcedure* getProc( const std::string &name );
|
CProcedure* getProc( const std::string &name );
|
||||||
|
|
||||||
|
const TProcedureMap& getProcMap() const{ return _ProcedureMap; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,12 +299,6 @@ namespace NLGUI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Procedure list
|
|
||||||
typedef std::map<std::string,CProcedure> TProcedureMap;
|
|
||||||
typedef TProcedureMap::iterator ItProcedureMap;
|
|
||||||
typedef TProcedureMap::const_iterator CstItProcedureMap;
|
|
||||||
TProcedureMap _ProcedureMap;
|
|
||||||
|
|
||||||
// mgt of sheet selections (inventory, buy, sell..)
|
// mgt of sheet selections (inventory, buy, sell..)
|
||||||
CCtrlSheetSelection _CtrlSheetSelection;
|
CCtrlSheetSelection _CtrlSheetSelection;
|
||||||
|
|
||||||
|
@ -331,6 +336,10 @@ namespace NLGUI
|
||||||
void reloadAllLuaFileScripts();
|
void reloadAllLuaFileScripts();
|
||||||
|
|
||||||
void setSetupOptionsCallback( ISetupOptionCallbackClass *cb ){ setupCallback = cb; }
|
void setSetupOptionsCallback( ISetupOptionCallbackClass *cb ){ setupCallback = cb; }
|
||||||
|
|
||||||
|
bool hasProc( const std::string &name ) const;
|
||||||
|
bool addProc( const std::string &name );
|
||||||
|
bool removeProc( const std::string &name );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
|
#include "nel/gui/proc.h"
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
{
|
{
|
||||||
class CInterfaceElement;
|
class CInterfaceElement;
|
||||||
class CInterfaceGroup;
|
class CInterfaceGroup;
|
||||||
class CInterfaceAnim;
|
class CInterfaceAnim;
|
||||||
class CProcedure;
|
|
||||||
class CCtrlSheetSelection;
|
class CCtrlSheetSelection;
|
||||||
class CInterfaceLink;
|
class CInterfaceLink;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ namespace NLGUI
|
||||||
virtual const std::string& getDefine(const std::string &id) const = 0;
|
virtual const std::string& getDefine(const std::string &id) const = 0;
|
||||||
virtual CInterfaceAnim* getAnim( const std::string &name ) const = 0;
|
virtual CInterfaceAnim* getAnim( const std::string &name ) const = 0;
|
||||||
virtual CProcedure* getProc( const std::string &name ) = 0;
|
virtual CProcedure* getProc( const std::string &name ) = 0;
|
||||||
|
virtual const TProcedureMap& getProcMap() const = 0;
|
||||||
virtual bool parseInterface( const std::vector< std::string > &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false ) = 0;
|
virtual bool parseInterface( const std::vector< std::string > &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false ) = 0;
|
||||||
virtual void initLUA() = 0;
|
virtual void initLUA() = 0;
|
||||||
virtual void uninitLUA() = 0;
|
virtual void uninitLUA() = 0;
|
||||||
|
@ -67,6 +68,9 @@ namespace NLGUI
|
||||||
virtual bool addLink( CInterfaceLink *link, const std::string &id ) = 0;
|
virtual bool addLink( CInterfaceLink *link, const std::string &id ) = 0;
|
||||||
virtual bool removeLink( const std::string &id ) = 0;
|
virtual bool removeLink( const std::string &id ) = 0;
|
||||||
virtual void removeAll() = 0;
|
virtual void removeAll() = 0;
|
||||||
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
{
|
{
|
||||||
|
@ -65,12 +66,46 @@ namespace NLGUI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CActionNameIs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CActionNameIs( const std::string &n )
|
||||||
|
{
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()( const CProcAction &action )
|
||||||
|
{
|
||||||
|
if( action.Action == name )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CProcedure
|
class CProcedure
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// List of the actions
|
// List of the actions
|
||||||
std::vector< CProcAction > Actions;
|
std::vector< CProcAction > Actions;
|
||||||
|
|
||||||
|
bool hasAction( const std::string &name ) const
|
||||||
|
{
|
||||||
|
std::vector< CProcAction >::const_iterator itr
|
||||||
|
= std::find_if( Actions.begin(), Actions.end(), CActionNameIs( name ) );
|
||||||
|
if( itr != Actions.end() )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::map< std::string, CProcedure > TProcedureMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2777,5 +2777,36 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CInterfaceParser::hasProc( const std::string &name ) const
|
||||||
|
{
|
||||||
|
TProcedureMap::const_iterator itr
|
||||||
|
= _ProcedureMap.find( name );
|
||||||
|
if( itr != _ProcedureMap.end() )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CInterfaceParser::addProc( const std::string &name )
|
||||||
|
{
|
||||||
|
if( hasProc( name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_ProcedureMap[ name ] = CProcedure();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CInterfaceParser::removeProc( const std::string &name )
|
||||||
|
{
|
||||||
|
TProcedureMap::iterator itr =
|
||||||
|
_ProcedureMap.find( name );
|
||||||
|
if( itr == _ProcedureMap.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_ProcedureMap.erase( itr );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
#include "proc_editor.h"
|
#include "proc_editor.h"
|
||||||
#include "action_editor.h"
|
#include "action_editor.h"
|
||||||
|
#include "nel/gui/interface_group.h"
|
||||||
|
#include "nel/gui/widget_manager.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -28,7 +29,6 @@ namespace GUIEditor
|
||||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
||||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
||||||
connect( editButton, SIGNAL( clicked( bool ) ), actionEditor, SLOT( show() ) );
|
connect( editButton, SIGNAL( clicked( bool ) ), actionEditor, SLOT( show() ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcEditor::~ProcEditor()
|
ProcEditor::~ProcEditor()
|
||||||
|
@ -36,4 +36,21 @@ namespace GUIEditor
|
||||||
delete actionEditor;
|
delete actionEditor;
|
||||||
actionEditor = NULL;
|
actionEditor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcEditor::setCurrentProc( const QString &name )
|
||||||
|
{
|
||||||
|
actionList->clear();
|
||||||
|
|
||||||
|
currentProc = name;
|
||||||
|
IParser *parser = CWidgetManager::getInstance()->getParser();
|
||||||
|
CProcedure *proc = parser->getProc( name.toStdString() );
|
||||||
|
|
||||||
|
std::vector< CProcAction >::const_iterator itr;
|
||||||
|
for( itr = proc->Actions.begin(); itr != proc->Actions.end(); ++itr )
|
||||||
|
{
|
||||||
|
actionList->addItem( itr->Action.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
setWindowTitle( QString( "Procedure Editor - %1" ).arg( currentProc ) );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -31,8 +31,11 @@ namespace GUIEditor
|
||||||
ProcEditor( QWidget *parent = NULL );
|
ProcEditor( QWidget *parent = NULL );
|
||||||
~ProcEditor();
|
~ProcEditor();
|
||||||
|
|
||||||
|
void setCurrentProc( const QString &name );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionEditor *actionEditor;
|
ActionEditor *actionEditor;
|
||||||
|
QString currentProc;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
#include "proc_list.h"
|
#include "proc_list.h"
|
||||||
#include "proc_editor.h"
|
#include "proc_editor.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include "nel/gui/interface_group.h"
|
||||||
|
#include "nel/gui/widget_manager.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -29,6 +33,8 @@ namespace GUIEditor
|
||||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkButtonClicked() ) );
|
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkButtonClicked() ) );
|
||||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
||||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditButtonClicked() ) );
|
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditButtonClicked() ) );
|
||||||
|
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddButtonClicked() ) );
|
||||||
|
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveButtonClicked() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcList::~ProcList()
|
ProcList::~ProcList()
|
||||||
|
@ -38,7 +44,7 @@ namespace GUIEditor
|
||||||
|
|
||||||
void ProcList::onGUILoaded()
|
void ProcList::onGUILoaded()
|
||||||
{
|
{
|
||||||
|
setupProcList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcList::onOkButtonClicked()
|
void ProcList::onOkButtonClicked()
|
||||||
|
@ -48,7 +54,68 @@ namespace GUIEditor
|
||||||
|
|
||||||
void ProcList::onEditButtonClicked()
|
void ProcList::onEditButtonClicked()
|
||||||
{
|
{
|
||||||
|
IParser *parser = CWidgetManager::getInstance()->getParser();
|
||||||
|
QListWidgetItem *item = procList->item( procList->currentRow() );
|
||||||
|
if( item == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
CProcedure *proc = parser->getProc( item->text().toStdString() );
|
||||||
|
if( proc == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
procEditor->setCurrentProc( item->text() );
|
||||||
procEditor->show();
|
procEditor->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcList::onAddButtonClicked()
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
QString newProc =
|
||||||
|
QInputDialog::getText( this,
|
||||||
|
tr( "Adding a new procedure" ),
|
||||||
|
tr( "Please specify the name of the new procedure" ),
|
||||||
|
QLineEdit::Normal,
|
||||||
|
QString(),
|
||||||
|
&ok );
|
||||||
|
if( ok )
|
||||||
|
{
|
||||||
|
IParser *parser = CWidgetManager::getInstance()->getParser();
|
||||||
|
if( !parser->addProc( newProc.toStdString() ) )
|
||||||
|
{
|
||||||
|
QMessageBox::critical( this,
|
||||||
|
tr( "Cannot add new procedure" ),
|
||||||
|
tr( "There was an error adding the new procedure" ) );
|
||||||
|
}
|
||||||
|
procList->addItem( newProc );
|
||||||
|
procList->sortItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcList::onRemoveButtonClicked()
|
||||||
|
{
|
||||||
|
IParser *parser = CWidgetManager::getInstance()->getParser();
|
||||||
|
QListWidgetItem *item = procList->item( procList->currentRow() );
|
||||||
|
if( item == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !parser->removeProc( item->text().toStdString() ) )
|
||||||
|
return;
|
||||||
|
item = procList->takeItem( procList->currentRow() );
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcList::setupProcList()
|
||||||
|
{
|
||||||
|
procList->clear();
|
||||||
|
|
||||||
|
const TProcedureMap& procMap =
|
||||||
|
CWidgetManager::getInstance()->getParser()->getProcMap();
|
||||||
|
|
||||||
|
TProcedureMap::const_iterator itr;
|
||||||
|
for( itr = procMap.begin(); itr != procMap.end(); ++itr )
|
||||||
|
{
|
||||||
|
procList->addItem( itr->first.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,11 @@ namespace GUIEditor
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onOkButtonClicked();
|
void onOkButtonClicked();
|
||||||
void onEditButtonClicked();
|
void onEditButtonClicked();
|
||||||
|
void onAddButtonClicked();
|
||||||
|
void onRemoveButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupProcList();
|
||||||
ProcEditor *procEditor;
|
ProcEditor *procEditor;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue