2014-03-11 16:52:06 +08:00
|
|
|
#ifndef __APP_DELEGATE_H__
|
|
|
|
#define __APP_DELEGATE_H__
|
|
|
|
|
2014-09-16 16:19:05 +08:00
|
|
|
#include "cocos2d.h"
|
2014-12-27 02:21:55 +08:00
|
|
|
#include "ProjectConfig/ProjectConfig.h"
|
|
|
|
#include "ProjectConfig/SimulatorConfig.h"
|
2014-09-16 16:19:05 +08:00
|
|
|
|
2014-03-11 16:52:06 +08:00
|
|
|
/**
|
|
|
|
@brief The cocos2d Application.
|
|
|
|
|
|
|
|
The reason for implement as private inheritance is to hide some interface call by Director.
|
|
|
|
*/
|
|
|
|
class AppDelegate : private cocos2d::Application
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AppDelegate();
|
|
|
|
virtual ~AppDelegate();
|
|
|
|
|
2014-08-25 10:57:58 +08:00
|
|
|
virtual void initGLContextAttrs();
|
|
|
|
|
2014-03-11 16:52:06 +08:00
|
|
|
/**
|
|
|
|
@brief Implement Director and Scene init code here.
|
|
|
|
@return true Initialize success, app continue.
|
|
|
|
@return false Initialize failed, app terminate.
|
|
|
|
*/
|
|
|
|
virtual bool applicationDidFinishLaunching();
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The function be called when the application enter background
|
|
|
|
@param the pointer of the application
|
|
|
|
*/
|
|
|
|
virtual void applicationDidEnterBackground();
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The function be called when the application enter foreground
|
|
|
|
@param the pointer of the application
|
|
|
|
*/
|
|
|
|
virtual void applicationWillEnterForeground();
|
2014-12-27 02:21:55 +08:00
|
|
|
|
|
|
|
void setProjectConfig(const ProjectConfig& project);
|
|
|
|
|
|
|
|
void reopenProject();
|
|
|
|
|
|
|
|
private:
|
|
|
|
ProjectConfig _project;
|
|
|
|
|
|
|
|
friend class StartupCall;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StartupCall : public cocos2d::Ref
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static StartupCall *create(AppDelegate *app);
|
|
|
|
void startup();
|
|
|
|
|
|
|
|
private:
|
|
|
|
StartupCall();
|
|
|
|
|
|
|
|
void trackEvent(const char *eventName);
|
|
|
|
void trackLaunchEvent();
|
|
|
|
|
|
|
|
void onPreviewCocosCSD(const std::string &path);
|
|
|
|
void onPreviewCocosCSB(const std::string &path);
|
|
|
|
void onPreviewLua(const std::string &path);
|
|
|
|
void onPreviewJs(const std::string &path);
|
|
|
|
|
|
|
|
void updateConfigParser(const ProjectConfig& project);
|
|
|
|
void updatePreviewFuncForPath(const std::string &path);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AppDelegate *_app;
|
|
|
|
std::function<void(const std::string &)> _previewFunc;
|
|
|
|
std::string _launchEvent;
|
2014-03-11 16:52:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __APP_DELEGATE_H__
|
|
|
|
|