2023-09-01 16:31:14 +08:00
|
|
|
#include "platform/PlatformConfig.h"
|
2023-09-05 22:17:18 +08:00
|
|
|
#if AX_TARGET_PLATFORM == AX_PLATFORM_WASM
|
2023-09-01 16:31:14 +08:00
|
|
|
|
2023-09-15 19:33:25 +08:00
|
|
|
#include "platform/wasm/devtools-wasm.h"
|
2023-09-01 16:31:14 +08:00
|
|
|
#include <emscripten.h>
|
|
|
|
#include "base/UTF8.h"
|
|
|
|
|
2023-09-15 19:33:25 +08:00
|
|
|
NS_AX_BEGIN
|
2023-09-01 16:31:14 +08:00
|
|
|
|
|
|
|
DevToolsImpl::DevToolsImpl()
|
|
|
|
{
|
|
|
|
_director = Director::getInstance();
|
|
|
|
_scheduler = _director->getScheduler();
|
|
|
|
_tick = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsImpl::update(float /*dt*/)
|
|
|
|
{
|
|
|
|
// tick for 2 frames becuase delta time of the 1st frame after resume is forced to 0
|
|
|
|
_tick ++;
|
|
|
|
if (_tick >= 2)
|
|
|
|
{
|
|
|
|
_director->pause();
|
|
|
|
_scheduler->unscheduleUpdate(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsImpl::step()
|
|
|
|
{
|
|
|
|
_director->resume();
|
|
|
|
_tick = 0;
|
|
|
|
_scheduler->scheduleUpdate(this, 0, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsImpl::pause()
|
|
|
|
{
|
|
|
|
_director->pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsImpl::resume()
|
|
|
|
{
|
|
|
|
_director->resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
DevToolsImpl* DevToolsImpl::getInstance()
|
|
|
|
{
|
|
|
|
static DevToolsImpl instance;
|
|
|
|
return &instance;
|
|
|
|
}
|
|
|
|
|
2023-09-15 19:33:25 +08:00
|
|
|
NS_AX_END
|
|
|
|
|
2023-09-01 16:31:14 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2023-09-15 19:33:25 +08:00
|
|
|
void axmol_director_pause()
|
2023-09-01 16:31:14 +08:00
|
|
|
{
|
2023-09-15 19:33:25 +08:00
|
|
|
ax::DevToolsImpl::getInstance()->pause();
|
2023-09-01 16:31:14 +08:00
|
|
|
}
|
|
|
|
|
2023-09-15 19:33:25 +08:00
|
|
|
void axmol_director_resume()
|
2023-09-01 16:31:14 +08:00
|
|
|
{
|
2023-09-15 19:33:25 +08:00
|
|
|
ax::DevToolsImpl::getInstance()->resume();
|
2023-09-01 16:31:14 +08:00
|
|
|
}
|
|
|
|
|
2023-09-15 19:33:25 +08:00
|
|
|
void axmol_director_step()
|
2023-09-01 16:31:14 +08:00
|
|
|
{
|
2023-09-15 19:33:25 +08:00
|
|
|
ax::DevToolsImpl::getInstance()->step();
|
2023-09-01 16:31:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-05 22:17:18 +08:00
|
|
|
#endif // AX_TARGET_PLATFORM == AX_PLATFORM_WASM
|