added IFileSystem::getFileDir and made XML bitmap font use relative path for texture.
gui editor now compiles again git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@654 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7cf5252eb9
commit
4c2e3119f4
|
@ -115,6 +115,10 @@ public:
|
|||
//! Converts a relative path to an absolute (unique) path, resolving symbolic links if required
|
||||
virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename) = 0;
|
||||
|
||||
//! Returns the directory a file is located in.
|
||||
/** \param filename: The file to get the directory from */
|
||||
virtual irr::core::stringc getFileDir(irr::core::stringc &filename) = 0;
|
||||
|
||||
//! Creates a list of files and directories in the current working directory and returns it.
|
||||
/** \return a Pointer to the created IFileList is returned. After the list has been used
|
||||
it has to be deleted using its IFileList::drop() method.
|
||||
|
|
|
@ -231,6 +231,22 @@ irr::core::stringc CFileSystem::getAbsolutePath(irr::core::stringc &filename)
|
|||
return ret;
|
||||
}
|
||||
|
||||
irr::core::stringc CFileSystem::getFileDir(irr::core::stringc &filename)
|
||||
{
|
||||
irr::core::stringc ret;
|
||||
|
||||
// find last forward or backslash
|
||||
s32 lastSlash = filename.findLast('/');
|
||||
s32 lastBackSlash = filename.findLast('\\');
|
||||
lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;
|
||||
|
||||
if (lastSlash >= 0 && lastSlash < (s32)filename.size())
|
||||
ret = filename.subString(0, lastSlash);
|
||||
else
|
||||
ret = ".";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Creates a list of files and directories in the current working directory
|
||||
IFileList* CFileSystem::createFileList()
|
||||
|
|
|
@ -58,6 +58,10 @@ public:
|
|||
//! Converts a relative path to an absolute (unique) path, resolving symbolic links
|
||||
virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename);
|
||||
|
||||
//! Returns the directory a file is located in.
|
||||
/** \param filename: The file to get the directory from */
|
||||
virtual irr::core::stringc getFileDir(irr::core::stringc &filename);
|
||||
|
||||
//! Creates a list of files and directories in the current working directory
|
||||
//! and returns it.
|
||||
virtual IFileList* createFileList();
|
||||
|
|
|
@ -1184,12 +1184,19 @@ IGUIFont* CGUIEnvironment::getFont(const c8* filename)
|
|||
{
|
||||
CGUIFont* font = new CGUIFont(this, f.Filename.c_str());
|
||||
ifont = (IGUIFont*)font;
|
||||
// change working directory, for loading textures
|
||||
core::stringc workingDir = FileSystem->getWorkingDirectory();
|
||||
FileSystem->changeWorkingDirectoryTo(FileSystem->getFileDir(f.Filename).c_str());
|
||||
|
||||
// load the font
|
||||
if (!font->load(xml))
|
||||
{
|
||||
font->drop();
|
||||
font = 0;
|
||||
ifont = 0;
|
||||
}
|
||||
// change working dir back again
|
||||
FileSystem->changeWorkingDirectoryTo( workingDir.c_str());
|
||||
}
|
||||
else if (t==EGFT_VECTOR)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "CGUIAttributeEditor.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
|
||||
#include "IFileSystem.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "IAttributes.h"
|
||||
#include "IGUIFont.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "IVideoDriver.h"
|
||||
#include "IOSOperator.h"
|
||||
#include "IReadFile.h"
|
||||
#include "IFileSystem.h"
|
||||
#include "IXMLWriter.h"
|
||||
#include "IGUISkin.h"
|
||||
#include "IGUIElementFactory.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "CGUITextureCacheBrowser.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "IGUIButton.h"
|
||||
#include "IGUISkin.h"
|
||||
#include "IGUIFont.h"
|
||||
#include "IVideoDriver.h"
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
AdditionalOptions=" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib "
|
||||
OutputFile="../../bin/Win32-visualstudio/GUIEditor.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""C:\Documents and Settings\Administrator\My Documents\svn\irrlicht\lib\Win32-visualstudio""
|
||||
AdditionalLibraryDirectories=""..\..\lib\Win32-visualstudio""
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/TestProject.pdb"
|
||||
SubSystem="1"
|
||||
|
|
|
@ -53,8 +53,7 @@ int main()
|
|||
IGUISkin *skin = env->createSkin(EGST_WINDOWS_METALLIC);
|
||||
env->setSkin(skin);
|
||||
|
||||
device->getFileSystem()->addFolderFileArchive ( "../../media/" );
|
||||
IGUIFont *font = env->getFont("lucida.xml");
|
||||
IGUIFont *font = env->getFont("../../media/lucida.xml");
|
||||
if (font)
|
||||
skin->setFont(font);
|
||||
skin->drop();
|
||||
|
|
Loading…
Reference in New Issue