ADDED: #1471 Loaded project files are now parsed, and the result is displayed.

This commit is contained in:
dfighter1985 2012-07-19 22:28:45 +02:00
parent b75a4a827e
commit 39d0e3dff7
6 changed files with 61 additions and 6 deletions

View file

@ -66,6 +66,7 @@ namespace NLGUI
virtual CCtrlSheetSelection &getCtrlSheetSelection() = 0; virtual CCtrlSheetSelection &getCtrlSheetSelection() = 0;
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;
}; };
} }

View file

@ -234,7 +234,7 @@ namespace NLGUI
* loadTextures : load all textures associated with the interface * loadTextures : load all textures associated with the interface
* this function add a globaltexture to the vector of global textures * 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 * createTexture : create a texture for the interface, possibly from an externally created texture

View file

@ -735,12 +735,14 @@ namespace NLGUI
/* /*
* loadTextures * 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; SGlobalTexture gt;
// Load texture file // Load texture file
string filename = CPath::lookup (textureFileName, false); string filename = CPath::lookup (textureFileName, false);
if (filename == "") return; if (filename == "")
return false;
CIFile ifTmp; CIFile ifTmp;
if (ifTmp.open(filename)) if (ifTmp.open(filename))
CBitmap::loadSize (ifTmp, gt.Width, gt.Height); CBitmap::loadSize (ifTmp, gt.Width, gt.Height);
@ -757,8 +759,10 @@ namespace NLGUI
// Load uv file // Load uv file
CIFile iFile; CIFile iFile;
filename = CPath::lookup (uvFileName, false); filename = CPath::lookup (uvFileName, false);
if (filename == "") return; if (filename == "")
if (!iFile.open(filename)) return; return false;
if (!iFile.open(filename))
return false;
_GlobalTextures.push_back (gt); _GlobalTextures.push_back (gt);
@ -824,6 +828,8 @@ namespace NLGUI
initIndexesToTextureIds (); initIndexesToTextureIds ();
initSystemTextures(); initSystemTextures();
initTypo(); initTypo();
return true;
} }

View file

@ -142,6 +142,8 @@ namespace GUIEditor
parser.getProjectFiles( projectFiles ); parser.getProjectFiles( projectFiles );
currentProject = parser.getProjectName().c_str(); currentProject = parser.getProjectName().c_str();
projectWindow->setupFiles( projectFiles ); projectWindow->setupFiles( projectFiles );
viewPort->parse( projectFiles );
viewPort->draw();
setCursor( Qt::ArrowCursor ); setCursor( Qt::ArrowCursor );
} }

View file

@ -18,6 +18,9 @@
#include "nelgui_widget.h" #include "nelgui_widget.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
#include "nel/gui/view_renderer.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 <set> #include <set>
#include <string> #include <string>
@ -38,7 +41,9 @@ namespace GUIEditor
void NelGUIWidget::init() 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(); Nel3DWidget::init();
createTextContext( "Ryzom.ttf" ); createTextContext( "Ryzom.ttf" );
@ -48,5 +53,42 @@ namespace GUIEditor
NLGUI::CViewRenderer::hwCursors = &hwCursors; NLGUI::CViewRenderer::hwCursors = &hwCursors;
NLGUI::CViewRenderer::getInstance()->init(); 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();
}
} }

View file

@ -19,6 +19,7 @@
#define NELGUI_WIDGET_H #define NELGUI_WIDGET_H
#include "nel3d_widget.h" #include "nel3d_widget.h"
#include "project_files.h"
namespace GUIEditor namespace GUIEditor
{ {
@ -31,6 +32,9 @@ namespace GUIEditor
~NelGUIWidget(); ~NelGUIWidget();
void init(); void init();
bool parse( SProjectFiles &files );
void draw();
}; };
} }