Merge branch 'v3.6.0' into develop_merge_v3.6

This commit is contained in:
minggo
2022-07-18 10:38:14 +08:00
3327 changed files with 149922 additions and 93327 deletions
+7 -14
View File
@@ -23,7 +23,6 @@
THE SOFTWARE.
****************************************************************************/
#include "PlayerProtocol.h"
#include "base/Macros.h"
@@ -31,34 +30,28 @@ PLAYER_NS_BEGIN
PlayerProtocol *PlayerProtocol::_instance = nullptr;
PlayerProtocol::PlayerProtocol()
{
CCASSERT(_instance == nullptr, "CAN NOT CREATE MORE PLAYER INSTANCE");
PlayerProtocol::PlayerProtocol() {
CC_ASSERT(_instance == nullptr); // Can not create more player instance.
_instance = this;
}
PlayerProtocol::~PlayerProtocol()
{
PlayerProtocol::~PlayerProtocol() {
_instance = nullptr;
}
PlayerProtocol *PlayerProtocol::getInstance()
{
PlayerProtocol *PlayerProtocol::getInstance() {
return _instance;
}
void PlayerProtocol::purgeInstance()
{
void PlayerProtocol::purgeInstance() {
if (_instance) delete _instance;
}
void PlayerProtocol::setPlayerSettings(const PlayerSettings &settings)
{
void PlayerProtocol::setPlayerSettings(const PlayerSettings &settings) {
_settings = settings;
}
PlayerSettings PlayerProtocol::getPlayerSettings() const
{
PlayerSettings PlayerProtocol::getPlayerSettings() const {
return _settings;
}
+37 -37
View File
@@ -42,8 +42,8 @@ NS_CC_EXTRA_BEGIN
unsigned int HTTPRequest::s_id = 0;
HTTPRequest *HTTPRequest::createWithUrl(HTTPRequestDelegate *delegate,
const char * url,
int method) {
const char *url,
int method) {
HTTPRequest *request = new HTTPRequest();
request->initWithDelegate(delegate, url, method);
request->addRef();
@@ -53,8 +53,8 @@ HTTPRequest *HTTPRequest::createWithUrl(HTTPRequestDelegate *delegate,
#if CC_LUA_ENGINE_ENABLED > 0
HTTPRequest *HTTPRequest::createWithUrlLua(LUA_FUNCTION listener,
const char * url,
int method) {
const char *url,
int method) {
HTTPRequest *request = new HTTPRequest();
request->initWithListener(listener, url, method);
request->autorelease();
@@ -75,7 +75,7 @@ bool HTTPRequest::initWithListener(LUA_FUNCTION listener, const char *url, int m
#endif
bool HTTPRequest::initWithUrl(const char *url, int method) {
CCASSERT(url, "HTTPRequest::initWithUrl() - invalid url");
CC_ASSERT(url);
_curl = curl_easy_init();
curl_easy_setopt(_curl, CURLOPT_URL, url);
curl_easy_setopt(_curl, CURLOPT_USERAGENT, "libcurl");
@@ -104,7 +104,7 @@ HTTPRequest::~HTTPRequest(void) {
}
void HTTPRequest::setRequestUrl(const char *url) {
CCASSERT(url, "HTTPRequest::setRequestUrl() - invalid url");
CC_ASSERT(url);
_url = url;
curl_easy_setopt(_curl, CURLOPT_URL, _url.c_str());
}
@@ -114,20 +114,20 @@ const string HTTPRequest::getRequestUrl(void) {
}
void HTTPRequest::addRequestHeader(const char *header) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addRequestHeader() - request not idle");
CCASSERT(header, "HTTPRequest::addRequestHeader() - invalid header");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
CC_ASSERT(header);
_headers.push_back(string(header));
}
void HTTPRequest::addPOSTValue(const char *key, const char *value) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addPOSTValue() - request not idle");
CCASSERT(key, "HTTPRequest::addPOSTValue() - invalid key");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
CC_ASSERT(key);
_postFields[string(key)] = string(value ? value : "");
}
void HTTPRequest::setPOSTData(const char *data) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setPOSTData() - request not idle");
CCASSERT(data, "HTTPRequest::setPOSTData() - invalid post data");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
CC_ASSERT(data);
_postFields.clear();
curl_easy_setopt(_curl, CURLOPT_POST, 1L);
curl_easy_setopt(_curl, CURLOPT_COPYPOSTFIELDS, data);
@@ -151,17 +151,17 @@ void HTTPRequest::addFormContents(const char *name, const char *value) {
}
void HTTPRequest::setCookieString(const char *cookie) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
curl_easy_setopt(_curl, CURLOPT_COOKIE, cookie ? cookie : "");
}
const string HTTPRequest::getCookieString(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
return _responseCookies;
}
void HTTPRequest::setAcceptEncoding(int acceptEncoding) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
switch (acceptEncoding) {
case kCCHTTPRequestAcceptEncodingGzip:
curl_easy_setopt(_curl, CURLOPT_ACCEPT_ENCODING, "gzip");
@@ -177,15 +177,15 @@ void HTTPRequest::setAcceptEncoding(int acceptEncoding) {
}
void HTTPRequest::setTimeout(int timeout) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setTimeout() - request not idle");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
curl_easy_setopt(_curl, CURLOPT_CONNECTTIMEOUT, timeout);
curl_easy_setopt(_curl, CURLOPT_TIMEOUT, timeout);
}
bool HTTPRequest::start(void) {
CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::start() - request not idle");
CC_ASSERT(_state == kCCHTTPRequestStateIdle);
_state = kCCHTTPRequestStateInProgress;
_state = kCCHTTPRequestStateInProgress;
_curlState = kCCHTTPRequestCURLStateBusy;
addRef();
@@ -236,12 +236,12 @@ int HTTPRequest::getState(void) {
}
int HTTPRequest::getResponseStatusCode(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
return _responseCode;
}
const HTTPRequestHeaders &HTTPRequest::getResponseHeaders(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseHeaders() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
return _responseHeaders;
}
@@ -254,12 +254,12 @@ const string HTTPRequest::getResponseHeadersString() {
}
const string HTTPRequest::getResponseString(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseString() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
return string(_responseBuffer ? static_cast<char *>(_responseBuffer) : "");
}
void *HTTPRequest::getResponseData(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
void *buff = malloc(_responseDataLength);
memcpy(buff, _responseBuffer, _responseDataLength);
return buff;
@@ -267,7 +267,7 @@ void *HTTPRequest::getResponseData(void) {
#if CC_LUA_ENGINE_ENABLED > 0
LUA_STRING HTTPRequest::getResponseDataLua(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseDataLua() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
LuaStack *stack = LuaEngine::getInstance()->getLuaStack();
stack->clean();
stack->pushString(static_cast<char *>(_responseBuffer), (int)_responseDataLength);
@@ -276,15 +276,15 @@ LUA_STRING HTTPRequest::getResponseDataLua(void) {
#endif
int HTTPRequest::getResponseDataLength(void) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
return (int)_responseDataLength;
}
size_t HTTPRequest::saveResponseData(const char *filename) {
CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::saveResponseData() - request not completed");
CC_ASSERT(_state == kCCHTTPRequestStateCompleted);
FILE *fp = fopen(filename, "wb");
CCASSERT(fp, "HTTPRequest::saveResponseData() - open file failure");
CC_ASSERT(fp);
size_t writedBytes = _responseDataLength;
if (writedBytes > 0) {
@@ -320,8 +320,8 @@ void HTTPRequest::update(float dt) {
if (_listener) {
LuaValueDict dict;
dict["name"] = LuaValue::stringValue("progress");
dict["total"] = LuaValue::intValue((int)_dltotal);
dict["name"] = LuaValue::stringValue("progress");
dict["total"] = LuaValue::intValue((int)_dltotal);
dict["dltotal"] = LuaValue::intValue((int)_dlnow);
dict["request"] = LuaValue::ccobjectValue(this, "HTTPRequest");
@@ -414,7 +414,7 @@ void HTTPRequest::onRequest(void) {
if (cookies) {
struct curl_slist *nc = cookies;
stringbuf buf;
stringbuf buf;
while (nc) {
buf.sputn(nc->data, strlen(nc->data));
buf.sputc('\n');
@@ -433,10 +433,10 @@ void HTTPRequest::onRequest(void) {
}
curl_slist_free_all(chunk);
_errorCode = code;
_errorCode = code;
_errorMessage = (code == CURLE_OK) ? "" : curl_easy_strerror(code);
_state = (code == CURLE_OK) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed;
_curlState = kCCHTTPRequestCURLStateClosed;
_state = (code == CURLE_OK) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed;
_curlState = kCCHTTPRequestCURLStateClosed;
}
size_t HTTPRequest::onWriteData(void *buffer, size_t bytes) {
@@ -452,7 +452,7 @@ size_t HTTPRequest::onWriteData(void *buffer, size_t bytes) {
}
size_t HTTPRequest::onWriteHeader(void *buffer, size_t bytes) {
char *headerBuffer = new char[bytes + 1];
char *headerBuffer = new char[bytes + 1];
headerBuffer[bytes] = 0;
memcpy(headerBuffer, buffer, bytes);
_responseHeaders.push_back(string(headerBuffer));
@@ -462,17 +462,17 @@ size_t HTTPRequest::onWriteHeader(void *buffer, size_t bytes) {
int HTTPRequest::onProgress(double dltotal, double dlnow, double ultotal, double ulnow) {
_dltotal = dltotal;
_dlnow = dlnow;
_dlnow = dlnow;
_ultotal = ultotal;
_ulnow = ulnow;
_ulnow = ulnow;
return _state == kCCHTTPRequestStateCancelled ? 1 : 0;
}
void HTTPRequest::cleanup(void) {
_state = kCCHTTPRequestStateCleared;
_state = kCCHTTPRequestStateCleared;
_responseBufferLength = 0;
_responseDataLength = 0;
_responseDataLength = 0;
if (_responseBuffer) {
free(_responseBuffer);
_responseBuffer = NULL;
@@ -196,8 +196,8 @@ void PlayerEditBoxServiceMac::showSingleLineEditBox(const cc::Rect &rect)
[[_sysEdit.textField cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[[_sysEdit.textField cell] setTruncatesLastVisibleLine:YES];
[_sysEdit setPosition:NSMakePoint(rect.origin.x, rect.origin.y)];
[_sysEdit setContentSize:NSMakeSize(rect.size.width, rect.size.height)];
[_sysEdit setPosition:NSMakePoint(rect.x, rect.y)];
[_sysEdit setContentSize:NSMakeSize(rect.width, rect.height)];
show();
}
@@ -207,8 +207,8 @@ void PlayerEditBoxServiceMac::showMultiLineEditBox(const cc::Rect &rect)
[[_sysEdit.textField cell] setLineBreakMode:NSLineBreakByCharWrapping];
[[_sysEdit.textField cell] setTruncatesLastVisibleLine:NO];
[_sysEdit setPosition:NSMakePoint(rect.origin.x, rect.origin.y)];
[_sysEdit setContentSize:NSMakeSize(rect.size.width, rect.size.height)];
[_sysEdit setPosition:NSMakePoint(rect.x, rect.y)];
[_sysEdit setContentSize:NSMakeSize(rect.width, rect.height)];
show();
}
@@ -246,7 +246,7 @@ PlayerTask *PlayerTaskServiceMac::createTask(const std::string &name,
const std::string &executePath,
const std::string &commandLineArguments)
{
CCASSERT(_tasks.find(name) == _tasks.end(), "Task already exists.");
CC_ASSERT(_tasks.find(name) == _tasks.end()); // Make sure task doesn't exist.
PlayerTaskMac *task = PlayerTaskMac::create(name, executePath, commandLineArguments);
_tasks.insert(name, task);
return task;
+20 -37
View File
@@ -23,58 +23,50 @@
THE SOFTWARE.
****************************************************************************/
#include <string>
#include "cocos/base/UTF8.h"
#include "cocos/base/Log.h"
#include "stdafx.h"
#include "PlayerEditBoxServiceWin.h"
#include "cocos/base/Log.h"
#include "cocos/base/UTF8.h"
#include "stdafx.h"
PLAYER_NS_BEGIN
PlayerEditBoxServiceWin::PlayerEditBoxServiceWin(HWND hwnd)
: _hfont(NULL)
{
: _hfont(NULL) {
_hwnd = hwnd;
HINSTANCE instance = (HINSTANCE)GetWindowLong(_hwnd, GWLP_HINSTANCE);
DWORD style = WS_CHILD | ES_LEFT | ES_AUTOHSCROLL;
_hwndSingle = CreateWindowEx(WS_EX_CLIENTEDGE, (LPCSTR)L"Edit", (LPCSTR)L"", style, 0, 0, 0, 0, _hwnd, NULL, instance, NULL);
style = WS_CHILD | ES_MULTILINE | ES_LEFT | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL;
_hwndMulti = CreateWindowEx(WS_EX_CLIENTEDGE,(LPCSTR) L"Edit", (LPCSTR)L"", style, 0, 0, 0, 0, _hwnd, NULL, instance, NULL);
_hwndMulti = CreateWindowEx(WS_EX_CLIENTEDGE, (LPCSTR)L"Edit", (LPCSTR)L"", style, 0, 0, 0, 0, _hwnd, NULL, instance, NULL);
}
PlayerEditBoxServiceWin::~PlayerEditBoxServiceWin()
{
PlayerEditBoxServiceWin::~PlayerEditBoxServiceWin() {
removeFont();
DestroyWindow(_hwndSingle);
DestroyWindow(_hwndMulti);
}
void PlayerEditBoxServiceWin::showSingleLineEditBox(const cc::Rect &rect)
{
MoveWindow(_hwndSingle, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, TRUE);
void PlayerEditBoxServiceWin::showSingleLineEditBox(const cc::Rect &rect) {
MoveWindow(_hwndSingle, rect.x, rect.y, rect.width, rect.height, TRUE);
ShowWindow(_hwndSingle, SW_SHOW);
SetFocus(_hwndSingle);
}
void PlayerEditBoxServiceWin::showMultiLineEditBox(const cc::Rect &rect)
{
MoveWindow(_hwndMulti, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, TRUE);
void PlayerEditBoxServiceWin::showMultiLineEditBox(const cc::Rect &rect) {
MoveWindow(_hwndMulti, rect.x, rect.y, rect.width, rect.height, TRUE);
ShowWindow(_hwndMulti, SW_SHOW);
SetFocus(_hwndMulti);
}
void PlayerEditBoxServiceWin::hide()
{
void PlayerEditBoxServiceWin::hide() {
}
void PlayerEditBoxServiceWin::setText(const std::string &text)
{
void PlayerEditBoxServiceWin::setText(const std::string &text) {
}
void PlayerEditBoxServiceWin::setFont(const std::string &name, int size)
{
void PlayerEditBoxServiceWin::setFont(const std::string &name, int size) {
removeFont();
std::u16string u16name;
@@ -87,28 +79,21 @@ void PlayerEditBoxServiceWin::setFont(const std::string &name, int size)
_hfont = CreateFont(size, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
0, OUT_DEFAULT_PRECIS, FW_NORMAL, DEFAULT_QUALITY, DEFAULT_PITCH,
(LPCTSTR)u16name.c_str());
if (!_hfont)
{
if (!_hfont) {
DWORD err = GetLastError();
CC_LOG_DEBUG("PlayerEditBoxServiceWin::setFont() - create HFONT for font \"%s\" failed, error code = 0x%08x",
name.c_str(), err);
}
else
{
name.c_str(), err);
} else {
SendMessage(_hwndSingle, WM_SETFONT, (WPARAM)_hfont, NULL);
SendMessage(_hwndMulti, WM_SETFONT, (WPARAM)_hfont, NULL);
}
}
void PlayerEditBoxServiceWin::setFontColor(const Color3B &color)
{
void PlayerEditBoxServiceWin::setFontColor(const Color3B &color) {
}
void PlayerEditBoxServiceWin::removeFont()
{
if (_hfont)
{
void PlayerEditBoxServiceWin::removeFont() {
if (_hfont) {
SendMessage(_hwndSingle, WM_SETFONT, NULL, NULL);
SendMessage(_hwndMulti, WM_SETFONT, NULL, NULL);
DeleteObject(_hfont);
@@ -116,9 +101,7 @@ void PlayerEditBoxServiceWin::removeFont()
_hfont = NULL;
}
void PlayerEditBoxServiceWin::setFormator(int /*formator*/ )
{
void PlayerEditBoxServiceWin::setFormator(int /*formator*/) {
}
PLAYER_NS_END
+14 -14
View File
@@ -75,8 +75,8 @@ bool PlayerTaskWin::run() {
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx
SECURITY_ATTRIBUTES sa = {0};
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
// Create a pipe for the child process's STDOUT.
if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0)) {
@@ -95,16 +95,16 @@ bool PlayerTaskWin::run() {
ZeroMemory(&_pi, sizeof(_pi));
STARTUPINFO si = {0};
si.cb = sizeof(STARTUPINFO);
si.hStdError = _childStdOutWrite;
si.hStdOutput = _childStdOutWrite;
si.hStdInput = _childStdInRead;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.cb = sizeof(STARTUPINFO);
si.hStdError = _childStdOutWrite;
si.hStdOutput = _childStdOutWrite;
si.hStdInput = _childStdInRead;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
#define MAX_COMMAND 4096 //MAX_PATH
const std::u16string u16command = makeCommandLine();
WCHAR command[MAX_COMMAND];
WCHAR command[MAX_COMMAND];
wcscpy_s(command, MAX_COMMAND, (WCHAR *)u16command.c_str());
BOOL success = CreateProcess(NULL,
@@ -124,9 +124,9 @@ bool PlayerTaskWin::run() {
return false;
}
_outputBuff = new CHAR[BUFF_SIZE + 1];
_outputBuff = new CHAR[BUFF_SIZE + 1];
_outputBuffWide = new WCHAR[BUFF_SIZE];
_state = STATE_RUNNING;
_state = STATE_RUNNING;
// cc::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);
return true;
@@ -206,10 +206,10 @@ void PlayerTaskWin::cleanup() {
if (_childStdInRead) CloseHandle(_childStdInRead);
if (_childStdInWrite) CloseHandle(_childStdInWrite);
_childStdOutRead = NULL;
_childStdOutRead = NULL;
_childStdOutWrite = NULL;
_childStdInRead = NULL;
_childStdInWrite = NULL;
_childStdInRead = NULL;
_childStdInWrite = NULL;
_state = STATE_COMPLETED;
@@ -243,7 +243,7 @@ PlayerTaskServiceWin::~PlayerTaskServiceWin() {
PlayerTask *PlayerTaskServiceWin::createTask(const std::string &name,
const std::string &executePath,
const std::string &commandLineArguments) {
CCASSERT(_tasks.find(name) == _tasks.end(), "Task already exists.");
CC_ASSERT(_tasks.find(name) == _tasks.end()); // Make sure task doesn't exist.
PlayerTaskWin *task = PlayerTaskWin::create(name, executePath, commandLineArguments);
_tasks.insert(name, task);
return task;
+10 -25
View File
@@ -23,66 +23,51 @@
THE SOFTWARE.
****************************************************************************/
#include "PlayerWin.h"
using namespace std;
PLAYER_NS_BEGIN
PlayerWin::PlayerWin()
: PlayerProtocol()
, _messageBoxService(nullptr)
, _menuService(nullptr)
, _editboxService(nullptr)
, _taskService(nullptr)
, _hwnd(NULL)
{
: PlayerProtocol(), _messageBoxService(nullptr), _menuService(nullptr), _editboxService(nullptr), _taskService(nullptr), _hwnd(NULL) {
}
PlayerWin::~PlayerWin()
{
PlayerWin::~PlayerWin() {
CC_SAFE_DELETE(_menuService);
CC_SAFE_DELETE(_messageBoxService);
CC_SAFE_DELETE(_fileDialogService);
}
PlayerWin *PlayerWin::createWithHwnd(HWND hWnd)
{
PlayerWin *PlayerWin::createWithHwnd(HWND hWnd) {
auto instance = new PlayerWin();
instance->_hwnd = hWnd;
instance->initServices();
return instance;
}
PlayerFileDialogServiceProtocol *PlayerWin::getFileDialogService()
{
PlayerFileDialogServiceProtocol *PlayerWin::getFileDialogService() {
return _fileDialogService;
}
PlayerMessageBoxServiceProtocol *PlayerWin::getMessageBoxService()
{
PlayerMessageBoxServiceProtocol *PlayerWin::getMessageBoxService() {
return _messageBoxService;
}
PlayerMenuServiceProtocol *PlayerWin::getMenuService()
{
PlayerMenuServiceProtocol *PlayerWin::getMenuService() {
return _menuService;
}
PlayerEditBoxServiceProtocol *PlayerWin::getEditBoxService()
{
PlayerEditBoxServiceProtocol *PlayerWin::getEditBoxService() {
return _editboxService;
}
PlayerTaskServiceProtocol *PlayerWin::getTaskService()
{
PlayerTaskServiceProtocol *PlayerWin::getTaskService() {
return _taskService;
}
// services
void PlayerWin::initServices()
{
CCASSERT(_menuService == nullptr, "CAN'T INITIALIZATION SERVICES MORE THAN ONCE");
void PlayerWin::initServices() {
CC_ASSERT(_menuService == nullptr); // Can't initialize services again.
_menuService = new PlayerMenuServiceWin(_hwnd);
_messageBoxService = new PlayerMessageBoxServiceWin(_hwnd);
_fileDialogService = new PlayerFileDialogServiceWin(_hwnd);
@@ -26,11 +26,11 @@
#include "ConfigParser.h"
#include "FileServer.h"
#include "cocos/base/Log.h"
#include "cocos/base/memory/Memory.h"
#include "cocos/platform/FileUtils.h"
#include "json/document.h"
#include "json/stringbuffer.h"
#include "json/writer.h"
#include "cocos/base/memory/Memory.h"
// ConfigParser
ConfigParser *ConfigParser::s_sharedConfigParserInstance = NULL;
@@ -49,7 +49,7 @@ void ConfigParser::purge() {
void ConfigParser::readConfig(const string &filepath) {
string fullPathFile = filepath;
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_WINDOWS)
#if (CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_WINDOWS)
// add writable path to search path temporarily for reading config file
vector<std::string> searchPathArray = cc::FileUtils::getInstance()->getSearchPaths();
searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath());
@@ -62,7 +62,7 @@ void ConfigParser::readConfig(const string &filepath) {
}
string fileContent = cc::FileUtils::getInstance()->getStringFromFile(fullPathFile);
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_WINDOWS)
#if (CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_WINDOWS)
// revert search path
searchPathArray.erase(searchPathArray.begin());
cc::FileUtils::getInstance()->setSearchPaths(searchPathArray);
+23 -33
View File
@@ -25,26 +25,23 @@ THE SOFTWARE.
****************************************************************************/
//#include "ConnectWaitLayer.h"
#include "Runtime.h"
#include "FileServer.h"
#include "ConfigParser.h"
#include "VisibleRect.h"
#include "FileServer.h"
#include "ResData.h"
#include "Runtime.h"
#include "VisibleRect.h"
using namespace cocos2d;
ConnectWaitLayer::ConnectWaitLayer()
{
ConnectWaitLayer::ConnectWaitLayer() {
int designWidth = 1280;
int designHeight = 800;
_imagebg = new Image();
if (ConfigParser::getInstance()->isLanscape())
{
if (ConfigParser::getInstance()->isLanscape()) {
_imagebg->initWithImageData(__landscapePngData, sizeof(__landscapePngData));
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designWidth, designHeight, ResolutionPolicy::EXACT_FIT);
} else
{
} else {
_imagebg->initWithImageData(__portraitPngData, sizeof(__portraitPngData));
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designHeight, designWidth, ResolutionPolicy::FIXED_HEIGHT);
}
@@ -81,10 +78,9 @@ ConnectWaitLayer::ConnectWaitLayer()
addChild(shineSprite, 9998);
std::string strip = getIPAddress();
if (strip.empty())
{
strip = "0.0.0.0";
}
if (strip.empty()) {
strip = "0.0.0.0";
}
char szIPAddress[64] = {0};
sprintf(szIPAddress, "IP: %s", strip.c_str());
@@ -96,8 +92,7 @@ ConnectWaitLayer::ConnectWaitLayer()
addChild(IPlabel, 9001);
std::string transferTip = "waiting for file transfer ...";
if (CC_PLATFORM_WINDOWS == CC_PLATFORM || CC_PLATFORM_MAC_OSX == CC_PLATFORM)
{
if (CC_PLATFORM_WINDOWS == CC_PLATFORM || CC_PLATFORM_MACOS == CC_PLATFORM) {
transferTip = "waiting for debugger to connect ...";
}
@@ -111,23 +106,20 @@ ConnectWaitLayer::ConnectWaitLayer()
addChild(verLable, 9002);
_labelUploadFile = Label::createWithSystemFont(transferTip, "", 36);
_labelUploadFile->setAnchorPoint(Vec2(0, 0));
_labelUploadFile->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, IPlabel->getPositionY()- spaceSizex));
_labelUploadFile->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, IPlabel->getPositionY() - spaceSizex));
_labelUploadFile->setAlignment(TextHAlignment::LEFT);
addChild(_labelUploadFile, 9003);
if (ConfigParser::getInstance()->isLanscape())
{
if (ConfigParser::getInstance()->isLanscape()) {
playSprite->setPosition(lanscaptX, lanscaptY);
shineSprite->setPosition(lanscaptX, lanscaptY);
}
else
{
} else {
playSprite->setPosition(portraitX, portraitY);
shineSprite->setPosition(portraitX, portraitY);
}
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [](Touch* touch, Event *event)->bool{
listener->onTouchBegan = [](Touch* touch, Event* event) -> bool {
auto target = static_cast<Sprite*>(event->getCurrentTarget());
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
@@ -136,12 +128,12 @@ ConnectWaitLayer::ConnectWaitLayer()
target->runAction(Sequence::createWithTwoActions(ScaleBy::create(0.05f, 0.9f), ScaleTo::create(0.125f, 1)));
return true;
};
listener->onTouchEnded = [](Touch* touch, Event *event){
listener->onTouchEnded = [](Touch* touch, Event* event) {
auto target = static_cast<Sprite*>(event->getCurrentTarget());
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
if (!rect.containsPoint(point)) return;
RuntimeEngine::getInstance()->setupRuntime();
RuntimeEngine::getInstance()->startScript("");
};
@@ -150,18 +142,16 @@ ConnectWaitLayer::ConnectWaitLayer()
this->scheduleUpdate();
}
ConnectWaitLayer::~ConnectWaitLayer()
{
CC_SAFE_RELEASE(_imagebg);
CC_SAFE_RELEASE(_imageplay);
CC_SAFE_RELEASE(_imageShine);
ConnectWaitLayer::~ConnectWaitLayer() {
CC_SAFE_RELEASE(_imagebg);
CC_SAFE_RELEASE(_imageplay);
CC_SAFE_RELEASE(_imageShine);
}
// clean up: ignore stdin, stdout and stderr
void ConnectWaitLayer::update(float fDelta)
{
void ConnectWaitLayer::update(float fDelta) {
std::string transferTip = FileServer::getShareInstance()->getTransingFileName();
if (transferTip.empty()){
if (transferTip.empty()) {
return;
}
_labelUploadFile->setString(transferTip);
+81 -129
View File
@@ -24,9 +24,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "Runtime.h"
#include "ConfigParser.h"
#include "ConsoleCommand.h"
#include "ConfigParser.h"
#include "Runtime.h"
#include "json/document.h"
#include "json/stringbuffer.h"
@@ -35,32 +35,26 @@ THE SOFTWARE.
using namespace cocos2d;
ConsoleCommand* ConsoleCommand::s_sharedConsoleCommand = nullptr;
ConsoleCommand* ConsoleCommand::getShareInstance()
{
if (s_sharedConsoleCommand == nullptr)
{
s_sharedConsoleCommand = new ConsoleCommand();
}
return s_sharedConsoleCommand;
ConsoleCommand* ConsoleCommand::getShareInstance() {
if (s_sharedConsoleCommand == nullptr) {
s_sharedConsoleCommand = new ConsoleCommand();
}
return s_sharedConsoleCommand;
}
void ConsoleCommand::purge()
{
if (s_sharedConsoleCommand != nullptr)
{
delete s_sharedConsoleCommand;
}
void ConsoleCommand::purge() {
if (s_sharedConsoleCommand != nullptr) {
delete s_sharedConsoleCommand;
}
}
void ConsoleCommand::init()
{
cocos2d::Console *_console = Director::getInstance()->getConsole();
void ConsoleCommand::init() {
cocos2d::Console* _console = Director::getInstance()->getConsole();
static struct Console::Command commands[] =
{
{"sendrequest","send command to runtime.Args[json format]",std::bind(&ConsoleCommand::onSendCommand, this, std::placeholders::_1, std::placeholders::_2)},
};
for (int i = 0;i< sizeof(commands) / sizeof(Console::Command);i++)
{
{
{"sendrequest", "send command to runtime.Args[json format]", std::bind(&ConsoleCommand::onSendCommand, this, std::placeholders::_1, std::placeholders::_2)},
};
for (int i = 0; i < sizeof(commands) / sizeof(Console::Command); i++) {
_console->addCommand(commands[i]);
}
@@ -73,160 +67,128 @@ void ConsoleCommand::init()
_fileserver->readResFileFinfo();
}
void ConsoleCommand::onSendCommand(int fd, const std::string &args)
{
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=](){
void ConsoleCommand::onSendCommand(int fd, const std::string& args) {
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]() {
rapidjson::Document dArgParse;
dArgParse.Parse<0>(args.c_str());
if (dArgParse.HasMember("cmd"))
{
if (dArgParse.HasMember("cmd")) {
string strcmd = dArgParse["cmd"].GetString();
rapidjson::Document dReplyParse;
dReplyParse.SetObject();
rapidjson::Document::AllocatorType& allocator = dReplyParse.GetAllocator();
dReplyParse.AddMember("cmd", rapidjson::Value(strcmd.c_str(), allocator)
, allocator);
if (dArgParse.HasMember("seq"))
{
dReplyParse.AddMember("seq",dArgParse["seq"],allocator);
dReplyParse.AddMember("cmd", rapidjson::Value(strcmd.c_str(), allocator), allocator);
if (dArgParse.HasMember("seq")) {
dReplyParse.AddMember("seq", dArgParse["seq"], allocator);
}
if(strcmp(strcmd.c_str(), "start-logic") == 0)
{
if (strcmp(strcmd.c_str(), "start-logic") == 0) {
auto runtime = RuntimeEngine::getInstance()->getRuntime();
if (!runtime)
{
if (!runtime) {
RuntimeEngine::getInstance()->setupRuntime();
runtime = RuntimeEngine::getInstance()->getRuntime();
}
if (runtime) runtime->onStartDebuger(dArgParse, dReplyParse);
} else if (strcmp(strcmd.c_str(),"clearcompile")==0)
{
} else if (strcmp(strcmd.c_str(), "clearcompile") == 0) {
auto runtime = RuntimeEngine::getInstance()->getRuntime();
if (!runtime)
{
if (!runtime) {
RuntimeEngine::getInstance()->setupRuntime();
runtime = RuntimeEngine::getInstance()->getRuntime();
}
if (runtime) runtime->onClearCompile(dArgParse, dReplyParse);
} else if(strcmp(strcmd.c_str(),"precompile")==0)
{
} else if (strcmp(strcmd.c_str(), "precompile") == 0) {
auto runtime = RuntimeEngine::getInstance()->getRuntime();
if (!runtime)
{
if (!runtime) {
RuntimeEngine::getInstance()->setupRuntime();
runtime = RuntimeEngine::getInstance()->getRuntime();
}
if (runtime) runtime->onPrecompile(dArgParse, dReplyParse);
} else if(strcmp(strcmd.c_str(), "reload") == 0)
{
} else if (strcmp(strcmd.c_str(), "reload") == 0) {
auto runtime = RuntimeEngine::getInstance()->getRuntime();
if (!runtime)
{
if (!runtime) {
RuntimeEngine::getInstance()->setupRuntime();
runtime = RuntimeEngine::getInstance()->getRuntime();
}
if (runtime) runtime->onReload(dArgParse, dReplyParse);
} else if(strcmp(strcmd.c_str(), "getversion") == 0)
{
} else if (strcmp(strcmd.c_str(), "getversion") == 0) {
rapidjson::Value bodyvalue(rapidjson::kObjectType);
bodyvalue.AddMember("version", rapidjson::Value(getRuntimeVersion(), allocator)
, allocator);
bodyvalue.AddMember("version", rapidjson::Value(getRuntimeVersion(), allocator), allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
dReplyParse.AddMember("code", 0, allocator);
} else if(strcmp(strcmd.c_str(), "getfileinfo") == 0)
{
} else if (strcmp(strcmd.c_str(), "getfileinfo") == 0) {
rapidjson::Value bodyvalue(rapidjson::kObjectType);
rapidjson::Document* filecfgjson = _fileserver->getFileCfgJson();
for (rapidjson::Value::MemberIterator itr = filecfgjson->MemberBegin()
; itr != filecfgjson->MemberEnd()
; ++itr)
{
for (rapidjson::Value::MemberIterator itr = filecfgjson->MemberBegin(); itr != filecfgjson->MemberEnd(); ++itr) {
bodyvalue.AddMember(itr->name, itr->value, allocator);
}
dReplyParse.AddMember("body", bodyvalue, allocator);
dReplyParse.AddMember("code", 0, allocator);
} else if (strcmp(strcmd.c_str(), "getEntryfile") == 0)
{
} else if (strcmp(strcmd.c_str(), "getEntryfile") == 0) {
rapidjson::Value bodyvalue(rapidjson::kObjectType);
rapidjson::Value entryFileValue(rapidjson::kStringType);
entryFileValue.SetString(ConfigParser::getInstance()->getEntryFile().c_str(), allocator);
bodyvalue.AddMember("entryfile", entryFileValue, allocator);
dReplyParse.AddMember("body", bodyvalue,allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
dReplyParse.AddMember("code", 0, allocator);
} else if(strcmp(strcmd.c_str(), "getIP") == 0)
{
} else if (strcmp(strcmd.c_str(), "getIP") == 0) {
rapidjson::Value bodyvalue(rapidjson::kObjectType);
rapidjson::Value IPValue(rapidjson::kStringType);
IPValue.SetString(getIPAddress().c_str(), allocator);
bodyvalue.AddMember("IP", IPValue,allocator);
dReplyParse.AddMember("body", bodyvalue,allocator);
bodyvalue.AddMember("IP", IPValue, allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
dReplyParse.AddMember("code", 0, allocator);
} else if(strcmp(strcmd.c_str(), "remove") == 0)
{
if (dArgParse.HasMember("files"))
{
} else if (strcmp(strcmd.c_str(), "remove") == 0) {
if (dArgParse.HasMember("files")) {
rapidjson::Value bodyvalue(rapidjson::kObjectType);
const rapidjson::Value& objectfiles = dArgParse["files"];
const char* filename = NULL;
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
{
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) {
filename = objectfiles[i].GetString();
// remove js compiled script
auto runtime = RuntimeEngine::getInstance()->getRuntime();
if (runtime) runtime->onRemove(filename);
// remove file from disk
string filepath(_fileserver->getWritePath() + "/" + filename);
if (FileUtils::getInstance()->isFileExist(filepath))
{
if(remove(filepath.c_str()) != 0)
{
if (FileUtils::getInstance()->isFileExist(filepath)) {
if (remove(filepath.c_str()) != 0) {
// remove failed
bodyvalue.AddMember(rapidjson::Value(filename, allocator)
, rapidjson::Value(2)
, allocator);
bodyvalue.AddMember(rapidjson::Value(filename, allocator), rapidjson::Value(2), allocator);
}
} else
{
} else {
// file not exist
bodyvalue.AddMember(rapidjson::Value(filename, allocator)
, rapidjson::Value(1)
, allocator);
bodyvalue.AddMember(rapidjson::Value(filename, allocator), rapidjson::Value(1), allocator);
}
// file remove success, remove it from record
if (! FileUtils::getInstance()->isFileExist(filepath))
if (!FileUtils::getInstance()->isFileExist(filepath))
_fileserver->removeResFileInfo(filename);
}
dReplyParse.AddMember("body", bodyvalue, allocator);
}
dReplyParse.AddMember("code",0,allocator);
} else if(strcmp(strcmd.c_str(), "shutdownapp") == 0)
{
dReplyParse.AddMember("code", 0, allocator);
} else if (strcmp(strcmd.c_str(), "shutdownapp") == 0) {
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
#include <windows.h>
auto glview = dynamic_cast<GLViewImpl*> (Director::getInstance()->getOpenGLView());
#include <windows.h>
auto glview = dynamic_cast<GLViewImpl*>(Director::getInstance()->getOpenGLView());
HWND hWnd = glview->getWin32Window();
::SendMessage(hWnd, WM_CLOSE, NULL, NULL);
#else
exit(0);
#endif
} else if(strcmp(strcmd.c_str(), "getplatform") == 0)
{
string platform="UNKNOW";
} else if (strcmp(strcmd.c_str(), "getplatform") == 0) {
string platform = "UNKNOW";
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
platform = "WIN32";
#elif (CC_PLATFORM == CC_PLATFORM_MAC_OSX)
#elif (CC_PLATFORM == CC_PLATFORM_MACOS)
platform = "MAC";
#elif (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
#elif (CC_PLATFORM == CC_PLATFORM_IOS)
platform = "IOS";
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
platform = "ANDROID";
@@ -237,63 +199,53 @@ void ConsoleCommand::onSendCommand(int fd, const std::string &args)
bodyvalue.AddMember("platform", platformValue, allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
dReplyParse.AddMember("code", 0, allocator);
} else if(strcmp(strcmd.c_str(), "usewritablepath") == 0)
{
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID)
} else if (strcmp(strcmd.c_str(), "usewritablepath") == 0) {
#if (CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID)
// only iOS and Android need to open using write path by Code IDE
FileServer::getShareInstance()->setIsUsingWritePath(true);
std::vector<std::string> searchPathArray = FileUtils::getInstance()->getSearchPaths();
searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath());
FileUtils::getInstance()->setSearchPaths(searchPathArray);
#endif
dReplyParse.AddMember("code", 0, allocator);
}
else if (strcmp(strcmd.c_str(), "workdir") == 0)
{
if (dArgParse.HasMember("path"))
{
} else if (strcmp(strcmd.c_str(), "workdir") == 0) {
if (dArgParse.HasMember("path")) {
const rapidjson::Value& objectPath = dArgParse["path"];
FileUtils::getInstance()->setDefaultResourceRootPath(objectPath.GetString());
rapidjson::Value bodyvalue(rapidjson::kObjectType);
bodyvalue.AddMember("path", rapidjson::Value(objectPath.GetString(), allocator)
, allocator);
bodyvalue.AddMember("path", rapidjson::Value(objectPath.GetString(), allocator), allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
}
dReplyParse.AddMember("code", 0, allocator);
}
else if (strcmp(strcmd.c_str(), "writablePath") == 0)
{
if (dArgParse.HasMember("path"))
{
} else if (strcmp(strcmd.c_str(), "writablePath") == 0) {
if (dArgParse.HasMember("path")) {
const rapidjson::Value& objectPath = dArgParse["path"];
FileUtils::getInstance()->setWritablePath(objectPath.GetString());
rapidjson::Value bodyvalue(rapidjson::kObjectType);
bodyvalue.AddMember("path", rapidjson::Value(objectPath.GetString(), allocator)
, allocator);
bodyvalue.AddMember("path", rapidjson::Value(objectPath.GetString(), allocator), allocator);
dReplyParse.AddMember("body", bodyvalue, allocator);
}
dReplyParse.AddMember("code", 0, allocator);
}
rapidjson::StringBuffer buffer;
rapidjson::Writer< rapidjson::StringBuffer > writer(buffer);
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
dReplyParse.Accept(writer);
string msgContent = buffer.GetString();
char msgLength[64] = {0x1, 0};
sprintf(msgLength + 1, "%ld:", msgContent.size());
string msg(msgLength + msgContent);
sendBuf(fd, msg.c_str(), msg.size());
}
});
}
ConsoleCommand::~ConsoleCommand()
{
Director::getInstance()->getConsole()->stop();
ConsoleCommand::~ConsoleCommand() {
Director::getInstance()->getConsole()->stop();
}
@@ -235,7 +235,7 @@ FileServer::FileServer() : _listenfd(-1),
_writeEndThread(false),
_responseRunning(false),
_responseEndThread(false) {
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID)
#if (CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID)
// need to be opened by Code IDE
_isUsingWritePath = false;
#else
@@ -244,7 +244,7 @@ FileServer::FileServer() : _listenfd(-1),
_writePath = cc::FileUtils::getInstance()->getWritablePath();
#if (CC_PLATFORM == CC_PLATFORM_MAC_OSX)
#if (CC_PLATFORM == CC_PLATFORM_MACOS)
#include "Widget_mac.h"
_writePath += getCurAppName();
_writePath += "/";
@@ -272,7 +272,6 @@ void FileServer::loopReceiveFile() {
char *protoBuf = new char[MAXPROTOLENGTH];
while (!_receiveEndThread) {
// recv start flag
char startflag[13] = {0};
recvBuf(fd, startflag, sizeof(startflag) - 1);
@@ -30,10 +30,10 @@ THE SOFTWARE.
#include "RuntimeProtocol.h"
#include "cocos/base/Log.h"
#include "cocos/platform/FileUtils.h"
#include "cocos/base/memory/Memory.h"
#include "cocos/platform/FileUtils.h"
#if ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MAC_OSX))
#if ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MACOS))
#include "DeviceEx.h"
#include "network/CCHTTPRequest.h"
#include "xxhash/xxhash.h"
@@ -119,12 +119,12 @@ void RuntimeEngine::setupRuntime() {
// get project type fron config.json
updateConfigParser();
auto entryFile = ConfigParser::getInstance()->getEntryFile();
#if (CC_PLATFORM != CC_PLATFORM_WINDOWS) && (CC_PLATFORM != CC_PLATFORM_MAC_OSX)
#if (CC_PLATFORM != CC_PLATFORM_WINDOWS) && (CC_PLATFORM != CC_PLATFORM_MACOS)
ConfigParser::getInstance()->readConfig();
entryFile = ConfigParser::getInstance()->getEntryFile();
#endif
_launchEvent = "js";
_runtime = _runtimes[kRuntimeEngineJs];
_runtime = _runtimes[kRuntimeEngineJs];
}
void RuntimeEngine::setProjectConfig(const ProjectConfig &config) {
@@ -137,7 +137,7 @@ const ProjectConfig &RuntimeEngine::getProjectConfig() {
}
void RuntimeEngine::setProjectPath(const std::string &workPath) {
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_MAC_OSX)
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_MACOS)
vector<std::string> searchPathArray = cc::FileUtils::getInstance()->getSearchPaths();
if (workPath.empty()) {
@@ -151,20 +151,20 @@ void RuntimeEngine::setProjectPath(const std::string &workPath) {
nEnd = i;
}
szAppDir[nEnd] = 0;
int iLen = 2 * wcslen((wchar_t *)szAppDir);
char *chRtn = new char[iLen + 1];
int iLen = 2 * wcslen((wchar_t *)szAppDir);
char *chRtn = new char[iLen + 1];
wcstombs(chRtn, (wchar_t *)szAppDir, iLen + 1);
std::string strPath = chRtn;
delete[] chRtn;
chRtn = NULL;
chRtn = NULL;
char fuldir[MAX_PATH] = {0};
_fullpath(fuldir, strPath.c_str(), MAX_PATH);
appPath = fuldir;
}
#elif (CC_PLATFORM == CC_PLATFORM_MAC_OSX)
#elif (CC_PLATFORM == CC_PLATFORM_MACOS)
appPath.append("/../../../");
#endif
appPath = replaceAll(appPath, "\\", "/");
appPath = replaceAll(appPath, "\\", "/");
g_projectPath = appPath;
} else {
g_projectPath = workPath;
@@ -190,7 +190,7 @@ void RuntimeEngine::startScript(const std::string &args) {
}
void RuntimeEngine::start() {
#if (CC_PLATFORM != CC_PLATFORM_WINDOWS) && (CC_PLATFORM != CC_PLATFORM_MAC_OSX)
#if (CC_PLATFORM != CC_PLATFORM_WINDOWS) && (CC_PLATFORM != CC_PLATFORM_MACOS)
_project.setDebuggerType(kCCRuntimeDebuggerCodeIDE);
#endif
@@ -215,7 +215,7 @@ void RuntimeEngine::start() {
}
setupRuntime();
//startScript("jsb-adapter/jsb-builtin.js");
//startScript("jsb-adapter/web-adapter.js");
//startScript("");
}
@@ -250,7 +250,7 @@ RuntimeProtocol *RuntimeEngine::getRuntime() {
void RuntimeEngine::updateConfigParser() {
// set entry file
auto parser = ConfigParser::getInstance();
auto parser = ConfigParser::getInstance();
string entryFile(_project.getScriptFileRealPath());
if (entryFile.find(_project.getProjectDir()) != string::npos) {
entryFile.erase(0, _project.getProjectDir().length());
@@ -269,11 +269,11 @@ void RuntimeEngine::trackEvent(const std::string &eventName) {
return;
}
#if ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MAC_OSX))
#if ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MACOS))
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
const char *platform = "win";
#elif (CC_PLATFORM == CC_PLATFORM_MAC_OSX)
#elif (CC_PLATFORM == CC_PLATFORM_MACOS)
const char *platform = "mac";
#else
const char *platform = "UNKNOWN";
@@ -298,7 +298,7 @@ void RuntimeEngine::trackEvent(const std::string &eventName) {
request->start();
*/
#endif // ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MAC_OSX))
#endif // ((CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_MACOS))
}
void RuntimeEngine::trackLaunchEvent() {
@@ -42,45 +42,45 @@ cc::Rect VisibleRect::getVisibleRect() {
cc::Vec2 VisibleRect::left() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
return cc::Vec2(s_visibleRect.x, s_visibleRect.y + s_visibleRect.height / 2);
}
cc::Vec2 VisibleRect::right() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width, s_visibleRect.y + s_visibleRect.height / 2);
}
cc::Vec2 VisibleRect::top() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2, s_visibleRect.origin.y + s_visibleRect.size.height);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width / 2, s_visibleRect.y + s_visibleRect.height);
}
cc::Vec2 VisibleRect::bottom() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2, s_visibleRect.origin.y);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width / 2, s_visibleRect.y);
}
cc::Vec2 VisibleRect::center() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width / 2, s_visibleRect.y + s_visibleRect.height / 2);
}
cc::Vec2 VisibleRect::leftTop() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y + s_visibleRect.size.height);
return cc::Vec2(s_visibleRect.x, s_visibleRect.y + s_visibleRect.height);
}
cc::Vec2 VisibleRect::rightTop() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y + s_visibleRect.size.height);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width, s_visibleRect.y + s_visibleRect.height);
}
cc::Vec2 VisibleRect::leftBottom() {
lazyInit();
return s_visibleRect.origin;
return cc::Vec2{s_visibleRect.x, s_visibleRect.y};
}
cc::Vec2 VisibleRect::rightBottom() {
lazyInit();
return cc::Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y);
return cc::Vec2(s_visibleRect.x + s_visibleRect.width, s_visibleRect.y);
}