mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 02:26:29 +03:00
Minor fixes.
--HG-- branch : dev
This commit is contained in:
@@ -6,11 +6,17 @@
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class DrawableSearcher {
|
||||
class EE_API DrawableSearcher {
|
||||
public:
|
||||
static Drawable * searchByName( const std::string& name );
|
||||
|
||||
static Drawable * searchById( const Uint32 & id );
|
||||
|
||||
static void setPrintWarnings( const bool& print );
|
||||
|
||||
static bool getPrintWarnings();
|
||||
protected:
|
||||
static bool sPrintWarnings;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -54,10 +54,10 @@ class EE_API TextureAtlasManager : public ResourceManager<TextureAtlas> {
|
||||
void printResources();
|
||||
|
||||
/** Sets if the warnings for not finding a resource must be printed in screen. */
|
||||
void printWarnings( const bool& warn );
|
||||
void setPrintWarnings( const bool& warn );
|
||||
|
||||
/** @return If warnings are being printed. */
|
||||
const bool& printWarnings() const;
|
||||
const bool& getPrintWarnings() const;
|
||||
protected:
|
||||
bool mWarnings;
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
bool DrawableSearcher::sPrintWarnings = false;
|
||||
|
||||
static Drawable * getSprite( const std::string& sprite ) {
|
||||
std::vector<SubTexture*> tSubTextureVec = TextureAtlasManager::instance()->getSubTexturesByPattern( sprite );
|
||||
|
||||
@@ -22,7 +24,7 @@ static Drawable * getSprite( const std::string& sprite ) {
|
||||
|
||||
static Drawable * searchByNameInternal( const std::string& name ) {
|
||||
Uint32 id = String::hash( name );
|
||||
Drawable * drawable = GlobalTextureAtlas::instance()->getById( id );
|
||||
Drawable * drawable = TextureAtlasManager::instance()->getSubTextureById( id );
|
||||
|
||||
if ( NULL == drawable ) {
|
||||
drawable = TextureFactory::instance()->getByHash( id );
|
||||
@@ -41,28 +43,31 @@ Drawable * DrawableSearcher::searchByName( const std::string& name ) {
|
||||
if ( name.size() ) {
|
||||
if ( name[0] == '@' ) {
|
||||
if ( String::startsWith( name, "@subtexture/" ) ) {
|
||||
return GlobalTextureAtlas::instance()->getByName( name.substr( 12 ) );
|
||||
drawable = TextureAtlasManager::instance()->getSubTextureByName( name.substr( 12 ) );
|
||||
} else if ( String::startsWith( name, "@image/" ) ) {
|
||||
return TextureFactory::instance()->getByName( name.substr( 7 ) );
|
||||
drawable = TextureFactory::instance()->getByName( name.substr( 7 ) );
|
||||
} else if ( String::startsWith( name, "@texture/" ) ) {
|
||||
return TextureFactory::instance()->getByName( name.substr( 9 ) );
|
||||
drawable = TextureFactory::instance()->getByName( name.substr( 9 ) );
|
||||
} else if ( String::startsWith( name, "@sprite/" ) ) {
|
||||
return getSprite( name.substr( 8 ) );
|
||||
drawable = getSprite( name.substr( 8 ) );
|
||||
} else if ( String::startsWith( name, "@drawable/" ) ) {
|
||||
return searchByNameInternal( name.substr( 10 ) );
|
||||
drawable = searchByNameInternal( name.substr( 10 ) );
|
||||
} else {
|
||||
return searchByNameInternal( name );
|
||||
drawable = searchByNameInternal( name );
|
||||
}
|
||||
} else {
|
||||
return searchByNameInternal( name );
|
||||
drawable = searchByNameInternal( name );
|
||||
}
|
||||
}
|
||||
|
||||
if ( NULL == drawable && sPrintWarnings )
|
||||
eePRINTL( "DrawableSearcher::searchByName: \"%s\" not found", name.c_str() );
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
Drawable * DrawableSearcher::searchById( const Uint32& id ) {
|
||||
Drawable * drawable = GlobalTextureAtlas::instance()->getById( id );
|
||||
Drawable * drawable = TextureAtlasManager::instance()->getSubTextureById( id );
|
||||
|
||||
if ( NULL == drawable ) {
|
||||
drawable = TextureFactory::instance()->getByHash( id );
|
||||
@@ -80,7 +85,18 @@ Drawable * DrawableSearcher::searchById( const Uint32& id ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( NULL == drawable && sPrintWarnings )
|
||||
eePRINTL( "DrawableSearcher::searchById: \"%ld\" not found", id );
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
void DrawableSearcher::setPrintWarnings( const bool& print ) {
|
||||
sPrintWarnings = print;
|
||||
}
|
||||
|
||||
bool DrawableSearcher::getPrintWarnings() {
|
||||
return sPrintWarnings;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -95,11 +95,11 @@ std::vector<SubTexture*> TextureAtlasManager::getSubTexturesByPatternId( const U
|
||||
return std::vector<SubTexture*>();
|
||||
}
|
||||
|
||||
void TextureAtlasManager::printWarnings( const bool& warn ) {
|
||||
void TextureAtlasManager::setPrintWarnings( const bool& warn ) {
|
||||
mWarnings = warn;
|
||||
}
|
||||
|
||||
const bool& TextureAtlasManager::printWarnings() const {
|
||||
const bool& TextureAtlasManager::getPrintWarnings() const {
|
||||
return mWarnings;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <eepp/ui/uiskinsimple.hpp>
|
||||
#include <eepp/graphics/textureatlasmanager.hpp>
|
||||
#include <eepp/graphics/drawable.hpp>
|
||||
#include <eepp/graphics/drawablesearcher.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -39,7 +39,7 @@ void UISkinSimple::setSkin( const Uint32& State ) {
|
||||
|
||||
std::string Name( mName + "_" + UISkin::getSkinStateName( State ) );
|
||||
|
||||
mDrawable[ State ] = TextureAtlasManager::instance()->getSubTextureByName( Name );
|
||||
mDrawable[ State ] = DrawableSearcher::searchByName( Name );
|
||||
}
|
||||
|
||||
bool UISkinSimple::stateExists( const Uint32 & state ) {
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace Demo_Test {
|
||||
void EETest::init() {
|
||||
EE = Engine::instance();
|
||||
|
||||
Log::instance()->setLiveWrite( true );
|
||||
Log::instance()->setConsoleOutput( true );
|
||||
|
||||
Translator t;
|
||||
|
||||
t.loadFromString(
|
||||
@@ -20,9 +23,6 @@ void EETest::init() {
|
||||
"</resources>"
|
||||
);
|
||||
|
||||
Log::instance()->setLiveWrite( true );
|
||||
Log::instance()->setConsoleOutput( true );
|
||||
|
||||
DrawBack = false;
|
||||
MultiViewportMode = false;
|
||||
|
||||
@@ -556,6 +556,7 @@ void EETest::createNewUI() {
|
||||
pushButton->setIcon( mTheme->getIconByName( "ok" ) );
|
||||
|
||||
UISprite * sprite = UISprite::New();
|
||||
sprite->setFlags( UI_AUTO_SIZE );
|
||||
sprite->setPosition( 50, 600 );
|
||||
sprite->setSprite( &SP );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user