mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 03:38:29 +00:00
[engine] [cocos2d-x] [jsb-adapter] 适配引擎 v2.4.13 版本
This commit is contained in:
parent
7f956acda7
commit
887d4a96c9
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": false,
|
||||||
|
"editor.codeActionsOnSave": {},
|
||||||
|
"[javascript][typescript][javascriptreact][typescriptreact]": {
|
||||||
|
"editor.formatOnSave": false,
|
||||||
|
"editor.codeActionsOnSave": {},
|
||||||
|
},
|
||||||
|
}
|
@ -869,7 +869,7 @@ function(cc_apply_definations target)
|
|||||||
target_compile_definitions(${target} PUBLIC
|
target_compile_definitions(${target} PUBLIC
|
||||||
$<IF:$<BOOL:${CC_USE_GFX_RENDERER}>,USE_GFX_RENDERER=1,USE_GFX_RENDERER=0>
|
$<IF:$<BOOL:${CC_USE_GFX_RENDERER}>,USE_GFX_RENDERER=1,USE_GFX_RENDERER=0>
|
||||||
$<IF:$<BOOL:${CC_USE_VIDEO}>,USE_VIDEO=1,USE_VIDEO=0>
|
$<IF:$<BOOL:${CC_USE_VIDEO}>,USE_VIDEO=1,USE_VIDEO=0>
|
||||||
$<IF:$<BOOL:${CC_USE_WEBVIEW}>,USE_WEBVIEW=1,USE_WEBVIEW=0>
|
$<IF:$<BOOL:${CC_USE_WEBVIEW}>,USE_WEB_VIEW=1,USE_WEB_VIEW=0>
|
||||||
$<IF:$<BOOL:${CC_USE_AUDIO}>,USE_AUDIO=1,USE_AUDIO=0>
|
$<IF:$<BOOL:${CC_USE_AUDIO}>,USE_AUDIO=1,USE_AUDIO=0>
|
||||||
$<IF:$<BOOL:${CC_USE_SOCKET}>,USE_SOCKET=1,USE_SOCKET=0>
|
$<IF:$<BOOL:${CC_USE_SOCKET}>,USE_SOCKET=1,USE_SOCKET=0>
|
||||||
$<IF:$<BOOL:${CC_USE_WEBSOCKET_SERVER}>,USE_WEBSOCKET_SERVER=1,USE_WEBSOCKET_SERVER=0>
|
$<IF:$<BOOL:${CC_USE_WEBSOCKET_SERVER}>,USE_WEBSOCKET_SERVER=1,USE_WEBSOCKET_SERVER=0>
|
||||||
|
@ -32,7 +32,7 @@ NS_CC_BEGIN
|
|||||||
|
|
||||||
CC_DLL const char* cocos2dVersion()
|
CC_DLL const char* cocos2dVersion()
|
||||||
{
|
{
|
||||||
return "2.4.12";
|
return "2.4.13";
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
@ -34,7 +34,7 @@ DRAGONBONES_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
class CacheModeAttachUtil;
|
class CacheModeAttachUtil;
|
||||||
|
|
||||||
class CCArmatureCacheDisplay : public cocos2d::middleware::IMiddleware, public cocos2d::Ref
|
class CCArmatureCacheDisplay : public cocos2d::Ref, public cocos2d::middleware::IMiddleware
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCArmatureCacheDisplay(const std::string& armatureName, const std::string& armatureKey, const std::string& atlasUUID, bool isShare);
|
CCArmatureCacheDisplay(const std::string& armatureName, const std::string& armatureKey, const std::string& atlasUUID, bool isShare);
|
||||||
|
@ -106,7 +106,7 @@ enum EmitterMode
|
|||||||
RADIUS = 1
|
RADIUS = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
class ParticleSimulator : public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
|
class ParticleSimulator : public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
|
||||||
|
|
||||||
//* @enum
|
//* @enum
|
||||||
enum {
|
enum {
|
||||||
|
@ -130,6 +130,10 @@ SkeletonAnimation::SkeletonAnimation ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonAnimation::~SkeletonAnimation () {
|
SkeletonAnimation::~SkeletonAnimation () {
|
||||||
|
SkeletonAnimation::destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkeletonAnimation::destroy() {
|
||||||
_startListener = nullptr;
|
_startListener = nullptr;
|
||||||
_interruptListener = nullptr;
|
_interruptListener = nullptr;
|
||||||
_endListener = nullptr;
|
_endListener = nullptr;
|
||||||
@ -139,9 +143,12 @@ SkeletonAnimation::~SkeletonAnimation () {
|
|||||||
|
|
||||||
if (_state) {
|
if (_state) {
|
||||||
clearTracks();
|
clearTracks();
|
||||||
if (_ownsAnimationStateData) delete _state->getData();
|
if (_ownsAnimationStateData) {
|
||||||
delete _state;
|
delete _state->getData();
|
||||||
}
|
}
|
||||||
|
CC_SAFE_DELETE(_state);
|
||||||
|
}
|
||||||
|
SkeletonRenderer::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::update (float deltaTime) {
|
void SkeletonAnimation::update (float deltaTime) {
|
||||||
|
@ -92,6 +92,7 @@ public:
|
|||||||
|
|
||||||
virtual void onAnimationStateEvent (TrackEntry* entry, EventType type, Event* event);
|
virtual void onAnimationStateEvent (TrackEntry* entry, EventType type, Event* event);
|
||||||
virtual void onTrackEntryEvent (TrackEntry* entry, EventType type, Event* event);
|
virtual void onTrackEntryEvent (TrackEntry* entry, EventType type, Event* event);
|
||||||
|
virtual void destroy();
|
||||||
|
|
||||||
AnimationState* getState() const;
|
AnimationState* getState() const;
|
||||||
|
|
||||||
|
@ -63,6 +63,11 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonCacheAnimation::~SkeletonCacheAnimation () {
|
SkeletonCacheAnimation::~SkeletonCacheAnimation () {
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkeletonCacheAnimation::destroy() {
|
||||||
|
stopSchedule();
|
||||||
if (_skeletonCache) {
|
if (_skeletonCache) {
|
||||||
_skeletonCache->release();
|
_skeletonCache->release();
|
||||||
_skeletonCache = nullptr;
|
_skeletonCache = nullptr;
|
||||||
@ -73,9 +78,8 @@ namespace spine {
|
|||||||
delete ani;
|
delete ani;
|
||||||
}
|
}
|
||||||
CC_SAFE_RELEASE_NULL(_attachUtil);
|
CC_SAFE_RELEASE_NULL(_attachUtil);
|
||||||
CC_SAFE_RELEASE(_nodeProxy);
|
CC_SAFE_RELEASE_NULL(_nodeProxy);
|
||||||
CC_SAFE_RELEASE(_effect);
|
CC_SAFE_RELEASE_NULL(_effect);
|
||||||
stopSchedule();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonCacheAnimation::update(float dt) {
|
void SkeletonCacheAnimation::update(float dt) {
|
||||||
|
@ -39,7 +39,7 @@ namespace spine {
|
|||||||
|
|
||||||
class CacheModeAttachUtil;
|
class CacheModeAttachUtil;
|
||||||
|
|
||||||
class SkeletonCacheAnimation : public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
|
class SkeletonCacheAnimation : public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
|
||||||
public:
|
public:
|
||||||
SkeletonCacheAnimation (const std::string& uuid, bool isShare);
|
SkeletonCacheAnimation (const std::string& uuid, bool isShare);
|
||||||
virtual ~SkeletonCacheAnimation ();
|
virtual ~SkeletonCacheAnimation ();
|
||||||
@ -98,6 +98,7 @@ namespace spine {
|
|||||||
void setToSetupPose ();
|
void setToSetupPose ();
|
||||||
void setBonesToSetupPose ();
|
void setBonesToSetupPose ();
|
||||||
void setSlotsToSetupPose ();
|
void setSlotsToSetupPose ();
|
||||||
|
void destroy();
|
||||||
private:
|
private:
|
||||||
float _timeScale = 1;
|
float _timeScale = 1;
|
||||||
bool _paused = false;
|
bool _paused = false;
|
||||||
|
@ -151,23 +151,37 @@ SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, const s
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::~SkeletonRenderer () {
|
SkeletonRenderer::~SkeletonRenderer () {
|
||||||
CC_SAFE_RELEASE(_effectDelegate);
|
SkeletonRenderer::destroy();
|
||||||
if (_ownsSkeletonData) delete _skeleton->getData();
|
|
||||||
if (_ownsSkeleton) delete _skeleton;
|
|
||||||
if (_ownsAtlas && _atlas) delete _atlas;
|
|
||||||
if (_attachmentLoader) delete _attachmentLoader;
|
|
||||||
if (_uuid != "") SkeletonDataMgr::getInstance()->releaseByUUID(_uuid);
|
|
||||||
if (_clipper) delete _clipper;
|
|
||||||
|
|
||||||
if (_debugBuffer) {
|
|
||||||
delete _debugBuffer;
|
|
||||||
_debugBuffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_SAFE_RELEASE(_attachUtil);
|
void SkeletonRenderer::destroy() {
|
||||||
CC_SAFE_RELEASE(_nodeProxy);
|
|
||||||
CC_SAFE_RELEASE(_effect);
|
|
||||||
stopSchedule();
|
stopSchedule();
|
||||||
|
CC_SAFE_RELEASE_NULL(_effectDelegate);
|
||||||
|
if (_ownsSkeletonData) {
|
||||||
|
if (_skeleton) {
|
||||||
|
delete _skeleton->getData();
|
||||||
|
}
|
||||||
|
_ownsSkeletonData = false;
|
||||||
|
}
|
||||||
|
if (_ownsSkeleton) {
|
||||||
|
CC_SAFE_DELETE(_skeleton);
|
||||||
|
}
|
||||||
|
if (_ownsAtlas && _atlas) {
|
||||||
|
CC_SAFE_DELETE(_atlas);
|
||||||
|
}
|
||||||
|
_skeleton = nullptr;
|
||||||
|
_atlas = nullptr;
|
||||||
|
CC_SAFE_DELETE(_attachmentLoader);
|
||||||
|
if (_uuid != "") {
|
||||||
|
SkeletonDataMgr::getInstance()->releaseByUUID(_uuid);
|
||||||
|
_uuid = "";
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(_clipper);
|
||||||
|
CC_SAFE_DELETE(_debugBuffer);
|
||||||
|
|
||||||
|
CC_SAFE_RELEASE_NULL(_attachUtil);
|
||||||
|
CC_SAFE_RELEASE_NULL(_nodeProxy);
|
||||||
|
CC_SAFE_RELEASE_NULL(_effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonRenderer::initWithUUID(const std::string& uuid) {
|
void SkeletonRenderer::initWithUUID(const std::string& uuid) {
|
||||||
|
@ -50,7 +50,7 @@ namespace spine {
|
|||||||
|
|
||||||
/** Draws a skeleton.
|
/** Draws a skeleton.
|
||||||
*/
|
*/
|
||||||
class SkeletonRenderer: public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
|
class SkeletonRenderer: public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
|
||||||
public:
|
public:
|
||||||
static SkeletonRenderer* create ();
|
static SkeletonRenderer* create ();
|
||||||
static SkeletonRenderer* createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
|
static SkeletonRenderer* createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
|
||||||
@ -126,6 +126,7 @@ namespace spine {
|
|||||||
virtual void stopSchedule();
|
virtual void stopSchedule();
|
||||||
void onEnable();
|
void onEnable();
|
||||||
void onDisable();
|
void onDisable();
|
||||||
|
virtual void destroy();
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
SkeletonRenderer ();
|
SkeletonRenderer ();
|
||||||
|
@ -273,19 +273,31 @@ void OpenHarmonyPlatform::onSurfaceChanged(OH_NativeXComponent* component, void*
|
|||||||
void OpenHarmonyPlatform::onSurfaceDestroyed(OH_NativeXComponent* component, void* window) {
|
void OpenHarmonyPlatform::onSurfaceDestroyed(OH_NativeXComponent* component, void* window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenHarmonyPlatform::setPreferedFramePersecond(int fps) {
|
||||||
|
if (fps == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_prefererredNanosecondsPerFrame = static_cast<long>(1.0 / fps * NANOSECONDS_PER_SECOND); // NOLINT(google-runtime-int)
|
||||||
|
}
|
||||||
|
|
||||||
void OpenHarmonyPlatform::tick() {
|
void OpenHarmonyPlatform::tick() {
|
||||||
static std::chrono::steady_clock::time_point prevTime;
|
static std::chrono::steady_clock::time_point prevTime;
|
||||||
static std::chrono::steady_clock::time_point now;
|
static std::chrono::steady_clock::time_point now;
|
||||||
static float dt = 0.f;
|
static float dt = 0.f;
|
||||||
static float dtSum = 0.f;
|
static double dtNS = NANOSECONDS_60FPS;
|
||||||
static uint32_t jsbInvocationTotalCount = 0;
|
if (dtNS < static_cast<double>(_prefererredNanosecondsPerFrame)) {
|
||||||
static uint32_t jsbInvocationTotalFrames = 0;
|
std::this_thread::sleep_for(std::chrono::nanoseconds(
|
||||||
|
_prefererredNanosecondsPerFrame - static_cast<int64_t>(dtNS)));
|
||||||
|
dtNS = static_cast<double>(_prefererredNanosecondsPerFrame);
|
||||||
|
}
|
||||||
|
prevTime = std::chrono::steady_clock::now();
|
||||||
std::shared_ptr<Scheduler> scheduler = g_app->getScheduler();
|
std::shared_ptr<Scheduler> scheduler = g_app->getScheduler();
|
||||||
scheduler->update(dt);
|
scheduler->update(dt);
|
||||||
EventDispatcher::dispatchTickEvent(dt);
|
EventDispatcher::dispatchTickEvent(dt);
|
||||||
PoolManager::getInstance()->getCurrentPool()->clear();
|
PoolManager::getInstance()->getCurrentPool()->clear();
|
||||||
now = std::chrono::steady_clock::now();
|
now = std::chrono::steady_clock::now();
|
||||||
dt = std::chrono::duration_cast<std::chrono::microseconds>(now - prevTime).count() / 1000000.f;
|
dtNS = dtNS * 0.1 + 0.9 * static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(now - prevTime).count());
|
||||||
prevTime = std::chrono::steady_clock::now();
|
dt = static_cast<float>(dtNS) / NANOSECONDS_PER_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace cc
|
}; // namespace cc
|
||||||
|
@ -78,7 +78,9 @@ public:
|
|||||||
static void onMessageCallback(const uv_async_t* req);
|
static void onMessageCallback(const uv_async_t* req);
|
||||||
static void timerCb(uv_timer_t* handle);
|
static void timerCb(uv_timer_t* handle);
|
||||||
void tick();
|
void tick();
|
||||||
|
void setPreferedFramePersecond(int fps);
|
||||||
|
|
||||||
|
int64_t _prefererredNanosecondsPerFrame{NANOSECONDS_60FPS};
|
||||||
OH_NativeXComponent* _component{nullptr};
|
OH_NativeXComponent* _component{nullptr};
|
||||||
OH_NativeXComponent_Callback _callback;
|
OH_NativeXComponent_Callback _callback;
|
||||||
uv_timer_t _timerHandle;
|
uv_timer_t _timerHandle;
|
||||||
|
@ -121,7 +121,8 @@ void Application::onResume()
|
|||||||
void Application::setPreferredFramesPerSecond(int fps)
|
void Application::setPreferredFramesPerSecond(int fps)
|
||||||
{
|
{
|
||||||
_fps = fps;
|
_fps = fps;
|
||||||
// setPreferredFramesPerSecondJNI(_fps);
|
cocos2d::OpenHarmonyPlatform* platform = cocos2d::OpenHarmonyPlatform::getInstance();
|
||||||
|
platform->setPreferedFramePersecond(_fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isDisplayStats() {
|
bool Application::isDisplayStats() {
|
||||||
|
@ -13203,6 +13203,21 @@ static bool js_cocos2dx_spine_SkeletonRenderer_paused(se::State& s)
|
|||||||
}
|
}
|
||||||
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused)
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused)
|
||||||
|
|
||||||
|
static bool js_cocos2dx_spine_SkeletonRenderer_destroy(se::State& s)
|
||||||
|
{
|
||||||
|
spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer*)s.nativeThisObject();
|
||||||
|
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonRenderer_destroy : Invalid Native Object");
|
||||||
|
const auto& args = s.args();
|
||||||
|
size_t argc = args.size();
|
||||||
|
if (argc == 0) {
|
||||||
|
cobj->destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonRenderer_destroy)
|
||||||
|
|
||||||
static bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(se::State& s)
|
static bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(se::State& s)
|
||||||
{
|
{
|
||||||
CC_UNUSED bool ok = true;
|
CC_UNUSED bool ok = true;
|
||||||
@ -14133,6 +14148,7 @@ bool js_register_cocos2dx_spine_SkeletonRenderer(se::Object* obj)
|
|||||||
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil));
|
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil));
|
||||||
cls->defineFunction("setOpacityModifyRGB", _SE(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB));
|
cls->defineFunction("setOpacityModifyRGB", _SE(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB));
|
||||||
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonRenderer_paused));
|
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonRenderer_paused));
|
||||||
|
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonRenderer_destroy));
|
||||||
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachment));
|
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachment));
|
||||||
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose));
|
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose));
|
||||||
cls->defineFunction("onEnable", _SE(js_cocos2dx_spine_SkeletonRenderer_onEnable));
|
cls->defineFunction("onEnable", _SE(js_cocos2dx_spine_SkeletonRenderer_onEnable));
|
||||||
@ -14600,6 +14616,21 @@ static bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(se::State& s)
|
|||||||
}
|
}
|
||||||
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener)
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener)
|
||||||
|
|
||||||
|
static bool js_cocos2dx_spine_SkeletonAnimation_destroy(se::State& s)
|
||||||
|
{
|
||||||
|
spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation*)s.nativeThisObject();
|
||||||
|
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonAnimation_destroy : Invalid Native Object");
|
||||||
|
const auto& args = s.args();
|
||||||
|
size_t argc = args.size();
|
||||||
|
if (argc == 0) {
|
||||||
|
cobj->destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonAnimation_destroy)
|
||||||
|
|
||||||
static bool js_cocos2dx_spine_SkeletonAnimation_getState(se::State& s)
|
static bool js_cocos2dx_spine_SkeletonAnimation_getState(se::State& s)
|
||||||
{
|
{
|
||||||
spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation*)s.nativeThisObject();
|
spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation*)s.nativeThisObject();
|
||||||
@ -15284,6 +15315,7 @@ bool js_register_cocos2dx_spine_SkeletonAnimation(se::Object* obj)
|
|||||||
cls->defineFunction("setTrackCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener));
|
cls->defineFunction("setTrackCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener));
|
||||||
cls->defineFunction("setAnimationStateData", _SE(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData));
|
cls->defineFunction("setAnimationStateData", _SE(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData));
|
||||||
cls->defineFunction("setEndListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setEndListener));
|
cls->defineFunction("setEndListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setEndListener));
|
||||||
|
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonAnimation_destroy));
|
||||||
cls->defineFunction("getState", _SE(js_cocos2dx_spine_SkeletonAnimation_getState));
|
cls->defineFunction("getState", _SE(js_cocos2dx_spine_SkeletonAnimation_getState));
|
||||||
cls->defineFunction("setCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener));
|
cls->defineFunction("setCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener));
|
||||||
cls->defineFunction("setTrackDisposeListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener));
|
cls->defineFunction("setTrackDisposeListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener));
|
||||||
@ -15652,6 +15684,21 @@ static bool js_cocos2dx_spine_SkeletonCacheAnimation_paused(se::State& s)
|
|||||||
}
|
}
|
||||||
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused)
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused)
|
||||||
|
|
||||||
|
static bool js_cocos2dx_spine_SkeletonCacheAnimation_destroy(se::State& s)
|
||||||
|
{
|
||||||
|
spine::SkeletonCacheAnimation* cobj = (spine::SkeletonCacheAnimation*)s.nativeThisObject();
|
||||||
|
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonCacheAnimation_destroy : Invalid Native Object");
|
||||||
|
const auto& args = s.args();
|
||||||
|
size_t argc = args.size();
|
||||||
|
if (argc == 0) {
|
||||||
|
cobj->destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_destroy)
|
||||||
|
|
||||||
static bool js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment(se::State& s)
|
static bool js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment(se::State& s)
|
||||||
{
|
{
|
||||||
CC_UNUSED bool ok = true;
|
CC_UNUSED bool ok = true;
|
||||||
@ -16334,6 +16381,7 @@ bool js_register_cocos2dx_spine_SkeletonCacheAnimation(se::Object* obj)
|
|||||||
cls->defineFunction("findAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation));
|
cls->defineFunction("findAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation));
|
||||||
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil));
|
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil));
|
||||||
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_paused));
|
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_paused));
|
||||||
|
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_destroy));
|
||||||
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment));
|
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment));
|
||||||
cls->defineFunction("setAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation));
|
cls->defineFunction("setAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation));
|
||||||
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose));
|
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose));
|
||||||
|
@ -923,6 +923,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_initWithUUID);
|
|||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused);
|
||||||
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_destroy);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachment);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachment);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_onEnable);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_onEnable);
|
||||||
@ -973,6 +974,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackInterruptListener);
|
|||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener);
|
||||||
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_destroy);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_getState);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_getState);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener);
|
||||||
@ -1022,6 +1024,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setTimeScale);
|
|||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused);
|
||||||
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_destroy);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation);
|
||||||
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose);
|
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose);
|
||||||
|
@ -509,10 +509,9 @@ void Object::setPrivateData(void* data){
|
|||||||
//issue https://github.com/nodejs/node/issues/23999
|
//issue https://github.com/nodejs/node/issues/23999
|
||||||
auto tmpThis = _objRef.getValue(_env);
|
auto tmpThis = _objRef.getValue(_env);
|
||||||
//_objRef.deleteRef();
|
//_objRef.deleteRef();
|
||||||
napi_ref result = nullptr;
|
|
||||||
NODE_API_CALL(status, _env,
|
NODE_API_CALL(status, _env,
|
||||||
napi_wrap(_env, tmpThis, data, weakCallback,
|
napi_wrap(_env, tmpThis, data, weakCallback,
|
||||||
(void*)this /* finalize_hint */, &result));
|
(void*)this /* finalize_hint */, nullptr));
|
||||||
//_objRef.setWeakref(_env, result);
|
//_objRef.setWeakref(_env, result);
|
||||||
setProperty("__native_ptr__", se::Value(static_cast<long>(reinterpret_cast<uintptr_t>(data))));
|
setProperty("__native_ptr__", se::Value(static_cast<long>(reinterpret_cast<uintptr_t>(data))));
|
||||||
}
|
}
|
||||||
|
@ -180,13 +180,13 @@ bool jsb_register_all_modules()
|
|||||||
se->addRegisterCallback(register_all_video);
|
se->addRegisterCallback(register_all_video);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_WEBVIEW
|
#if USE_WEB_VIEW
|
||||||
se->addRegisterCallback(register_all_webview);
|
se->addRegisterCallback(register_all_webview);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY)
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY)
|
||||||
|
|
||||||
#if USE_WEBVIEW
|
#if USE_WEB_VIEW
|
||||||
se->addRegisterCallback(register_all_webview);
|
se->addRegisterCallback(register_all_webview);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -379,6 +379,12 @@ void XMLHttpRequest::getHeader(const std::string& header)
|
|||||||
// Transform field name to lower case as they are case-insensitive
|
// Transform field name to lower case as they are case-insensitive
|
||||||
std::transform(http_field.begin(), http_field.end(), http_field.begin(), ::tolower);
|
std::transform(http_field.begin(), http_field.end(), http_field.begin(), ::tolower);
|
||||||
|
|
||||||
|
if (CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY && _httpHeader.find(http_field) != _httpHeader.end()) {
|
||||||
|
_httpHeader[http_field].insert(strlen(_httpHeader[http_field].c_str()) - 1, ",");
|
||||||
|
_httpHeader[http_field].insert(strlen(_httpHeader[http_field].c_str()) - 1, http_value);
|
||||||
|
http_value = _httpHeader[http_field];
|
||||||
|
}
|
||||||
|
|
||||||
_httpHeader[http_field] = http_value;
|
_httpHeader[http_field] = http_value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
cocos2d-x/external/config.json
vendored
4
cocos2d-x/external/config.json
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "v24-11",
|
"version": "v24-12",
|
||||||
"zip_file_size": "181264997",
|
"zip_file_size": "181682416",
|
||||||
"repo_name": "cocos-engine-external",
|
"repo_name": "cocos-engine-external",
|
||||||
"repo_parent": "https://github.com/cocos/"
|
"repo_parent": "https://github.com/cocos/"
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LWS_INSTALL_DATADIR "/home/cloud_dragon/lsy/lycium/usr/libwebsockets-arm64-v8a-install/share"
|
#define LWS_INSTALL_DATADIR "/Users/cocos/Github/cocos2d-x-3rd-party-libs-src/contrib/install-android/arm64/share"
|
||||||
|
|
||||||
/* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL.
|
/* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL.
|
||||||
* LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
|
* LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
|
||||||
@ -35,7 +35,7 @@
|
|||||||
#define LWS_LIBRARY_VERSION_NUMBER (LWS_LIBRARY_VERSION_MAJOR*1000000)+(LWS_LIBRARY_VERSION_MINOR*1000)+LWS_LIBRARY_VERSION_PATCH
|
#define LWS_LIBRARY_VERSION_NUMBER (LWS_LIBRARY_VERSION_MAJOR*1000000)+(LWS_LIBRARY_VERSION_MINOR*1000)+LWS_LIBRARY_VERSION_PATCH
|
||||||
|
|
||||||
/* The current git commit hash that we're building from */
|
/* The current git commit hash that we're building from */
|
||||||
/* #undef LWS_BUILD_HASH */
|
#define LWS_BUILD_HASH "cocos@cocoss-MacBook-Pro.local-v3.4-182-g408ba56"
|
||||||
|
|
||||||
/* Build with OpenSSL support */
|
/* Build with OpenSSL support */
|
||||||
#define LWS_OPENSSL_SUPPORT
|
#define LWS_OPENSSL_SUPPORT
|
||||||
@ -83,16 +83,16 @@
|
|||||||
/* #undef LWS_MINGW_SUPPORT */
|
/* #undef LWS_MINGW_SUPPORT */
|
||||||
|
|
||||||
/* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */
|
/* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */
|
||||||
/* #undef LWS_BUILTIN_GETIFADDRS */
|
#define LWS_BUILTIN_GETIFADDRS
|
||||||
|
|
||||||
/* use SHA1() not internal libwebsockets_SHA1 */
|
/* use SHA1() not internal libwebsockets_SHA1 */
|
||||||
/* #undef LWS_SHA1_USE_OPENSSL_NAME */
|
/* #undef LWS_SHA1_USE_OPENSSL_NAME */
|
||||||
|
|
||||||
/* SSL server using ECDH certificate */
|
/* SSL server using ECDH certificate */
|
||||||
/* #undef LWS_SSL_SERVER_WITH_ECDH_CERT */
|
/* #undef LWS_SSL_SERVER_WITH_ECDH_CERT */
|
||||||
#define LWS_HAVE_SSL_CTX_set1_param
|
/* #undef LWS_HAVE_SSL_CTX_set1_param */
|
||||||
#define LWS_HAVE_X509_VERIFY_PARAM_set1_host
|
/* #undef LWS_HAVE_X509_VERIFY_PARAM_set1_host */
|
||||||
#define LWS_HAVE_RSA_SET0_KEY
|
/* #undef LWS_HAVE_RSA_SET0_KEY */
|
||||||
|
|
||||||
/* #undef LWS_HAVE_UV_VERSION_H */
|
/* #undef LWS_HAVE_UV_VERSION_H */
|
||||||
|
|
||||||
@ -147,9 +147,9 @@
|
|||||||
|
|
||||||
/* OpenSSL various APIs */
|
/* OpenSSL various APIs */
|
||||||
|
|
||||||
#define LWS_HAVE_TLS_CLIENT_METHOD
|
/* #undef LWS_HAVE_TLS_CLIENT_METHOD */
|
||||||
#define LWS_HAVE_TLSV1_2_CLIENT_METHOD
|
/* #undef LWS_HAVE_TLSV1_2_CLIENT_METHOD */
|
||||||
#define LWS_HAVE_SSL_SET_INFO_CALLBACK
|
/* #undef LWS_HAVE_SSL_SET_INFO_CALLBACK */
|
||||||
|
|
||||||
#define LWS_HAS_INTPTR_T
|
#define LWS_HAS_INTPTR_T
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cocos2d-x-lite",
|
"name": "cocos2d-x-lite",
|
||||||
"version": "2.4.12",
|
"version": "2.4.13",
|
||||||
"description": "Cocos2d-x, compact version",
|
"description": "Cocos2d-x, compact version",
|
||||||
"main": "gulpfile.js",
|
"main": "gulpfile.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import { ContextType } from '../../../ets/common/Constants';
|
||||||
|
|
||||||
|
interface context {
|
||||||
|
onPageShow: () => void;
|
||||||
|
onPageHide: () => void;
|
||||||
|
workerInit: () => void;
|
||||||
|
postMessage: (msgType: string, msgData: string) => void;
|
||||||
|
postSyncMessage: (msgType: string, msgData: string) => Promise<boolean | string | number>;
|
||||||
|
setPostMessageFunction: (postMessage: (msgType: string, msgData: string) => void) => void;
|
||||||
|
setPostSyncMessageFunction: (postSyncMessage: (msgType: string, msgData: string) => void) => void;
|
||||||
|
nativeEngineInit: () => void;
|
||||||
|
nativeEngineStart: () => void;
|
||||||
|
onTextChange: (param: string) => void;
|
||||||
|
onComplete: (param: string) => void;
|
||||||
|
shouldStartLoading: (viewTag: number, url: string) => void;
|
||||||
|
finishLoading: (viewTag: number, url: string) => void;
|
||||||
|
failLoading: (viewTag: number, url: string) => void;
|
||||||
|
onBackPress: () => void;
|
||||||
|
onCreate: () => void;
|
||||||
|
onDestroy: () => void;
|
||||||
|
onShow: () => void;
|
||||||
|
onHide: () => void;
|
||||||
|
resourceManagerInit: (resourceManager: any) => void;
|
||||||
|
writablePathInit: (cacheDir: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getContext: (type: ContextType) => context;
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "libcocos.so",
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"version": "",
|
||||||
|
"description": "Please describe the basic information."
|
||||||
|
}
|
@ -27,27 +27,30 @@ import worker from '@ohos.worker';
|
|||||||
import { Constants } from '../common/Constants'
|
import { Constants } from '../common/Constants'
|
||||||
|
|
||||||
export class WorkerManager {
|
export class WorkerManager {
|
||||||
private static instance: WorkerManager;
|
private cocosWorker: worker.Worker;
|
||||||
private cocosWorker: any;
|
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.cocosWorker = new worker.Worker("entry/ets/workers/cocos_worker.ts", {type:"classic", name: "CocosWorker"});
|
this.cocosWorker = new worker.Worker("entry/ets/workers/cocos_worker.ts", {
|
||||||
this.cocosWorker.onerror = function (e) {
|
type: "classic",
|
||||||
var msg = e.message;
|
name: "CocosWorker"
|
||||||
var filename = e.filename;
|
});
|
||||||
var lineno = e.lineno;
|
this.cocosWorker.onerror = (e) => {
|
||||||
var colno = e.colno;
|
let msg = e.message;
|
||||||
|
let filename = e.filename;
|
||||||
|
let lineno = e.lineno;
|
||||||
|
let colno = e.colno;
|
||||||
console.error(`on Error ${msg} ${filename} ${lineno} ${colno}`);
|
console.error(`on Error ${msg} ${filename} ${lineno} ${colno}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInstance(): WorkerManager {
|
public static getInstance(): WorkerManager {
|
||||||
if (AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) == null) {
|
if (AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager == undefined) {
|
||||||
AppStorage.SetOrCreate(Constants.APP_KEY_WORKER_MANAGER, new WorkerManager);
|
AppStorage.SetOrCreate(Constants.APP_KEY_WORKER_MANAGER, new WorkerManager);
|
||||||
}
|
}
|
||||||
return AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER);
|
return AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager;
|
||||||
}
|
}
|
||||||
public getWorker(): any {
|
|
||||||
|
public getWorker(): worker.Worker {
|
||||||
return this.cocosWorker;
|
return this.cocosWorker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
globalThis.oh = {};
|
globalThis.oh = {} as any;
|
||||||
|
|
||||||
function boot() {
|
function boot() {
|
||||||
const cc = globalThis.cc;
|
const cc = globalThis.cc;
|
||||||
var settings = globalThis._CCSettings;
|
var settings = globalThis._CCSettings;
|
||||||
|
@ -22,10 +22,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import worker from '@ohos.worker';
|
|
||||||
import { DedicatedWorkerGlobalScope } from '@ohos.worker';
|
import { DedicatedWorkerGlobalScope } from '@ohos.worker';
|
||||||
// NOTE: don't use this import all statement, because this has compile issue.
|
|
||||||
// import * as wk from '@ohos.worker';
|
|
||||||
import { MessageEvent } from '@ohos.worker';
|
import { MessageEvent } from '@ohos.worker';
|
||||||
|
|
||||||
export class PortProxy {
|
export class PortProxy {
|
||||||
@ -35,8 +32,8 @@ export class PortProxy {
|
|||||||
|
|
||||||
public _messageHandle?: (e: MessageEvent<any>) => void;
|
public _messageHandle?: (e: MessageEvent<any>) => void;
|
||||||
|
|
||||||
constructor (port) {
|
constructor(worker) {
|
||||||
this.port = port;
|
this.port = worker;
|
||||||
this.port.onmessage = this.onMessage.bind(this);
|
this.port.onmessage = this.onMessage.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,15 +46,17 @@ export class PortProxy {
|
|||||||
if (!this.actionHandleMap[id]) {
|
if (!this.actionHandleMap[id]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.actionHandleMap[id].call(this, response)
|
this.actionHandleMap[id].call(this, response);
|
||||||
delete this.actionHandleMap[id];
|
delete this.actionHandleMap[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public postReturnMessage(e: any, res: any) {
|
public postReturnMessage(e: any, res: any) {
|
||||||
if (e.type == "sync" && res != null && res != undefined) {
|
if (e.type == "sync" && res != null && res != undefined) {
|
||||||
this.port.postMessage({ type: "syncResult", data: { id: e.data.cbId, response: res } });
|
this.port.postMessage({ type: "syncResult", data: { id: e.data.cbId, response: res } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public postMessage(msgName: string, msgData: any) {
|
public postMessage(msgName: string, msgData: any) {
|
||||||
this.port.postMessage({ type: "async", data: { name: msgName, param: msgData } });
|
this.port.postMessage({ type: "async", data: { name: msgName, param: msgData } });
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { PortProxy } from '../common/PortProxy';
|
||||||
import { PortProxy } from '../common/PortProxy'
|
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
PLAYING = 0,
|
PLAYING = 0,
|
||||||
@ -35,7 +34,13 @@ enum EventType {
|
|||||||
READY_TO_PLAY,
|
READY_TO_PLAY,
|
||||||
UPDATE,
|
UPDATE,
|
||||||
QUIT_FULLSCREEN = 1000
|
QUIT_FULLSCREEN = 1000
|
||||||
};
|
}
|
||||||
|
|
||||||
|
interface param {
|
||||||
|
videoTag?: number,
|
||||||
|
videoEvent?: EventType,
|
||||||
|
args?: number
|
||||||
|
}
|
||||||
|
|
||||||
@Observed
|
@Observed
|
||||||
export class VideoInfo {
|
export class VideoInfo {
|
||||||
@ -44,24 +49,21 @@ export class VideoInfo {
|
|||||||
public w: number = 0;
|
public w: number = 0;
|
||||||
public h: number = 0;
|
public h: number = 0;
|
||||||
// url
|
// url
|
||||||
public url: string | Resource = ""
|
public url: string | Resource = "";
|
||||||
public viewTag: string = ''
|
public viewTag: number = 0;
|
||||||
public visible: boolean = true
|
public visible: boolean = true;
|
||||||
|
|
||||||
public duration: number = 0;
|
public duration: number = 0;
|
||||||
public currentTime: number = 0;
|
public currentTime: number = 0;
|
||||||
public isFullScreen: boolean = false;
|
public isFullScreen: boolean = false;
|
||||||
public currentProgressRate:number | string | PlaybackSpeed;
|
public currentProgressRate?: number | string | PlaybackSpeed;
|
||||||
|
|
||||||
public resourceType: number = 0;
|
public resourceType: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md#videocontroller
|
* https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md#videocontroller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public controller: VideoController = new VideoController()
|
public controller: VideoController = new VideoController()
|
||||||
|
|
||||||
constructor(x: number, y: number, w: number, h: number, viewTag: string) {
|
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.w = w;
|
this.w = w;
|
||||||
@ -70,49 +72,70 @@ export class VideoInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export struct CocosVideoPlayer {
|
export struct CocosVideoPlayer {
|
||||||
@ObjectLink videoInfo: VideoInfo;
|
@ObjectLink videoInfo: VideoInfo;
|
||||||
public workPort: PortProxy;
|
public workPort: PortProxy | null = null;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Video({ src: this.videoInfo.url, controller: this.videoInfo.controller, currentProgressRate:this.videoInfo.currentProgressRate })
|
Video({
|
||||||
|
src: this.videoInfo.url,
|
||||||
|
controller: this.videoInfo.controller,
|
||||||
|
currentProgressRate: this.videoInfo.currentProgressRate as number | string | PlaybackSpeed
|
||||||
|
})
|
||||||
.position({ x: this.videoInfo.x, y: this.videoInfo.y })
|
.position({ x: this.videoInfo.x, y: this.videoInfo.y })
|
||||||
.width(this.videoInfo.w)
|
.width(this.videoInfo.w)
|
||||||
.height(this.videoInfo.h)
|
.height(this.videoInfo.h)
|
||||||
.controls(false)
|
.controls(false)
|
||||||
.autoPlay(false)
|
.autoPlay(false)
|
||||||
.onStart(() => {
|
.onStart(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.PLAYING});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag as number,
|
||||||
|
videoEvent: EventType.PLAYING as EventType
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPause(() => {
|
.onPause(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.PAUSED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag as number,
|
||||||
|
videoEvent: EventType.PAUSED as EventType
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onFinish(() => {
|
.onFinish(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.COMPLETED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag,
|
||||||
|
videoEvent: EventType.COMPLETED
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPrepared((event: {
|
.onPrepared((event): void => {
|
||||||
duration: number;
|
this.videoInfo.duration = event?.duration as number;
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
this.videoInfo.duration = event.duration;
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.READY_TO_PLAY, args:event.duration});
|
videoEvent: EventType.READY_TO_PLAY,
|
||||||
|
args: event?.duration
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onClick((event: ClickEvent) => {
|
.onClick((event): void => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.CLICKED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag,
|
||||||
|
videoEvent: EventType.CLICKED
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onUpdate((event?: {
|
.onUpdate((event) => {
|
||||||
time: number;
|
this.videoInfo.currentTime = event?.time as number;
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
this.videoInfo.currentTime = event.time
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.UPDATE, args:event.time});
|
videoEvent: EventType.UPDATE,
|
||||||
|
args: event?.time
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onFullscreenChange((event?: {
|
.onFullscreenChange((event) => {
|
||||||
fullscreen: boolean;
|
if (!event?.fullscreen) {
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
if (!event.fullscreen) {
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.QUIT_FULLSCREEN});
|
videoEvent: EventType.QUIT_FULLSCREEN
|
||||||
|
} as param);
|
||||||
}
|
}
|
||||||
this.videoInfo.isFullScreen = event.fullscreen
|
this.videoInfo.isFullScreen = event?.fullscreen as boolean;
|
||||||
})
|
})
|
||||||
.visibility(this.videoInfo.visible ? Visibility.Visible : Visibility.None)
|
.visibility(this.videoInfo.visible ? Visibility.Visible : Visibility.None)
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,14 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { PortProxy } from '../common/PortProxy';
|
||||||
import { PortProxy } from '../common/PortProxy'
|
import web from '@ohos.web.webview';
|
||||||
import web from '@ohos.web.webview'
|
|
||||||
|
interface param {
|
||||||
|
viewTag: number,
|
||||||
|
url: string,
|
||||||
|
}
|
||||||
|
|
||||||
@Observed
|
@Observed
|
||||||
export class WebViewInfo {
|
export class WebViewInfo {
|
||||||
// position
|
// position
|
||||||
@ -34,18 +39,17 @@ export class WebViewInfo {
|
|||||||
public w: number = 0;
|
public w: number = 0;
|
||||||
public h: number = 0;
|
public h: number = 0;
|
||||||
// url
|
// url
|
||||||
public url: string = ''
|
public url: string = '';
|
||||||
// tag
|
// tag
|
||||||
public viewTag: string = ''
|
public viewTag: number = 0;
|
||||||
// Whether to display
|
// Whether to display
|
||||||
public visible: boolean = true
|
public visible: boolean = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* doc : https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md#webcontroller
|
* doc : https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md#webcontroller
|
||||||
*/
|
*/
|
||||||
public controller: WebController = new WebController()
|
public controller: web.WebviewController = new web.WebviewController();
|
||||||
|
|
||||||
constructor(x: number, y: number, w: number, h: number, viewTag: string) {
|
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.w = w;
|
this.w = w;
|
||||||
@ -54,7 +58,7 @@ export class WebViewInfo {
|
|||||||
|
|
||||||
web.once("webInited", () => {
|
web.once("webInited", () => {
|
||||||
if (this.url != '') {
|
if (this.url != '') {
|
||||||
this.controller.loadUrl({url: this.url});
|
this.controller.loadUrl(this.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,33 +67,33 @@ export class WebViewInfo {
|
|||||||
@Component
|
@Component
|
||||||
export struct CocosWebView {
|
export struct CocosWebView {
|
||||||
@ObjectLink viewInfo: WebViewInfo;
|
@ObjectLink viewInfo: WebViewInfo;
|
||||||
public workPort: PortProxy;
|
public workPort: PortProxy | null = null;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Web({ src: "", controller: this.viewInfo.controller })
|
Web({ src: this.viewInfo.url, controller: this.viewInfo.controller })
|
||||||
.position({ x: this.viewInfo.x, y: this.viewInfo.y })
|
.position({ x: this.viewInfo.x, y: this.viewInfo.y })
|
||||||
.width(this.viewInfo.w)
|
.width(this.viewInfo.w)
|
||||||
.height(this.viewInfo.h)
|
.height(this.viewInfo.h)
|
||||||
.border({ width: 1 })
|
.border({ width: 1 })
|
||||||
.onPageBegin((event) => {
|
.onPageBegin((event) => {
|
||||||
this.workPort.postMessage("onPageBegin", {viewTag:this.viewInfo.viewTag, url:event.url});
|
this.workPort?.postMessage("onPageBegin", {
|
||||||
|
viewTag: this.viewInfo.viewTag as number,
|
||||||
|
url: event?.url as string
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPageEnd((event) => {
|
.onPageEnd((event) => {
|
||||||
this.workPort.postMessage("onPageEnd", {viewTag:this.viewInfo.viewTag, url:event.url})
|
this.workPort?.postMessage("onPageEnd", { viewTag: this.viewInfo.viewTag as number, url: event?.url as string } as param)
|
||||||
})
|
})
|
||||||
.onErrorReceive((event) => {
|
.onErrorReceive((event) => {
|
||||||
this.workPort.postMessage("onErrorReceive", {viewTag:this.viewInfo.viewTag, url:this.viewInfo.url})
|
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||||
})
|
})
|
||||||
.onHttpErrorReceive((event) => {
|
.onHttpErrorReceive((event) => {
|
||||||
this.workPort.postMessage("onErrorReceive", {viewTag:this.viewInfo.viewTag, url:this.viewInfo.url})
|
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||||
})
|
})
|
||||||
// 开启DOM存储权限
|
.domStorageAccess(true)// enable DOM storage permissions
|
||||||
.domStorageAccess(true)
|
.databaseAccess(true)// enable database storage permissions
|
||||||
// 开启数据库存储权限
|
.imageAccess(true)// enable image loading permissions
|
||||||
.databaseAccess(true)
|
.javaScriptAccess(true)// support JS code running
|
||||||
// 图片加载相关权限
|
|
||||||
.imageAccess(true)
|
|
||||||
// 支持JS代码运行
|
|
||||||
.javaScriptAccess(true)
|
|
||||||
.visibility(this.viewInfo.visible ? Visibility.Visible : Visibility.None)
|
.visibility(this.viewInfo.visible ? Visibility.Visible : Visibility.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,11 +26,11 @@
|
|||||||
export struct EditBoxDialog {
|
export struct EditBoxDialog {
|
||||||
private showMessage: string = ''
|
private showMessage: string = ''
|
||||||
private inputMessage: string = ''
|
private inputMessage: string = ''
|
||||||
onTextChange: (msg: string) => void
|
onTextChange?: (msg: string) => void;
|
||||||
accept: (msg: string) => void
|
accept?: (msg: string) => void;
|
||||||
controller: CustomDialogController
|
controller?: CustomDialogController;
|
||||||
cancel: () => void
|
cancel?: () => void;
|
||||||
confirm: () => void
|
confirm?: () => void;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
@ -48,14 +48,14 @@ export struct EditBoxDialog {
|
|||||||
if (this.accept) {
|
if (this.accept) {
|
||||||
this.accept(this.inputMessage);
|
this.accept(this.inputMessage);
|
||||||
}
|
}
|
||||||
this.controller.close();
|
this.controller?.close();
|
||||||
})
|
})
|
||||||
Blank(8).width(16)
|
Blank(8).width(16)
|
||||||
Button('完成').onClick(() => {
|
Button('完成').onClick(() => {
|
||||||
if (this.accept) {
|
if (this.accept) {
|
||||||
this.accept(this.inputMessage);
|
this.accept(this.inputMessage);
|
||||||
}
|
}
|
||||||
this.controller.close();
|
this.controller?.close();
|
||||||
})
|
})
|
||||||
}.padding({ left: 8, right: 8, top: 8, bottom: 8 })
|
}.padding({ left: 8, right: 8, top: 8, bottom: 8 })
|
||||||
.backgroundColor(Color.Gray)
|
.backgroundColor(Color.Gray)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||||
import cocos from "libcocos.so";
|
import cocos from 'libcocos.so';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import window from '@ohos.window';
|
import window from '@ohos.window';
|
||||||
|
|
||||||
const nativeContext = cocos.getContext(ContextType.ENGINE_UTILS);
|
const nativeContext = cocos.getContext(ContextType.ENGINE_UTILS);
|
||||||
|
@ -22,44 +22,71 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import nativerender from "libcocos.so";
|
import nativerender from 'libcocos.so';
|
||||||
|
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { WorkerManager } from '../cocos/WorkerManager';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import featureAbility from '@ohos.ability.featureAbility'
|
import { EditBoxDialog } from '../components/EditBoxDialog';
|
||||||
import { EditBoxDialog } from '../components/EditBoxDialog'
|
import { CocosWebView, WebViewInfo } from '../components/CocosWebView';
|
||||||
import { WebViewInfo, CocosWebView } from '../components/CocosWebView'
|
import { CocosVideoPlayer, VideoInfo } from '../components/CocosVideoPlayer';
|
||||||
import { VideoInfo, CocosVideoPlayer } from '../components/CocosVideoPlayer'
|
import { MessageEvent } from '@ohos.worker';
|
||||||
|
import { PortProxy } from '../common/PortProxy';
|
||||||
|
|
||||||
import {PortProxy} from '../common/PortProxy'
|
|
||||||
const nativePageLifecycle = nativerender.getContext(ContextType.JSPAGE_LIFECYCLE);
|
const nativePageLifecycle = nativerender.getContext(ContextType.JSPAGE_LIFECYCLE);
|
||||||
const engineUtils = nativerender.getContext(ContextType.ENGINE_UTILS);
|
const engineUtils = nativerender.getContext(ContextType.ENGINE_UTILS);
|
||||||
|
|
||||||
|
interface WorkerMessage {
|
||||||
|
type: string;
|
||||||
|
data: data;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface data {
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
param: number | string | param
|
||||||
|
}
|
||||||
|
|
||||||
|
interface param {
|
||||||
|
tag?: number,
|
||||||
|
url?: string,
|
||||||
|
contents?: string,
|
||||||
|
mimeType?: string,
|
||||||
|
encoding?: string,
|
||||||
|
baseUrl?: string,
|
||||||
|
jsContents?: string,
|
||||||
|
x?: number,
|
||||||
|
y?: number,
|
||||||
|
w?: number,
|
||||||
|
h?: number,
|
||||||
|
visible?: boolean,
|
||||||
|
resourceType?: number,
|
||||||
|
time?: number,
|
||||||
|
fullScreen?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct Index {
|
struct Index {
|
||||||
@State showMessage: string = ''
|
@State showMessage: string = ''
|
||||||
@State webViewArray: WebViewInfo[] = [];
|
@State webViewArray: WebViewInfo[] = [];
|
||||||
@State videoArray: VideoInfo[] = [];
|
@State videoArray: VideoInfo[] = [];
|
||||||
//private index: number = 0;
|
private webViewIndexMap: Map<number, number> = new Map<number, number>();
|
||||||
private webViewIndexMap: Map<number, number> = new Map;
|
private videoIndexMap: Map<number, number> = new Map<number, number>();
|
||||||
private videoIndexMap: Map<number, number> = new Map;
|
|
||||||
|
|
||||||
private workPort: PortProxy = new PortProxy(WorkerManager.getInstance().getWorker());
|
private workPort: PortProxy = new PortProxy(WorkerManager.getInstance().getWorker());
|
||||||
dialogController: CustomDialogController = new CustomDialogController({
|
dialogController: CustomDialogController = new CustomDialogController({
|
||||||
builder: EditBoxDialog({
|
builder: EditBoxDialog({
|
||||||
showMessage: this.showMessage,
|
showMessage: this.showMessage,
|
||||||
onTextChange: (msg: string) => {
|
onTextChange: (msg: string): void => {
|
||||||
this.showMessage = msg;
|
this.showMessage = msg;
|
||||||
this.workPort.postMessage('onTextInput', msg)
|
this.workPort.postMessage('onTextInput', msg);
|
||||||
},
|
},
|
||||||
accept: (msg: string) => {
|
accept: (msg: string): void => {
|
||||||
this.showMessage = msg;
|
this.showMessage = msg;
|
||||||
this.workPort.postMessage('onComplete', msg)
|
this.workPort.postMessage('onComplete', msg);
|
||||||
},
|
}
|
||||||
}),
|
}),
|
||||||
cancel: () => {
|
cancel: (): void => {
|
||||||
this.workPort.postMessage('onComplete', this.showMessage)
|
this.workPort.postMessage('onComplete', this.showMessage);
|
||||||
},
|
},
|
||||||
autoCancel: true,
|
autoCancel: true,
|
||||||
alignment: DialogAlignment.Bottom,
|
alignment: DialogAlignment.Bottom,
|
||||||
@ -68,180 +95,190 @@ struct Index {
|
|||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
console.log('[LIFECYCLE-Index] cocos aboutToAppear');
|
console.log('[LIFECYCLE-Index] cocos aboutToAppear');
|
||||||
this.workPort._messageHandle = (e) => {
|
this.workPort._messageHandle = async (e: MessageEvent<WorkerMessage>): Promise<void> => {
|
||||||
//let data = e['data'];
|
let data: WorkerMessage = e.data;
|
||||||
var data = e.data;
|
let msg = data.data;
|
||||||
var msg = data.data;
|
let result: boolean | string | number | null = null;
|
||||||
var result;
|
|
||||||
switch (msg.name) {
|
switch (msg.name) {
|
||||||
// EditBox
|
// EditBox
|
||||||
case "showEditBox": {
|
case "showEditBox": {
|
||||||
this.showMessage = msg.param
|
this.showMessage = msg.param as string;
|
||||||
this.dialogController.open()
|
this.dialogController.open();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "hideEditBox": {
|
case "hideEditBox": {
|
||||||
this.showMessage = ''
|
this.showMessage = '';
|
||||||
this.dialogController.close()
|
this.dialogController.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// WebView
|
// WebView
|
||||||
case "createWebView": {
|
case "createWebView": {
|
||||||
this.webViewArray.push(new WebViewInfo(0, 0, 0, 0, msg.param))
|
this.webViewArray.push(new WebViewInfo(0, 0, 0, 0, msg.param as number));
|
||||||
this.webViewIndexMap.set(msg.param, this.webViewArray.length - 1);
|
this.webViewIndexMap.set(msg.param as number, this.webViewArray.length - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "removeWebView": {
|
case "removeWebView": {
|
||||||
if (this.webViewArray.length > 0) {
|
if (this.webViewArray.length > 0) {
|
||||||
this.webViewArray.splice(this.webViewIndexMap.get(msg.param), 1)
|
this.webViewArray.splice(this.webViewIndexMap.get(msg?.param as number) as number, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadUrl": {
|
case "loadUrl": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].url = web.url;
|
this.webViewArray[index].url = web?.url as string;
|
||||||
this.webViewArray[index].controller.loadUrl({url: web.url});
|
this.webViewArray[index].controller.loadUrl(web?.url as string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadHTMLString": {
|
case "loadHTMLString": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.loadData({data: web.contents, mimeType:"text/html",encoding:"UTF-8", baseUrl:web.baseUrl});
|
this.webViewArray[index].controller.loadData(
|
||||||
|
web?.contents as string,
|
||||||
|
"text/html",
|
||||||
|
"UTF-8",
|
||||||
|
web?.baseUrl
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadData": {
|
case "loadData": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.loadData({data: web.contents, mimeType:web.mimeType,encoding:web.encoding, baseUrl:web.baseUrl});
|
this.webViewArray[index].controller.loadData(
|
||||||
|
web?.contents as string,
|
||||||
|
web?.mimeType as string,
|
||||||
|
web?.encoding as string,
|
||||||
|
web?.baseUrl as string
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "evaluateJS": {
|
case "evaluateJS": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag)
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.runJavaScript({
|
this.webViewArray[index].controller.runJavaScript(web?.jsContents as string);
|
||||||
script: web.jsContents
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reload": {
|
case "reload": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.refresh();
|
this.webViewArray[index].controller.refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "stopLoading": {
|
case "stopLoading": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.stop();
|
this.webViewArray[index].controller.stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "canGoForward": {
|
case "canGoForward": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
result = this.webViewArray[index].controller.accessForward();
|
result = this.webViewArray[index].controller.accessForward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "canGoBack": {
|
case "canGoBack": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
result = this.webViewArray[index].controller.accessBackward();
|
result = this.webViewArray[index].controller.accessBackward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "goForward": {
|
case "goForward": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.forward();
|
this.webViewArray[index].controller.forward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "goBack": {
|
case "goBack": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.backward();
|
this.webViewArray[index].controller.backward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setWebViewRect": {
|
case "setWebViewRect": {
|
||||||
var web = msg.param;
|
let web = msg.param as param
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].x = px2vp(web.x);
|
this.webViewArray[index].x = px2vp(web?.x as number) as number;
|
||||||
this.webViewArray[index].y = px2vp(web.y);
|
this.webViewArray[index].y = px2vp(web?.y as number) as number;
|
||||||
this.webViewArray[index].w = px2vp(web.w);
|
this.webViewArray[index].w = px2vp(web?.w as number) as number;
|
||||||
this.webViewArray[index].h = px2vp(web.h);
|
this.webViewArray[index].h = px2vp(web?.h as number) as number;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setVisible":
|
case "setVisible": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].visible = web.visible;
|
this.webViewArray[index].visible = web?.visible as boolean;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
// video
|
// video
|
||||||
case "createVideo":
|
case "createVideo": {
|
||||||
this.videoArray.push(new VideoInfo(0, 0, 0, 0, msg.param))
|
this.videoArray.push(new VideoInfo(0, 0, 0, 0, msg.param as number));
|
||||||
this.videoIndexMap.set(msg.param, this.videoArray.length - 1);
|
this.videoIndexMap.set(msg.param as number, this.videoArray.length - 1);
|
||||||
break;
|
break;
|
||||||
case "removeVideo":
|
}
|
||||||
|
case "removeVideo": {
|
||||||
if (this.videoArray.length > 0) {
|
if (this.videoArray.length > 0) {
|
||||||
this.videoArray.splice(this.videoIndexMap.get(msg.param), 1)
|
this.videoArray.splice(this.videoIndexMap.get(msg.param as number) as number, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "setVideoUrl":
|
case "setVideoUrl":
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
var resourceType = video.resourceType;
|
let resourceType = video.resourceType;
|
||||||
if (resourceType == 1) {
|
if (resourceType == 1) {
|
||||||
this.videoArray[index].url = $rawfile(video.url);
|
this.videoArray[index].url = $rawfile(video.url as string);
|
||||||
} else {
|
} else {
|
||||||
this.videoArray[index].url = video.url;
|
this.videoArray[index].url = video.url as string;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setVideoRect": {
|
case "setVideoRect": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].x = px2vp(video.x);
|
this.videoArray[index].x = px2vp(video?.x as number) as number;
|
||||||
this.videoArray[index].y = px2vp(video.y);
|
this.videoArray[index].y = px2vp(video?.y as number) as number;
|
||||||
this.videoArray[index].w = px2vp(video.w);
|
this.videoArray[index].w = px2vp(video?.w as number) as number;
|
||||||
this.videoArray[index].h = px2vp(video.h);
|
this.videoArray[index].h = px2vp(video?.h as number) as number;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startVideo": {
|
case "startVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.start();
|
this.videoArray[index].controller.start();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "pauseVideo": {
|
case "pauseVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.pause();
|
this.videoArray[index].controller.pause();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "stopVideo": {
|
case "stopVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.stop();
|
this.videoArray[index].controller.stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "resumeVideo": {
|
case "resumeVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.start();
|
this.videoArray[index].controller.start();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "getVideoDuration": {
|
case "getVideoDuration": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
result = this.videoArray[index].duration;
|
result = this.videoArray[index].duration;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "seekVideoTo": {
|
case "seekVideoTo": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].controller.setCurrentTime(video.time, SeekMode.Accurate);
|
this.videoArray[index].controller.setCurrentTime(video?.time as number, SeekMode.Accurate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setVideoVisible": {
|
case "setVideoVisible": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].visible = video.visible;
|
this.videoArray[index].visible = video.visible as boolean;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setFullScreenEnabled": {
|
case "setFullScreenEnabled": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].isFullScreen = video.fullScreen;
|
this.videoArray[index].isFullScreen = video.fullScreen as boolean;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "currentTime": {
|
case "currentTime": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
result = this.videoArray[index].currentTime;
|
result = this.videoArray[index].currentTime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -279,7 +316,11 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({
|
||||||
|
direction: FlexDirection.Column,
|
||||||
|
alignItems: ItemAlign.Center,
|
||||||
|
justifyContent: FlexAlign.Center
|
||||||
|
} as FlexOptions) {
|
||||||
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'cocos' })
|
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'cocos' })
|
||||||
.onLoad((context) => {
|
.onLoad((context) => {
|
||||||
// Set the cache directory in the ts layer.
|
// Set the cache directory in the ts layer.
|
||||||
@ -289,13 +330,13 @@ struct Index {
|
|||||||
console.log('cocos onDestroy')
|
console.log('cocos onDestroy')
|
||||||
})
|
})
|
||||||
|
|
||||||
ForEach(this.webViewArray, (item: WebViewInfo, index: number) => {
|
ForEach(this.webViewArray, (item: WebViewInfo) => {
|
||||||
CocosWebView({ viewInfo: item, workPort: this.workPort })
|
CocosWebView({ viewInfo: item, workPort: this.workPort })
|
||||||
}, item => item.viewTag)
|
}, (item: WebViewInfo): string => item.viewTag.toString())
|
||||||
|
|
||||||
ForEach(this.videoArray, (item: VideoInfo, index: number) => {
|
ForEach(this.videoArray, (item: VideoInfo) => {
|
||||||
CocosVideoPlayer({ videoInfo: item, workPort: this.workPort })
|
CocosVideoPlayer({ videoInfo: item, workPort: this.workPort })
|
||||||
}, item => item.viewTag)
|
}, (item: VideoInfo): string => item.viewTag.toString())
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
|
@ -23,15 +23,14 @@ import hilog from '@ohos.hilog';
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import worker from '@ohos.worker';
|
import worker from '@ohos.worker';
|
||||||
import cocos from "libcocos.so";
|
import cocos from 'libcocos.so';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import { launchEngine } from '../cocos/game'
|
import { launchEngine } from '../cocos/game';
|
||||||
import { PortProxy } from '../common/PortProxy';
|
import { PortProxy } from '../common/PortProxy';
|
||||||
|
|
||||||
const nativeContext = cocos.getContext(ContextType.WORKER_INIT);
|
const nativeContext = cocos.getContext(ContextType.WORKER_INIT);
|
||||||
nativeContext.workerInit()
|
nativeContext.workerInit();
|
||||||
|
|
||||||
const nativeEditBox = cocos.getContext(ContextType.EDITBOX_UTILS);
|
const nativeEditBox = cocos.getContext(ContextType.EDITBOX_UTILS);
|
||||||
const nativeWebView = cocos.getContext(ContextType.WEBVIEW_UTILS);
|
const nativeWebView = cocos.getContext(ContextType.WEBVIEW_UTILS);
|
||||||
@ -39,12 +38,12 @@ const appLifecycle = cocos.getContext(ContextType.APP_LIFECYCLE);
|
|||||||
|
|
||||||
let uiPort = new PortProxy(worker.parentPort);
|
let uiPort = new PortProxy(worker.parentPort);
|
||||||
|
|
||||||
nativeContext.postMessage = function(msgType: string, msgData:string) {
|
nativeContext.postMessage = function (msgType: string, msgData: string): void {
|
||||||
uiPort.postMessage(msgType, msgData);
|
uiPort.postMessage(msgType, msgData);
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeContext.postSyncMessage = async function(msgType: string, msgData:string) {
|
nativeContext.postSyncMessage = async function (msgType: string, msgData: string): Promise<boolean | string | number> {
|
||||||
const result = await uiPort.postSyncMessage(msgType, msgData);
|
const result = await uiPort.postSyncMessage(msgType, msgData) as boolean | string | number;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,23 +54,16 @@ nativeContext.setPostSyncMessageFunction.call(nativeContext, nativeContext.postS
|
|||||||
uiPort._messageHandle = function (e) {
|
uiPort._messageHandle = function (e) {
|
||||||
var data = e.data;
|
var data = e.data;
|
||||||
var msg = data.data;
|
var msg = data.data;
|
||||||
hilog.info(0x0000, 'testTag',msg.name,msg.param);
|
|
||||||
|
|
||||||
switch (msg.name) {
|
switch (msg.name) {
|
||||||
case "onXCLoad":
|
case "onXCLoad":
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', '_messageHandle onXCLoad');
|
|
||||||
console.info("cocos worker:_messageHandle onXCLoad");
|
|
||||||
const renderContext = cocos.getContext(ContextType.NATIVE_RENDER_API);
|
const renderContext = cocos.getContext(ContextType.NATIVE_RENDER_API);
|
||||||
renderContext.nativeEngineInit();
|
renderContext.nativeEngineInit();
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'begin invoke launchEngine');
|
|
||||||
launchEngine().then(() => {
|
launchEngine().then(() => {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launch CC engine finished');
|
|
||||||
console.info('launch CC engine finished');
|
console.info('launch CC engine finished');
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launch CC engine failed');
|
|
||||||
console.error('launch CC engine failed');
|
console.error('launch CC engine failed');
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
globalThis.oh.postMessage = nativeContext.postMessage;
|
globalThis.oh.postMessage = nativeContext.postMessage;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,27 @@
|
|||||||
|
import { ContextType } from '../../../ets/common/Constants';
|
||||||
|
|
||||||
|
interface context {
|
||||||
|
onPageShow: () => void;
|
||||||
|
onPageHide: () => void;
|
||||||
|
workerInit: () => void;
|
||||||
|
postMessage: (msgType: string, msgData: string) => void;
|
||||||
|
postSyncMessage: (msgType: string, msgData: string) => Promise<boolean | string | number>;
|
||||||
|
setPostMessageFunction: (postMessage: (msgType: string, msgData: string) => void) => void;
|
||||||
|
setPostSyncMessageFunction: (postSyncMessage: (msgType: string, msgData: string) => void) => void;
|
||||||
|
nativeEngineInit: () => void;
|
||||||
|
nativeEngineStart: () => void;
|
||||||
|
onTextChange: (param: string) => void;
|
||||||
|
onComplete: (param: string) => void;
|
||||||
|
shouldStartLoading: (viewTag: number, url: string) => void;
|
||||||
|
finishLoading: (viewTag: number, url: string) => void;
|
||||||
|
failLoading: (viewTag: number, url: string) => void;
|
||||||
|
onBackPress: () => void;
|
||||||
|
onCreate: () => void;
|
||||||
|
onDestroy: () => void;
|
||||||
|
onShow: () => void;
|
||||||
|
onHide: () => void;
|
||||||
|
resourceManagerInit: (resourceManager: any) => void;
|
||||||
|
writablePathInit: (cacheDir: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getContext: (type: ContextType) => context;
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "libcocos.so",
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"version": "",
|
||||||
|
"description": "Please describe the basic information."
|
||||||
|
}
|
@ -27,27 +27,30 @@ import worker from '@ohos.worker';
|
|||||||
import { Constants } from '../common/Constants'
|
import { Constants } from '../common/Constants'
|
||||||
|
|
||||||
export class WorkerManager {
|
export class WorkerManager {
|
||||||
private static instance: WorkerManager;
|
private cocosWorker: worker.Worker;
|
||||||
private cocosWorker: any;
|
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.cocosWorker = new worker.Worker("entry/ets/workers/cocos_worker.ts", {type:"classic", name: "CocosWorker"});
|
this.cocosWorker = new worker.Worker("entry/ets/workers/cocos_worker.ts", {
|
||||||
this.cocosWorker.onerror = function (e) {
|
type: "classic",
|
||||||
var msg = e.message;
|
name: "CocosWorker"
|
||||||
var filename = e.filename;
|
});
|
||||||
var lineno = e.lineno;
|
this.cocosWorker.onerror = (e) => {
|
||||||
var colno = e.colno;
|
let msg = e.message;
|
||||||
|
let filename = e.filename;
|
||||||
|
let lineno = e.lineno;
|
||||||
|
let colno = e.colno;
|
||||||
console.error(`on Error ${msg} ${filename} ${lineno} ${colno}`);
|
console.error(`on Error ${msg} ${filename} ${lineno} ${colno}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInstance(): WorkerManager {
|
public static getInstance(): WorkerManager {
|
||||||
if (AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) == null) {
|
if (AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager == undefined) {
|
||||||
AppStorage.SetOrCreate(Constants.APP_KEY_WORKER_MANAGER, new WorkerManager);
|
AppStorage.SetOrCreate(Constants.APP_KEY_WORKER_MANAGER, new WorkerManager);
|
||||||
}
|
}
|
||||||
return AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER);
|
return AppStorage.Get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager;
|
||||||
}
|
}
|
||||||
public getWorker(): any {
|
|
||||||
|
public getWorker(): worker.Worker {
|
||||||
return this.cocosWorker;
|
return this.cocosWorker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
globalThis.oh = {};
|
globalThis.oh = {} as any;
|
||||||
|
|
||||||
function boot() {
|
function boot() {
|
||||||
const cc = globalThis.cc;
|
const cc = globalThis.cc;
|
||||||
var settings = globalThis._CCSettings;
|
var settings = globalThis._CCSettings;
|
||||||
|
@ -22,10 +22,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import worker from '@ohos.worker';
|
|
||||||
import { DedicatedWorkerGlobalScope } from '@ohos.worker';
|
import { DedicatedWorkerGlobalScope } from '@ohos.worker';
|
||||||
// NOTE: don't use this import all statement, because this has compile issue.
|
|
||||||
// import * as wk from '@ohos.worker';
|
|
||||||
import { MessageEvent } from '@ohos.worker';
|
import { MessageEvent } from '@ohos.worker';
|
||||||
|
|
||||||
export class PortProxy {
|
export class PortProxy {
|
||||||
@ -35,8 +32,8 @@ export class PortProxy {
|
|||||||
|
|
||||||
public _messageHandle?: (e: MessageEvent<any>) => void;
|
public _messageHandle?: (e: MessageEvent<any>) => void;
|
||||||
|
|
||||||
constructor (port) {
|
constructor(worker) {
|
||||||
this.port = port;
|
this.port = worker;
|
||||||
this.port.onmessage = this.onMessage.bind(this);
|
this.port.onmessage = this.onMessage.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,15 +46,17 @@ export class PortProxy {
|
|||||||
if (!this.actionHandleMap[id]) {
|
if (!this.actionHandleMap[id]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.actionHandleMap[id].call(this, response)
|
this.actionHandleMap[id].call(this, response);
|
||||||
delete this.actionHandleMap[id];
|
delete this.actionHandleMap[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public postReturnMessage(e: any, res: any) {
|
public postReturnMessage(e: any, res: any) {
|
||||||
if (e.type == "sync" && res != null && res != undefined) {
|
if (e.type == "sync" && res != null && res != undefined) {
|
||||||
this.port.postMessage({ type: "syncResult", data: { id: e.data.cbId, response: res } });
|
this.port.postMessage({ type: "syncResult", data: { id: e.data.cbId, response: res } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public postMessage(msgName: string, msgData: any) {
|
public postMessage(msgName: string, msgData: any) {
|
||||||
this.port.postMessage({ type: "async", data: { name: msgName, param: msgData } });
|
this.port.postMessage({ type: "async", data: { name: msgName, param: msgData } });
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { PortProxy } from '../common/PortProxy';
|
||||||
import { PortProxy } from '../common/PortProxy'
|
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
PLAYING = 0,
|
PLAYING = 0,
|
||||||
@ -35,7 +34,13 @@ enum EventType {
|
|||||||
READY_TO_PLAY,
|
READY_TO_PLAY,
|
||||||
UPDATE,
|
UPDATE,
|
||||||
QUIT_FULLSCREEN = 1000
|
QUIT_FULLSCREEN = 1000
|
||||||
};
|
}
|
||||||
|
|
||||||
|
interface param {
|
||||||
|
videoTag?: number,
|
||||||
|
videoEvent?: EventType,
|
||||||
|
args?: number
|
||||||
|
}
|
||||||
|
|
||||||
@Observed
|
@Observed
|
||||||
export class VideoInfo {
|
export class VideoInfo {
|
||||||
@ -44,24 +49,21 @@ export class VideoInfo {
|
|||||||
public w: number = 0;
|
public w: number = 0;
|
||||||
public h: number = 0;
|
public h: number = 0;
|
||||||
// url
|
// url
|
||||||
public url: string | Resource = ""
|
public url: string | Resource = "";
|
||||||
public viewTag: string = ''
|
public viewTag: number = 0;
|
||||||
public visible: boolean = true
|
public visible: boolean = true;
|
||||||
|
|
||||||
public duration: number = 0;
|
public duration: number = 0;
|
||||||
public currentTime: number = 0;
|
public currentTime: number = 0;
|
||||||
public isFullScreen: boolean = false;
|
public isFullScreen: boolean = false;
|
||||||
public currentProgressRate:number | string | PlaybackSpeed;
|
public currentProgressRate?: number | string | PlaybackSpeed;
|
||||||
|
|
||||||
public resourceType: number = 0;
|
public resourceType: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md#videocontroller
|
* https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md#videocontroller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public controller: VideoController = new VideoController()
|
public controller: VideoController = new VideoController()
|
||||||
|
|
||||||
constructor(x: number, y: number, w: number, h: number, viewTag: string) {
|
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.w = w;
|
this.w = w;
|
||||||
@ -70,49 +72,70 @@ export class VideoInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export struct CocosVideoPlayer {
|
export struct CocosVideoPlayer {
|
||||||
@ObjectLink videoInfo: VideoInfo;
|
@ObjectLink videoInfo: VideoInfo;
|
||||||
public workPort: PortProxy;
|
public workPort: PortProxy | null = null;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Video({ src: this.videoInfo.url, controller: this.videoInfo.controller, currentProgressRate:this.videoInfo.currentProgressRate })
|
Video({
|
||||||
|
src: this.videoInfo.url,
|
||||||
|
controller: this.videoInfo.controller,
|
||||||
|
currentProgressRate: this.videoInfo.currentProgressRate as number | string | PlaybackSpeed
|
||||||
|
})
|
||||||
.position({ x: this.videoInfo.x, y: this.videoInfo.y })
|
.position({ x: this.videoInfo.x, y: this.videoInfo.y })
|
||||||
.width(this.videoInfo.w)
|
.width(this.videoInfo.w)
|
||||||
.height(this.videoInfo.h)
|
.height(this.videoInfo.h)
|
||||||
.controls(false)
|
.controls(false)
|
||||||
.autoPlay(false)
|
.autoPlay(false)
|
||||||
.onStart(() => {
|
.onStart(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.PLAYING});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag as number,
|
||||||
|
videoEvent: EventType.PLAYING as EventType
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPause(() => {
|
.onPause(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.PAUSED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag as number,
|
||||||
|
videoEvent: EventType.PAUSED as EventType
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onFinish(() => {
|
.onFinish(() => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.COMPLETED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag,
|
||||||
|
videoEvent: EventType.COMPLETED
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPrepared((event: {
|
.onPrepared((event): void => {
|
||||||
duration: number;
|
this.videoInfo.duration = event?.duration as number;
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
this.videoInfo.duration = event.duration;
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.READY_TO_PLAY, args:event.duration});
|
videoEvent: EventType.READY_TO_PLAY,
|
||||||
|
args: event?.duration
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onClick((event: ClickEvent) => {
|
.onClick((event): void => {
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.CLICKED});
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
|
videoTag: this.videoInfo.viewTag,
|
||||||
|
videoEvent: EventType.CLICKED
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onUpdate((event?: {
|
.onUpdate((event) => {
|
||||||
time: number;
|
this.videoInfo.currentTime = event?.time as number;
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
this.videoInfo.currentTime = event.time
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.UPDATE, args:event.time});
|
videoEvent: EventType.UPDATE,
|
||||||
|
args: event?.time
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onFullscreenChange((event?: {
|
.onFullscreenChange((event) => {
|
||||||
fullscreen: boolean;
|
if (!event?.fullscreen) {
|
||||||
}) => {
|
this.workPort?.postMessage("onVideoEvent", {
|
||||||
if (!event.fullscreen) {
|
videoTag: this.videoInfo.viewTag,
|
||||||
this.workPort.postMessage("onVideoEvent",{videoTag:this.videoInfo.viewTag, videoEvent:EventType.QUIT_FULLSCREEN});
|
videoEvent: EventType.QUIT_FULLSCREEN
|
||||||
|
} as param);
|
||||||
}
|
}
|
||||||
this.videoInfo.isFullScreen = event.fullscreen
|
this.videoInfo.isFullScreen = event?.fullscreen as boolean;
|
||||||
})
|
})
|
||||||
.visibility(this.videoInfo.visible ? Visibility.Visible : Visibility.None)
|
.visibility(this.videoInfo.visible ? Visibility.Visible : Visibility.None)
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,14 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { PortProxy } from '../common/PortProxy';
|
||||||
import { PortProxy } from '../common/PortProxy'
|
import web from '@ohos.web.webview';
|
||||||
import web from '@ohos.web.webview'
|
|
||||||
|
interface param {
|
||||||
|
viewTag: number,
|
||||||
|
url: string,
|
||||||
|
}
|
||||||
|
|
||||||
@Observed
|
@Observed
|
||||||
export class WebViewInfo {
|
export class WebViewInfo {
|
||||||
// position
|
// position
|
||||||
@ -34,18 +39,17 @@ export class WebViewInfo {
|
|||||||
public w: number = 0;
|
public w: number = 0;
|
||||||
public h: number = 0;
|
public h: number = 0;
|
||||||
// url
|
// url
|
||||||
public url: string = ''
|
public url: string = '';
|
||||||
// tag
|
// tag
|
||||||
public viewTag: string = ''
|
public viewTag: number = 0;
|
||||||
// Whether to display
|
// Whether to display
|
||||||
public visible: boolean = true
|
public visible: boolean = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* doc : https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md#webcontroller
|
* doc : https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md#webcontroller
|
||||||
*/
|
*/
|
||||||
public controller: WebController = new WebController()
|
public controller: web.WebviewController = new web.WebviewController();
|
||||||
|
|
||||||
constructor(x: number, y: number, w: number, h: number, viewTag: string) {
|
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.w = w;
|
this.w = w;
|
||||||
@ -54,7 +58,7 @@ export class WebViewInfo {
|
|||||||
|
|
||||||
web.once("webInited", () => {
|
web.once("webInited", () => {
|
||||||
if (this.url != '') {
|
if (this.url != '') {
|
||||||
this.controller.loadUrl({url: this.url});
|
this.controller.loadUrl(this.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,33 +67,33 @@ export class WebViewInfo {
|
|||||||
@Component
|
@Component
|
||||||
export struct CocosWebView {
|
export struct CocosWebView {
|
||||||
@ObjectLink viewInfo: WebViewInfo;
|
@ObjectLink viewInfo: WebViewInfo;
|
||||||
public workPort: PortProxy;
|
public workPort: PortProxy | null = null;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Web({ src: "", controller: this.viewInfo.controller })
|
Web({ src: this.viewInfo.url, controller: this.viewInfo.controller })
|
||||||
.position({ x: this.viewInfo.x, y: this.viewInfo.y })
|
.position({ x: this.viewInfo.x, y: this.viewInfo.y })
|
||||||
.width(this.viewInfo.w)
|
.width(this.viewInfo.w)
|
||||||
.height(this.viewInfo.h)
|
.height(this.viewInfo.h)
|
||||||
.border({ width: 1 })
|
.border({ width: 1 })
|
||||||
.onPageBegin((event) => {
|
.onPageBegin((event) => {
|
||||||
this.workPort.postMessage("onPageBegin", {viewTag:this.viewInfo.viewTag, url:event.url});
|
this.workPort?.postMessage("onPageBegin", {
|
||||||
|
viewTag: this.viewInfo.viewTag as number,
|
||||||
|
url: event?.url as string
|
||||||
|
} as param);
|
||||||
})
|
})
|
||||||
.onPageEnd((event) => {
|
.onPageEnd((event) => {
|
||||||
this.workPort.postMessage("onPageEnd", {viewTag:this.viewInfo.viewTag, url:event.url})
|
this.workPort?.postMessage("onPageEnd", { viewTag: this.viewInfo.viewTag as number, url: event?.url as string } as param)
|
||||||
})
|
})
|
||||||
.onErrorReceive((event) => {
|
.onErrorReceive((event) => {
|
||||||
this.workPort.postMessage("onErrorReceive", {viewTag:this.viewInfo.viewTag, url:this.viewInfo.url})
|
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||||
})
|
})
|
||||||
.onHttpErrorReceive((event) => {
|
.onHttpErrorReceive((event) => {
|
||||||
this.workPort.postMessage("onErrorReceive", {viewTag:this.viewInfo.viewTag, url:this.viewInfo.url})
|
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||||
})
|
})
|
||||||
// 开启DOM存储权限
|
.domStorageAccess(true)// enable DOM storage permissions
|
||||||
.domStorageAccess(true)
|
.databaseAccess(true)// enable database storage permissions
|
||||||
// 开启数据库存储权限
|
.imageAccess(true)// enable image loading permissions
|
||||||
.databaseAccess(true)
|
.javaScriptAccess(true)// support JS code running
|
||||||
// 图片加载相关权限
|
|
||||||
.imageAccess(true)
|
|
||||||
// 支持JS代码运行
|
|
||||||
.javaScriptAccess(true)
|
|
||||||
.visibility(this.viewInfo.visible ? Visibility.Visible : Visibility.None)
|
.visibility(this.viewInfo.visible ? Visibility.Visible : Visibility.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,11 +26,11 @@
|
|||||||
export struct EditBoxDialog {
|
export struct EditBoxDialog {
|
||||||
private showMessage: string = ''
|
private showMessage: string = ''
|
||||||
private inputMessage: string = ''
|
private inputMessage: string = ''
|
||||||
onTextChange: (msg: string) => void
|
onTextChange?: (msg: string) => void;
|
||||||
accept: (msg: string) => void
|
accept?: (msg: string) => void;
|
||||||
controller: CustomDialogController
|
controller?: CustomDialogController;
|
||||||
cancel: () => void
|
cancel?: () => void;
|
||||||
confirm: () => void
|
confirm?: () => void;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
@ -48,14 +48,14 @@ export struct EditBoxDialog {
|
|||||||
if (this.accept) {
|
if (this.accept) {
|
||||||
this.accept(this.inputMessage);
|
this.accept(this.inputMessage);
|
||||||
}
|
}
|
||||||
this.controller.close();
|
this.controller?.close();
|
||||||
})
|
})
|
||||||
Blank(8).width(16)
|
Blank(8).width(16)
|
||||||
Button('完成').onClick(() => {
|
Button('完成').onClick(() => {
|
||||||
if (this.accept) {
|
if (this.accept) {
|
||||||
this.accept(this.inputMessage);
|
this.accept(this.inputMessage);
|
||||||
}
|
}
|
||||||
this.controller.close();
|
this.controller?.close();
|
||||||
})
|
})
|
||||||
}.padding({ left: 8, right: 8, top: 8, bottom: 8 })
|
}.padding({ left: 8, right: 8, top: 8, bottom: 8 })
|
||||||
.backgroundColor(Color.Gray)
|
.backgroundColor(Color.Gray)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||||
import cocos from "libcocos.so";
|
import cocos from 'libcocos.so';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import window from '@ohos.window';
|
import window from '@ohos.window';
|
||||||
|
|
||||||
const nativeContext = cocos.getContext(ContextType.ENGINE_UTILS);
|
const nativeContext = cocos.getContext(ContextType.ENGINE_UTILS);
|
||||||
|
@ -22,44 +22,71 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import nativerender from "libcocos.so";
|
import nativerender from 'libcocos.so';
|
||||||
|
|
||||||
import { WorkerManager } from '../cocos/WorkerManager'
|
import { WorkerManager } from '../cocos/WorkerManager';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import featureAbility from '@ohos.ability.featureAbility'
|
import { EditBoxDialog } from '../components/EditBoxDialog';
|
||||||
import { EditBoxDialog } from '../components/EditBoxDialog'
|
import { CocosWebView, WebViewInfo } from '../components/CocosWebView';
|
||||||
import { WebViewInfo, CocosWebView } from '../components/CocosWebView'
|
import { CocosVideoPlayer, VideoInfo } from '../components/CocosVideoPlayer';
|
||||||
import { VideoInfo, CocosVideoPlayer } from '../components/CocosVideoPlayer'
|
import { MessageEvent } from '@ohos.worker';
|
||||||
|
import { PortProxy } from '../common/PortProxy';
|
||||||
|
|
||||||
import {PortProxy} from '../common/PortProxy'
|
|
||||||
const nativePageLifecycle = nativerender.getContext(ContextType.JSPAGE_LIFECYCLE);
|
const nativePageLifecycle = nativerender.getContext(ContextType.JSPAGE_LIFECYCLE);
|
||||||
const engineUtils = nativerender.getContext(ContextType.ENGINE_UTILS);
|
const engineUtils = nativerender.getContext(ContextType.ENGINE_UTILS);
|
||||||
|
|
||||||
|
interface WorkerMessage {
|
||||||
|
type: string;
|
||||||
|
data: data;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface data {
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
param: number | string | param
|
||||||
|
}
|
||||||
|
|
||||||
|
interface param {
|
||||||
|
tag?: number,
|
||||||
|
url?: string,
|
||||||
|
contents?: string,
|
||||||
|
mimeType?: string,
|
||||||
|
encoding?: string,
|
||||||
|
baseUrl?: string,
|
||||||
|
jsContents?: string,
|
||||||
|
x?: number,
|
||||||
|
y?: number,
|
||||||
|
w?: number,
|
||||||
|
h?: number,
|
||||||
|
visible?: boolean,
|
||||||
|
resourceType?: number,
|
||||||
|
time?: number,
|
||||||
|
fullScreen?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct Index {
|
struct Index {
|
||||||
@State showMessage: string = ''
|
@State showMessage: string = ''
|
||||||
@State webViewArray: WebViewInfo[] = [];
|
@State webViewArray: WebViewInfo[] = [];
|
||||||
@State videoArray: VideoInfo[] = [];
|
@State videoArray: VideoInfo[] = [];
|
||||||
//private index: number = 0;
|
private webViewIndexMap: Map<number, number> = new Map<number, number>();
|
||||||
private webViewIndexMap: Map<number, number> = new Map;
|
private videoIndexMap: Map<number, number> = new Map<number, number>();
|
||||||
private videoIndexMap: Map<number, number> = new Map;
|
|
||||||
|
|
||||||
private workPort: PortProxy = new PortProxy(WorkerManager.getInstance().getWorker());
|
private workPort: PortProxy = new PortProxy(WorkerManager.getInstance().getWorker());
|
||||||
dialogController: CustomDialogController = new CustomDialogController({
|
dialogController: CustomDialogController = new CustomDialogController({
|
||||||
builder: EditBoxDialog({
|
builder: EditBoxDialog({
|
||||||
showMessage: this.showMessage,
|
showMessage: this.showMessage,
|
||||||
onTextChange: (msg: string) => {
|
onTextChange: (msg: string): void => {
|
||||||
this.showMessage = msg;
|
this.showMessage = msg;
|
||||||
this.workPort.postMessage('onTextInput', msg)
|
this.workPort.postMessage('onTextInput', msg);
|
||||||
},
|
},
|
||||||
accept: (msg: string) => {
|
accept: (msg: string): void => {
|
||||||
this.showMessage = msg;
|
this.showMessage = msg;
|
||||||
this.workPort.postMessage('onComplete', msg)
|
this.workPort.postMessage('onComplete', msg);
|
||||||
},
|
}
|
||||||
}),
|
}),
|
||||||
cancel: () => {
|
cancel: (): void => {
|
||||||
this.workPort.postMessage('onComplete', this.showMessage)
|
this.workPort.postMessage('onComplete', this.showMessage);
|
||||||
},
|
},
|
||||||
autoCancel: true,
|
autoCancel: true,
|
||||||
alignment: DialogAlignment.Bottom,
|
alignment: DialogAlignment.Bottom,
|
||||||
@ -68,180 +95,190 @@ struct Index {
|
|||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
console.log('[LIFECYCLE-Index] cocos aboutToAppear');
|
console.log('[LIFECYCLE-Index] cocos aboutToAppear');
|
||||||
this.workPort._messageHandle = (e) => {
|
this.workPort._messageHandle = async (e: MessageEvent<WorkerMessage>): Promise<void> => {
|
||||||
//let data = e['data'];
|
let data: WorkerMessage = e.data;
|
||||||
var data = e.data;
|
let msg = data.data;
|
||||||
var msg = data.data;
|
let result: boolean | string | number | null = null;
|
||||||
var result;
|
|
||||||
switch (msg.name) {
|
switch (msg.name) {
|
||||||
// EditBox
|
// EditBox
|
||||||
case "showEditBox": {
|
case "showEditBox": {
|
||||||
this.showMessage = msg.param
|
this.showMessage = msg.param as string;
|
||||||
this.dialogController.open()
|
this.dialogController.open();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "hideEditBox": {
|
case "hideEditBox": {
|
||||||
this.showMessage = ''
|
this.showMessage = '';
|
||||||
this.dialogController.close()
|
this.dialogController.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// WebView
|
// WebView
|
||||||
case "createWebView": {
|
case "createWebView": {
|
||||||
this.webViewArray.push(new WebViewInfo(0, 0, 0, 0, msg.param))
|
this.webViewArray.push(new WebViewInfo(0, 0, 0, 0, msg.param as number));
|
||||||
this.webViewIndexMap.set(msg.param, this.webViewArray.length - 1);
|
this.webViewIndexMap.set(msg.param as number, this.webViewArray.length - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "removeWebView": {
|
case "removeWebView": {
|
||||||
if (this.webViewArray.length > 0) {
|
if (this.webViewArray.length > 0) {
|
||||||
this.webViewArray.splice(this.webViewIndexMap.get(msg.param), 1)
|
this.webViewArray.splice(this.webViewIndexMap.get(msg?.param as number) as number, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadUrl": {
|
case "loadUrl": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].url = web.url;
|
this.webViewArray[index].url = web?.url as string;
|
||||||
this.webViewArray[index].controller.loadUrl({url: web.url});
|
this.webViewArray[index].controller.loadUrl(web?.url as string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadHTMLString": {
|
case "loadHTMLString": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.loadData({data: web.contents, mimeType:"text/html",encoding:"UTF-8", baseUrl:web.baseUrl});
|
this.webViewArray[index].controller.loadData(
|
||||||
|
web?.contents as string,
|
||||||
|
"text/html",
|
||||||
|
"UTF-8",
|
||||||
|
web?.baseUrl
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "loadData": {
|
case "loadData": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.loadData({data: web.contents, mimeType:web.mimeType,encoding:web.encoding, baseUrl:web.baseUrl});
|
this.webViewArray[index].controller.loadData(
|
||||||
|
web?.contents as string,
|
||||||
|
web?.mimeType as string,
|
||||||
|
web?.encoding as string,
|
||||||
|
web?.baseUrl as string
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "evaluateJS": {
|
case "evaluateJS": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag)
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].controller.runJavaScript({
|
this.webViewArray[index].controller.runJavaScript(web?.jsContents as string);
|
||||||
script: web.jsContents
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reload": {
|
case "reload": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.refresh();
|
this.webViewArray[index].controller.refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "stopLoading": {
|
case "stopLoading": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.stop();
|
this.webViewArray[index].controller.stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "canGoForward": {
|
case "canGoForward": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
result = this.webViewArray[index].controller.accessForward();
|
result = this.webViewArray[index].controller.accessForward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "canGoBack": {
|
case "canGoBack": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
result = this.webViewArray[index].controller.accessBackward();
|
result = this.webViewArray[index].controller.accessBackward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "goForward": {
|
case "goForward": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.forward();
|
this.webViewArray[index].controller.forward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "goBack": {
|
case "goBack": {
|
||||||
var index = this.webViewIndexMap.get(msg.param);
|
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||||
this.webViewArray[index].controller.backward();
|
this.webViewArray[index].controller.backward();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setWebViewRect": {
|
case "setWebViewRect": {
|
||||||
var web = msg.param;
|
let web = msg.param as param
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].x = px2vp(web.x);
|
this.webViewArray[index].x = px2vp(web?.x as number) as number;
|
||||||
this.webViewArray[index].y = px2vp(web.y);
|
this.webViewArray[index].y = px2vp(web?.y as number) as number;
|
||||||
this.webViewArray[index].w = px2vp(web.w);
|
this.webViewArray[index].w = px2vp(web?.w as number) as number;
|
||||||
this.webViewArray[index].h = px2vp(web.h);
|
this.webViewArray[index].h = px2vp(web?.h as number) as number;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setVisible":
|
case "setVisible": {
|
||||||
var web = msg.param;
|
let web = msg.param as param;
|
||||||
var index = this.webViewIndexMap.get(web.tag);
|
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||||
this.webViewArray[index].visible = web.visible;
|
this.webViewArray[index].visible = web?.visible as boolean;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
// video
|
// video
|
||||||
case "createVideo":
|
case "createVideo": {
|
||||||
this.videoArray.push(new VideoInfo(0, 0, 0, 0, msg.param))
|
this.videoArray.push(new VideoInfo(0, 0, 0, 0, msg.param as number));
|
||||||
this.videoIndexMap.set(msg.param, this.videoArray.length - 1);
|
this.videoIndexMap.set(msg.param as number, this.videoArray.length - 1);
|
||||||
break;
|
break;
|
||||||
case "removeVideo":
|
}
|
||||||
|
case "removeVideo": {
|
||||||
if (this.videoArray.length > 0) {
|
if (this.videoArray.length > 0) {
|
||||||
this.videoArray.splice(this.videoIndexMap.get(msg.param), 1)
|
this.videoArray.splice(this.videoIndexMap.get(msg.param as number) as number, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "setVideoUrl":
|
case "setVideoUrl":
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
var resourceType = video.resourceType;
|
let resourceType = video.resourceType;
|
||||||
if (resourceType == 1) {
|
if (resourceType == 1) {
|
||||||
this.videoArray[index].url = $rawfile(video.url);
|
this.videoArray[index].url = $rawfile(video.url as string);
|
||||||
} else {
|
} else {
|
||||||
this.videoArray[index].url = video.url;
|
this.videoArray[index].url = video.url as string;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setVideoRect": {
|
case "setVideoRect": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].x = px2vp(video.x);
|
this.videoArray[index].x = px2vp(video?.x as number) as number;
|
||||||
this.videoArray[index].y = px2vp(video.y);
|
this.videoArray[index].y = px2vp(video?.y as number) as number;
|
||||||
this.videoArray[index].w = px2vp(video.w);
|
this.videoArray[index].w = px2vp(video?.w as number) as number;
|
||||||
this.videoArray[index].h = px2vp(video.h);
|
this.videoArray[index].h = px2vp(video?.h as number) as number;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startVideo": {
|
case "startVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.start();
|
this.videoArray[index].controller.start();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "pauseVideo": {
|
case "pauseVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.pause();
|
this.videoArray[index].controller.pause();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "stopVideo": {
|
case "stopVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.stop();
|
this.videoArray[index].controller.stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "resumeVideo": {
|
case "resumeVideo": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
this.videoArray[index].controller.start();
|
this.videoArray[index].controller.start();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "getVideoDuration": {
|
case "getVideoDuration": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
result = this.videoArray[index].duration;
|
result = this.videoArray[index].duration;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "seekVideoTo": {
|
case "seekVideoTo": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].controller.setCurrentTime(video.time, SeekMode.Accurate);
|
this.videoArray[index].controller.setCurrentTime(video?.time as number, SeekMode.Accurate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setVideoVisible": {
|
case "setVideoVisible": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].visible = video.visible;
|
this.videoArray[index].visible = video.visible as boolean;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setFullScreenEnabled": {
|
case "setFullScreenEnabled": {
|
||||||
var video = msg.param;
|
let video = msg.param as param;
|
||||||
var index = this.videoIndexMap.get(video.tag);
|
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||||
this.videoArray[index].isFullScreen = video.fullScreen;
|
this.videoArray[index].isFullScreen = video.fullScreen as boolean;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "currentTime": {
|
case "currentTime": {
|
||||||
var index = this.videoIndexMap.get(msg.param);
|
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||||
result = this.videoArray[index].currentTime;
|
result = this.videoArray[index].currentTime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -279,7 +316,11 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({
|
||||||
|
direction: FlexDirection.Column,
|
||||||
|
alignItems: ItemAlign.Center,
|
||||||
|
justifyContent: FlexAlign.Center
|
||||||
|
} as FlexOptions) {
|
||||||
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'cocos' })
|
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'cocos' })
|
||||||
.onLoad((context) => {
|
.onLoad((context) => {
|
||||||
// Set the cache directory in the ts layer.
|
// Set the cache directory in the ts layer.
|
||||||
@ -289,13 +330,13 @@ struct Index {
|
|||||||
console.log('cocos onDestroy')
|
console.log('cocos onDestroy')
|
||||||
})
|
})
|
||||||
|
|
||||||
ForEach(this.webViewArray, (item: WebViewInfo, index: number) => {
|
ForEach(this.webViewArray, (item: WebViewInfo) => {
|
||||||
CocosWebView({ viewInfo: item, workPort: this.workPort })
|
CocosWebView({ viewInfo: item, workPort: this.workPort })
|
||||||
}, item => item.viewTag)
|
}, (item: WebViewInfo): string => item.viewTag.toString())
|
||||||
|
|
||||||
ForEach(this.videoArray, (item: VideoInfo, index: number) => {
|
ForEach(this.videoArray, (item: VideoInfo) => {
|
||||||
CocosVideoPlayer({ videoInfo: item, workPort: this.workPort })
|
CocosVideoPlayer({ videoInfo: item, workPort: this.workPort })
|
||||||
}, item => item.viewTag)
|
}, (item: VideoInfo): string => item.viewTag.toString())
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
|
@ -23,15 +23,14 @@ import hilog from '@ohos.hilog';
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import worker from '@ohos.worker';
|
import worker from '@ohos.worker';
|
||||||
import cocos from "libcocos.so";
|
import cocos from 'libcocos.so';
|
||||||
import { ContextType } from "../common/Constants"
|
import { ContextType } from '../common/Constants';
|
||||||
import { launchEngine } from '../cocos/game'
|
import { launchEngine } from '../cocos/game';
|
||||||
import { PortProxy } from '../common/PortProxy';
|
import { PortProxy } from '../common/PortProxy';
|
||||||
|
|
||||||
const nativeContext = cocos.getContext(ContextType.WORKER_INIT);
|
const nativeContext = cocos.getContext(ContextType.WORKER_INIT);
|
||||||
nativeContext.workerInit()
|
nativeContext.workerInit();
|
||||||
|
|
||||||
const nativeEditBox = cocos.getContext(ContextType.EDITBOX_UTILS);
|
const nativeEditBox = cocos.getContext(ContextType.EDITBOX_UTILS);
|
||||||
const nativeWebView = cocos.getContext(ContextType.WEBVIEW_UTILS);
|
const nativeWebView = cocos.getContext(ContextType.WEBVIEW_UTILS);
|
||||||
@ -39,12 +38,12 @@ const appLifecycle = cocos.getContext(ContextType.APP_LIFECYCLE);
|
|||||||
|
|
||||||
let uiPort = new PortProxy(worker.parentPort);
|
let uiPort = new PortProxy(worker.parentPort);
|
||||||
|
|
||||||
nativeContext.postMessage = function(msgType: string, msgData:string) {
|
nativeContext.postMessage = function (msgType: string, msgData: string): void {
|
||||||
uiPort.postMessage(msgType, msgData);
|
uiPort.postMessage(msgType, msgData);
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeContext.postSyncMessage = async function(msgType: string, msgData:string) {
|
nativeContext.postSyncMessage = async function (msgType: string, msgData: string): Promise<boolean | string | number> {
|
||||||
const result = await uiPort.postSyncMessage(msgType, msgData);
|
const result = await uiPort.postSyncMessage(msgType, msgData) as boolean | string | number;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,23 +54,16 @@ nativeContext.setPostSyncMessageFunction.call(nativeContext, nativeContext.postS
|
|||||||
uiPort._messageHandle = function (e) {
|
uiPort._messageHandle = function (e) {
|
||||||
var data = e.data;
|
var data = e.data;
|
||||||
var msg = data.data;
|
var msg = data.data;
|
||||||
hilog.info(0x0000, 'testTag',msg.name,msg.param);
|
|
||||||
|
|
||||||
switch (msg.name) {
|
switch (msg.name) {
|
||||||
case "onXCLoad":
|
case "onXCLoad":
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', '_messageHandle onXCLoad');
|
|
||||||
console.info("cocos worker:_messageHandle onXCLoad");
|
|
||||||
const renderContext = cocos.getContext(ContextType.NATIVE_RENDER_API);
|
const renderContext = cocos.getContext(ContextType.NATIVE_RENDER_API);
|
||||||
renderContext.nativeEngineInit();
|
renderContext.nativeEngineInit();
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'begin invoke launchEngine');
|
|
||||||
launchEngine().then(() => {
|
launchEngine().then(() => {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launch CC engine finished');
|
|
||||||
console.info('launch CC engine finished');
|
console.info('launch CC engine finished');
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launch CC engine failed');
|
|
||||||
console.error('launch CC engine failed');
|
console.error('launch CC engine failed');
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
globalThis.oh.postMessage = nativeContext.postMessage;
|
globalThis.oh.postMessage = nativeContext.postMessage;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
9
cocos2d-x/tools/cocos2d-console/.gitignore
vendored
9
cocos2d-x/tools/cocos2d-console/.gitignore
vendored
@ -46,6 +46,15 @@ xcuserdata/
|
|||||||
DerivedData/
|
DerivedData/
|
||||||
.idea/*
|
.idea/*
|
||||||
|
|
||||||
|
# Ignore the files from download
|
||||||
|
bin/sdkbox*
|
||||||
|
plugins/plugin_compile/build_web/bin
|
||||||
|
plugins/plugin_jscompile/
|
||||||
|
plugins/plugin_luacompile/bin/msvcr110.dll
|
||||||
|
plugins/plugin_generate/proj_modifier/plutil-win32/
|
||||||
|
version.json
|
||||||
|
v*-console-*.zip
|
||||||
|
|
||||||
# vim
|
# vim
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ class CCPlugin(object):
|
|||||||
if os.path.isdir(cocos2dx_path):
|
if os.path.isdir(cocos2dx_path):
|
||||||
return cocos2dx_path
|
return cocos2dx_path
|
||||||
|
|
||||||
if cls.get_cocos2d_mode() is not "distro":
|
if cls.get_cocos2d_mode() != "distro":
|
||||||
# In 'distro' mode this is not a warning since
|
# In 'distro' mode this is not a warning since
|
||||||
# the source code is not expected to be installed
|
# the source code is not expected to be installed
|
||||||
Logging.warning(MultiLanguage.get_string('COCOS_WARNING_ENGINE_NOT_FOUND'))
|
Logging.warning(MultiLanguage.get_string('COCOS_WARNING_ENGINE_NOT_FOUND'))
|
||||||
@ -940,7 +940,7 @@ def _check_python_version():
|
|||||||
ret = False
|
ret = False
|
||||||
|
|
||||||
if not ret:
|
if not ret:
|
||||||
print(MultiLanguage.get_string('COCOS_PYTHON_VERSION_TIP_FMT') % (major_ver, minor_ver))
|
print(str('COCOS PYTHON VERSION DOES NOT MATCH: %d.%d, WHILE 2.7+ IS REQUIRED') % (major_ver, minor_ver))
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -525,6 +525,12 @@ class AndroidBuilder(object):
|
|||||||
if match:
|
if match:
|
||||||
package = match.group(1)
|
package = match.group(1)
|
||||||
break
|
break
|
||||||
|
else :
|
||||||
|
pattern = r'namespace[ \t]+[\'\"](.*)[\'\"]'
|
||||||
|
match = re.match(pattern, line_str)
|
||||||
|
if match:
|
||||||
|
package = match.group(1)
|
||||||
|
break
|
||||||
if package is None:
|
if package is None:
|
||||||
# get package name from AndroidManifest.xml
|
# get package name from AndroidManifest.xml
|
||||||
package = self._xml_attr(manifest_path, 'AndroidManifest.xml', 'manifest', 'package')
|
package = self._xml_attr(manifest_path, 'AndroidManifest.xml', 'manifest', 'package')
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
PLAYER_NS_BEGIN
|
PLAYER_NS_BEGIN
|
||||||
|
|
||||||
class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cocos2d::Ref
|
class CC_LIBSIM_DLL PlayerWin : public cocos2d::Ref, public PlayerProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static PlayerWin *createWithHwnd(HWND hWnd);
|
static PlayerWin *createWithHwnd(HWND hWnd);
|
||||||
|
@ -43,6 +43,7 @@ let LabelOutline = cc.Class({
|
|||||||
extends: require('./CCComponent'),
|
extends: require('./CCComponent'),
|
||||||
editor: CC_EDITOR && {
|
editor: CC_EDITOR && {
|
||||||
menu: 'i18n:MAIN_MENU.component.renderers/LabelOutline',
|
menu: 'i18n:MAIN_MENU.component.renderers/LabelOutline',
|
||||||
|
help: 'i18n:COMPONENT.help_url.labelOutline',
|
||||||
executeInEditMode: true,
|
executeInEditMode: true,
|
||||||
requireComponent: cc.Label,
|
requireComponent: cc.Label,
|
||||||
},
|
},
|
||||||
|
@ -43,6 +43,7 @@ let LabelShadow = cc.Class({
|
|||||||
extends: require('./CCComponent'),
|
extends: require('./CCComponent'),
|
||||||
editor: CC_EDITOR && {
|
editor: CC_EDITOR && {
|
||||||
menu: 'i18n:MAIN_MENU.component.renderers/LabelShadow',
|
menu: 'i18n:MAIN_MENU.component.renderers/LabelShadow',
|
||||||
|
help: 'i18n:COMPONENT.help_url.labelShadow',
|
||||||
executeInEditMode: true,
|
executeInEditMode: true,
|
||||||
requireComponent: cc.Label,
|
requireComponent: cc.Label,
|
||||||
},
|
},
|
||||||
|
@ -5,6 +5,8 @@ module.exports = {
|
|||||||
"animation": "https://docs.cocos.com/creator/2.4/manual/en/components/animation.html",
|
"animation": "https://docs.cocos.com/creator/2.4/manual/en/components/animation.html",
|
||||||
"sprite": "https://docs.cocos.com/creator/2.4/manual/en/components/sprite.html",
|
"sprite": "https://docs.cocos.com/creator/2.4/manual/en/components/sprite.html",
|
||||||
"label": "https://docs.cocos.com/creator/2.4/manual/en/components/label.html",
|
"label": "https://docs.cocos.com/creator/2.4/manual/en/components/label.html",
|
||||||
|
"labelOutline": "https://docs.cocos.com/creator/2.4/manual/en/components/label-outline.html",
|
||||||
|
"labelShadow": "https://docs.cocos.com/creator/2.4/manual/en/components/label-shadow.html",
|
||||||
"canvas": "https://docs.cocos.com/creator/2.4/manual/en/components/canvas.html",
|
"canvas": "https://docs.cocos.com/creator/2.4/manual/en/components/canvas.html",
|
||||||
"spine": "https://docs.cocos.com/creator/2.4/manual/en/components/spine.html",
|
"spine": "https://docs.cocos.com/creator/2.4/manual/en/components/spine.html",
|
||||||
"widget": "https://docs.cocos.com/creator/2.4/manual/en/components/widget.html",
|
"widget": "https://docs.cocos.com/creator/2.4/manual/en/components/widget.html",
|
||||||
|
@ -5,6 +5,8 @@ module.exports = {
|
|||||||
"animation": "https://docs.cocos.com/creator/2.4/manual/zh/components/animation.html",
|
"animation": "https://docs.cocos.com/creator/2.4/manual/zh/components/animation.html",
|
||||||
"sprite": "https://docs.cocos.com/creator/2.4/manual/zh/components/sprite.html",
|
"sprite": "https://docs.cocos.com/creator/2.4/manual/zh/components/sprite.html",
|
||||||
"label": "https://docs.cocos.com/creator/2.4/manual/zh/components/label.html",
|
"label": "https://docs.cocos.com/creator/2.4/manual/zh/components/label.html",
|
||||||
|
"labelOutline": "https://docs.cocos.com/creator/2.4/manual/zh/components/label-outline.html",
|
||||||
|
"labelShadow": "https://docs.cocos.com/creator/2.4/manual/zh/components/label-shadow.html",
|
||||||
"canvas": "https://docs.cocos.com/creator/2.4/manual/zh/components/canvas.html",
|
"canvas": "https://docs.cocos.com/creator/2.4/manual/zh/components/canvas.html",
|
||||||
"spine": "https://docs.cocos.com/creator/2.4/manual/zh/components/spine.html",
|
"spine": "https://docs.cocos.com/creator/2.4/manual/zh/components/spine.html",
|
||||||
"widget": "https://docs.cocos.com/creator/2.4/manual/zh/components/widget.html",
|
"widget": "https://docs.cocos.com/creator/2.4/manual/zh/components/widget.html",
|
||||||
|
@ -12631,6 +12631,7 @@ var dragonBones;
|
|||||||
var rawTimeline = rawTimelines_3[_b];
|
var rawTimeline = rawTimelines_3[_b];
|
||||||
this._parseSlotTimeline(rawTimeline);
|
this._parseSlotTimeline(rawTimeline);
|
||||||
}
|
}
|
||||||
|
this._actionFrames.sort((a, b) => { return a.frameStart - b.frameStart; });
|
||||||
}
|
}
|
||||||
if (dragonBones.DataParser.FFD in rawData) {
|
if (dragonBones.DataParser.FFD in rawData) {
|
||||||
var rawTimelines = rawData[dragonBones.DataParser.FFD];
|
var rawTimelines = rawData[dragonBones.DataParser.FFD];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cocos-creator-js",
|
"name": "cocos-creator-js",
|
||||||
"version": "2.4.12",
|
"version": "2.4.13",
|
||||||
"description": "Cocos Creator is a complete package of game development tools and workflow, including a game engine, resource management, scene editing, game preview, debug and publish one project to multiple platforms.",
|
"description": "Cocos Creator is a complete package of game development tools and workflow, including a game engine, resource management, scene editing, game preview, debug and publish one project to multiple platforms.",
|
||||||
"homepage": "https://www.cocos.com",
|
"homepage": "https://www.cocos.com",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -211,5 +211,5 @@ if (CC_DEV) {
|
|||||||
* If you post a bug to forum, please attach this flag.
|
* If you post a bug to forum, please attach this flag.
|
||||||
* @property {String} ENGINE_VERSION
|
* @property {String} ENGINE_VERSION
|
||||||
*/
|
*/
|
||||||
const engineVersion = '2.4.12';
|
const engineVersion = '2.4.13';
|
||||||
_global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
|
_global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
|
||||||
|
@ -354,8 +354,8 @@ const cacheManager = require('./jsb-cache-manager');
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._nativeSkeleton) {
|
if (this._nativeSkeleton) {
|
||||||
this._nativeSkeleton.stopSchedule();
|
|
||||||
this._nativeSkeleton._comp = null;
|
this._nativeSkeleton._comp = null;
|
||||||
|
this._nativeSkeleton.destroy();
|
||||||
this._nativeSkeleton = null;
|
this._nativeSkeleton = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,8 +763,8 @@ const cacheManager = require('./jsb-cache-manager');
|
|||||||
this.animation = this.defaultAnimation;
|
this.animation = this.defaultAnimation;
|
||||||
} else {
|
} else {
|
||||||
if (this._nativeSkeleton) {
|
if (this._nativeSkeleton) {
|
||||||
this._nativeSkeleton.stopSchedule();
|
|
||||||
this._nativeSkeleton._comp = null;
|
this._nativeSkeleton._comp = null;
|
||||||
|
this._nativeSkeleton.destroy();
|
||||||
this._nativeSkeleton = null;
|
this._nativeSkeleton = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -774,8 +774,8 @@ const cacheManager = require('./jsb-cache-manager');
|
|||||||
skeleton.onDestroy = function(){
|
skeleton.onDestroy = function(){
|
||||||
_onDestroy.call(this);
|
_onDestroy.call(this);
|
||||||
if (this._nativeSkeleton) {
|
if (this._nativeSkeleton) {
|
||||||
this._nativeSkeleton.stopSchedule();
|
|
||||||
this._nativeSkeleton._comp = null;
|
this._nativeSkeleton._comp = null;
|
||||||
|
this._nativeSkeleton.destroy();
|
||||||
this._nativeSkeleton = null;
|
this._nativeSkeleton = null;
|
||||||
}
|
}
|
||||||
this._stateData = null;
|
this._stateData = null;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
var _topLeft = new vec3();
|
var _topLeft = new vec3();
|
||||||
var _bottomRight = new vec3();
|
var _bottomRight = new vec3();
|
||||||
|
|
||||||
let kWebViewTag = 0;
|
let kVideoTag = 0;
|
||||||
let videoPlayers = [];
|
let videoPlayers = [];
|
||||||
const VideoEvent = {
|
const VideoEvent = {
|
||||||
PLAYING: 0,
|
PLAYING: 0,
|
||||||
@ -143,6 +143,16 @@
|
|||||||
video.setVisible(false)
|
video.setVisible(false)
|
||||||
|
|
||||||
let cbs = this.__eventListeners;
|
let cbs = this.__eventListeners;
|
||||||
|
|
||||||
|
video.removeEventListener("loadedmetadata", cbs.loadedmetadata);
|
||||||
|
video.removeEventListener("ended", cbs.ended);
|
||||||
|
video.removeEventListener("play", cbs.play);
|
||||||
|
video.removeEventListener("pause", cbs.pause);
|
||||||
|
video.removeEventListener("click", cbs.click);
|
||||||
|
video.removeEventListener("canplay", cbs.onCanPlay);
|
||||||
|
video.removeEventListener("canplaythrough", cbs.onCanPlay);
|
||||||
|
video.removeEventListener("suspend", cbs.onCanPlay);
|
||||||
|
|
||||||
cbs.loadedmetadata = null;
|
cbs.loadedmetadata = null;
|
||||||
cbs.ended = null;
|
cbs.ended = null;
|
||||||
cbs.play = null;
|
cbs.play = null;
|
||||||
@ -480,7 +490,7 @@
|
|||||||
this._events = {};
|
this._events = {};
|
||||||
this._currentTime = 0;
|
this._currentTime = 0;
|
||||||
this._duration = 0;
|
this._duration = 0;
|
||||||
this._videoIndex = kWebViewTag++;
|
this._videoIndex = kVideoTag++;
|
||||||
this._matViewProj_temp = new mat4();
|
this._matViewProj_temp = new mat4();
|
||||||
window.oh.postMessage("createVideo", this._videoIndex);
|
window.oh.postMessage("createVideo", this._videoIndex);
|
||||||
videoPlayers.push(this);
|
videoPlayers.push(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user