From 39d0e3dff7c217aea8624140f0251f6f1254b700 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 19 Jul 2012 22:28:45 +0200 Subject: [PATCH] ADDED: #1471 Loaded project files are now parsed, and the result is displayed. --- code/nel/include/nel/gui/parser.h | 1 + code/nel/include/nel/gui/view_renderer.h | 2 +- code/nel/src/gui/view_renderer.cpp | 14 ++++-- .../plugins/gui_editor/gui_editor_window.cpp | 2 + .../src/plugins/gui_editor/nelgui_widget.cpp | 44 ++++++++++++++++++- .../src/plugins/gui_editor/nelgui_widget.h | 4 ++ 6 files changed, 61 insertions(+), 6 deletions(-) diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index e032928c7..e9736ec2a 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -66,6 +66,7 @@ namespace NLGUI virtual CCtrlSheetSelection &getCtrlSheetSelection() = 0; virtual bool addLink( CInterfaceLink *link, const std::string &id ) = 0; virtual bool removeLink( const std::string &id ) = 0; + virtual void removeAll() = 0; }; } diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h index d716997ce..44d9c3cea 100644 --- a/code/nel/include/nel/gui/view_renderer.h +++ b/code/nel/include/nel/gui/view_renderer.h @@ -234,7 +234,7 @@ namespace NLGUI * loadTextures : load all textures associated with the interface * this function add a globaltexture to the vector of global textures */ - void loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC); + bool loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC); /* * createTexture : create a texture for the interface, possibly from an externally created texture diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index c8ddae40b..87132d5fd 100644 --- a/code/nel/src/gui/view_renderer.cpp +++ b/code/nel/src/gui/view_renderer.cpp @@ -735,12 +735,14 @@ namespace NLGUI /* * loadTextures */ - void CViewRenderer::loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC) + bool CViewRenderer::loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC) { SGlobalTexture gt; // Load texture file string filename = CPath::lookup (textureFileName, false); - if (filename == "") return; + if (filename == "") + return false; + CIFile ifTmp; if (ifTmp.open(filename)) CBitmap::loadSize (ifTmp, gt.Width, gt.Height); @@ -757,8 +759,10 @@ namespace NLGUI // Load uv file CIFile iFile; filename = CPath::lookup (uvFileName, false); - if (filename == "") return; - if (!iFile.open(filename)) return; + if (filename == "") + return false; + if (!iFile.open(filename)) + return false; _GlobalTextures.push_back (gt); @@ -824,6 +828,8 @@ namespace NLGUI initIndexesToTextureIds (); initSystemTextures(); initTypo(); + + return true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 677f14d18..9b34fc7a1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -142,6 +142,8 @@ namespace GUIEditor parser.getProjectFiles( projectFiles ); currentProject = parser.getProjectName().c_str(); projectWindow->setupFiles( projectFiles ); + viewPort->parse( projectFiles ); + viewPort->draw(); setCursor( Qt::ArrowCursor ); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp index 6d4b304d5..21a8d4a1f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp @@ -18,6 +18,9 @@ #include "nelgui_widget.h" #include "nel/misc/path.h" #include "nel/gui/view_renderer.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/path.h" #include #include @@ -38,7 +41,9 @@ namespace GUIEditor void NelGUIWidget::init() { - NLMISC::CPath::addSearchPath( "fonts" ); + NLMISC::CPath::remapExtension( "dds", "tga", true ); + NLMISC::CPath::remapExtension( "dds", "png", true ); + NLMISC::CPath::remapExtension( "png", "tga", true ); Nel3DWidget::init(); createTextContext( "Ryzom.ttf" ); @@ -48,5 +53,42 @@ namespace GUIEditor NLGUI::CViewRenderer::hwCursors = &hwCursors; NLGUI::CViewRenderer::getInstance()->init(); } + + bool NelGUIWidget::parse( SProjectFiles &files ) + { + CWidgetManager::getInstance()->reset(); + IParser *parser = CWidgetManager::getInstance()->getParser(); + parser->removeAll(); + CViewRenderer::getInstance()->reset(); + + std::vector< std::string >::iterator itr; + for( itr = files.mapFiles.begin(); itr != files.mapFiles.end(); ++itr ) + { + std::string &file = *itr; + std::string::size_type i = file.find_last_of( '.' ); + std::string mapFile = file.substr( 0, i ); + mapFile.append( ".txt" ); + + if( !CViewRenderer::getInstance()->loadTextures( file, mapFile, false ) ) + { + CViewRenderer::getInstance()->reset(); + return false; + } + } + + if( !parser->parseInterface( files.guiFiles, false ) ) + return false; + + CWidgetManager::getInstance()->updateAllLocalisedElements(); + return true; + } + + void NelGUIWidget::draw() + { + getDriver()->clearBuffers( NLMISC::CRGBA::Black ); + CWidgetManager::getInstance()->checkCoords(); + CWidgetManager::getInstance()->drawViews( 0 ); + getDriver()->swapBuffers(); + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h index d91856e96..c00d25c04 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h @@ -19,6 +19,7 @@ #define NELGUI_WIDGET_H #include "nel3d_widget.h" +#include "project_files.h" namespace GUIEditor { @@ -31,6 +32,9 @@ namespace GUIEditor ~NelGUIWidget(); void init(); + bool parse( SProjectFiles &files ); + void draw(); + }; }