mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8087 from cocoscodeide/v3
fix runtime build error for 3.3
This commit is contained in:
commit
431064bc45
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"templateVersion":"1.3",
|
"templateVersion":"1.4",
|
||||||
"runtimeVersion":"1.3"
|
"runtimeVersion":"1.4"
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"init_cfg":{
|
"init_cfg":{
|
||||||
"isLandscape": true,
|
"isLandscape": true,
|
||||||
|
"isWindowTop": false,
|
||||||
"name": "HelloLua",
|
"name": "HelloLua",
|
||||||
"width": 960,
|
"width": 960,
|
||||||
"height": 640,
|
"height": 640,
|
||||||
"entry": "src/main.lua",
|
"entry": "src/main.lua",
|
||||||
"consolePort": 6010
|
"consolePort": 6010,
|
||||||
|
"uploadPort": 6020
|
||||||
},
|
},
|
||||||
"simulator_screen_size": [
|
"simulator_screen_size": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,10 +38,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
initRuntime();
|
initRuntime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ConfigParser::getInstance()->isInit()) {
|
|
||||||
ConfigParser::getInstance()->readConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize director
|
// initialize director
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto glview = director->getOpenGLView();
|
auto glview = director->getOpenGLView();
|
||||||
|
@ -57,10 +53,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
director->setOpenGLView(glview);
|
director->setOpenGLView(glview);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
|
||||||
director->setAnimationInterval(1.0 / 60);
|
|
||||||
|
|
||||||
auto engine = LuaEngine::getInstance();
|
auto engine = LuaEngine::getInstance();
|
||||||
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||||
|
@ -98,4 +90,3 @@ void AppDelegate::applicationWillEnterForeground()
|
||||||
|
|
||||||
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#ifndef __APP_DELEGATE_H__
|
#ifndef __APP_DELEGATE_H__
|
||||||
#define __APP_DELEGATE_H__
|
#define __APP_DELEGATE_H__
|
||||||
|
|
||||||
#include "CCApplication.h"
|
#include "cocos2d.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The cocos2d Application.
|
@brief The cocos2d Application.
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,16 @@ ConfigParser *ConfigParser::getInstance(void)
|
||||||
if (!s_sharedInstance)
|
if (!s_sharedInstance)
|
||||||
{
|
{
|
||||||
s_sharedInstance = new ConfigParser();
|
s_sharedInstance = new ConfigParser();
|
||||||
|
s_sharedInstance->readConfig();
|
||||||
}
|
}
|
||||||
return s_sharedInstance;
|
return s_sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigParser::isInit()
|
|
||||||
{
|
|
||||||
return _isInit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigParser::readConfig()
|
void ConfigParser::readConfig()
|
||||||
{
|
{
|
||||||
_isInit = true;
|
_isWindowTop = false;
|
||||||
_consolePort = 6010;
|
_consolePort = 6010;
|
||||||
|
_uploadPort = 6020;
|
||||||
string filecfg = "config.json";
|
string filecfg = "config.json";
|
||||||
|
|
||||||
string fileContent;
|
string fileContent;
|
||||||
|
@ -72,6 +69,16 @@ void ConfigParser::readConfig()
|
||||||
}
|
}
|
||||||
if (objectInitView.HasMember("consolePort")){
|
if (objectInitView.HasMember("consolePort")){
|
||||||
_consolePort = objectInitView["consolePort"].GetUint();
|
_consolePort = objectInitView["consolePort"].GetUint();
|
||||||
|
if(_consolePort<=0)
|
||||||
|
_consolePort = 6010;
|
||||||
|
}
|
||||||
|
if (objectInitView.HasMember("uploadPort")){
|
||||||
|
_uploadPort = objectInitView["uploadPort"].GetUint();
|
||||||
|
if(_uploadPort<=0)
|
||||||
|
_uploadPort = 6020;
|
||||||
|
}
|
||||||
|
if (objectInitView.HasMember("isWindowTop") && objectInitView["isWindowTop"].IsBool()){
|
||||||
|
_isWindowTop= objectInitView["isWindowTop"].GetBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +102,7 @@ void ConfigParser::readConfig()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParser::ConfigParser(void):_isInit(false),_isLandscape(true)
|
ConfigParser::ConfigParser(void):_isLandscape(true)
|
||||||
{
|
{
|
||||||
_initViewSize.setSize(960,640);
|
_initViewSize.setSize(960,640);
|
||||||
_viewName = "HelloLua";
|
_viewName = "HelloLua";
|
||||||
|
@ -127,10 +134,18 @@ bool ConfigParser::isLanscape()
|
||||||
return _isLandscape;
|
return _isLandscape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfigParser::isWindowTop()
|
||||||
|
{
|
||||||
|
return _isWindowTop;
|
||||||
|
}
|
||||||
int ConfigParser::getConsolePort()
|
int ConfigParser::getConsolePort()
|
||||||
{
|
{
|
||||||
return _consolePort;
|
return _consolePort;
|
||||||
}
|
}
|
||||||
|
int ConfigParser::getUploadPort()
|
||||||
|
{
|
||||||
|
return _uploadPort;
|
||||||
|
}
|
||||||
int ConfigParser::getScreenSizeCount(void)
|
int ConfigParser::getScreenSizeCount(void)
|
||||||
{
|
{
|
||||||
return (int)_screenSizeArray.size();
|
return (int)_screenSizeArray.size();
|
||||||
|
|
|
@ -37,8 +37,9 @@ public:
|
||||||
rapidjson::Document& getConfigJsonRoot();
|
rapidjson::Document& getConfigJsonRoot();
|
||||||
const SimulatorScreenSize getScreenSize(int index);
|
const SimulatorScreenSize getScreenSize(int index);
|
||||||
int getConsolePort();
|
int getConsolePort();
|
||||||
|
int getUploadPort();
|
||||||
bool isLanscape();
|
bool isLanscape();
|
||||||
bool isInit();
|
bool isWindowTop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConfigParser(void);
|
ConfigParser(void);
|
||||||
|
@ -48,8 +49,9 @@ private:
|
||||||
string _viewName;
|
string _viewName;
|
||||||
string _entryfile;
|
string _entryfile;
|
||||||
bool _isLandscape;
|
bool _isLandscape;
|
||||||
bool _isInit;
|
bool _isWindowTop;
|
||||||
int _consolePort;
|
int _consolePort;
|
||||||
|
int _uploadPort;
|
||||||
|
|
||||||
rapidjson::Document _docRootjson;
|
rapidjson::Document _docRootjson;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
||||||
#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
||||||
|
|
||||||
#include "network/lua_cocos2dx_network_manual.h"
|
|
||||||
#include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h"
|
#include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h"
|
||||||
|
#include "network/lua_cocos2dx_network_manual.h"
|
||||||
#include "cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h"
|
#include "cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h"
|
||||||
#include "cocostudio/lua_cocos2dx_coco_studio_manual.hpp"
|
#include "cocostudio/lua_cocos2dx_coco_studio_manual.hpp"
|
||||||
#include "extension/lua_cocos2dx_extension_manual.h"
|
#include "extension/lua_cocos2dx_extension_manual.h"
|
||||||
#include "ui/lua_cocos2dx_ui_manual.hpp"
|
#include "ui/lua_cocos2dx_ui_manual.hpp"
|
||||||
#include "spine/lua_cocos2dx_spine_manual.hpp"
|
#include "spine/lua_cocos2dx_spine_manual.hpp"
|
||||||
#include "3d/lua_cocos2dx_3d_manual.h"
|
#include "3d/lua_cocos2dx_3d_manual.h"
|
||||||
|
#include "audioengine/lua_cocos2dx_audioengine_manual.h"
|
||||||
|
|
||||||
int lua_module_register(lua_State* L)
|
int lua_module_register(lua_State* L)
|
||||||
{
|
{
|
||||||
//Dont' change the module register order unless you know what your are doing
|
//Dont' change the module register order unless you know what your are doing
|
||||||
register_network_module(L);
|
|
||||||
register_cocosdenshion_module(L);
|
register_cocosdenshion_module(L);
|
||||||
|
register_network_module(L);
|
||||||
register_cocosbuilder_module(L);
|
register_cocosbuilder_module(L);
|
||||||
register_cocostudio_module(L);
|
register_cocostudio_module(L);
|
||||||
register_ui_moudle(L);
|
register_ui_moudle(L);
|
||||||
register_extension_module(L);
|
register_extension_module(L);
|
||||||
register_spine_module(L);
|
register_spine_module(L);
|
||||||
register_cocos3d_module(L);
|
register_cocos3d_module(L);
|
||||||
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||||
|
register_audioengine_module(L);
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,7 @@ using namespace std;
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
std::string g_resourcePath;
|
std::string g_resourcePath;
|
||||||
|
static std::string g_projectPath;
|
||||||
namespace cocos2d {
|
|
||||||
extern const char* cocos2dVersion();
|
|
||||||
};
|
|
||||||
|
|
||||||
//1M size
|
//1M size
|
||||||
#define MAXPROTOLENGTH 1048576
|
#define MAXPROTOLENGTH 1048576
|
||||||
|
@ -67,7 +64,7 @@ namespace cocos2d {
|
||||||
extern string getIPAddress();
|
extern string getIPAddress();
|
||||||
const char* getRuntimeVersion()
|
const char* getRuntimeVersion()
|
||||||
{
|
{
|
||||||
return "1.3";
|
return "1.4";
|
||||||
}
|
}
|
||||||
|
|
||||||
static string& replaceAll(string& str,const string& old_value,const string& new_value)
|
static string& replaceAll(string& str,const string& old_value,const string& new_value)
|
||||||
|
@ -76,7 +73,7 @@ static string& replaceAll(string& str,const string& old_value,const string& new_
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
int pos=0;
|
int pos=0;
|
||||||
if((pos=str.find(old_value,start))!=string::npos) {
|
if((pos=str.find(old_value, start)) != string::npos) {
|
||||||
str.replace(pos,old_value.length(),new_value);
|
str.replace(pos,old_value.length(),new_value);
|
||||||
start = pos + new_value.length();
|
start = pos + new_value.length();
|
||||||
}
|
}
|
||||||
|
@ -84,6 +81,7 @@ static string& replaceAll(string& str,const string& old_value,const string& new_
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool resetLuaModule(string fileName)
|
static bool resetLuaModule(string fileName)
|
||||||
{
|
{
|
||||||
if (fileName.empty())
|
if (fileName.empty())
|
||||||
|
@ -154,9 +152,6 @@ void startScript(string strDebugArg)
|
||||||
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
|
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
|
@ -739,8 +734,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
char szVersion[1024]={0};
|
char szVersion[1024]={0};
|
||||||
|
sprintf(szVersion,"runtimeVersion:%s \nengineVersion:%s",getRuntimeVersion(),cocos2dVersion());
|
||||||
sprintf(szVersion,"runtimeVersion:%s \ncocos2dVersion:%s",getRuntimeVersion(),cocos2dVersion());
|
|
||||||
Label* verLable = Label::createWithSystemFont(szVersion,"",24);
|
Label* verLable = Label::createWithSystemFont(szVersion,"",24);
|
||||||
verLable->setAnchorPoint(Vec2(0,0));
|
verLable->setAnchorPoint(Vec2(0,0));
|
||||||
int width = verLable->getBoundingBox().size.width;
|
int width = verLable->getBoundingBox().size.width;
|
||||||
|
@ -811,11 +805,13 @@ public:
|
||||||
_console->listenOnTCP(6010);
|
_console->listenOnTCP(6010);
|
||||||
#endif
|
#endif
|
||||||
_fileserver = nullptr;
|
_fileserver = nullptr;
|
||||||
#if(CC_PLATFORM_MAC != CC_TARGET_PLATFORM && CC_PLATFORM_WIN32 != CC_TARGET_PLATFORM)
|
|
||||||
_fileserver= FileServer::getShareInstance();
|
_fileserver= FileServer::getShareInstance();
|
||||||
|
#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM)
|
||||||
|
_fileserver->listenOnTCP(ConfigParser::getInstance()->getUploadPort());
|
||||||
|
#else
|
||||||
_fileserver->listenOnTCP(6020);
|
_fileserver->listenOnTCP(6020);
|
||||||
_fileserver->readResFileFinfo();
|
|
||||||
#endif
|
#endif
|
||||||
|
_fileserver->readResFileFinfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ConsoleCustomCommand()
|
~ConsoleCustomCommand()
|
||||||
|
@ -931,6 +927,32 @@ public:
|
||||||
#else
|
#else
|
||||||
exit(0);
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
|
}else if(strcmp(strcmd.c_str(),"shutdownapp")==0)
|
||||||
|
{
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
extern void shutDownApp();
|
||||||
|
shutDownApp();
|
||||||
|
#else
|
||||||
|
exit(0);
|
||||||
|
#endif
|
||||||
|
}else if (strcmp(strcmd.c_str(),"getplatform")==0)
|
||||||
|
{
|
||||||
|
string platform="UNKNOW";
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
platform = "WIN32";
|
||||||
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
|
platform = "MAC";
|
||||||
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
platform = "IOS";
|
||||||
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
platform = "ANDROID";
|
||||||
|
#endif
|
||||||
|
rapidjson::Value bodyvalue(rapidjson::kObjectType);
|
||||||
|
rapidjson::Value platformValue(rapidjson::kStringType);
|
||||||
|
platformValue.SetString(platform.c_str(),dReplyParse.GetAllocator());
|
||||||
|
bodyvalue.AddMember("platform",platformValue,dReplyParse.GetAllocator());
|
||||||
|
dReplyParse.AddMember("body",bodyvalue,dReplyParse.GetAllocator());
|
||||||
|
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());
|
||||||
}
|
}
|
||||||
|
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
|
@ -982,13 +1004,17 @@ int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S)
|
||||||
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
return 0;
|
return 0;
|
||||||
std::string argtmp = arg0;
|
std::string originPath = arg0;
|
||||||
if (!FileUtils::getInstance()->isAbsolutePath(arg0))
|
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
|
||||||
arg0 = g_resourcePath+arg0;
|
arg0 = g_resourcePath+originPath;
|
||||||
cobj->addSearchPath(arg0);
|
cobj->addSearchPath(arg0);
|
||||||
|
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
|
||||||
|
cobj->addSearchPath(g_projectPath + originPath);
|
||||||
|
#endif
|
||||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
if (!FileUtils::getInstance()->isAbsolutePath(argtmp))
|
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
|
||||||
cobj->addSearchPath(argtmp);
|
cobj->addSearchPath(originPath);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1036,17 +1062,22 @@ int lua_cocos2dx_runtime_setSearchPaths(lua_State* tolua_S)
|
||||||
ok &= luaval_to_std_vector_string(tolua_S, 2,&vecPaths);
|
ok &= luaval_to_std_vector_string(tolua_S, 2,&vecPaths);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
return 0;
|
return 0;
|
||||||
std::vector<std::string> argtmp;
|
std::vector<std::string> originPath; // for IOS platform.
|
||||||
|
std::vector<std::string> projPath; // for Desktop platform.
|
||||||
for (int i = 0; i < vecPaths.size(); i++)
|
for (int i = 0; i < vecPaths.size(); i++)
|
||||||
{
|
{
|
||||||
if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i]))
|
if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i]))
|
||||||
{
|
{
|
||||||
argtmp.push_back(vecPaths[i]);
|
originPath.push_back(vecPaths[i]); // for IOS platform.
|
||||||
|
projPath.push_back(g_projectPath+vecPaths[i]); //for Desktop platform.
|
||||||
vecPaths[i] = g_resourcePath + vecPaths[i];
|
vecPaths[i] = g_resourcePath + vecPaths[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
vecPaths.insert(vecPaths.end(),projPath.begin(),projPath.end());
|
||||||
|
#endif
|
||||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
vecPaths.insert(vecPaths.end(),argtmp.begin(),argtmp.end());
|
vecPaths.insert(vecPaths.end(),originPath.begin(),originPath.end());
|
||||||
#endif
|
#endif
|
||||||
cobj->setSearchPaths(vecPaths);
|
cobj->setSearchPaths(vecPaths);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1093,24 +1124,29 @@ bool initRuntime()
|
||||||
vector<string> searchPathArray;
|
vector<string> searchPathArray;
|
||||||
searchPathArray=FileUtils::getInstance()->getSearchPaths();
|
searchPathArray=FileUtils::getInstance()->getSearchPaths();
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
if (g_resourcePath.empty())
|
if (g_projectPath.empty())
|
||||||
{
|
{
|
||||||
extern std::string getCurAppPath();
|
extern std::string getCurAppPath();
|
||||||
string resourcePath = getCurAppPath();
|
string appPath = getCurAppPath();
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
resourcePath.append("/../../");
|
appPath.append("/../../");
|
||||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
resourcePath.append("/../../../");
|
appPath.append("/../../../");
|
||||||
#endif
|
#endif
|
||||||
resourcePath =replaceAll(resourcePath,"\\","/");
|
appPath =replaceAll(appPath,"\\","/");
|
||||||
g_resourcePath = resourcePath;
|
g_projectPath = appPath;
|
||||||
}
|
}
|
||||||
|
searchPathArray.insert(searchPathArray.begin(),g_projectPath);
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
g_resourcePath = FileUtils::getInstance()->getWritablePath();
|
g_resourcePath = FileUtils::getInstance()->getWritablePath();
|
||||||
g_resourcePath += "debugruntime/";
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
|
std::string getCurAppName(void);
|
||||||
|
g_resourcePath += getCurAppName();
|
||||||
|
g_resourcePath +="/";
|
||||||
#endif
|
#endif
|
||||||
|
g_resourcePath += "debugruntime/";
|
||||||
|
|
||||||
g_resourcePath=replaceAll(g_resourcePath,"\\","/");
|
g_resourcePath=replaceAll(g_resourcePath,"\\","/");
|
||||||
if (g_resourcePath.at(g_resourcePath.length()-1) != '/'){
|
if (g_resourcePath.at(g_resourcePath.length()-1) != '/'){
|
||||||
g_resourcePath.append("/");
|
g_resourcePath.append("/");
|
||||||
|
@ -1124,6 +1160,10 @@ bool initRuntime()
|
||||||
LuaStack* stack = engine->getLuaStack();
|
LuaStack* stack = engine->getLuaStack();
|
||||||
register_runtime_override_function(stack->getLuaState());
|
register_runtime_override_function(stack->getLuaState());
|
||||||
luaopen_debugger(engine->getLuaStack()->getLuaState());
|
luaopen_debugger(engine->getLuaStack()->getLuaState());
|
||||||
|
|
||||||
|
static ConsoleCustomCommand *g_customCommand;
|
||||||
|
g_customCommand = new ConsoleCustomCommand();
|
||||||
|
g_customCommand->init();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,17 +1185,11 @@ bool startRuntime()
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
Director::getInstance()->setDisplayStats(true);
|
Director::getInstance()->setDisplayStats(true);
|
||||||
|
|
||||||
static ConsoleCustomCommand *g_customCommand;
|
|
||||||
g_customCommand = new ConsoleCustomCommand();
|
|
||||||
g_customCommand->init();
|
|
||||||
|
|
||||||
auto scene = Scene::create();
|
auto scene = Scene::create();
|
||||||
auto connectLayer = new ConnectWaitLayer();
|
auto connectLayer = new ConnectWaitLayer();
|
||||||
connectLayer->autorelease();
|
connectLayer->autorelease();
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
scene->addChild(connectLayer);
|
scene->addChild(connectLayer);
|
||||||
director->runWithScene(scene);
|
director->runWithScene(scene);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,5 @@ using namespace std;
|
||||||
bool initRuntime();
|
bool initRuntime();
|
||||||
bool startRuntime();
|
bool startRuntime();
|
||||||
|
|
||||||
bool reloadScript(string modulefile);
|
|
||||||
|
|
||||||
#endif // _RUNTIME__H_
|
#endif // _RUNTIME__H_
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,17 +8,11 @@
|
||||||
"copy_resources": [
|
"copy_resources": [
|
||||||
{
|
{
|
||||||
"from": "../../../src",
|
"from": "../../../src",
|
||||||
"to": "src",
|
"to": "src"
|
||||||
"exclude": [
|
|
||||||
"*.gz"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"from": "../../../res",
|
"from": "../../../res",
|
||||||
"to": "res",
|
"to": "res"
|
||||||
"exclude": [
|
|
||||||
"*.gz"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"must_copy_resources": [
|
"must_copy_resources": [
|
||||||
|
|
|
@ -6,7 +6,8 @@ LOCAL_MODULE := cocos2dlua_shared
|
||||||
|
|
||||||
LOCAL_MODULE_FILENAME := libcocos2dlua
|
LOCAL_MODULE_FILENAME := libcocos2dlua
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := hellolua/main.cpp \
|
||||||
|
hellolua/Runtime_android.cpp \
|
||||||
../../Classes/protobuf-lite/google/protobuf/io/coded_stream.cc \
|
../../Classes/protobuf-lite/google/protobuf/io/coded_stream.cc \
|
||||||
../../Classes/protobuf-lite/google/protobuf/stubs/common.cc \
|
../../Classes/protobuf-lite/google/protobuf/stubs/common.cc \
|
||||||
../../Classes/protobuf-lite/google/protobuf/extension_set.cc \
|
../../Classes/protobuf-lite/google/protobuf/extension_set.cc \
|
||||||
|
@ -29,9 +30,7 @@ LOCAL_SRC_FILES := \
|
||||||
../../Classes/runtime/lua_debugger.c \
|
../../Classes/runtime/lua_debugger.c \
|
||||||
../../Classes/VisibleRect.cpp \
|
../../Classes/VisibleRect.cpp \
|
||||||
../../Classes/AppDelegate.cpp \
|
../../Classes/AppDelegate.cpp \
|
||||||
../../Classes/ConfigParser.cpp \
|
../../Classes/ConfigParser.cpp
|
||||||
lua/Runtime_android.cpp \
|
|
||||||
lua/main.cpp
|
|
||||||
|
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := \
|
LOCAL_C_INCLUDES := \
|
||||||
|
@ -45,4 +44,3 @@ LOCAL_STATIC_LIBRARIES := cocos2d_lua_static
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
$(call import-module,scripting/lua-bindings/proj.android)
|
$(call import-module,scripting/lua-bindings/proj.android)
|
||||||
|
|
||||||
|
|
|
@ -6,21 +6,6 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
string getSDCardPath()
|
|
||||||
{
|
|
||||||
JniMethodInfo t;
|
|
||||||
string sdcardPath("");
|
|
||||||
|
|
||||||
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lua/AppActivity", "getSDCardPath", "()Ljava/lang/String;")) {
|
|
||||||
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
|
|
||||||
t.env->DeleteLocalRef(t.classID);
|
|
||||||
sdcardPath = JniHelper::jstring2string(str);
|
|
||||||
t.env->DeleteLocalRef(str);
|
|
||||||
}
|
|
||||||
return sdcardPath;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
string getIPAddress()
|
string getIPAddress()
|
||||||
{
|
{
|
||||||
JniMethodInfo t;
|
JniMethodInfo t;
|
|
@ -19,10 +19,6 @@ extern "C"
|
||||||
{
|
{
|
||||||
bool Java_org_cocos2dx_lua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz)
|
bool Java_org_cocos2dx_lua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz)
|
||||||
{
|
{
|
||||||
if (!ConfigParser::getInstance()->isInit())
|
|
||||||
{
|
|
||||||
ConfigParser::getInstance()->readConfig();
|
|
||||||
}
|
|
||||||
return ConfigParser::getInstance()->isLanscape();
|
return ConfigParser::getInstance()->isLanscape();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,22 +45,18 @@ import android.net.NetworkInfo;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
// The name of .so is specified in AndroidMenifest.xml. NativityActivity will load it automatically for you.
|
|
||||||
// You can use "System.loadLibrary()" to load other .so files.
|
|
||||||
|
|
||||||
public class AppActivity extends Cocos2dxActivity{
|
public class AppActivity extends Cocos2dxActivity{
|
||||||
|
|
||||||
static String hostIPAdress="0.0.0.0";
|
static String hostIPAdress="0.0.0.0";
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if(nativeIsLandScape()) {
|
if(nativeIsLandScape()) {
|
||||||
|
@ -79,7 +75,7 @@ public class AppActivity extends Cocos2dxActivity{
|
||||||
{
|
{
|
||||||
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||||
builder.setTitle("Warning");
|
builder.setTitle("Warning");
|
||||||
builder.setMessage("Open Wifi for debuging...");
|
builder.setMessage("Please open WIFI for debuging...");
|
||||||
builder.setPositiveButton("OK",new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("OK",new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,7 +85,9 @@ public class AppActivity extends Cocos2dxActivity{
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setCancelable(false);
|
|
||||||
|
builder.setNegativeButton("Cancel", null);
|
||||||
|
builder.setCancelable(true);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,14 +124,6 @@ public class AppActivity extends Cocos2dxActivity{
|
||||||
return hostIPAdress;
|
return hostIPAdress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSDCardPath() {
|
|
||||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
||||||
String strSDCardPathString = Environment.getExternalStorageDirectory().getPath();
|
|
||||||
return strSDCardPathString;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native boolean nativeIsLandScape();
|
private static native boolean nativeIsLandScape();
|
||||||
private static native boolean nativeIsDebug();
|
private static native boolean nativeIsDebug();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
#import "RootViewController.h"
|
#import "RootViewController.h"
|
||||||
#import "platform/ios/CCEAGLView-ios.h"
|
#import "platform/ios/CCEAGLView-ios.h"
|
||||||
#include "ConfigParser.h"
|
|
||||||
|
|
||||||
@implementation AppController
|
@implementation AppController
|
||||||
|
|
||||||
|
@ -48,9 +47,7 @@ static AppDelegate s_sharedApplication;
|
||||||
cocos2d::GLViewImpl::convertAttrs();
|
cocos2d::GLViewImpl::convertAttrs();
|
||||||
|
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
|
|
||||||
ConfigParser::getInstance()->readConfig();
|
|
||||||
|
|
||||||
// Add the view controller's view to the window and display.
|
// Add the view controller's view to the window and display.
|
||||||
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#import "RootViewController.h"
|
#import "RootViewController.h"
|
||||||
#import "cocos2d.h"
|
#import "cocos2d.h"
|
||||||
#import "CCEAGLView.h"
|
#import "platform/ios/CCEAGLView-ios.h"
|
||||||
#include "ConfigParser.h"
|
#include "ConfigParser.h"
|
||||||
|
|
||||||
@implementation RootViewController
|
@implementation RootViewController
|
||||||
|
|
|
@ -40,9 +40,9 @@
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
bool g_landscape = false;
|
bool g_landscape = false;
|
||||||
bool g_windTop = true;
|
bool g_windTop = false;
|
||||||
cocos2d::Size g_screenSize;
|
cocos2d::Size g_screenSize;
|
||||||
GLView* g_eglView = nullptr;
|
GLViewImpl* g_eglView = nullptr;
|
||||||
|
|
||||||
static AppController* g_nsAppDelegate=nullptr;
|
static AppController* g_nsAppDelegate=nullptr;
|
||||||
|
|
||||||
|
@ -58,6 +58,16 @@ std::string getCurAppPath(void)
|
||||||
return [[[NSBundle mainBundle] bundlePath] UTF8String];
|
return [[[NSBundle mainBundle] bundlePath] UTF8String];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getCurAppName(void)
|
||||||
|
{
|
||||||
|
string appName = [[[NSProcessInfo processInfo] processName] UTF8String];
|
||||||
|
int found = appName.find(" ");
|
||||||
|
if (found!=std::string::npos)
|
||||||
|
appName = appName.substr(0,found);
|
||||||
|
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
-(void) dealloc
|
-(void) dealloc
|
||||||
{
|
{
|
||||||
Director::getInstance()->end();
|
Director::getInstance()->end();
|
||||||
|
@ -102,12 +112,12 @@ std::string getCurAppPath(void)
|
||||||
width = height;
|
width = height;
|
||||||
height = tmpvalue;
|
height = tmpvalue;
|
||||||
}
|
}
|
||||||
g_windTop = true;
|
g_windTop = ConfigParser::getInstance()->isWindowTop();
|
||||||
g_eglView = cocos2d::GLViewImpl::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor);
|
g_eglView = GLViewImpl::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor);
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
director->setOpenGLView(g_eglView);
|
director->setOpenGLView(g_eglView);
|
||||||
|
|
||||||
window = g_eglView->getCocoaWindow();
|
window = glfwGetCocoaWindow(g_eglView->getWindow());
|
||||||
[NSApp setDelegate: self];
|
[NSApp setDelegate: self];
|
||||||
|
|
||||||
[self createViewMenu];
|
[self createViewMenu];
|
||||||
|
@ -336,7 +346,7 @@ void createSimulator(const char* viewName, float width, float height,bool isLand
|
||||||
{
|
{
|
||||||
if ([sender state] == NSOnState) return;
|
if ([sender state] == NSOnState) return;
|
||||||
float scale = (float)[sender tag] / 100.0f;
|
float scale = (float)[sender tag] / 100.0f;
|
||||||
(dynamic_cast<GLViewImpl*>(g_eglView))->setFrameZoomFactor(scale);
|
g_eglView->setFrameZoomFactor(scale);
|
||||||
[self updateView];
|
[self updateView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
|
|
||||||
int ret = Application::getInstance()->run();
|
int ret = Application::getInstance()->run();
|
||||||
|
|
||||||
#ifdef USE_WIN32_CONSOLE
|
#ifdef USE_WIN32_CONSOLE
|
||||||
|
|
|
@ -21,6 +21,15 @@ local function main()
|
||||||
-- avoid memory leak
|
-- avoid memory leak
|
||||||
collectgarbage("setpause", 100)
|
collectgarbage("setpause", 100)
|
||||||
collectgarbage("setstepmul", 5000)
|
collectgarbage("setstepmul", 5000)
|
||||||
|
|
||||||
|
-- initialize director
|
||||||
|
local director = cc.Director:getInstance()
|
||||||
|
|
||||||
|
--turn on display FPS
|
||||||
|
director:setDisplayStats(true)
|
||||||
|
|
||||||
|
--set FPS. the default value is 1.0/60 if you don't call this
|
||||||
|
director:setAnimationInterval(1.0 / 60)
|
||||||
|
|
||||||
cc.FileUtils:getInstance():addSearchPath("src")
|
cc.FileUtils:getInstance():addSearchPath("src")
|
||||||
cc.FileUtils:getInstance():addSearchPath("res")
|
cc.FileUtils:getInstance():addSearchPath("res")
|
||||||
|
|
Loading…
Reference in New Issue