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 bool addLink( CInterfaceLink *link, 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
* 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

View file

@ -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;
}

View file

@ -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 );
}

View file

@ -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 <set>
#include <string>
@ -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();
}
}

View file

@ -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();
};
}