mirror of https://github.com/axmolengine/axmol.git
Merge branch 'master' of https://github.com/cocos2d/cocos2d-x into MenuTest
This commit is contained in:
commit
24a34e50bf
|
@ -27,11 +27,17 @@ THE SOFTWARE.
|
|||
#include "ccMacros.h"
|
||||
#include "ccConfig.h"
|
||||
#include <string.h>
|
||||
#include "cocoa/CCDictionary.h"
|
||||
#include "cocoa/CCInteger.h"
|
||||
#include "cocoa/CCBool.h"
|
||||
#include "cocos2d.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
||||
CCConfiguration* CCConfiguration::s_gSharedConfiguration = NULL;
|
||||
|
||||
CCConfiguration::CCConfiguration(void)
|
||||
|
@ -45,57 +51,96 @@ CCConfiguration::CCConfiguration(void)
|
|||
, m_nMaxSamplesAllowed(0)
|
||||
, m_nMaxTextureUnits(0)
|
||||
, m_pGlExtensions(NULL)
|
||||
, m_pDefaults(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
bool CCConfiguration::init(void)
|
||||
{
|
||||
CCLOG("cocos2d: GL_VENDOR: %s", glGetString(GL_VENDOR));
|
||||
CCLOG("cocos2d: GL_RENDERER: %s", glGetString(GL_RENDERER));
|
||||
CCLOG("cocos2d: GL_VERSION: %s", glGetString(GL_VERSION));
|
||||
m_pDefaults = CCDictionary::create();
|
||||
m_pDefaults->retain();
|
||||
|
||||
m_pDefaults->setObject( CCString::create( cocos2dVersion() ), "cocos2d.version");
|
||||
|
||||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
m_pDefaults->setObject( CCBool::create(true), "cocos2d.compiled_with_profiler");
|
||||
#else
|
||||
m_pDefaults->setObject( CCBool::create(false), "cocos2d.compiled_with_profiler");
|
||||
#endif
|
||||
|
||||
#if CC_ENABLE_GL_STATE_CACHE == 0
|
||||
m_pDefaults->setObject( CCBool::create(false), "cocos2d.compiled_with_gl_state_cache");
|
||||
#else
|
||||
m_pDefaults->setObject( CCBool::create(true), "cocos2d.compiled_with_gl_state_cache");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCConfiguration::~CCConfiguration(void)
|
||||
{
|
||||
m_pDefaults->release();
|
||||
}
|
||||
|
||||
void CCConfiguration::dumpInfo(void) const
|
||||
{
|
||||
// Dump
|
||||
CCPrettyPrinter visitor(0);
|
||||
m_pDefaults->acceptVisitor(visitor);
|
||||
|
||||
CCLOG("%s", visitor.getResult().c_str());
|
||||
|
||||
|
||||
// And Dump some warnings as well
|
||||
#if CC_ENABLE_PROFILERS
|
||||
CCLOG("cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.h)");
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
#if CC_ENABLE_GL_STATE_CACHE == 0
|
||||
CCLOG("");
|
||||
CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it (from ccConfig.h)");
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void CCConfiguration::gatherGPUInfo()
|
||||
{
|
||||
m_pDefaults->setObject( CCString::create( (const char*)glGetString(GL_VENDOR)), "gl.vendor");
|
||||
m_pDefaults->setObject( CCString::create( (const char*)glGetString(GL_RENDERER)), "gl.renderer");
|
||||
m_pDefaults->setObject( CCString::create( (const char*)glGetString(GL_VERSION)), "gl.version");
|
||||
|
||||
m_pGlExtensions = (char *)glGetString(GL_EXTENSIONS);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_nMaxTextureSize);
|
||||
m_pDefaults->setObject( CCInteger::create((int)m_nMaxTextureSize), "gl.max_texture_size");
|
||||
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &m_nMaxTextureUnits);
|
||||
m_pDefaults->setObject( CCInteger::create((int)m_nMaxTextureUnits), "gl.max_texture_units");
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
glGetIntegerv(GL_MAX_SAMPLES_APPLE, &m_nMaxSamplesAllowed);
|
||||
m_pDefaults->setObject( CCInteger::create((int)m_nMaxSamplesAllowed), "gl.max_samples_allowed");
|
||||
#endif
|
||||
|
||||
m_bSupportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
||||
m_pDefaults->setObject( CCBool::create(m_bSupportsPVRTC), "gl.supports_PVRTC");
|
||||
|
||||
m_bSupportsNPOT = true;
|
||||
m_pDefaults->setObject( CCBool::create(m_bSupportsNPOT), "gl.supports_NPOT");
|
||||
|
||||
m_bSupportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888");
|
||||
m_pDefaults->setObject( CCBool::create(m_bSupportsBGRA8888), "gl.supports_BGRA8888");
|
||||
|
||||
m_bSupportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer");
|
||||
m_pDefaults->setObject( CCBool::create(m_bSupportsDiscardFramebuffer), "gl.supports_discard_framebuffer");
|
||||
|
||||
m_bSupportsShareableVAO = checkForGLExtension("vertex_array_object");
|
||||
|
||||
CCLOG("cocos2d: GL_MAX_TEXTURE_SIZE: %d", m_nMaxTextureSize);
|
||||
CCLOG("cocos2d: GL_MAX_TEXTURE_UNITS: %d",m_nMaxTextureUnits);
|
||||
CCLOG("cocos2d: GL supports PVRTC: %s", (m_bSupportsPVRTC ? "YES" : "NO"));
|
||||
CCLOG("cocos2d: GL supports BGRA8888 textures: %s", (m_bSupportsBGRA8888 ? "YES" : "NO"));
|
||||
CCLOG("cocos2d: GL supports NPOT textures: %s", (m_bSupportsNPOT ? "YES" : "NO"));
|
||||
CCLOG("cocos2d: GL supports discard_framebuffer: %s", (m_bSupportsDiscardFramebuffer ? "YES" : "NO"));
|
||||
CCLOG("cocos2d: GL supports shareable VAO: %s", (m_bSupportsShareableVAO ? "YES" : "NO") );
|
||||
|
||||
bool CC_UNUSED bEnableProfilers = false;
|
||||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
bEnableProfilers = true;
|
||||
#else
|
||||
bEnableProfilers = false;
|
||||
#endif
|
||||
CCLOG("cocos2d: compiled with Profiling Support: %s",
|
||||
bEnableProfilers ? "YES - *** Disable it when you finish profiling ***" : "NO");
|
||||
|
||||
#if CC_ENABLE_GL_STATE_CACHE == 0
|
||||
CCLOG("");
|
||||
CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h");
|
||||
printf("\n");
|
||||
#endif
|
||||
m_pDefaults->setObject( CCBool::create(m_bSupportsShareableVAO), "gl.supports_vertex_array_object");
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCConfiguration* CCConfiguration::sharedConfiguration(void)
|
||||
|
@ -114,7 +159,7 @@ void CCConfiguration::purgeConfiguration(void)
|
|||
CC_SAFE_RELEASE_NULL(s_gSharedConfiguration);
|
||||
}
|
||||
|
||||
bool CCConfiguration::checkForGLExtension(const string &searchName)
|
||||
bool CCConfiguration::checkForGLExtension(const string &searchName) const
|
||||
{
|
||||
bool bRet = false;
|
||||
const char *kSearchName = searchName.c_str();
|
||||
|
@ -128,4 +173,124 @@ bool CCConfiguration::checkForGLExtension(const string &searchName)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
//
|
||||
// getters for specific variables.
|
||||
// Mantained for backward compatiblity reasons only.
|
||||
//
|
||||
int CCConfiguration::getMaxTextureSize(void) const
|
||||
{
|
||||
return m_nMaxTextureSize;
|
||||
}
|
||||
|
||||
int CCConfiguration::getMaxModelviewStackDepth(void) const
|
||||
{
|
||||
return m_nMaxModelviewStackDepth;
|
||||
}
|
||||
|
||||
int CCConfiguration::getMaxTextureUnits(void) const
|
||||
{
|
||||
return m_nMaxTextureUnits;
|
||||
}
|
||||
|
||||
bool CCConfiguration::supportsNPOT(void) const
|
||||
{
|
||||
return m_bSupportsNPOT;
|
||||
}
|
||||
|
||||
bool CCConfiguration::supportsPVRTC(void) const
|
||||
{
|
||||
return m_bSupportsPVRTC;
|
||||
}
|
||||
|
||||
bool CCConfiguration::supportsBGRA8888(void) const
|
||||
{
|
||||
return m_bSupportsBGRA8888;
|
||||
}
|
||||
|
||||
bool CCConfiguration::supportsDiscardFramebuffer(void) const
|
||||
{
|
||||
return m_bSupportsDiscardFramebuffer;
|
||||
}
|
||||
|
||||
bool CCConfiguration::supportsShareableVAO(void) const
|
||||
{
|
||||
return m_bSupportsShareableVAO;
|
||||
}
|
||||
|
||||
//
|
||||
// generic getters for properties
|
||||
//
|
||||
const char *CCConfiguration::getCString( const char *key ) const
|
||||
{
|
||||
CCObject *ret = m_pDefaults->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( CCString *str=dynamic_cast<CCString*>(ret) )
|
||||
return str->getCString();
|
||||
|
||||
CCAssert(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** returns the value of a given key as a boolean */
|
||||
bool CCConfiguration::getBool( const char *key ) const
|
||||
{
|
||||
CCObject *ret = m_pDefaults->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( CCBool *obj=dynamic_cast<CCBool*>(ret) )
|
||||
return obj->getValue();
|
||||
CCAssert(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return false;
|
||||
}
|
||||
|
||||
/** returns the value of a given key as a double */
|
||||
double CCConfiguration::getNumber( const char *key ) const
|
||||
{
|
||||
CCObject *ret = m_pDefaults->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( CCDouble *obj=dynamic_cast<CCDouble*>(ret) )
|
||||
return obj->getValue();
|
||||
|
||||
if( CCInteger *obj=dynamic_cast<CCInteger*>(ret) )
|
||||
return obj->getValue();
|
||||
|
||||
CCAssert(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
CCObject * CCConfiguration::getObject( const char *key ) const
|
||||
{
|
||||
return m_pDefaults->objectForKey(key);
|
||||
}
|
||||
|
||||
//
|
||||
// load file
|
||||
//
|
||||
void CCConfiguration::loadConfigFile( const char *filename )
|
||||
{
|
||||
CCDictionary *dict = CCDictionary::createWithContentsOfFile(filename);
|
||||
CCAssert(dict, "cannot create dictionary");
|
||||
|
||||
// Add all keys in the existing dictionary
|
||||
CCDictElement* element;
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
if( ! m_pDefaults->objectForKey( element->getStrKey() ) )
|
||||
m_pDefaults->setObject(element->getObject(), element->getStrKey() );
|
||||
else
|
||||
CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -28,10 +28,22 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "CCGL.h"
|
||||
#include "cocoa/CCString.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
typedef enum _ccConfigurationType {
|
||||
ConfigurationError,
|
||||
ConfigurationString,
|
||||
ConfigurationInt,
|
||||
ConfigurationDouble,
|
||||
ConfigurationBoolean
|
||||
} ccConfigurationType;
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup global
|
||||
* @{
|
||||
|
@ -45,78 +57,80 @@ class CC_DLL CCConfiguration : public CCObject
|
|||
public:
|
||||
/** returns a shared instance of CCConfiguration */
|
||||
static CCConfiguration *sharedConfiguration(void);
|
||||
|
||||
/** purge the shared instance of CCConfiguration */
|
||||
static void purgeConfiguration(void);
|
||||
public:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
virtual ~CCConfiguration(void);
|
||||
|
||||
/** OpenGL Max texture size. */
|
||||
inline int getMaxTextureSize(void)
|
||||
{
|
||||
return m_nMaxTextureSize;
|
||||
}
|
||||
|
||||
int getMaxTextureSize(void) const;
|
||||
|
||||
/** OpenGL Max Modelview Stack Depth. */
|
||||
inline int getMaxModelviewStackDepth(void)
|
||||
{
|
||||
return m_nMaxModelviewStackDepth;
|
||||
}
|
||||
int getMaxModelviewStackDepth(void) const;
|
||||
|
||||
/** returns the maximum texture units
|
||||
@since v2.0.0
|
||||
*/
|
||||
inline int getMaxTextureUnits(void)
|
||||
{
|
||||
return m_nMaxTextureUnits;
|
||||
}
|
||||
int getMaxTextureUnits(void) const;
|
||||
|
||||
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
|
||||
OpenGL ES 2.0 already supports NPOT (iOS).
|
||||
|
||||
@since v0.99.2
|
||||
*/
|
||||
inline bool supportsNPOT(void)
|
||||
{
|
||||
return m_bSupportsNPOT;
|
||||
}
|
||||
bool supportsNPOT(void) const;
|
||||
|
||||
/** Whether or not PVR Texture Compressed is supported */
|
||||
inline bool supportsPVRTC(void)
|
||||
{
|
||||
return m_bSupportsPVRTC;
|
||||
}
|
||||
bool supportsPVRTC(void) const;
|
||||
|
||||
/** Whether or not BGRA8888 textures are supported.
|
||||
@since v0.99.2
|
||||
*/
|
||||
inline bool supportsBGRA8888(void)
|
||||
{
|
||||
return m_bSupportsBGRA8888;
|
||||
}
|
||||
bool supportsBGRA8888(void) const;
|
||||
|
||||
/** Whether or not glDiscardFramebufferEXT is supported
|
||||
@since v0.99.2
|
||||
*/
|
||||
inline bool supportsDiscardFramebuffer(void)
|
||||
{
|
||||
return m_bSupportsDiscardFramebuffer;
|
||||
}
|
||||
bool supportsDiscardFramebuffer(void) const;
|
||||
|
||||
/** Whether or not shareable VAOs are supported.
|
||||
@since v2.0.0
|
||||
*/
|
||||
inline bool supportsShareableVAO(void)
|
||||
{
|
||||
return m_bSupportsShareableVAO;
|
||||
}
|
||||
bool supportsShareableVAO(void) const;
|
||||
|
||||
/** returns whether or not an OpenGL is supported */
|
||||
bool checkForGLExtension(const std::string &searchName);
|
||||
bool checkForGLExtension(const std::string &searchName) const;
|
||||
|
||||
bool init(void);
|
||||
|
||||
/** returns the value of a given key as a string */
|
||||
const char* getCString( const char *key ) const;
|
||||
|
||||
/** returns the value of a given key as a boolean */
|
||||
bool getBool( const char *key ) const;
|
||||
|
||||
/** returns the value of a given key as a double */
|
||||
double getNumber( const char *key ) const;
|
||||
|
||||
/** returns the value of a given key as a double */
|
||||
CCObject * getObject( const char *key ) const;
|
||||
|
||||
/** dumps the current configuration on the console */
|
||||
void dumpInfo(void) const;
|
||||
|
||||
/** gathers OpenGL / GPU information */
|
||||
void gatherGPUInfo( void );
|
||||
|
||||
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */
|
||||
void loadConfigFile( const char *filename );
|
||||
|
||||
private:
|
||||
CCConfiguration(void);
|
||||
static CCConfiguration *s_gSharedConfiguration;
|
||||
static std::string s_sConfigfile;
|
||||
|
||||
protected:
|
||||
GLint m_nMaxTextureSize;
|
||||
|
@ -129,6 +143,7 @@ protected:
|
|||
GLint m_nMaxSamplesAllowed;
|
||||
GLint m_nMaxTextureUnits;
|
||||
char * m_pGlExtensions;
|
||||
CCDictionary *m_pDefaults;
|
||||
};
|
||||
|
||||
// end of global group
|
||||
|
|
|
@ -23,6 +23,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// standard includes
|
||||
#include <string>
|
||||
|
||||
// cocos2d includes
|
||||
#include "CCDirector.h"
|
||||
#include "ccFPSImages.h"
|
||||
#include "draw_nodes/CCDrawingPrimitives.h"
|
||||
|
@ -57,7 +62,9 @@ THE SOFTWARE.
|
|||
#include "kazmath/GL/matrix.h"
|
||||
#include "support/CCProfiling.h"
|
||||
#include "CCEGLView.h"
|
||||
#include <string>
|
||||
#include "CCConfiguration.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Position of the FPS
|
||||
|
@ -98,9 +105,7 @@ CCDirector::CCDirector(void)
|
|||
}
|
||||
|
||||
bool CCDirector::init(void)
|
||||
{
|
||||
CCLOG("cocos2d: %s", cocos2dVersion());
|
||||
|
||||
{
|
||||
// scenes
|
||||
m_pRunningScene = NULL;
|
||||
m_pNextScene = NULL;
|
||||
|
@ -304,6 +309,11 @@ void CCDirector::setOpenGLView(CCEGLView *pobOpenGLView)
|
|||
|
||||
if (m_pobOpenGLView != pobOpenGLView)
|
||||
{
|
||||
// Configuration. Gather GPU info
|
||||
CCConfiguration *conf = CCConfiguration::sharedConfiguration();
|
||||
conf->gatherGPUInfo();
|
||||
conf->dumpInfo();
|
||||
|
||||
// EAGLView is not a CCObject
|
||||
delete m_pobOpenGLView; // [openGLView_ release]
|
||||
m_pobOpenGLView = pobOpenGLView;
|
||||
|
|
|
@ -101,6 +101,7 @@ void CCPrettyPrinter::visit(const CCBool * p)
|
|||
{
|
||||
char buf[50] = {0};
|
||||
sprintf(buf, "%s", p->getValue() ? "true" : "false");
|
||||
_result += buf;
|
||||
}
|
||||
|
||||
void CCPrettyPrinter::visit(const CCInteger *p)
|
||||
|
|
|
@ -23,6 +23,10 @@ public:
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/* override functions */
|
||||
virtual void acceptVisitor(CCDataVisitor &visitor) { visitor.visit(this); }
|
||||
|
||||
private:
|
||||
int m_nValue;
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "cocos2d-2.1rc0-x-2.1.3";
|
||||
return "2.1rc0-x-2.1.3";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
echo 'cocos2d-x template installer'
|
||||
|
||||
COCOS2D_VER='cocos2d-2.0-rc2-x-2.0.1'
|
||||
COCOS2D_VER='cocos2d-2.1rc0-x-2.1.3'
|
||||
BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode"
|
||||
BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode"
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ Classes/UserDefaultTest/UserDefaultTest.cpp \
|
|||
Classes/ZwoptexTest/ZwoptexTest.cpp \
|
||||
Classes/FileUtilsTest/FileUtilsTest.cpp \
|
||||
Classes/DataVisitorTest/DataVisitorTest.cpp \
|
||||
Classes/ConfigurationTest/ConfigurationTest.cpp \
|
||||
Classes/controller.cpp \
|
||||
Classes/testBasic.cpp \
|
||||
Classes/AppDelegate.cpp \
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
#include "ConfigurationTest.h"
|
||||
#include "../testResource.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
TESTLAYER_CREATE_FUNC(ConfigurationLoadConfig);
|
||||
TESTLAYER_CREATE_FUNC(ConfigurationQuery);
|
||||
|
||||
static NEWTESTFUNC createFunctions[] = {
|
||||
CF(ConfigurationLoadConfig),
|
||||
CF(ConfigurationQuery)
|
||||
};
|
||||
|
||||
static int sceneIdx=-1;
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
||||
static CCLayer* nextAction()
|
||||
{
|
||||
sceneIdx++;
|
||||
sceneIdx = sceneIdx % MAX_LAYER;
|
||||
|
||||
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
||||
pLayer->init();
|
||||
pLayer->autorelease();
|
||||
|
||||
return pLayer;
|
||||
}
|
||||
|
||||
static CCLayer* backAction()
|
||||
{
|
||||
sceneIdx--;
|
||||
int total = MAX_LAYER;
|
||||
if( sceneIdx < 0 )
|
||||
sceneIdx += total;
|
||||
|
||||
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
||||
pLayer->init();
|
||||
pLayer->autorelease();
|
||||
|
||||
return pLayer;
|
||||
}
|
||||
|
||||
static CCLayer* restartAction()
|
||||
{
|
||||
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
||||
pLayer->init();
|
||||
pLayer->autorelease();
|
||||
|
||||
return pLayer;
|
||||
}
|
||||
|
||||
void ConfigurationTestScene::runThisTest()
|
||||
{
|
||||
sceneIdx = -1;
|
||||
addChild(nextAction());
|
||||
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
||||
|
||||
std::string ConfigurationBase::title()
|
||||
{
|
||||
return "Configuration Test";
|
||||
}
|
||||
|
||||
std::string ConfigurationBase::subtitle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void ConfigurationBase::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
// add title and subtitle
|
||||
std::string str = title();
|
||||
const char * pTitle = str.c_str();
|
||||
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||
}
|
||||
|
||||
// add menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ConfigurationBase::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ConfigurationBase::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ConfigurationBase::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
void ConfigurationBase::onExit()
|
||||
{
|
||||
CCLayer::onExit();
|
||||
}
|
||||
|
||||
void ConfigurationBase::restartCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* s = new ConfigurationTestScene();
|
||||
s->addChild( restartAction() );
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void ConfigurationBase::nextCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* s = new ConfigurationTestScene();
|
||||
s->addChild( nextAction() );
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void ConfigurationBase::backCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* s = new ConfigurationTestScene();
|
||||
s->addChild( backAction() );
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ConfigurationLoadConfig
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void ConfigurationLoadConfig::onEnter()
|
||||
{
|
||||
ConfigurationBase::onEnter();
|
||||
|
||||
CCConfiguration::sharedConfiguration()->loadConfigFile("animations/animations.plist");
|
||||
CCConfiguration::sharedConfiguration()->dumpInfo();
|
||||
|
||||
}
|
||||
|
||||
std::string ConfigurationLoadConfig::subtitle()
|
||||
{
|
||||
return "Loading config file manually. See console";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ConfigurationQuery
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void ConfigurationQuery::onEnter()
|
||||
{
|
||||
ConfigurationBase::onEnter();
|
||||
|
||||
CCLOG("cocos2d version: %s", CCConfiguration::sharedConfiguration()->getCString("cocos2d.version") );
|
||||
CCLOG("OpenGL version: %s", CCConfiguration::sharedConfiguration()->getCString("gl.version") );
|
||||
}
|
||||
|
||||
std::string ConfigurationQuery::subtitle()
|
||||
{
|
||||
return "Using getCString(). Check the console";
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef __CONFIGURATIONTEST_H__
|
||||
#define __CONFIGURATIONTEST_H__
|
||||
|
||||
#include "../testBasic.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
|
||||
// the class inherit from TestScene
|
||||
// every Scene each test used must inherit from TestScene,
|
||||
// make sure the test have the menu item for back to main menu
|
||||
class ConfigurationTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class ConfigurationBase : public CCLayer
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void restartCallback(CCObject* pSender);
|
||||
void nextCallback(CCObject* pSender);
|
||||
void backCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class ConfigurationLoadConfig : public ConfigurationBase
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class ConfigurationQuery : public ConfigurationBase
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
#endif // __CONFIGURATIONTEST_H__
|
|
@ -128,7 +128,10 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
case TEST_DATAVISTOR:
|
||||
pScene = new DataVisitorTestScene();
|
||||
break;
|
||||
default:
|
||||
case TEST_CONFIGURATION:
|
||||
pScene = new ConfigurationTestScene();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include "SpineTest/SpineTest.h"
|
||||
#include "TexturePackerEncryptionTest/TextureAtlasEncryptionTest.h"
|
||||
#include "DataVisitorTest/DataVisitorTest.h"
|
||||
|
||||
#include "ConfigurationTest/ConfigurationTest.h"
|
||||
enum
|
||||
{
|
||||
TEST_ACTIONS = 0,
|
||||
|
@ -117,7 +117,10 @@ enum
|
|||
TEST_SPINE,
|
||||
TEST_TEXTUREPACKER_ENCRYPTION,
|
||||
TEST_DATAVISTOR,
|
||||
TESTS_COUNT,
|
||||
TEST_CONFIGURATION,
|
||||
|
||||
// last one
|
||||
TESTS_COUNT,
|
||||
};
|
||||
|
||||
const std::string g_aTestNames[TESTS_COUNT] = {
|
||||
|
@ -178,7 +181,8 @@ const std::string g_aTestNames[TESTS_COUNT] = {
|
|||
"FileUtilsTest",
|
||||
"SpineTest",
|
||||
"TexturePackerEncryption",
|
||||
"DataVistorTest"
|
||||
"DataVistorTest",
|
||||
"ConfigurationTest"
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -84,6 +84,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \
|
|||
../Classes/ZwoptexTest/ZwoptexTest.cpp \
|
||||
../Classes/FileUtilsTest/FileUtilsTest.cpp \
|
||||
../Classes/DataVisitorTest/DataVisitorTest.cpp \
|
||||
../Classes/ConfigurationTest/ConfigurationTest.cpp \
|
||||
../Classes/controller.cpp \
|
||||
../Classes/testBasic.cpp \
|
||||
../Classes/AppDelegate.cpp \
|
||||
|
|
|
@ -1 +1 @@
|
|||
6b5e473d37f1653e3e4098f7a69cd6be2b4bc4b4
|
||||
55285e0eccaf3807a3e3f232f528c2a4ff80a6be
|
|
@ -87,6 +87,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \
|
|||
../Classes/FileUtilsTest/FileUtilsTest.cpp \
|
||||
../Classes/SpineTest/SpineTest.cpp \
|
||||
../Classes/DataVisitorTest/DataVisitorTest.cpp \
|
||||
../Classes/ConfigurationTest/ConfigurationTest.cpp \
|
||||
../Classes/controller.cpp \
|
||||
../Classes/testBasic.cpp \
|
||||
../Classes/AppDelegate.cpp \
|
||||
|
|
|
@ -1 +1 @@
|
|||
90d267b6c461f771978ca8a8d23c6e688cfa7077
|
||||
5bf596dcac34b37a7ba44a2063590fb43de53efb
|
|
@ -480,6 +480,11 @@ files
|
|||
(../Classes/DataVisitorTest)
|
||||
DataVisitorTest.cpp
|
||||
DataVisitorTest.h
|
||||
|
||||
[Test/ConfigurationTest]
|
||||
(../Classes/ConfigurationTest)
|
||||
ConfigurationTest.cpp
|
||||
ConfigurationTest.h
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \
|
|||
../Classes/ZwoptexTest/ZwoptexTest.cpp \
|
||||
../Classes/SpineTest/SpineTest.cpp \
|
||||
../Classes/DataVisitorTest/DataVisitorTest.cpp \
|
||||
../Classes/ConfigurationTest/ConfigurationTest.cpp \
|
||||
../Classes/controller.cpp \
|
||||
../Classes/testBasic.cpp \
|
||||
../Classes/AppDelegate.cpp \
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="..\Classes\ChipmunkTest\ChipmunkTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ClippingNodeTest\ClippingNodeTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ConfigurationTest\ConfigurationTest.cpp" />
|
||||
<ClCompile Include="..\Classes\DataVisitorTest\DataVisitorTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocosBuilderTest\AnimationsTest\AnimationsTestLayer.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest\TimelineCallbackTestLayer.cpp" />
|
||||
|
@ -216,6 +217,7 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="..\Classes\ChipmunkTest\ChipmunkTest.h" />
|
||||
<ClInclude Include="..\Classes\ClippingNodeTest\ClippingNodeTest.h" />
|
||||
<ClInclude Include="..\Classes\ConfigurationTest\ConfigurationTest.h" />
|
||||
<ClInclude Include="..\Classes\DataVisitorTest\DataVisitorTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocosBuilderTest\AnimationsTest\AnimationsLayerLoader.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocosBuilderTest\AnimationsTest\AnimationsTestLayer.h" />
|
||||
|
|
|
@ -223,6 +223,9 @@
|
|||
<Filter Include="Classes\DataVisitorTest">
|
||||
<UniqueIdentifier>{8049d378-12f7-46ba-ba96-091f3c0a4600}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ConfigurationTest">
|
||||
<UniqueIdentifier>{81ec2355-7efd-49e0-b6cb-b1bba23fbbc8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
|
@ -504,6 +507,9 @@
|
|||
<ClCompile Include="..\Classes\DataVisitorTest\DataVisitorTest.cpp">
|
||||
<Filter>Classes\DataVisitorTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ConfigurationTest\ConfigurationTest.cpp">
|
||||
<Filter>Classes\ConfigurationTest</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
|
@ -965,5 +971,8 @@
|
|||
<ClInclude Include="..\Classes\DataVisitorTest\DataVisitorTest.h">
|
||||
<Filter>Classes\DataVisitorTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ConfigurationTest\ConfigurationTest.h">
|
||||
<Filter>Classes\ConfigurationTest</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -24,7 +24,10 @@ if [ "$PLATFORM"x = "android"x ]; then
|
|||
./generate-jsbindings.sh
|
||||
|
||||
build_android Cpp HelloCpp
|
||||
build_android Cpp TestCpp
|
||||
build_android Cpp AssetsManagerTest
|
||||
build_android Javascript TestJavascript
|
||||
build_android Lua HelloLua
|
||||
build_android Lua TestLua
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue