diff --git a/bin/assets/ee.ini b/bin/assets/ee.ini index d52fcf716..e9fef62fb 100755 --- a/bin/assets/ee.ini +++ b/bin/assets/ee.ini @@ -6,7 +6,7 @@ BitColor = 32 Windowed = 1 Resizeable = 1 WinIcon = assets/icon/ee.png -VSync = 0 +VSync = 1 GLVersion = Default Backend = Default JoystickEnabled = 0 diff --git a/include/eepp/graphics/image.hpp b/include/eepp/graphics/image.hpp index bb32448fd..b79b7351d 100644 --- a/include/eepp/graphics/image.hpp +++ b/include/eepp/graphics/image.hpp @@ -44,11 +44,16 @@ class EE_API Image { */ static bool getInfo( const std::string& path, int * width, int * height, int * channels ); - /** @return True if the file is a valid image + /** @return True if the file is a valid image ( reads the file header to know if the file is an image file format supported ) * @param path the image path */ static bool isImage( const std::string& path ); + /** @return If the path or file name has a supported image file extension + * @param path the image path or file name + */ + static bool isImageExtension( const std::string& path ); + /** @return The last failure image loading/info reason */ static std::string getLastFailureReason(); diff --git a/include/eepp/ui/uiskin.hpp b/include/eepp/ui/uiskin.hpp index 0f8fcca43..0bf30cc40 100644 --- a/include/eepp/ui/uiskin.hpp +++ b/include/eepp/ui/uiskin.hpp @@ -18,6 +18,8 @@ class EE_API UISkin { static const char * getSkinStateName( const Uint32& State ); + static bool isStateName( const std::string& State ); + UISkin( const std::string& name, const Uint32& Type ); virtual ~UISkin(); diff --git a/include/eepp/ui/uiskincomplex.hpp b/include/eepp/ui/uiskincomplex.hpp index 6ebeb14dc..2a7f56a2e 100644 --- a/include/eepp/ui/uiskincomplex.hpp +++ b/include/eepp/ui/uiskincomplex.hpp @@ -16,6 +16,8 @@ class EE_API UISkinComplex : public UISkin { static std::string getSideSuffix( const Uint32& Side ); + static bool isSideSuffix( const std::string& suffix ); + enum UISkinComplexSides { Left = 0, Right, diff --git a/include/eepp/ui/uitheme.hpp b/include/eepp/ui/uitheme.hpp index 103ce0b83..5bdb163db 100644 --- a/include/eepp/ui/uitheme.hpp +++ b/include/eepp/ui/uitheme.hpp @@ -27,11 +27,11 @@ class EE_API UITheme : protected ResourceManager { static UITheme * loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtlas * getTextureAtlas ); - static UITheme * loadFromFile( UITheme * tTheme, const std::string& Path, const std::string ImgExt = "png" ); + static UITheme * loadFromFile( UITheme * tTheme, const std::string& Path ); static UITheme * loadFromTextureAtlas( Graphics::TextureAtlas * getTextureAtlas, const std::string& Name, const std::string NameAbbr ); - static UITheme * loadFromFile( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt = "png" ); + static UITheme * loadFromFile( const std::string& Path, const std::string& Name, const std::string& NameAbbr ); void addThemeElement( const std::string& Element ); @@ -84,14 +84,8 @@ class EE_API UITheme : protected ResourceManager { std::string mAbbr; Graphics::TextureAtlas *mTextureAtlas; UITooltipStyleConfig mFontStyleConfig; - std::list mUIElements; - std::list mUIIcons; - void getTextureAtlas( Graphics::TextureAtlas * SG ); - - static bool searchFilesOfElement( Graphics::TextureAtlas * SG, const std::string& Path, std::string Element, Uint32& IsComplex, const std::string ImgExt ); - - static bool searchFilesInAtlas( Graphics::TextureAtlas * SG, std::string Element, Uint32& IsComplex ); + void setTextureAtlas( Graphics::TextureAtlas * SG ); }; }} diff --git a/premake4.lua b/premake4.lua index 28ba6bb94..3062ab2a9 100644 --- a/premake4.lua +++ b/premake4.lua @@ -150,7 +150,7 @@ newoption { description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.", allowed = { { "SDL2", "SDL2 (default and recommended)" }, - { "SFML", "SFML2 ( SFML 1.6 not supported )" }, + { "SFML", "SFML2" }, { "SDL2,SFML", "SDL2+SFML" } } } diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index e6619d615..d0a7cabc3 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -28,7 +28,13 @@ QmlJSGlobal - 2 + + Nim + + NimGlobal + + + 3 UTF-8 false 4 diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 9aa112d27..caad1366d 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -88,7 +88,6 @@ ../../src/eepp/ui/uithemedefault.cpp ../../src/eepp/ui/uitouchdragablewidget.cpp ../../src/eepp/ui/uiwidget.cpp -../../../eeiv/src/capp.cpp ../../include/eepp/audio/soundmanager.hpp ../../include/eepp/audio/soundloader.hpp ../../include/eepp/audio/soundstream.hpp @@ -745,4 +744,3 @@ ../../include/eepp/system/md5.hpp ../../src/eepp/system/md5.cpp ../../src/examples/strobe/strobe.cpp -../../../eeiv/src/capp.hpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index b235c68ae..341e66a6f 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -1,8 +1,5 @@ ../../src/ ../../include/ -../../src/examples/strobe -../../../eeiv/src -. ../../include/eepp/graphics ../../src/eepp/graphics ../../include/eepp/ui diff --git a/src/eepp/graphics/image.cpp b/src/eepp/graphics/image.cpp index 11b70a980..f85d81528 100644 --- a/src/eepp/graphics/image.cpp +++ b/src/eepp/graphics/image.cpp @@ -224,6 +224,24 @@ bool Image::isImage( const std::string& path ) { return STBI_unknown != stbi_test( path.c_str() ); } +bool Image::isImageExtension( const std::string& path ) { + std::string Ext( FileSystem::fileExtension( path ) ); + + return ( Ext == "png" || + Ext == "tga" || + Ext == "bmp" || + Ext == "jpg" || + Ext == "gif" || + Ext == "jpeg" || + Ext == "dds" || + Ext == "psd" || + Ext == "hdr" || + Ext == "pic" || + Ext == "pvr" || + Ext == "pkm" + ); +} + std::string Image::getLastFailureReason() { return std::string( stbi_failure_reason() ); } diff --git a/src/eepp/graphics/textureatlasloader.cpp b/src/eepp/graphics/textureatlasloader.cpp index c975fddd2..2eaeba3ca 100644 --- a/src/eepp/graphics/textureatlasloader.cpp +++ b/src/eepp/graphics/textureatlasloader.cpp @@ -326,34 +326,6 @@ bool TextureAtlasLoader::updateTextureAtlas() { return false; } -static bool IsImage( std::string path ) { - if ( FileSystem::fileSize( path ) ) { - std::string File = path.substr( path.find_last_of("/\\") + 1 ); - std::string Ext = File.substr( File.find_last_of(".") + 1 ); - String::toLowerInPlace( Ext ); - - if ( Ext == "png" || - Ext == "tga" || - Ext == "bmp" || - Ext == "jpg" || - Ext == "gif" || - Ext == "jpeg" || - Ext == "dds" || - Ext == "psd" || - Ext == "hdr" || - Ext == "pic" || - Ext == "pvr" || - Ext == "pkm" - ) { - return true; - } else { - return Image::isImage( path ); - } - } - - return false; -} - bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ) { if ( !TextureAtlasPath.size() || !ImagesPath.size() || !FileSystem::fileExists( TextureAtlasPath ) || !FileSystem::isDirectory( ImagesPath ) ) return false; @@ -390,7 +362,7 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: std::string realpath( ImagesPath + PathFiles[z] ); // Avoids reading file headers for known extensions - if ( IsImage( realpath ) ) + if ( Image::isImageExtension( realpath ) ) totalImages++; } diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp index cccc3e600..a353f1833 100644 --- a/src/eepp/ui/tools/textureatlasnew.cpp +++ b/src/eepp/ui/tools/textureatlasnew.cpp @@ -142,7 +142,7 @@ void TextureAtlasNew::windowClose( const UIEvent * Event ) { eeDelete( this ); } -static bool IsValidExtension( const std::string& ext ) { +static bool isValidExtension( const std::string& ext ) { return ext == "png" || ext == "bmp" || ext == "dds" || ext == "tga"; } @@ -165,7 +165,7 @@ void TextureAtlasNew::textureAtlasSave( const UIEvent * Event ) { std::string ext = FileSystem::fileExtension( FPath, true ); - if ( !IsValidExtension( ext ) ) { + if ( !isValidExtension( ext ) ) { FPath = FileSystem::fileRemoveExtension( FPath ); ext = mSaveFileType->getText(); diff --git a/src/eepp/ui/uiskin.cpp b/src/eepp/ui/uiskin.cpp index 908a52743..5a7ee1b4d 100644 --- a/src/eepp/ui/uiskin.cpp +++ b/src/eepp/ui/uiskin.cpp @@ -16,6 +16,16 @@ const char * UISkin::getSkinStateName( const Uint32& State ) { return UISkinStatesNames[ State ]; } +bool UISkin::isStateName( const std::string& State ) { + for ( int i = 0; i < UISkinState::StateCount; i++ ) { + if ( State == UISkinStatesNames[i] ) { + return true; + } + } + + return false; +} + UISkin::UISkin( const std::string& name, const Uint32& Type ) : mType( Type ), mName( name ), diff --git a/src/eepp/ui/uiskincomplex.cpp b/src/eepp/ui/uiskincomplex.cpp index 01539a3b5..34c358c72 100644 --- a/src/eepp/ui/uiskincomplex.cpp +++ b/src/eepp/ui/uiskincomplex.cpp @@ -8,7 +8,7 @@ static const char SideSuffix[ UISkinComplex::SideCount ][4] = { "ml", "mr","d","u","ul","ur","dl","dr","m" }; -UISkinComplex *UISkinComplex::New(const std::string & name) { +UISkinComplex * UISkinComplex::New(const std::string & name) { return eeNew( UISkinComplex, ( name ) ); } @@ -18,6 +18,16 @@ std::string UISkinComplex::getSideSuffix( const Uint32& Side ) { return std::string( SideSuffix[ Side ] ); } +bool UISkinComplex::isSideSuffix( const std::string& suffix ) { + for ( int i = 0; i < UISkinComplex::SideCount; i++ ) { + if ( suffix == SideSuffix[i] ) { + return true; + } + } + + return false; +} + UISkinComplex::UISkinComplex(const std::string& name ) : UISkin( name, SkinComplex ) { diff --git a/src/eepp/ui/uitheme.cpp b/src/eepp/ui/uitheme.cpp index eedc1d641..1c44d15e1 100644 --- a/src/eepp/ui/uitheme.cpp +++ b/src/eepp/ui/uitheme.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -9,119 +10,36 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - namespace EE { namespace UI { -static void loadThemeElements( std::list& UI_THEME_ELEMENTS, std::list& UI_THEME_ICONS ) { - UI_THEME_ELEMENTS.push_back( "control" ); - UI_THEME_ELEMENTS.push_back( "button" ); - UI_THEME_ELEMENTS.push_back( "textinput" ); - UI_THEME_ELEMENTS.push_back( "checkbox" ); - UI_THEME_ELEMENTS.push_back( "checkbox_active" ); - UI_THEME_ELEMENTS.push_back( "checkbox_inactive" ); - UI_THEME_ELEMENTS.push_back( "button" ); - UI_THEME_ELEMENTS.push_back( "radiobutton" ); - UI_THEME_ELEMENTS.push_back( "radiobutton_active" ); - UI_THEME_ELEMENTS.push_back( "radiobutton_inactive" ); - UI_THEME_ELEMENTS.push_back( "hslider" ); - UI_THEME_ELEMENTS.push_back( "hslider_bg" ); - UI_THEME_ELEMENTS.push_back( "hslider_button" ); - UI_THEME_ELEMENTS.push_back( "vslider" ); - UI_THEME_ELEMENTS.push_back( "vslider_bg" ); - UI_THEME_ELEMENTS.push_back( "vslider_button" ); - UI_THEME_ELEMENTS.push_back( "spinbox" ); - UI_THEME_ELEMENTS.push_back( "spinbox_input" ); - UI_THEME_ELEMENTS.push_back( "spinbox_btnup" ); - UI_THEME_ELEMENTS.push_back( "spinbox_btndown" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar_slider" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar_bg" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar_button" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar_btnup" ); - UI_THEME_ELEMENTS.push_back( "hscrollbar_btndown" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar_slider" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar_bg" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar_button" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar_btnup" ); - UI_THEME_ELEMENTS.push_back( "vscrollbar_btndown" ); - UI_THEME_ELEMENTS.push_back( "progressbar" ); - UI_THEME_ELEMENTS.push_back( "progressbar_filler" ); - UI_THEME_ELEMENTS.push_back( "listbox" ); - UI_THEME_ELEMENTS.push_back( "listboxitem" ); - UI_THEME_ELEMENTS.push_back( "dropdownlist" ); - UI_THEME_ELEMENTS.push_back( "combobox" ); - UI_THEME_ELEMENTS.push_back( "combobox_button" ); - UI_THEME_ELEMENTS.push_back( "menu" ); - UI_THEME_ELEMENTS.push_back( "menuitem" ); - UI_THEME_ELEMENTS.push_back( "separator" ); - UI_THEME_ELEMENTS.push_back( "menucheckbox_active" ); - UI_THEME_ELEMENTS.push_back( "menucheckbox_inactive" ); - UI_THEME_ELEMENTS.push_back( "menuarrow" ); - UI_THEME_ELEMENTS.push_back( "textedit" ); - UI_THEME_ELEMENTS.push_back( "textedit_box" ); - UI_THEME_ELEMENTS.push_back( "tooltip" ); - UI_THEME_ELEMENTS.push_back( "genericgrid" ); - UI_THEME_ELEMENTS.push_back( "gridcell" ); - UI_THEME_ELEMENTS.push_back( "windeco" ); - UI_THEME_ELEMENTS.push_back( "winback" ); - UI_THEME_ELEMENTS.push_back( "winborderleft" ); - UI_THEME_ELEMENTS.push_back( "winborderright" ); - UI_THEME_ELEMENTS.push_back( "winborderbottom" ); - UI_THEME_ELEMENTS.push_back( "winclose" ); - UI_THEME_ELEMENTS.push_back( "winmax" ); - UI_THEME_ELEMENTS.push_back( "winmin" ); - UI_THEME_ELEMENTS.push_back( "winshade" ); - UI_THEME_ELEMENTS.push_back( "winmenu" ); - UI_THEME_ELEMENTS.push_back( "winmenubutton" ); - UI_THEME_ELEMENTS.push_back( "tabwidget" ); - UI_THEME_ELEMENTS.push_back( "tabcontainer" ); - UI_THEME_ELEMENTS.push_back( "tab" ); - UI_THEME_ELEMENTS.push_back( "tab_left" ); - UI_THEME_ELEMENTS.push_back( "tab_right" ); +static std::string elemNameFromSkinSimple( const std::vector& nameParts ) { + std::string str; + int lPart = (int)nameParts.size() - 1; - UI_THEME_ICONS.push_back( "ok" ); - UI_THEME_ICONS.push_back( "cancel" ); - UI_THEME_ICONS.push_back( "remove" ); - UI_THEME_ICONS.push_back( "go-up" ); - UI_THEME_ICONS.push_back( "quit" ); - UI_THEME_ICONS.push_back( "add" ); - UI_THEME_ICONS.push_back( "document-open" ); - UI_THEME_ICONS.push_back( "document-close" ); - UI_THEME_ICONS.push_back( "document-new" ); - UI_THEME_ICONS.push_back( "document-save" ); - UI_THEME_ICONS.push_back( "document-save-as" ); + for ( int i = 0; i < lPart; i++ ) { + str += nameParts[i]; + + if ( i != lPart - 1 ) { + str += "_"; + } + } + + return str; } -void UITheme::addThemeElement( const std::string& Element ) { - mUIElements.push_back( Element ); -} +static std::string elemNameFromSkinComplex( const std::vector& nameParts ) { + std::string str; + int lPart = (int)nameParts.size() - 2; -void UITheme::addThemeIcon( const std::string& Icon ) { - mUIIcons.push_back( Icon ); + for ( int i = 0; i < lPart; i++ ) { + str += nameParts[i]; + + if ( i != lPart - 1 ) { + str += "_"; + } + } + + return str; } UITheme * UITheme::New( const std::string & name, const std::string & abbr, Font * defaultFont ) { @@ -138,34 +56,39 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla Clock TE; - loadThemeElements( tTheme->mUIElements, tTheme->mUIIcons ); + tTheme->setTextureAtlas( TextureAtlas ); - Uint32 i; - bool Found; - std::string Element; - std::vector ElemFound; - std::vector ElemType; + std::list& resources = TextureAtlas->getResources(); + std::list::iterator it; + std::string sAbbr( tTheme->getAbbr() + "_" ); + std::map elemFound; - tTheme->getTextureAtlas( TextureAtlas ); + for ( it = resources.begin(); it != resources.end(); it++ ) { + SubTexture* subTexture = *it; - for ( std::list::iterator it = tTheme->mUIElements.begin() ; it != tTheme->mUIElements.end(); it++ ) { - Uint32 IsComplex = 0; + std::string name( subTexture->getName() ); - Element = tTheme->getAbbr() + "_" + *it; + if ( String::startsWith( name, sAbbr ) ) { + std::vector nameParts = String::split( name, '_' ); - Found = searchFilesInAtlas( TextureAtlas, Element, IsComplex ); + if ( nameParts.size() >= 3 ) { + int lPart = nameParts.size() - 1; + int llPart = nameParts.size() - 2; - if ( Found ) { - ElemFound.push_back( Element ); - ElemType.push_back( IsComplex ); + if ( UISkin::isStateName( nameParts[ lPart ] ) ) { + elemFound[ elemNameFromSkinSimple( nameParts ) ] = false; + } else if ( UISkin::isStateName( nameParts[ llPart ] ) && UISkinComplex::isSideSuffix( nameParts[ lPart ] ) ) { + elemFound[ elemNameFromSkinComplex( nameParts ) ] = true; + } + } } } - for ( i = 0; i < ElemFound.size(); i++ ) { - if ( ElemType[i] ) - tTheme->add( UISkinComplex::New( ElemFound[i] ) ); + for ( std::map::iterator it = elemFound.begin(); it != elemFound.end(); it++ ) { + if ( it->second ) + tTheme->add( UISkinComplex::New( it->first ) ); else - tTheme->add( UISkinSimple::New( ElemFound[i] ) ); + tTheme->add( UISkinSimple::New( it->first ) ); } eePRINTL( "UI Theme Loaded in: %4.3f ms ( from TextureAtlas )", TE.getElapsed().asMilliseconds() ); @@ -173,15 +96,9 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla return tTheme; } -UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, const std::string ImgExt ) { +UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path ) { Clock TE; - loadThemeElements( tTheme->mUIElements, tTheme->mUIIcons ); - - Uint32 i; - bool Found; - std::string Element; - std::string ElemName; std::string RPath( Path ); FileSystem::dirPathAddSlashAtEnd( RPath ); @@ -189,33 +106,41 @@ UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, cons if ( !FileSystem::isDirectory( RPath ) ) return NULL; - std::vector ElemFound; - std::vector ElemType; - Graphics::TextureAtlas * tSG = eeNew( Graphics::TextureAtlas, ( tTheme->getAbbr() ) ); - tTheme->getTextureAtlas( tSG ); + tTheme->setTextureAtlas( tSG ); - for ( std::list::iterator it = tTheme->mUIElements.begin() ; it != tTheme->mUIElements.end(); it++ ) { - Uint32 IsComplex = 0; + std::vector resources = FileSystem::filesGetInPath( RPath ); + std::vector::iterator it; + std::string sAbbr( tTheme->getAbbr() + "_" ); + std::string sAbbrIcon( tTheme->getAbbr() + "_icon_" ); + std::map elemFound; - Element = tTheme->getAbbr() + "_" + *it; + for ( it = resources.begin(); it != resources.end(); it++ ) { + std::string fpath( RPath + (*it) ); + std::string name( FileSystem::fileRemoveExtension( *it ) ); - Found = searchFilesOfElement( tSG, RPath, Element, IsComplex, ImgExt ); + if ( !FileSystem::isDirectory( fpath ) ) { + if ( String::startsWith( name, sAbbrIcon ) ) { + tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + } else if ( String::startsWith( name, sAbbr ) ) { + std::vector nameParts = String::split( name, '_' ); - if ( Found ) { - ElemFound.push_back( Element ); - ElemType.push_back( IsComplex ); - } - } + if ( nameParts.size() >= 3 ) { + int lPart = nameParts.size() - 1; + int llPart = nameParts.size() - 2; - // Load the icons from path. - for ( std::list::iterator it = tTheme->mUIIcons.begin() ; it != tTheme->mUIIcons.end(); it++ ) { - ElemName = tTheme->getAbbr() + "_icon_" + *it; - Element = RPath + ElemName + "." + ImgExt; + if ( UISkin::isStateName( nameParts[ lPart ] ) ) { + elemFound[ elemNameFromSkinSimple( nameParts ) ] = false; - if ( FileSystem::fileExists( Element ) ) { - tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( Element ), ElemName ) ) ); + tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + } else if ( UISkin::isStateName( nameParts[ llPart ] ) && UISkinComplex::isSideSuffix( nameParts[ lPart ] ) ) { + elemFound[ elemNameFromSkinComplex( nameParts ) ] = true; + + tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + } + } + } } } @@ -224,11 +149,11 @@ UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, cons else eeSAFE_DELETE( tSG ); - for ( i = 0; i < ElemFound.size(); i++ ) { - if ( ElemType[i] ) - tTheme->add( UISkinComplex::New( ElemFound[i] ) ); + for ( std::map::iterator it = elemFound.begin(); it != elemFound.end(); it++ ) { + if ( it->second ) + tTheme->add( UISkinComplex::New( it->first ) ); else - tTheme->add( UISkinSimple::New( ElemFound[i] ) ); + tTheme->add( UISkinSimple::New( it->first ) ); } eePRINTL( "UI Theme Loaded in: %4.3f ms ( from path )", TE.getElapsed().asMilliseconds() ); @@ -236,95 +161,14 @@ UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, cons return tTheme; } -UITheme * UITheme::loadFromFile( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) { - return loadFromFile( UITheme::New( Name, NameAbbr ), Path, ImgExt ); +UITheme * UITheme::loadFromFile( const std::string& Path, const std::string& Name, const std::string& NameAbbr ) { + return loadFromFile( UITheme::New( Name, NameAbbr ), Path ); } UITheme * UITheme::loadFromTextureAtlas( Graphics::TextureAtlas * TextureAtlas, const std::string& Name, const std::string NameAbbr ) { return loadFromTextureAtlas( UITheme::New( Name, NameAbbr ), TextureAtlas ); } -bool UITheme::searchFilesInAtlas( Graphics::TextureAtlas * SG, std::string Element, Uint32& IsComplex ) { - bool Found = false; - Uint32 i = 0, s = 0; - std::string ElemName; - IsComplex = 0; - - // Search Complex Skin - for ( i = 0; i < UISkinState::StateCount; i++ ) { - for ( s = 0; s < UISkinComplex::SideCount; s++ ) { - ElemName = Element + "_" + UISkin::getSkinStateName( i ) + "_" + UISkinComplex::getSideSuffix( s ); - - if ( SG->getByName( ElemName ) ) { - IsComplex = 1; - Found = true; - break; - } - } - - if ( Found ) { - break; - } - } - - // Search Simple Skin - if ( !IsComplex ) { - for ( i = 0; i < UISkinState::StateCount; i++ ) { - ElemName = Element + "_" + UISkin::getSkinStateName( i ); - - if ( SG->getByName( ElemName ) ) { - Found = true; - break; - } - } - } - - return Found; -} - -bool UITheme::searchFilesOfElement( Graphics::TextureAtlas * SG, const std::string& Path, std::string Element, Uint32& IsComplex, const std::string ImgExt ) { - bool Found = false; - Uint32 i = 0, s = 0; - std::string ElemPath; - std::string ElemFullPath; - std::string ElemName; - IsComplex = 0; - - // Search Complex Skin - for ( i = 0; i < UISkinState::StateCount; i++ ) { - for ( s = 0; s < UISkinComplex::SideCount; s++ ) { - ElemName = Element + "_" + UISkin::getSkinStateName( i ) + "_" + UISkinComplex::getSideSuffix( s ); - ElemPath = Path + ElemName; - ElemFullPath = ElemPath + "." + ImgExt; - - if ( FileSystem::fileExists( ElemFullPath ) ) { - SG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( ElemFullPath ), ElemName ) ) ); - - IsComplex = 1; - Found = true; - break; - } - } - } - - // Seach Simple Skin - if ( !IsComplex ) { - for ( i = 0; i < UISkinState::StateCount; i++ ) { - ElemName = Element + "_" + UISkin::getSkinStateName( i ); - ElemPath = Path + ElemName; - ElemFullPath = ElemPath + "." + ImgExt; - - if ( FileSystem::fileExists( ElemFullPath ) ) { - SG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( ElemFullPath ), ElemName ) ) ); - - Found = true; - } - } - } - - return Found; -} - UITheme::UITheme(const std::string& name, const std::string& Abbr, Graphics::Font * defaultFont ) : ResourceManager ( false ), mName( name ), @@ -373,7 +217,7 @@ Graphics::TextureAtlas * UITheme::getTextureAtlas() const { return mTextureAtlas; } -void UITheme::getTextureAtlas( Graphics::TextureAtlas * SG ) { +void UITheme::setTextureAtlas( Graphics::TextureAtlas * SG ) { mTextureAtlas = SG; } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index aeac8db62..55e9e327f 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -293,7 +293,7 @@ void EETest::createUI() { UIManager::instance()->init(UI_MAN_OPS); UIManager::instance()->setTranslator( mTranslator ); - //mTheme = UITheme::loadFromFile( UIThemeDefault::New( mThemeName, mThemeName ), MyPath + mThemeName + "/" ); + //mTheme = UITheme::loadFromFile( UIThemeDefault::New( mThemeName, mThemeName ), MyPath + "ui/" + mThemeName + "/" ); TextureAtlasLoader tgl( MyPath + "ui/" + mThemeName + EE_TEXTURE_ATLAS_EXTENSION );