Implemented new action.

--HG--
branch : dfighter-tools
This commit is contained in:
dfighter1985 2014-10-11 21:43:28 +02:00
parent e5d2e9293d
commit ded18b266c
6 changed files with 112 additions and 14 deletions

View file

@ -529,6 +529,8 @@ namespace NLGUI
bool unGroupSelection();
void setMultiSelection( bool b ){ multiSelection = b; }
bool createNewGUI( const std::string &project, const std::string &window );
private:
CWidgetManager();
~CWidgetManager();

View file

@ -35,6 +35,7 @@
#include "nel/gui/reflect_register.h"
#include "nel/gui/editor_selection_watcher.h"
#include "nel/misc/events.h"
#include "nel/gui/root_group.h"
namespace NLGUI
{
@ -1041,6 +1042,8 @@ namespace NLGUI
resetGlobalAlphasProps();
activeAnims.clear();
editorSelection.clear();
}
@ -3604,6 +3607,48 @@ namespace NLGUI
}
bool CWidgetManager::createNewGUI( const std::string &project, const std::string &window )
{
reset();
for( int i = 0; i < _MasterGroups.size(); i++ )
delete _MasterGroups[i].Group;
_MasterGroups.clear();
// First create the master group
CRootGroup *root = new CRootGroup( CViewBase::TCtorParam() );
SMasterGroup mg;
mg.Group = root;
root->setIdRecurse( project );
root->setW( 1024 );
root->setH( 768 );
root->setActive( true );
// Create the first / main window
CInterfaceGroup *wnd = new CInterfaceGroup( CViewBase::TCtorParam() );
wnd->setW( 1024 );
wnd->setH( 768 );
wnd->setParent( root );
wnd->setParentPos( root );
wnd->setParentSize( root );
wnd->setPosRef( Hotspot_MM );
wnd->setParentPosRef( Hotspot_MM );
wnd->setIdRecurse( window );
wnd->setActive( true );
// Add the window
root->addElement( wnd );
mg.addWindow( wnd, wnd->getPriority() );
_MasterGroups.push_back( mg );
_Pointer = new CViewPointer( CViewBase::TCtorParam() );
return true;
}
CWidgetManager::CWidgetManager()
{
LinkHack();

View file

@ -207,6 +207,21 @@ namespace GUIEditor
return;
close();
std::string proj = d.getProjectName().toUtf8().constData();
std::string wnd = d.getWindowName().toUtf8().constData();
bool b = GUICtrl->createNewGUI( proj, wnd );
if( !b )
{
QMessageBox::information( this,
tr( "Creating new GUI project" ),
tr( "Failed to create new GUI project :(" ) );
reset();
}
std::string mg = std::string( "ui:" ) + proj;
hierarchyView->buildHierarchy( mg );
}
void GUIEditorWindow::save()
@ -279,6 +294,20 @@ namespace GUIEditor
}
void GUIEditorWindow::reset()
{
projectFiles.clearAll();
projectWindow->clear();
hierarchyView->clearHierarchy();
GUICtrl->reset();
browserCtrl.clear();
linkList->clear();
procList->clear();
currentProject = "";
currentProjectFile = "";
projectParser.clear();
}
bool GUIEditorWindow::close()
{
if( currentProject.isEmpty() )
@ -296,16 +325,7 @@ namespace GUIEditor
disconnect( w, SIGNAL( sgnSelectionChanged() ), hierarchyView, SLOT( onSelectionChanged() ) );
disconnect( w, SIGNAL( sgnSelectionChanged() ), &browserCtrl, SLOT( onSelectionChanged() ) );
projectFiles.clearAll();
projectWindow->clear();
hierarchyView->clearHierarchy();
GUICtrl->reset();
browserCtrl.clear();
linkList->clear();
procList->clear();
currentProject = "";
currentProjectFile = "";
projectParser.clear();
reset();
return true;
}

View file

@ -70,6 +70,7 @@ protected:
void showEvent( QShowEvent *evnt );
private:
void reset();
void createMenus();
void removeMenus();

View file

@ -114,11 +114,29 @@ namespace GUIEditor
if( e != NULL )
e->setActive( true );
timerID = startTimer( 200 );
guiLoaded = true;
Q_EMIT guiLoadComplete();
onGUILoaded();
CWidgetManager::getInstance()->registerSelectionWatcher( watcher );
return true;
}
bool NelGUICtrl::createNewGUI( const std::string &project, const std::string &window )
{
reset();
bool ok = CWidgetManager::getInstance()->createNewGUI( project, window );
if( !ok )
return false;
std::string mg = std::string( "ui:" ) + project;
std::string ag = mg + ":" + window;
CWidgetManager::getInstance()->updateAllLocalisedElements();
CWidgetManager::getInstance()->activateMasterGroup( mg, true );
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( ag );
if( e != NULL )
e->setActive( true );
onGUILoaded();
return true;
}
@ -160,6 +178,15 @@ namespace GUIEditor
}
}
void NelGUICtrl::onGUILoaded()
{
timerID = startTimer( 200 );
guiLoaded = true;
Q_EMIT guiLoadComplete();
CWidgetManager::getInstance()->registerSelectionWatcher( watcher );
}
void NelGUICtrl::show()
{
if( timerID == 0 )

View file

@ -43,6 +43,7 @@ namespace GUIEditor
void init();
bool parse( SProjectFiles &files );
bool createNewGUI( const std::string &project, const std::string &window );
void draw();
void reset();
CEditorSelectionWatcher* getWatcher(){ return watcher; }
@ -61,6 +62,8 @@ Q_SIGNALS:
void timerEvent( QTimerEvent *evnt );
private:
void onGUILoaded();
int timerID;
bool guiLoaded;
CEditorSelectionWatcher *watcher;