#include "stdafx.h" #include "UIManager.h" #include "Tokenizer.h" #include "UIImageFont.h" bool cUIManager::LoadImageFonts( const cString& pathName ) { /// ÆÄÀÏ ¿­±â cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load image fonts" ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) return false; unsigned int index = str.ToInt(); /// À̹ÌÁö À妽º if( tokenizer.GetNext( &str ) == false ) return false; unsigned int imageIndex = str.ToInt(); /// ÅØ½ºÃ³ ½ÃÀÛ À§Ä¡ if( tokenizer.GetNext( &str ) == false ) return false; unsigned int texX = str.ToInt(); if( tokenizer.GetNext( &str ) == false ) return false; unsigned int texY = str.ToInt(); /// ÅØ½ºÃ³ ÆùÆ® ¹®ÀÚ Å©±â if( tokenizer.GetNext( &str ) == false ) return false; unsigned int charWidth = str.ToInt(); if( tokenizer.GetNext( &str ) == false ) return false; unsigned int charHeight = str.ToInt(); /// À̹ÌÁö ÆùÆ®¸¦ »ý¼º NiTexture* tex = UIMAN->GetSkin()->GetTexture( imageIndex ); if( tex == 0 ) continue; cUIImageFont* imageFont = new cUIImageFont( tex, texX, texY, charWidth, charHeight ); if( mImageFontMap.Insert( index, imageFont ) == false ) { assert( 0 && "failed to insert image font, maybe already exist" ); return false; } } return true; } cUIImageFont* cUIManager::GetImageFont( unsigned int fontIndex ) { cImageFontMap::cIterator i = mImageFontMap.Find( fontIndex ); if( i == mImageFontMap.End() ) return 0; else return (cUIImageFont*)(i->mSecond); }