mirror of https://github.com/axmolengine/axmol.git
Qt 5 port: Fixes to build against "develop" branch
The Qt 5 port was based on the "master" branch. This patch updates all Qt 5 changes to build correctly with the "develop" branch. Tested with GCC 4.6 and Qt 5.1.0 on Linux.
This commit is contained in:
parent
0557eb9674
commit
2f35353020
|
@ -41,7 +41,7 @@ namespace CocosDenshion {
|
||||||
static QString
|
static QString
|
||||||
fullPath(const char *filename)
|
fullPath(const char *filename)
|
||||||
{
|
{
|
||||||
return QString::fromStdString(CCFileUtils::sharedFileUtils()->fullPathForFilename(filename));
|
return QString::fromStdString(FileUtils::getInstance()->fullPathForFilename(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
class CocosQt5AudioBackend {
|
class CocosQt5AudioBackend {
|
||||||
|
@ -119,7 +119,7 @@ simple_audio_engine = NULL;
|
||||||
@brief Get the shared Engine object,it will new one when first time be called
|
@brief Get the shared Engine object,it will new one when first time be called
|
||||||
*/
|
*/
|
||||||
SimpleAudioEngine *
|
SimpleAudioEngine *
|
||||||
SimpleAudioEngine::sharedEngine()
|
SimpleAudioEngine::getInstance()
|
||||||
{
|
{
|
||||||
if (simple_audio_engine == NULL) {
|
if (simple_audio_engine == NULL) {
|
||||||
simple_audio_engine = new SimpleAudioEngine;
|
simple_audio_engine = new SimpleAudioEngine;
|
||||||
|
@ -283,8 +283,11 @@ SimpleAudioEngine::setEffectsVolume(float volume)
|
||||||
@bLoop Whether to loop the effect playing, default value is false
|
@bLoop Whether to loop the effect playing, default value is false
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop)
|
SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
||||||
|
float pitch, float pan, float gain)
|
||||||
{
|
{
|
||||||
|
// TODO: Handle pitch, pan and gain
|
||||||
|
|
||||||
CocosQt5AudioBackend::gcEffects();
|
CocosQt5AudioBackend::gcEffects();
|
||||||
|
|
||||||
QString filename = fullPath(pszFilePath);
|
QString filename = fullPath(pszFilePath);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
AccelerometerListener::AccelerometerListener(CCAccelerometer *accelerometer)
|
AccelerometerListener::AccelerometerListener(Accelerometer *accelerometer)
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_accelerometer(accelerometer)
|
, m_accelerometer(accelerometer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,13 +38,13 @@ class AccelerometerListener : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AccelerometerListener(CCAccelerometer *accelerometer);
|
AccelerometerListener(Accelerometer *accelerometer);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onReadingChanged();
|
void onReadingChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCAccelerometer *m_accelerometer;
|
Accelerometer *m_accelerometer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* COCOS2DX_ACCELEROMETER_LISTENER_QT5_H */
|
#endif /* COCOS2DX_ACCELEROMETER_LISTENER_QT5_H */
|
||||||
|
|
|
@ -33,29 +33,29 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
static CCAccelerometer *
|
static Accelerometer *
|
||||||
shared_accelerometer = NULL;
|
shared_accelerometer = NULL;
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer()
|
Accelerometer::Accelerometer()
|
||||||
: m_accelerometer(new QAccelerometer)
|
: m_accelerometer(new QAccelerometer)
|
||||||
, m_listener(new AccelerometerListener(this))
|
, m_listener(new AccelerometerListener(this))
|
||||||
, m_delegate(NULL)
|
, m_function(nullptr)
|
||||||
{
|
{
|
||||||
QObject::connect(m_accelerometer, SIGNAL(readingChanged()),
|
QObject::connect(m_accelerometer, SIGNAL(readingChanged()),
|
||||||
m_listener, SLOT(onReadingChanged()));
|
m_listener, SLOT(onReadingChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CCAccelerometer::~CCAccelerometer()
|
Accelerometer::~Accelerometer()
|
||||||
{
|
{
|
||||||
delete m_listener;
|
delete m_listener;
|
||||||
delete m_accelerometer;
|
delete m_accelerometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCAccelerometer *
|
Accelerometer *
|
||||||
CCAccelerometer::sharedAccelerometer()
|
Accelerometer::sharedAccelerometer()
|
||||||
{
|
{
|
||||||
if (shared_accelerometer == NULL) {
|
if (shared_accelerometer == NULL) {
|
||||||
shared_accelerometer = new CCAccelerometer;
|
shared_accelerometer = new Accelerometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shared_accelerometer;
|
return shared_accelerometer;
|
||||||
|
@ -63,13 +63,13 @@ CCAccelerometer::sharedAccelerometer()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CCAccelerometer::setDelegate(CCAccelerometerDelegate *pDelegate)
|
Accelerometer::setDelegate(std::function<void(Acceleration*)> function)
|
||||||
{
|
{
|
||||||
m_delegate = pDelegate;
|
m_function = function;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCAccelerometer::setAccelerometerInterval(float interval)
|
Accelerometer::setAccelerometerInterval(float interval)
|
||||||
{
|
{
|
||||||
if (interval == 0.0) {
|
if (interval == 0.0) {
|
||||||
m_accelerometer->setDataRate(0.0);
|
m_accelerometer->setDataRate(0.0);
|
||||||
|
@ -80,21 +80,21 @@ CCAccelerometer::setAccelerometerInterval(float interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCAccelerometer::readingChanged()
|
Accelerometer::readingChanged()
|
||||||
{
|
{
|
||||||
if (m_delegate == NULL) {
|
if (m_function == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccelerometerReading *reading = m_accelerometer->reading();
|
QAccelerometerReading *reading = m_accelerometer->reading();
|
||||||
|
|
||||||
CCAcceleration accel;
|
Acceleration accel;
|
||||||
accel.x = reading->x();
|
accel.x = reading->x();
|
||||||
accel.y = reading->y();
|
accel.y = reading->y();
|
||||||
accel.z = reading->z();
|
accel.z = reading->z();
|
||||||
accel.timestamp = reading->timestamp();
|
accel.timestamp = reading->timestamp();
|
||||||
|
|
||||||
m_delegate->didAccelerate(&accel);
|
m_function(&accel);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -31,20 +31,21 @@
|
||||||
|
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class QAccelerometer;
|
class QAccelerometer;
|
||||||
class AccelerometerListener;
|
class AccelerometerListener;
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class CCAccelerometer {
|
class Accelerometer {
|
||||||
public:
|
public:
|
||||||
CCAccelerometer();
|
Accelerometer();
|
||||||
~CCAccelerometer();
|
~Accelerometer();
|
||||||
|
|
||||||
static CCAccelerometer *sharedAccelerometer();
|
static Accelerometer *sharedAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate *pDelegate);
|
void setDelegate(std::function<void(Acceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval);
|
void setAccelerometerInterval(float interval);
|
||||||
|
|
||||||
/* Functions to be called from AccelerometerListener */
|
/* Functions to be called from AccelerometerListener */
|
||||||
|
@ -53,7 +54,7 @@ class CCAccelerometer {
|
||||||
private:
|
private:
|
||||||
QAccelerometer *m_accelerometer;
|
QAccelerometer *m_accelerometer;
|
||||||
AccelerometerListener *m_listener;
|
AccelerometerListener *m_listener;
|
||||||
CCAccelerometerDelegate *m_delegate;
|
std::function<void(Acceleration*)> m_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Cocos2DQt5MainloopIntegration : public QObject {
|
||||||
protected:
|
protected:
|
||||||
virtual void timerEvent(QTimerEvent *event)
|
virtual void timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
cocos2d::CCDirector::sharedDirector()->mainLoop();
|
cocos2d::Director::getInstance()->mainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -68,7 +68,7 @@ class Cocos2DQt5MainloopIntegration : public QObject {
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
// Application singleton
|
// Application singleton
|
||||||
static CCApplication *
|
static Application *
|
||||||
application = NULL;
|
application = NULL;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -77,14 +77,21 @@ global_fake_argc = 1;
|
||||||
static char *
|
static char *
|
||||||
global_fake_argv[1];
|
global_fake_argv[1];
|
||||||
|
|
||||||
CCApplication *
|
// @deprecated Use getInstance() instead
|
||||||
CCApplication::sharedApplication()
|
Application *
|
||||||
|
Application::sharedApplication()
|
||||||
|
{
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
Application *
|
||||||
|
Application::getInstance()
|
||||||
{
|
{
|
||||||
CC_ASSERT(application != NULL);
|
CC_ASSERT(application != NULL);
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::CCApplication()
|
Application::Application()
|
||||||
: m_application(NULL)
|
: m_application(NULL)
|
||||||
, m_animationInterval(1000 / 60)
|
, m_animationInterval(1000 / 60)
|
||||||
, m_resourceRootPath("")
|
, m_resourceRootPath("")
|
||||||
|
@ -101,7 +108,7 @@ CCApplication::CCApplication()
|
||||||
application = this;
|
application = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::~CCApplication()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
delete m_mainloop;
|
delete m_mainloop;
|
||||||
delete m_application;
|
delete m_application;
|
||||||
|
@ -111,7 +118,7 @@ CCApplication::~CCApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CCApplication::run()
|
Application::run()
|
||||||
{
|
{
|
||||||
// Initialize instance and cocos2d.
|
// Initialize instance and cocos2d.
|
||||||
if (!applicationDidFinishLaunching()) {
|
if (!applicationDidFinishLaunching()) {
|
||||||
|
@ -124,7 +131,7 @@ CCApplication::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCApplication::setAnimationInterval(double interval)
|
Application::setAnimationInterval(double interval)
|
||||||
{
|
{
|
||||||
// Interval is expressed in seconds
|
// Interval is expressed in seconds
|
||||||
m_animationInterval = interval * 1000;
|
m_animationInterval = interval * 1000;
|
||||||
|
@ -133,32 +140,32 @@ CCApplication::setAnimationInterval(double interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCApplication::setResourceRootPath(const std::string &rootResDir)
|
Application::setResourceRootPath(const std::string &rootResDir)
|
||||||
{
|
{
|
||||||
m_resourceRootPath = rootResDir;
|
m_resourceRootPath = rootResDir;
|
||||||
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/') {
|
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/') {
|
||||||
m_resourceRootPath += '/';
|
m_resourceRootPath += '/';
|
||||||
}
|
}
|
||||||
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
|
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||||
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||||
pFileUtils->setSearchPaths(searchPaths);
|
pFileUtils->setSearchPaths(searchPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &
|
const std::string &
|
||||||
CCApplication::getResourceRootPath()
|
Application::getResourceRootPath()
|
||||||
{
|
{
|
||||||
return m_resourceRootPath;
|
return m_resourceRootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetPlatform
|
TargetPlatform
|
||||||
CCApplication::getTargetPlatform()
|
Application::getTargetPlatform()
|
||||||
{
|
{
|
||||||
return kTargetLinux;
|
return kTargetLinux;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType
|
ccLanguageType
|
||||||
CCApplication::getCurrentLanguage()
|
Application::getCurrentLanguage()
|
||||||
{
|
{
|
||||||
QLocale locale;
|
QLocale locale;
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ class Cocos2DQt5MainloopIntegration;
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class CCApplication : public CCApplicationProtocol {
|
class Application : public ApplicationProtocol {
|
||||||
public:
|
public:
|
||||||
CCApplication();
|
Application();
|
||||||
virtual ~CCApplication();
|
virtual ~Application();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Callback by CCDirector for limit FPS.
|
@brief Callback by Director for limit FPS.
|
||||||
@interval The time, which expressed in second in second, between current frame and next.
|
@interval The time, which expressed in second in second, between current frame and next.
|
||||||
*/
|
*/
|
||||||
void setAnimationInterval(double interval);
|
void setAnimationInterval(double interval);
|
||||||
|
@ -55,10 +55,13 @@ class CCApplication : public CCApplicationProtocol {
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current application instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication* sharedApplication();
|
static Application* getInstance();
|
||||||
|
|
||||||
|
/** @deprecated Use getInstance() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||||
|
|
||||||
/* override functions */
|
/* override functions */
|
||||||
virtual ccLanguageType getCurrentLanguage();
|
virtual ccLanguageType getCurrentLanguage();
|
||||||
|
|
|
@ -33,6 +33,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
/* @deprecated, use cocos2d::log() instead (see below) */
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
@ -53,12 +54,32 @@ void CCLog(const char * pszFormat, ...)
|
||||||
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCMessageBox(const char * pszMsg, const char * pszTitle)
|
void log(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
CCLog("%s: %s", pszTitle, pszMsg);
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCLuaLog(const char * pszFormat)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
|
{
|
||||||
|
log("%s: %s", pszTitle, pszMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaLog(const char * pszFormat)
|
||||||
{
|
{
|
||||||
puts(pszFormat);
|
puts(pszFormat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
int CCDevice::getDPI()
|
int Device::getDPI()
|
||||||
{
|
{
|
||||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||||
QScreen *screen = app->primaryScreen();
|
QScreen *screen = app->primaryScreen();
|
||||||
|
|
|
@ -49,7 +49,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class Cocos2DQt5OpenGLIntegration : public QWindow {
|
class Cocos2DQt5OpenGLIntegration : public QWindow {
|
||||||
public:
|
public:
|
||||||
Cocos2DQt5OpenGLIntegration(CCEGLView *view, int width, int height);
|
Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height);
|
||||||
~Cocos2DQt5OpenGLIntegration();
|
~Cocos2DQt5OpenGLIntegration();
|
||||||
|
|
||||||
virtual void touchEvent(QTouchEvent *event);
|
virtual void touchEvent(QTouchEvent *event);
|
||||||
|
@ -58,11 +58,11 @@ class Cocos2DQt5OpenGLIntegration : public QWindow {
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCEGLView *m_egl_view;
|
EGLView *m_egl_view;
|
||||||
QOpenGLContext *m_context;
|
QOpenGLContext *m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
Cocos2DQt5OpenGLIntegration::Cocos2DQt5OpenGLIntegration(CCEGLView *view, int width, int height)
|
Cocos2DQt5OpenGLIntegration::Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height)
|
||||||
: m_egl_view(view)
|
: m_egl_view(view)
|
||||||
, m_context(NULL)
|
, m_context(NULL)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ bool
|
||||||
Cocos2DQt5OpenGLIntegration::event(QEvent *event)
|
Cocos2DQt5OpenGLIntegration::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::Close) {
|
if (event->type() == QEvent::Close) {
|
||||||
CCDirector::sharedDirector()->end();
|
Director::getInstance()->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWindow::event(event);
|
return QWindow::event(event);
|
||||||
|
@ -128,28 +128,35 @@ Cocos2DQt5OpenGLIntegration::swapBuffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Global CCEGLView singleton for this module */
|
/* Global EGLView singleton for this module */
|
||||||
static CCEGLView *
|
static EGLView *
|
||||||
egl_view = NULL;
|
egl_view = NULL;
|
||||||
|
|
||||||
|
|
||||||
CCEGLView *
|
/** @deprecated Use getInstance() instead */
|
||||||
CCEGLView::sharedOpenGLView()
|
EGLView *
|
||||||
|
EGLView::sharedOpenGLView()
|
||||||
|
{
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLView *
|
||||||
|
EGLView::getInstance()
|
||||||
{
|
{
|
||||||
if (egl_view == NULL) {
|
if (egl_view == NULL) {
|
||||||
egl_view = new CCEGLView;
|
egl_view = new EGLView;
|
||||||
}
|
}
|
||||||
|
|
||||||
return egl_view;
|
return egl_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CCEGLView::CCEGLView()
|
EGLView::EGLView()
|
||||||
: m_integration(NULL)
|
: m_integration(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView::~CCEGLView()
|
EGLView::~EGLView()
|
||||||
{
|
{
|
||||||
if (m_integration) {
|
if (m_integration) {
|
||||||
delete m_integration;
|
delete m_integration;
|
||||||
|
@ -157,7 +164,7 @@ CCEGLView::~CCEGLView()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCEGLView::setFrameSize(float width, float height)
|
EGLView::setFrameSize(float width, float height)
|
||||||
{
|
{
|
||||||
if (m_integration == NULL) {
|
if (m_integration == NULL) {
|
||||||
m_integration = new Cocos2DQt5OpenGLIntegration(this,
|
m_integration = new Cocos2DQt5OpenGLIntegration(this,
|
||||||
|
@ -166,11 +173,11 @@ CCEGLView::setFrameSize(float width, float height)
|
||||||
m_integration->resize(width, height);
|
m_integration->resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLViewProtocol::setFrameSize(width, height);
|
EGLViewProtocol::setFrameSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCEGLView::swapBuffers()
|
EGLView::swapBuffers()
|
||||||
{
|
{
|
||||||
if (m_integration != NULL) {
|
if (m_integration != NULL) {
|
||||||
m_integration->swapBuffers();
|
m_integration->swapBuffers();
|
||||||
|
@ -178,14 +185,14 @@ CCEGLView::swapBuffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCEGLView::setIMEKeyboardState(bool bOpen)
|
EGLView::setIMEKeyboardState(bool bOpen)
|
||||||
{
|
{
|
||||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||||
app->inputMethod()->setVisible(bOpen);
|
app->inputMethod()->setVisible(bOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCEGLView::end()
|
EGLView::end()
|
||||||
{
|
{
|
||||||
QGuiApplication::exit(0);
|
QGuiApplication::exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,15 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class Cocos2DQt5OpenGLIntegration;
|
class Cocos2DQt5OpenGLIntegration;
|
||||||
|
|
||||||
class CCEGLView : public CCEGLViewProtocol {
|
class EGLView : public EGLViewProtocol {
|
||||||
public:
|
public:
|
||||||
CCEGLView();
|
EGLView();
|
||||||
virtual ~CCEGLView();
|
virtual ~EGLView();
|
||||||
|
|
||||||
static CCEGLView *sharedOpenGLView();
|
static EGLView *getInstance();
|
||||||
|
|
||||||
|
/** @deprecated Use getInstance() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static EGLView *sharedOpenGLView();
|
||||||
|
|
||||||
virtual bool isOpenGLReady() { return (m_integration != NULL); }
|
virtual bool isOpenGLReady() { return (m_integration != NULL); }
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,10 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class CC_DLL CCFileUtilsQt5 : public CCFileUtils
|
class CC_DLL FileUtilsQt5 : public FileUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCFileUtilsQt5();
|
FileUtilsQt5();
|
||||||
|
|
||||||
/* override funtions */
|
/* override funtions */
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
@ -55,23 +55,23 @@ class CC_DLL CCFileUtilsQt5 : public CCFileUtils
|
||||||
virtual bool isFileExist(const std::string& strFilePath);
|
virtual bool isFileExist(const std::string& strFilePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
CCFileUtils *
|
FileUtils *
|
||||||
CCFileUtils::sharedFileUtils()
|
FileUtils::getInstance()
|
||||||
{
|
{
|
||||||
if (s_sharedFileUtils == NULL)
|
if (s_sharedFileUtils == NULL)
|
||||||
{
|
{
|
||||||
s_sharedFileUtils = new CCFileUtilsQt5();
|
s_sharedFileUtils = new FileUtilsQt5();
|
||||||
s_sharedFileUtils->init();
|
s_sharedFileUtils->init();
|
||||||
}
|
}
|
||||||
return s_sharedFileUtils;
|
return s_sharedFileUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCFileUtilsQt5::CCFileUtilsQt5()
|
FileUtilsQt5::FileUtilsQt5()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CCFileUtilsQt5::init()
|
FileUtilsQt5::init()
|
||||||
{
|
{
|
||||||
// Determine directory of the application executable
|
// Determine directory of the application executable
|
||||||
QDir app_dir = QDir("/proc/self/exe").canonicalPath();
|
QDir app_dir = QDir("/proc/self/exe").canonicalPath();
|
||||||
|
@ -79,13 +79,13 @@ CCFileUtilsQt5::init()
|
||||||
|
|
||||||
// Resources should be placed alongside the binary (same directory)
|
// Resources should be placed alongside the binary (same directory)
|
||||||
QString path = app_dir.path() + "/Resources/";
|
QString path = app_dir.path() + "/Resources/";
|
||||||
m_strDefaultResRootPath = path.toStdString();
|
_defaultResRootPath = path.toStdString();
|
||||||
|
|
||||||
return CCFileUtils::init();
|
return FileUtils::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
CCFileUtilsQt5::getWritablePath()
|
FileUtilsQt5::getWritablePath()
|
||||||
{
|
{
|
||||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
|
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ CCFileUtilsQt5::getWritablePath()
|
||||||
return dir.path().toStdString();
|
return dir.path().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCFileUtilsQt5::isFileExist(const std::string& strFilePath)
|
bool FileUtilsQt5::isFileExist(const std::string& strFilePath)
|
||||||
{
|
{
|
||||||
QString filePath = QString::fromStdString(strFilePath);
|
QString filePath = QString::fromStdString(strFilePath);
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ bool CCFileUtilsQt5::isFileExist(const std::string& strFilePath)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not found, look for file in m_strDefaultResRootPath
|
// If not found, look for file in _defaultResRootPath
|
||||||
QString defaultResRootPath = QString::fromStdString(m_strDefaultResRootPath);
|
QString defaultResRootPath = QString::fromStdString(_defaultResRootPath);
|
||||||
return QFile(QDir(defaultResRootPath).filePath(filePath)).exists();
|
return QFile(QDir(defaultResRootPath).filePath(filePath)).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,18 @@ SOURCES += ../actions/CCAction.cpp \
|
||||||
../cocoa/CCNS.cpp \
|
../cocoa/CCNS.cpp \
|
||||||
../cocoa/CCObject.cpp \
|
../cocoa/CCObject.cpp \
|
||||||
../cocoa/CCSet.cpp \
|
../cocoa/CCSet.cpp \
|
||||||
../cocoa/CCZone.cpp \
|
|
||||||
../cocoa/CCArray.cpp \
|
../cocoa/CCArray.cpp \
|
||||||
../cocoa/CCDictionary.cpp \
|
../cocoa/CCDictionary.cpp \
|
||||||
../cocoa/CCString.cpp \
|
../cocoa/CCString.cpp \
|
||||||
../cocoa/CCDataVisitor.cpp \
|
../cocoa/CCDataVisitor.cpp \
|
||||||
|
../cocoa/CCData.cpp \
|
||||||
../draw_nodes/CCDrawingPrimitives.cpp \
|
../draw_nodes/CCDrawingPrimitives.cpp \
|
||||||
../draw_nodes/CCDrawNode.cpp \
|
../draw_nodes/CCDrawNode.cpp \
|
||||||
../effects/CCGrabber.cpp \
|
../effects/CCGrabber.cpp \
|
||||||
../effects/CCGrid.cpp \
|
../effects/CCGrid.cpp \
|
||||||
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
||||||
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
||||||
|
../keyboard_dispatcher/CCKeyboardDispatcher.cpp \
|
||||||
../label_nodes/CCLabelAtlas.cpp \
|
../label_nodes/CCLabelAtlas.cpp \
|
||||||
../label_nodes/CCLabelBMFont.cpp \
|
../label_nodes/CCLabelBMFont.cpp \
|
||||||
../label_nodes/CCLabelTTF.cpp \
|
../label_nodes/CCLabelTTF.cpp \
|
||||||
|
@ -62,7 +63,6 @@ SOURCES += ../actions/CCAction.cpp \
|
||||||
../particle_nodes/CCParticleBatchNode.cpp \
|
../particle_nodes/CCParticleBatchNode.cpp \
|
||||||
../platform/CCSAXParser.cpp \
|
../platform/CCSAXParser.cpp \
|
||||||
../platform/CCThread.cpp \
|
../platform/CCThread.cpp \
|
||||||
../platform/platform.cpp \
|
|
||||||
../platform/CCImageCommonWebp.cpp \
|
../platform/CCImageCommonWebp.cpp \
|
||||||
../platform/CCEGLViewProtocol.cpp \
|
../platform/CCEGLViewProtocol.cpp \
|
||||||
../platform/CCFileUtils.cpp \
|
../platform/CCFileUtils.cpp \
|
||||||
|
@ -82,7 +82,6 @@ SOURCES += ../actions/CCAction.cpp \
|
||||||
../sprite_nodes/CCSpriteFrame.cpp \
|
../sprite_nodes/CCSpriteFrame.cpp \
|
||||||
../sprite_nodes/CCSpriteFrameCache.cpp \
|
../sprite_nodes/CCSpriteFrameCache.cpp \
|
||||||
../support/ccUTF8.cpp \
|
../support/ccUTF8.cpp \
|
||||||
../support/CCPointExtension.cpp \
|
|
||||||
../support/CCProfiling.cpp \
|
../support/CCProfiling.cpp \
|
||||||
../support/user_default/CCUserDefault.cpp \
|
../support/user_default/CCUserDefault.cpp \
|
||||||
../support/TransformUtils.cpp \
|
../support/TransformUtils.cpp \
|
||||||
|
@ -105,6 +104,7 @@ SOURCES += ../actions/CCAction.cpp \
|
||||||
../textures/CCTextureCache.cpp \
|
../textures/CCTextureCache.cpp \
|
||||||
../textures/CCTextureETC.cpp \
|
../textures/CCTextureETC.cpp \
|
||||||
../textures/CCTexturePVR.cpp \
|
../textures/CCTexturePVR.cpp \
|
||||||
|
../textures/etc/etc1.cpp \
|
||||||
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||||
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||||
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||||
|
@ -136,17 +136,17 @@ SOURCES += ../actions/CCAction.cpp \
|
||||||
../CCDirector.cpp \
|
../CCDirector.cpp \
|
||||||
../CCScheduler.cpp \
|
../CCScheduler.cpp \
|
||||||
../ccFPSImages.c \
|
../ccFPSImages.c \
|
||||||
|
../ccTypes.cpp \
|
||||||
../cocos2d.cpp
|
../cocos2d.cpp
|
||||||
|
|
||||||
# Headers with QObject subclasses (will be processed by moc)
|
# Headers with QObject subclasses (will be processed by moc)
|
||||||
HEADERS += ../platform/qt5/AccelerometerListener.h
|
HEADERS += ../platform/qt5/AccelerometerListener.h
|
||||||
|
|
||||||
# WebP
|
# WebP
|
||||||
INCLUDEPATH += ../platform/third_party/marmalade/libwebp/webp
|
INCLUDEPATH += ../../external/libwebp/webp
|
||||||
SOURCES += $$files(../platform/third_party/marmalade/libwebp/dec/*.c)
|
SOURCES += $$files(../../external/libwebp/dec/*.c)
|
||||||
SOURCES += $$files(../platform/third_party/marmalade/libwebp/dsp/*.c)
|
SOURCES += $$files(../../external/libwebp/dsp/*.c)
|
||||||
#SOURCES += $$files(../platform/third_party/marmalade/libwebp/mux/*.c)
|
SOURCES += $$files(../../external/libwebp/utils/*.c)
|
||||||
SOURCES += $$files(../platform/third_party/marmalade/libwebp/utils/*.c)
|
|
||||||
|
|
||||||
# FreeType (FIXME: use pkg-config)
|
# FreeType (FIXME: use pkg-config)
|
||||||
INCLUDEPATH += /usr/include/freetype2
|
INCLUDEPATH += /usr/include/freetype2
|
||||||
|
|
|
@ -3,8 +3,13 @@ DEFINES += CC_TARGET_QT5
|
||||||
|
|
||||||
CONFIG += silent
|
CONFIG += silent
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-psabi
|
# Disable some warnings to make compiler output easier to read during development
|
||||||
QMAKE_CFLAGS += -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-psabi
|
DISABLED_WARNINGS = -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-psabi
|
||||||
|
QMAKE_CXXFLAGS += $${DISABLED_WARNINGS} -Wno-reorder
|
||||||
|
QMAKE_CFLAGS += $${DISABLED_WARNINGS}
|
||||||
|
|
||||||
|
# C++11 support (GCC 4.6; for newer versions, change to -std=c++11)
|
||||||
|
QMAKE_CXXFLAGS += -Doverride= -std=c++0x
|
||||||
|
|
||||||
OS_TYPE = linux
|
OS_TYPE = linux
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ SOURCES += ../CCBReader/CCBFileLoader.cpp \
|
||||||
../CCBReader/CCBSequence.cpp \
|
../CCBReader/CCBSequence.cpp \
|
||||||
../CCBReader/CCBSequenceProperty.cpp \
|
../CCBReader/CCBSequenceProperty.cpp \
|
||||||
../CCBReader/CCBValue.cpp \
|
../CCBReader/CCBValue.cpp \
|
||||||
../CCBReader/CCData.cpp \
|
|
||||||
../CCBReader/CCNode+CCBRelativePositioning.cpp \
|
../CCBReader/CCNode+CCBRelativePositioning.cpp \
|
||||||
../GUI/CCScrollView/CCScrollView.cpp \
|
../GUI/CCScrollView/CCScrollView.cpp \
|
||||||
../GUI/CCScrollView/CCSorting.cpp \
|
../GUI/CCScrollView/CCSorting.cpp \
|
||||||
|
|
|
@ -57,15 +57,17 @@ SOURCES += ../Classes/AccelerometerTest/AccelerometerTest.cpp \
|
||||||
../Classes/ExtensionsTest/ExtensionsTest.cpp \
|
../Classes/ExtensionsTest/ExtensionsTest.cpp \
|
||||||
../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \
|
../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \
|
||||||
../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \
|
../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \
|
||||||
../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \
|
../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \
|
||||||
../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \
|
../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \
|
||||||
|
../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \
|
||||||
../Classes/FontTest/FontTest.cpp \
|
../Classes/FontTest/FontTest.cpp \
|
||||||
../Classes/IntervalTest/IntervalTest.cpp \
|
../Classes/IntervalTest/IntervalTest.cpp \
|
||||||
|
../Classes/KeyboardTest/KeyboardTest.cpp \
|
||||||
../Classes/KeypadTest/KeypadTest.cpp \
|
../Classes/KeypadTest/KeypadTest.cpp \
|
||||||
../Classes/LabelTest/LabelTest.cpp \
|
../Classes/LabelTest/LabelTest.cpp \
|
||||||
../Classes/LayerTest/LayerTest.cpp \
|
../Classes/LayerTest/LayerTest.cpp \
|
||||||
|
@ -105,6 +107,7 @@ SOURCES += ../Classes/AccelerometerTest/AccelerometerTest.cpp \
|
||||||
../Classes/controller.cpp \
|
../Classes/controller.cpp \
|
||||||
../Classes/testBasic.cpp \
|
../Classes/testBasic.cpp \
|
||||||
../Classes/AppDelegate.cpp \
|
../Classes/AppDelegate.cpp \
|
||||||
|
../Classes/BaseTest.cpp \
|
||||||
../Classes/VisibleRect.cpp
|
../Classes/VisibleRect.cpp
|
||||||
|
|
||||||
LIBS += $${LINK_AGAINST_COCOS2DX}
|
LIBS += $${LINK_AGAINST_COCOS2DX}
|
||||||
|
|
Loading…
Reference in New Issue