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

--HG--
branch : gsoc2012-gui-editor
hg/feature/sse2
dfighter1985 13 years ago
parent efb1d8a6aa
commit cadd13ba53

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

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

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

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

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

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

Loading…
Cancel
Save