Implement new axmol log system based on fmtlib (#1732)

* Implement new log macros based on fmtlib

* Fix ci

* Fix ci

* Fix android ci

* Fix warnings

* Replace more ax::log by AXLOGX

* Fix ci

* Fix linux build

* Use stack memory for log prefix

* Fix linux build

* Fix warning

* Add ILogOutput support

* Replace old log calls with new log macros

* Fixup

* Fixup

* Fixup

* Update ci msvc to 14.39

* Update Console.h [skip ci]

* Pass log level to ILogOutput
This commit is contained in:
Deal 2024-03-07 08:47:00 +08:00 committed by GitHub
parent 8bf71b1593
commit 5d2c42e73f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
98 changed files with 719 additions and 675 deletions

View File

@ -25,7 +25,7 @@ jobs:
submodules: 'recursive'
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: '14.37'
toolset: '14.39'
arch: 'x64'
- name: Build
shell: pwsh
@ -38,7 +38,7 @@ jobs:
submodules: 'recursive'
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: '14.37'
toolset: '14.39'
arch: 'x64'
- name: Build
shell: pwsh
@ -52,7 +52,7 @@ jobs:
submodules: 'recursive'
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: '14.37'
toolset: '14.39'
arch: 'x64'
uwp: true
- name: Build
@ -80,7 +80,7 @@ jobs:
- name: Build
shell: pwsh
run: .\build.ps1 -p win32 -a 'x64' -cc clang -winsdk $env:WINSDK_VER
run: .\build.ps1 -p win32 -a 'x64' -cc clang -sdk $env:WINSDK_VER
linux:
runs-on: ubuntu-latest
steps:

View File

@ -4,6 +4,7 @@ Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -101,7 +102,7 @@ bool Speed::initWithAction(ActionInterval* action, float speed)
AXASSERT(action != nullptr, "action must not be NULL");
if (action == nullptr)
{
log("Speed::initWithAction error: action is nullptr!");
AXLOGE("Speed::initWithAction error: action is nullptr!");
return false;
}
@ -128,7 +129,8 @@ void Speed::startWithTarget(Node* target)
_innerAction->startWithTarget(target);
}
else
log("Speed::startWithTarget error: target(%p) or _innerAction(%p) is nullptr!", target, _innerAction);
AXLOGE("Speed::startWithTarget error: target({}) or _innerAction({}) is nullptr!", fmt::ptr(target),
fmt::ptr(_innerAction));
}
void Speed::stop()
@ -212,7 +214,7 @@ bool Follow::initWithTargetAndOffset(Node* followedNode, float xOffset, float yO
AXASSERT(followedNode != nullptr, "FollowedNode can't be NULL");
if (followedNode == nullptr)
{
log("Follow::initWithTarget error: followedNode is nullptr!");
AXLOGE("Follow::initWithTarget error: followedNode is nullptr!");
return false;
}

View File

@ -3,6 +3,7 @@ Copyright (c) 2008-2009 Jason Booth
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -78,7 +79,7 @@ void ActionEase::startWithTarget(Node* target)
}
else
{
ax::log("ActionEase::startWithTarget error: target or _inner is nullptr!");
AXLOGE("ActionEase::startWithTarget error: target or _inner is nullptr!");
}
}

View File

@ -241,7 +241,7 @@ bool Sequence::initWithTwoActions(FiniteTimeAction* actionOne, FiniteTimeAction*
AXASSERT(actionTwo != nullptr, "actionTwo can't be nullptr!");
if (actionOne == nullptr || actionTwo == nullptr)
{
log("Sequence::initWithTwoActions error: action is nullptr!!");
AXLOGE("Sequence::initWithTwoActions error: action is nullptr!!");
return false;
}
@ -295,12 +295,12 @@ void Sequence::startWithTarget(Node* target)
{
if (target == nullptr)
{
log("Sequence::startWithTarget error: target is nullptr!");
AXLOGE("Sequence::startWithTarget error: target is nullptr!");
return;
}
if (_actions[0] == nullptr || _actions[1] == nullptr)
{
log("Sequence::startWithTarget error: _actions[0] or _actions[1] is nullptr!");
AXLOGE("Sequence::startWithTarget error: _actions[0] or _actions[1] is nullptr!");
return;
}
if (_duration > FLT_EPSILON)
@ -552,7 +552,7 @@ bool RepeatForever::initWithAction(ActionInterval* action)
AXASSERT(action != nullptr, "action can't be nullptr!");
if (action == nullptr)
{
log("RepeatForever::initWithAction error:action is nullptr!");
AXLOGE("RepeatForever::initWithAction error:action is nullptr!");
return false;
}
@ -697,7 +697,7 @@ bool Spawn::initWithTwoActions(FiniteTimeAction* action1, FiniteTimeAction* acti
AXASSERT(action2 != nullptr, "action2 can't be nullptr!");
if (action1 == nullptr || action2 == nullptr)
{
log("Spawn::initWithTwoActions error: action is nullptr!");
AXLOGE("Spawn::initWithTwoActions error: action is nullptr!");
return false;
}
@ -750,12 +750,12 @@ void Spawn::startWithTarget(Node* target)
{
if (target == nullptr)
{
log("Spawn::startWithTarget error: target is nullptr!");
AXLOGE("Spawn::startWithTarget error: target is nullptr!");
return;
}
if (_one == nullptr || _two == nullptr)
{
log("Spawn::startWithTarget error: _one or _two is nullptr!");
AXLOGE("Spawn::startWithTarget error: _one or _two is nullptr!");
return;
}
@ -1545,7 +1545,7 @@ bool JumpBy::initWithDuration(float duration, const Vec2& position, float height
AXASSERT(jumps >= 0, "Number of jumps must be >= 0");
if (jumps < 0)
{
log("JumpBy::initWithDuration error: Number of jumps must be >= 0");
AXLOGE("JumpBy::initWithDuration error: Number of jumps must be >= 0");
return false;
}
@ -1626,7 +1626,7 @@ bool JumpTo::initWithDuration(float duration, const Vec2& position, float height
AXASSERT(jumps >= 0, "Number of jumps must be >= 0");
if (jumps < 0)
{
log("JumpTo::initWithDuration error:Number of jumps must be >= 0");
AXLOGE("JumpTo::initWithDuration error:Number of jumps must be >= 0");
return false;
}
@ -2002,7 +2002,7 @@ bool Blink::initWithDuration(float duration, int blinks)
AXASSERT(blinks >= 0, "blinks should be >= 0");
if (blinks < 0)
{
log("Blink::initWithDuration error:blinks should be >= 0");
AXLOGE("Blink::initWithDuration error:blinks should be >= 0");
return false;
}
@ -2386,7 +2386,7 @@ bool ReverseTime::initWithAction(FiniteTimeAction* action)
AXASSERT(action != _other, "action doesn't equal to _other!");
if (action == nullptr || action == _other)
{
log("ReverseTime::initWithAction error: action is null or action equal to _other");
AXLOGE("ReverseTime::initWithAction error: action is null or action equal to _other");
return false;
}
@ -2475,7 +2475,7 @@ bool Animate::initWithAnimation(Animation* animation)
AXASSERT(animation != nullptr, "Animate: argument Animation must be non-nullptr");
if (animation == nullptr)
{
log("Animate::initWithAnimation: argument Animation must be non-nullptr");
AXLOGE("Animate::initWithAnimation: argument Animation must be non-nullptr");
return false;
}

View File

@ -251,7 +251,7 @@ void AnimationCache::addAnimationsWithFile(std::string_view plist)
AXASSERT(!plist.empty(), "Invalid texture file name");
if (plist.empty())
{
log("%s error:file name is empty!", __FUNCTION__);
AXLOGE("{} error:file name is empty!", __FUNCTION__);
return;
}
@ -260,7 +260,7 @@ void AnimationCache::addAnimationsWithFile(std::string_view plist)
AXASSERT(!dict.empty(), "CCAnimationCache: File could not be found");
if (dict.empty())
{
log("AnimationCache::addAnimationsWithFile error:%s not exist!", plist.data());
AXLOGE("AnimationCache::addAnimationsWithFile error:{} not exist!", plist);
}
addAnimationsWithDictionary(dict, plist);

View File

@ -483,14 +483,14 @@ std::vector<Vec2> AutoPolygon::reduce(const std::vector<Vec2>& points, const Rec
// if there are less than 3 points, then we have nothing
if (size < 3)
{
log("AUTOPOLYGON: cannot reduce points for %s that has less than 3 points in input, e: %f", _filename.c_str(),
AXLOGE("AUTOPOLYGON: cannot reduce points for {} that has less than 3 points in input, e: {}", _filename,
epsilon);
return std::vector<Vec2>();
}
// if there are less than 9 points (but more than 3), then we don't need to reduce it
else if (size < 9)
{
log("AUTOPOLYGON: cannot reduce points for %s e: %f", _filename.c_str(), epsilon);
AXLOGE("AUTOPOLYGON: cannot reduce points for {} e: {}", _filename, epsilon);
return points;
}
float maxEp = MIN(rect.size.width, rect.size.height);
@ -511,7 +511,7 @@ std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& points, const ax:
// if there are less than 3 points, then we have nothing
if (points.size() < 3)
{
log("AUTOPOLYGON: cannot expand points for %s with less than 3 points, e: %f", _filename.c_str(), epsilon);
AXLOGE("AUTOPOLYGON: cannot expand points for {} with less than 3 points, e: {}", _filename, epsilon);
return std::vector<Vec2>();
}
@ -589,7 +589,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
// if there are less than 3 points, then we can't triangulate
if (points.size() < 3)
{
log("AUTOPOLYGON: cannot triangulate %s with less than 3 points", _filename.c_str());
AXLOGE("AUTOPOLYGON: cannot triangulate {} with less than 3 points", _filename);
return TrianglesCommand::Triangles();
}

View File

@ -64,7 +64,7 @@ void FontAtlas::loadFontAtlas(std::string_view fontatlasFile, hlookup::string_ma
std::string_view type = settings["type"];
if (type != "fontatlas")
{
ax::print("Load fontatlas %s fail, invalid asset type: %s", fontatlasFile.data(), type.data());
AXLOGE("Load fontatlas {} fail, invalid asset type: {}", fontatlasFile, type);
return;
}
@ -76,8 +76,8 @@ void FontAtlas::loadFontAtlas(std::string_view fontatlasFile, hlookup::string_ma
{
if (it->second->getReferenceCount() != 1)
{
ax::print("Load fontatlas %s fail, due to exist fontatlas with same key %s and in used",
fontatlasFile.data(), atlasName.data());
AXLOGE("Load fontatlas {} fail, due to exist fontatlas with same key {} and in used", fontatlasFile,
atlasName);
return;
}
else
@ -90,8 +90,7 @@ void FontAtlas::loadFontAtlas(std::string_view fontatlasFile, hlookup::string_ma
auto font = FontFreeType::create(sourceFont, faceSize, GlyphCollection::DYNAMIC, ""sv, true, 0.0f);
if (!font)
{
ax::print("Load fontatils %s fail due to create source font %s fail", fontatlasFile.data(),
sourceFont.data());
AXLOGE("Load fontatils {} fail due to create source font {} fail", fontatlasFile, sourceFont);
return;
}
@ -121,7 +120,7 @@ void FontAtlas::loadFontAtlas(std::string_view fontatlasFile, hlookup::string_ma
}
catch (std::exception& ex)
{
ax::print("Load fontatils %s fail due to exception occured: %s", fontatlasFile.data(), ex.what());
AXLOGE("Load fontatils {} fail due to exception occured: {}", fontatlasFile, ex.what());
}
}
@ -225,8 +224,8 @@ void FontAtlas::initWithSettings(void* opaque /*simdjson::ondemand::document*/)
std::string strCharCode;
for (auto field : settings["letters"].get_object())
{
strCharCode = static_cast<std::string_view>(field.unescaped_key());
auto letterInfo = field.value();
strCharCode = static_cast<std::string_view>(field.unescaped_key());
auto letterInfo = field.value();
tempDef.U = static_cast<float>(letterInfo["U"].get_double());
tempDef.V = static_cast<float>(letterInfo["V"].get_double());
tempDef.xAdvance = static_cast<float>(letterInfo["advance"].get_double());
@ -362,7 +361,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
for (auto&& charCode : charCodeSet)
{
auto bitmap = _fontFreeType->getGlyphBitmap(charCode, bitmapWidth, bitmapHeight, tempRect, tempDef.xAdvance);
if (bitmap && bitmapWidth > 0 && bitmapHeight > 0)
if (bitmap && bitmapWidth > 0 && bitmapHeight > 0)
{
tempDef.validDefinition = true;
tempDef.width = tempRect.size.width + _letterPadding + _letterEdgeExtend;
@ -390,8 +389,8 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
_currLineHeight = glyphHeight;
}
_fontFreeType->renderCharAt(_currentPageData, (int)_currentPageOrigX + adjustForExtend,
(int)_currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight,
_width, _height);
(int)_currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight,
_width, _height);
tempDef.U = _currentPageOrigX;
tempDef.V = _currentPageOrigY;

View File

@ -303,7 +303,7 @@ bool FontFreeType::loadFontFace(std::string_view fontPath, int faceSize)
FT_Done_Face(face);
ax::log("Init font '%s' failed, only unicode ttf/ttc was supported.", fontPath.data());
AXLOGW("Init font '{}' failed, only unicode ttf/ttc was supported.", fontPath);
return false;
}
@ -406,8 +406,7 @@ unsigned char* FontFreeType::getGlyphBitmap(char32_t charCode,
if (charUTF8 == "\n")
charUTF8 = "\\n";
ax::log("The font face: %s doesn't contains char: <%s>", _fontFace->charmap->face->family_name,
charUTF8.c_str());
AXLOGW("The font face: {} doesn't contains char: <{}>", _fontFace->charmap->face->family_name, charUTF8);
if (_mssingGlyphCharacter != 0)
{

View File

@ -216,7 +216,7 @@ AUDIO_ID AudioEngine::play2d(std::string_view filePath, const AudioPlayerSetting
if (_audioIDInfoMap.size() >= _maxInstances)
{
log("Fail to play %s cause by limited max instance of AudioEngine", filePath.data());
AXLOGE("Fail to play {} cause by limited max instance of AudioEngine", filePath);
break;
}
if (profileHelper)
@ -224,7 +224,7 @@ AUDIO_ID AudioEngine::play2d(std::string_view filePath, const AudioPlayerSetting
if (profileHelper->profile.maxInstances != 0 &&
profileHelper->audioIDs.size() >= profileHelper->profile.maxInstances)
{
log("Fail to play %s cause by limited max instance of AudioProfile", filePath.data());
AXLOGE("Fail to play {} cause by limited max instance of AudioProfile", filePath);
break;
}
if (profileHelper->profile.minDelay > TIME_DELAY_PRECISION)
@ -233,7 +233,7 @@ AUDIO_ID AudioEngine::play2d(std::string_view filePath, const AudioPlayerSetting
if (profileHelper->lastPlayTime > TIME_DELAY_PRECISION &&
currTime - profileHelper->lastPlayTime <= profileHelper->profile.minDelay)
{
log("Fail to play %s cause by limited minimum delay", filePath.data());
AXLOGE("Fail to play {} cause by limited minimum delay", filePath);
break;
}
}
@ -505,7 +505,7 @@ bool AudioEngine::isLoop(AUDIO_ID audioID)
return tmpIterator->second.loop;
}
log("AudioEngine::isLoop-->The audio instance %d is non-existent", audioID);
AXLOGW("AudioEngine::isLoop-->The audio instance {} is non-existent", audioID);
return false;
}
@ -517,7 +517,7 @@ float AudioEngine::getVolume(AUDIO_ID audioID)
return tmpIterator->second.volume;
}
log("AudioEngine::getVolume-->The audio instance %d is non-existent", audioID);
AXLOGW("AudioEngine::getVolume-->The audio instance {} is non-existent", audioID);
return 0.0f;
}

View File

@ -54,85 +54,157 @@
#include "base/UTF8.h"
#include "yasio/xxsocket.hpp"
// !FIXME: the previous version of ax::log not thread safe
// since axmol make it multi-threading safe by default
#if !defined(AX_LOG_MULTITHREAD)
# define AX_LOG_MULTITHREAD 1
#endif
#include "yasio/utils.hpp"
#if !defined(AX_LOG_TO_CONSOLE)
# define AX_LOG_TO_CONSOLE 1
#endif
#define AX_VSNPRINTF_BUFFER_LENGTH 512
NS_AX_BEGIN
extern const char* axmolVersion(void);
#define PROMPT "> "
#define PROMPT "> "
#define DEFAULT_COMMAND_SEPARATOR '|'
static const size_t SEND_BUFSIZ = 512;
/** private functions */
namespace
{
#if defined(__MINGW32__)
// inet
const char* inet_ntop(int af, const void* src, char* dst, int cnt)
{
struct sockaddr_in srcaddr;
memset(&srcaddr, 0, sizeof(struct sockaddr_in));
memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr));
srcaddr.sin_family = af;
if (WSAAddressToStringA((struct sockaddr*)&srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD)&cnt) != 0)
{
return nullptr;
}
return dst;
}
#pragma region The new Log API since axmol-2.1.3
#if defined(_AX_DEBUG) && _AX_DEBUG == 1
static LogLevel s_logLevel = LogLevel::Debug;
#else
static LogLevel s_logLevel = LogLevel::Info;
#endif
//
// Free functions to log
//
static LogFmtFlag s_logFmtFlags = LogFmtFlag::Null;
static ILogOutput* s_logOutput = nullptr;
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32)
void SendLogToWindow(const char* log)
AX_API void setLogLevel(LogLevel level)
{
static const int AXLOG_STRING_TAG = 1;
// Send data as a message
COPYDATASTRUCT myCDS;
myCDS.dwData = AXLOG_STRING_TAG;
myCDS.cbData = (DWORD)strlen(log) + 1;
myCDS.lpData = (PVOID)log;
if (Director::getInstance()->getGLView())
{
HWND hwnd = Director::getInstance()->getGLView()->getWin32Window();
// use non-block version of SendMessage
PostMessage(hwnd, WM_COPYDATA, (WPARAM)(HWND)hwnd, (LPARAM)(LPVOID)&myCDS);
}
s_logLevel = level;
}
AX_API LogLevel getLogLevel()
{
return s_logLevel;
}
AX_API void setLogFmtFlag(LogFmtFlag flags)
{
s_logFmtFlags = flags;
}
AX_API void setLogOutput(ILogOutput* output)
{
s_logOutput = output;
}
AX_API std::string_view makeLogPrefix(LogBufferType&& stack_buffer, LogLevel level)
{
if (s_logFmtFlags != LogFmtFlag::Null)
{
#if defined(_WIN32)
# define xmol_getpid() (uintptr_t)::GetCurrentProcessId()
# define xmol_gettid() (uintptr_t)::GetCurrentThreadId()
# define localtime_r(utc, t) ::localtime_s(t, utc)
#else
# define xmol_getpid() (uintptr_t)::getpid()
# define xmol_gettid() (uintptr_t)::pthread_self()
#endif
} // namespace
static void print_impl(std::string& buf) {
#if AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID
__android_log_print(ANDROID_LOG_DEBUG, "axmol debug info", "%s", buf.c_str());
#elif defined(_WIN32)
buf.push_back('\n');
size_t offset = 0;
if (bitmask::any(s_logFmtFlags, LogFmtFlag::Level))
{
char levelName;
switch (level)
{
case LogLevel::Debug:
levelName = 'D';
break;
case LogLevel::Info:
levelName = 'I';
break;
case LogLevel::Warn:
levelName = 'W';
break;
case LogLevel::Error:
levelName = 'E';
break;
default:
levelName = '?';
}
offset += fmt::format_to_n(stack_buffer.data(), stack_buffer.size(), "{}/", levelName).size;
}
if (bitmask::any(s_logFmtFlags, LogFmtFlag::TimeStamp))
{
struct tm ts = {0};
auto tv_msec = yasio::clock<yasio::system_clock_t>();
auto tv_sec = static_cast<time_t>(tv_msec / std::milli::den);
localtime_r(&tv_sec, &ts);
offset += fmt::format_to_n(stack_buffer.data() + offset, stack_buffer.size() - offset,
"[{}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:03d}]", ts.tm_year + 1900,
ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec,
static_cast<int>(tv_msec % std::milli::den))
.size;
}
if (bitmask::any(s_logFmtFlags, LogFmtFlag::ProcessId))
offset += fmt::format_to_n(stack_buffer.data() + offset, stack_buffer.size() - offset, "[PID:{:x}]",
xmol_getpid())
.size;
if (bitmask::any(s_logFmtFlags, LogFmtFlag::ThreadId))
offset += fmt::format_to_n(stack_buffer.data() + offset, stack_buffer.size() - offset, "[TID:{:x}]",
xmol_gettid())
.size;
return std::string_view{stack_buffer.data(), offset};
}
else
return std::string_view{};
}
AX_DLL void printLog(std::string&& message, LogLevel level, size_t prefixSize, const char* tag)
{
#if defined(__ANDROID__)
struct trim_one_eol
{
explicit trim_one_eol(std::string& v) : value(v)
{
trimed = !v.empty() && v.back() == '\n';
if (trimed)
value.back() = '\0';
}
~trim_one_eol()
{
if (trimed)
value.back() = '\n';
}
operator const char* const() const { return value.c_str(); }
std::string& value;
bool trimed{false};
};
int prio;
switch(level) {
case LogLevel::Info:
prio = ANDROID_LOG_INFO;
break;
case LogLevel::Warn:
prio = ANDROID_LOG_WARN;
break;
case LogLevel::Error:
prio = ANDROID_LOG_ERROR;
break;
default:
prio = ANDROID_LOG_DEBUG;
}
__android_log_print(prio, tag, "%s", static_cast<const char*>(trim_one_eol{message}) + prefixSize);
#else
AX_UNUSED_PARAM(prefixSize);
AX_UNUSED_PARAM(tag);
# if defined(_WIN32)
// print to debugger output window
std::wstring wbuf = ntcvt::from_chars(buf);
std::wstring wbuf = ntcvt::from_chars(message);
OutputDebugStringW(wbuf.c_str());
# if AX_LOG_TO_CONSOLE
# if AX_LOG_TO_CONSOLE
auto hStdout = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdout)
{
@ -142,25 +214,20 @@ static void print_impl(std::string& buf) {
DWORD wcch = static_cast<DWORD>(wbuf.size());
::WriteConsoleW(hStdout, wbuf.c_str(), wcch, nullptr, 0);
}
# endif
# if !AX_LOG_MULTITHREAD
// print to log window
SendLogToWindow(buf.c_str());
# endif
#else
buf.push_back('\n');
# endif
# else
// Linux, Mac, iOS, etc
fprintf(stdout, "%s", buf.c_str());
fprintf(stdout, "%s", message.c_str());
fflush(stdout);
# endif
#endif
#if !AX_LOG_MULTITHREAD
Director::getInstance()->getConsole()->print(buf.c_str());
#endif
if (s_logOutput)
s_logOutput->write(std::move(message), level);
}
#pragma endregion
void print(const char* format, ...)
AX_API void print(const char* format, ...)
{
va_list args;
@ -168,18 +235,7 @@ void print(const char* format, ...)
auto buf = StringUtils::vformat(format, args);
va_end(args);
print_impl(buf);
}
void log(const char* format, ...)
{
va_list args;
va_start(args, format);
auto buf = StringUtils::vformat(format, args);
va_end(args);
print_impl(buf);
printLog(std::move(buf += '\n'), LogLevel::Debug, 0, "axmol debug info");
}
// FIXME: Deprecated
@ -513,19 +569,20 @@ bool Console::listenOnTCP(int port)
return ipsv == ipsv_dual_stack;
});
const char* finalBindAddr = this->_bindAddress.empty() ? (ipsv != ipsv_ipv6 ? "0.0.0.0" : ("::")) : this->_bindAddress.c_str();
const char* finalBindAddr =
this->_bindAddress.empty() ? (ipsv != ipsv_ipv6 ? "0.0.0.0" : ("::")) : this->_bindAddress.c_str();
ip::endpoint ep{finalBindAddr, static_cast<u_short>(port)};
if (sock.pserve(ep) != 0)
{
int ec = xxsocket::get_last_errno();
ax::print("Console: open server failed, ec:%d", ec);
AXLOGW("Console: open server failed, ec:{}", ec);
return false;
}
if (ep.af() == AF_INET)
ax::print("Console: IPV4 server is listening on %s", ep.to_string().c_str());
AXLOGI("Console: IPV4 server is listening on {}", ep.to_string());
else if (ep.af() == AF_INET6)
ax::print("Console: IPV6 server is listening on %s", ep.to_string().c_str());
AXLOGI("Console: IPV6 server is listening on {}", ep.to_string());
return listenOnFileDescriptor(sock.release_handle());
}
@ -534,7 +591,7 @@ bool Console::listenOnFileDescriptor(int fd)
{
if (_running)
{
ax::print("Console already started. 'stop' it before calling 'listen' again");
AXLOGW("Console already started. 'stop' it before calling 'listen' again");
return false;
}
@ -636,16 +693,6 @@ void Console::delSubCommand(Command& cmd, std::string_view subCmdName)
cmd.delSubCommand(subCmdName);
}
void Console::print(const char* buf)
{
if (_sendDebugStrings)
{
_DebugStringsMutex.lock();
_DebugStrings.emplace_back(buf);
_DebugStringsMutex.unlock();
}
}
void Console::setBindAddress(std::string_view address)
{
_bindAddress = address;
@ -675,7 +722,7 @@ void Console::loop()
{
/* error */
if (errno != EINTR)
ax::print("Abnormal error in poll_io()\n");
AXLOGW("Abnormal error in poll_io()\n");
continue;
}
else if (nready == 0)
@ -713,7 +760,7 @@ void Console::loop()
int n = 0;
if (ioctl(fd, FIONREAD, &n) < 0)
{
ax::log("Abnormal error in ioctl()\n");
AXLOGE("Abnormal error in ioctl()\n");
break;
}
#endif
@ -1236,7 +1283,7 @@ void Console::commandResolution(socket_native_type /*fd*/, std::string_view args
Scheduler* sched = Director::getInstance()->getScheduler();
sched->runOnAxmolThread([=]() {
Director::getInstance()->getGLView()->setDesignResolutionSize(width, height,
static_cast<ResolutionPolicy>(policy));
static_cast<ResolutionPolicy>(policy));
});
}

View File

@ -42,24 +42,96 @@ typedef SSIZE_T ssize_t;
#include <functional>
#include <string>
#include <mutex>
#include <array>
#include <stdarg.h>
#include "yasio/io_watcher.hpp"
#include "base/Ref.h"
#include "base/Macros.h"
#include "base/bitmask.h"
#include "platform/PlatformMacros.h"
#include "fmt/compile.h"
NS_AX_BEGIN
/// The max length of CCLog message.
static const int MAX_LOG_LENGTH = 16 * 1024;
#pragma region The new Log API since axmol-2.1.3
enum class LogLevel
{
Debug,
Info,
Warn,
Error,
Silent /* only for setLogLevel(); must be last */
};
enum class LogFmtFlag
{
Null,
Level = 1,
TimeStamp = 1 << 1,
ProcessId = 1 << 2,
ThreadId = 1 << 3,
Full = Level | TimeStamp | ProcessId | ThreadId,
};
AX_ENABLE_BITMASK_OPS(LogFmtFlag);
class ILogOutput
{
public:
virtual ~ILogOutput() {}
virtual void write(std::string&&, LogLevel) = 0;
};
/* @brief control log level */
AX_API void setLogLevel(LogLevel level);
AX_API LogLevel getLogLevel();
/* @brief control log prefix format */
AX_API void setLogFmtFlag(LogFmtFlag flags);
/* @brief set log output */
AX_API void setLogOutput(ILogOutput* output);
/*
* @brief lowlevel print log message
* @param message the message to print
* @level the level of current log item see also LogLevel
* @prefixSize the prefix size
* @tag optional, the log tag of current log item
*/
AX_API void printLog(std::string&& message, LogLevel level, size_t prefixSize, const char* tag);
template <typename _FmtType, typename... _Types>
inline void printLogT(LogLevel level, _FmtType&& fmt, std::string_view prefix, _Types&&... args)
{
if (getLogLevel() <= level)
{
auto message = fmt::format(std::forward<_FmtType>(fmt), prefix, std::forward<_Types>(args)...);
printLog(std::move(message), level, prefix.size(), "axmol");
}
}
using LogBufferType = std::array<char, 128>;
// for internal use make log prefix: D/[2024-02-29 00:00:00.123][PID:][TID:]
AX_API std::string_view makeLogPrefix(LogBufferType&& stack_buffer, LogLevel level);
#define AXLOG_WITH_LEVEL(level, fmtOrMsg, ...) \
ax::printLogT(level, FMT_COMPILE("{}" fmtOrMsg "\n"), ax::makeLogPrefix(ax::LogBufferType{}, level), ##__VA_ARGS__)
#define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGI(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Info, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGW(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Warn, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGE(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Error, fmtOrMsg, ##__VA_ARGS__)
#pragma endregion
/**
@brief Output Debug message.
*/
void AX_DLL print(const char* format, ...) AX_FORMAT_PRINTF(1, 2);
/* AX_DEPRECATED_ATTRIBUTE*/ void AX_DLL log(const char* format, ...) AX_FORMAT_PRINTF(1, 2); // use print instead
/* AX_DEPRECATED_ATTRIBUTE*/ AX_API void print(const char* format, ...) AX_FORMAT_PRINTF(1, 2); // use AXLOGD instead
/** Console is helper class that lets the developer control the game from TCP connection.
Console will spawn a new thread that will listen to a specified TCP port.
@ -196,11 +268,6 @@ public:
void delSubCommand(std::string_view cmdName, std::string_view subCmdName);
void delSubCommand(Command& cmd, std::string_view subCmdName);
/** print something in the console */
void print(const char* buf);
AX_DEPRECATED_ATTRIBUTE void log(const char* buf) { print(buf); }
/**
* set bind address
*

View File

@ -2,6 +2,7 @@
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -154,7 +155,7 @@ void Controller::startDiscoveryController()
if (iter == s_allController.end())
{
log("disconnect:Could not find the controller");
AXLOGW("disconnect:Could not find the controller");
return;
}
@ -317,7 +318,7 @@ void Controller::registerListeners()
if (iter == s_allController.end())
{
log("Could not find the controller");
AXLOGW("Could not find the controller");
return;
}

View File

@ -401,7 +401,7 @@ void Director::setGLView(GLView* glView)
// Configuration. Gather GPU info
Configuration* conf = Configuration::getInstance();
conf->gatherGPUInfo();
AXLOG("%s\n", conf->getInfo().c_str());
AXLOGI("{}\n", conf->getInfo());
if (_glView)
_glView->release();
@ -680,7 +680,7 @@ void Director::purgeCachedData()
// Note: some tests such as ActionsTest are leaking refcounted textures
// There should be no test textures left in the cache
log("%s\n", _textureCache->getCachedTextureInfo().c_str());
AXLOGI("{}\n", _textureCache->getCachedTextureInfo());
}
FileUtils::getInstance()->purgeCachedEntries();
}

View File

@ -1395,10 +1395,10 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(std::string_view li
});
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
log("-----------------------------------");
AXLOGI("-----------------------------------");
for (auto&& l : *sceneGraphListeners)
{
log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node,
AXLOGI("listener priority: node ([{}]{}), priority ({})", typeid(*l->_node).name(), l->_node,
_nodePriorityMap[l->_node]);
}
#endif
@ -1433,10 +1433,10 @@ void EventDispatcher::sortEventListenersOfFixedPriority(std::string_view listene
listeners->setGt0Index(index);
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
log("-----------------------------------");
AXLOGI("-----------------------------------");
for (auto&& l : *fixedListeners)
{
log("listener priority: node (%p), fixed (%d)", l->_node, l->_fixedPriority);
AXLOGI("listener priority: node ({}), fixed ({})", l->_node, l->_fixedPriority);
}
#endif
}

View File

@ -41,16 +41,16 @@ THE SOFTWARE.
# if _AX_DEBUG > 0
# if AX_ENABLE_SCRIPT_BINDING
extern bool AX_DLL cc_assert_script_compatible(const char* msg);
# define AXASSERT(cond, msg) \
do \
{ \
if (!(cond)) \
{ \
const char* m = (msg); \
if (m && *m && !cc_assert_script_compatible(m)) \
ax::log("Assert failed: %s", m); \
AX_ASSERT(cond); \
} \
# define AXASSERT(cond, msg) \
do \
{ \
if (!(cond)) \
{ \
const char* m = (msg); \
if (m && *m && !cc_assert_script_compatible(m)) \
AXLOGE("Assert failed: {}", m); \
AX_ASSERT(cond); \
} \
} while (0)
# else
# define AXASSERT(cond, msg) AX_ASSERT(cond)
@ -69,7 +69,7 @@ extern bool AX_DLL cc_assert_script_compatible(const char* msg);
#include "base/Random.h"
#define AX_HALF_PI (M_PI * 0.5f)
#define AX_HALF_PI (M_PI * 0.5f)
#define AX_DOUBLE_PI (M_PI * 2)
@ -86,15 +86,15 @@ extern bool AX_DLL cc_assert_script_compatible(const char* msg);
/** @def AX_DEGREES_TO_RADIANS
converts degrees to radians
*/
#define AX_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__)*0.01745329252f) // PI / 180
#define AX_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f) // PI / 180
/** @def AX_RADIANS_TO_DEGREES
converts radians to degrees
*/
#define AX_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__)*57.29577951f) // PI * 180
#define AX_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) // PI * 180
#define AX_REPEAT_FOREVER (UINT_MAX - 1)
#define kRepeatForever AX_REPEAT_FOREVER
#define AX_REPEAT_FOREVER (UINT_MAX - 1)
#define kRepeatForever AX_REPEAT_FOREVER
/** @def AX_BLEND_SRC
default gl blend src function. Compatible with premultiplied alpha images.
@ -114,11 +114,11 @@ default gl blend src function. Compatible with premultiplied alpha images.
@since v0.99.4
*/
#define AX_DIRECTOR_END() \
do \
{ \
#define AX_DIRECTOR_END() \
do \
{ \
auto __director = ax::Director::getInstance(); \
__director->end(); \
__director->end(); \
} while (0)
/** @def AX_CONTENT_SCALE_FACTOR
@ -134,20 +134,20 @@ On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
/** @def AX_RECT_PIXELS_TO_POINTS
Converts a rect in pixels to points
*/
#define AX_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) \
#define AX_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) \
ax::Rect((__rect_in_pixels__).origin.x / AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_pixels__).origin.y / AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_pixels__).size.width / AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_pixels__).size.height / AX_CONTENT_SCALE_FACTOR())
(__rect_in_pixels__).origin.y / AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_pixels__).size.width / AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_pixels__).size.height / AX_CONTENT_SCALE_FACTOR())
/** @def AX_RECT_POINTS_TO_PIXELS
Converts a rect in points to pixels
*/
#define AX_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) \
#define AX_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) \
ax::Rect((__rect_in_points_points__).origin.x* AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_points_points__).origin.y* AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_points_points__).size.width* AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_points_points__).size.height* AX_CONTENT_SCALE_FACTOR())
(__rect_in_points_points__).origin.y* AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_points_points__).size.width* AX_CONTENT_SCALE_FACTOR(), \
(__rect_in_points_points__).size.height* AX_CONTENT_SCALE_FACTOR())
/** @def AX_POINT_PIXELS_TO_POINTS
Converts a rect in pixels to points
@ -164,15 +164,16 @@ On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
/** @def AX_POINT_PIXELS_TO_POINTS
Converts a rect in pixels to points
*/
#define AX_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \
#define AX_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \
ax::Vec2((__size_in_pixels__).width / AX_CONTENT_SCALE_FACTOR(), \
(__size_in_pixels__).height / AX_CONTENT_SCALE_FACTOR())
(__size_in_pixels__).height / AX_CONTENT_SCALE_FACTOR())
/** @def AX_POINT_POINTS_TO_PIXELS
Converts a rect in points to pixels
*/
#define AX_SIZE_POINTS_TO_PIXELS(__size_in_points__) \
ax::Vec2((__size_in_points__).width* AX_CONTENT_SCALE_FACTOR(), (__size_in_points__).height* AX_CONTENT_SCALE_FACTOR())
#define AX_SIZE_POINTS_TO_PIXELS(__size_in_points__) \
ax::Vec2((__size_in_points__).width* AX_CONTENT_SCALE_FACTOR(), \
(__size_in_points__).height* AX_CONTENT_SCALE_FACTOR())
#ifndef FLT_EPSILON
# define FLT_EPSILON 1.192092896e-07F
@ -190,13 +191,13 @@ It should work same as apples CFSwapInt32LittleToHost(..)
*/
/// when define returns true it means that our architecture uses big endian
#define AX_HOST_IS_BIG_ENDIAN (bool)(*(unsigned short*)"\0\xff" < 0x100)
#define AX_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define AX_SWAP16(i) ((i & 0x00ff) << 8 | (i & 0xff00) >> 8)
#define AX_HOST_IS_BIG_ENDIAN (bool)(*(unsigned short*)"\0\xff" < 0x100)
#define AX_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define AX_SWAP16(i) ((i & 0x00ff) << 8 | (i & 0xff00) >> 8)
#define AX_SWAP_INT32_LITTLE_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? AX_SWAP32(i) : (i))
#define AX_SWAP_INT16_LITTLE_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? AX_SWAP16(i) : (i))
#define AX_SWAP_INT32_BIG_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? (i) : AX_SWAP32(i))
#define AX_SWAP_INT16_BIG_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? (i) : AX_SWAP16(i))
#define AX_SWAP_INT32_BIG_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? (i) : AX_SWAP32(i))
#define AX_SWAP_INT16_BIG_TO_HOST(i) ((AX_HOST_IS_BIG_ENDIAN == true) ? (i) : AX_SWAP16(i))
/**********************/
/** Profiling Macros **/
@ -204,11 +205,11 @@ It should work same as apples CFSwapInt32LittleToHost(..)
#if AX_ENABLE_PROFILERS
# define AX_PROFILER_DISPLAY_TIMERS() NS_AX::Profiler::getInstance()->displayTimers()
# define AX_PROFILER_PURGE_ALL() NS_AX::Profiler::getInstance()->releaseAllTimers()
# define AX_PROFILER_PURGE_ALL() NS_AX::Profiler::getInstance()->releaseAllTimers()
# define AX_PROFILER_START(__name__) NS_AX::ProfilingBeginTimingBlock(__name__)
# define AX_PROFILER_STOP(__name__) NS_AX::ProfilingEndTimingBlock(__name__)
# define AX_PROFILER_RESET(__name__) NS_AX::ProfilingResetTimingBlock(__name__)
# define AX_PROFILER_START(__name__) NS_AX::ProfilingBeginTimingBlock(__name__)
# define AX_PROFILER_STOP(__name__) NS_AX::ProfilingEndTimingBlock(__name__)
# define AX_PROFILER_RESET(__name__) NS_AX::ProfilingResetTimingBlock(__name__)
# define AX_PROFILER_START_CATEGORY(__cat__, __name__) \
do \
@ -349,7 +350,7 @@ It should work same as apples CFSwapInt32LittleToHost(..)
#define AX_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(__drawcalls__, __vertices__) \
do \
{ \
auto __renderer__ = ax::Director::getInstance()->getRenderer(); \
auto __renderer__ = ax::Director::getInstance() -> getRenderer(); \
__renderer__->addDrawnBatches(__drawcalls__); \
__renderer__->addDrawnVertices(__vertices__); \
} while (0)

View File

@ -3,6 +3,7 @@ Copyright (c) 2010 Stuart Carnie
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -81,7 +82,7 @@ void Profiler::displayTimers()
for (auto&& iter : _activeTimers)
{
ProfilingTimer* timer = iter.second;
log("%s", timer->getDescription().c_str());
AXLOGI("{}", timer->getDescription());
}
}

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2017 Chukong Technologies
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -156,17 +157,17 @@ void Ref::printLeaks()
// Dump Ref object memory leaks
if (__refAllocationList.empty())
{
log("[memory] All Ref objects successfully cleaned up (no leaks detected).\n");
AXLOGI("[memory] All Ref objects successfully cleaned up (no leaks detected).\n");
}
else
{
log("[memory] WARNING: %d Ref objects still active in memory.\n", (int)__refAllocationList.size());
AXLOGI("[memory] WARNING: {} Ref objects still active in memory.\n", (int)__refAllocationList.size());
for (const auto& ref : __refAllocationList)
{
AX_ASSERT(ref);
const char* type = typeid(*ref).name();
log("[memory] LEAK: Ref object '%s' still active with reference count %d.\n", (type ? type : ""),
AXLOGI("[memory] LEAK: Ref object '{}' still active with reference count {}.\n", (type ? type : ""),
ref->getReferenceCount());
}
}
@ -187,7 +188,7 @@ static void untrackRef(Ref* ref)
auto iter = std::find(__refAllocationList.begin(), __refAllocationList.end(), ref);
if (iter == __refAllocationList.end())
{
log("[memory] CORRUPTION: Attempting to free (%s) with invalid ref tracking record.\n", typeid(*ref).name());
AXLOGI("[memory] CORRUPTION: Attempting to free ({}) with invalid ref tracking record.\n", typeid(*ref).name());
return;
}

View File

@ -379,7 +379,7 @@ void UserDefault::lazyInit()
// construct file mapping
if (!_fileStream.open(_filePath, IFileStream::Mode::OVERLAPPED))
{
log("[Warning] UserDefault::init open storage file '%s' failed!", _filePath.c_str());
AXLOGW("UserDefault::init open storage file '{}' failed!", _filePath);
return;
}
@ -389,7 +389,7 @@ void UserDefault::lazyInit()
{ // construct a empty file mapping
if (!_fileStream.resize(_curMapSize))
{
log("[Warning] UserDefault::init failed to truncate '%s'.", _filePath.c_str());
AXLOGW("UserDefault::init failed to truncate '{}'.", _filePath);
return;
}
_rwmmap = std::make_shared<mio::mmap_sink>(_fileStream.nativeHandle(), 0, _curMapSize);
@ -429,9 +429,9 @@ void UserDefault::lazyInit()
{
closeFileMapping();
::remove(_filePath.c_str());
log("[Warning] UserDefault::init map file '%s' failed, we can't save data persisit this time, next time "
AXLOGW("UserDefault::init map file '{}' failed, we can't save data persisit this time, next time "
"we will retry!",
_filePath.c_str());
_filePath);
}
}
#else
@ -450,7 +450,7 @@ void UserDefault::lazyInit()
}
else
{
log("UserDefault::init load xml file: %s failed, %s", _filePath.c_str(), ret.description());
AXLOGE("UserDefault::init load xml file: {} failed, {}", _filePath, ret.description());
}
}
@ -488,7 +488,7 @@ void UserDefault::flush()
_curMapSize <<= 1; // X2
if (!_fileStream.resize(_curMapSize))
ax::log("[Warning] UserDefault::flush failed to truncate '%s'.", _filePath.c_str());
AXLOGW("UserDefault::flush failed to truncate '{}'.", _filePath);
_rwmmap->map(_fileStream.nativeHandle(), 0, _curMapSize, error);
}

View File

@ -278,13 +278,13 @@ int astc_decompress_image(const uint8_t* in,
benchmark_printer(const char* fmt, int w, int h, float den)
: _fmt(fmt), _w(w), _h(h), _den(den), _start(yasio::highp_clock())
{}
~benchmark_printer() { ax::log(_fmt, _w, _h, (yasio::highp_clock() - _start) / _den); }
~benchmark_printer() { AXLOGI(_fmt, _w, _h, (yasio::highp_clock() - _start) / _den); }
const char* _fmt;
int _w, _h;
float _den;
yasio::highp_time_t _start;
};
benchmark_printer __printer("decompress astc image (%dx%d) cost: %.3lf(ms)", dim_x, dim_y, (float)std::milli::den);
benchmark_printer __printer("decompress astc image ({}x{}) cost: {}(ms)", dim_x, dim_y, (float)std::milli::den);
#endif
return astc_decompress_job_manager::get_instance()->decompress_parallel_sync(in, inlen, out, dim_x, dim_y, block_x,
block_y);

View File

@ -168,7 +168,7 @@ VlcMediaEngine::VlcMediaEngine()
_vlc = libvlc_new(0, nullptr);
if (!_vlc)
{
ax::print("VlcMediaEngine: libvlc_new fail, ensure install vlc and ubuntu-restricted-extras");
AXLOGI("VlcMediaEngine: libvlc_new fail, ensure install vlc and ubuntu-restricted-extras");
return;
}
@ -312,7 +312,7 @@ bool VlcMediaEngine::updatePlaybackProperties()
if (track->i_type == libvlc_track_video)
{
track_codec_to_mime_type(track, _videoCodecMimeType);
ax::print("VlcMediaEngine: sourceUri: %s, codec: %s", _sourceUri.c_str(), _videoCodecMimeType.c_str());
AXLOGD("VlcMediaEngine: sourceUri: {}, codec: {}", _sourceUri, _videoCodecMimeType);
auto vdi = track->video;
_videoDim.set(vdi->i_width, vdi->i_height);
@ -329,7 +329,7 @@ bool VlcMediaEngine::updatePlaybackProperties()
{
auto track = libvlc_media_tracklist_at(tracks, 0);
track_codec_to_mime_type(track, _videoCodecMimeType);
ax::print("VlcMediaEngine: sourceUri: %s, codec: %s", _sourceUri.c_str(), _videoCodecMimeType.c_str());
AXLOGI("VlcMediaEngine: sourceUri: {}, codec: {}", _sourceUri, _videoCodecMimeType);
auto vdi = track->video;
_videoDim.set(vdi->i_width, vdi->i_height);

View File

@ -83,7 +83,7 @@ public:
{
_initInternal();
DLLOG("Construct DownloadTaskCURL %p", this);
AXLOGD("Construct DownloadTaskCURL {}", fmt::ptr(this));
}
virtual ~DownloadTaskCURL()
@ -104,7 +104,7 @@ public:
if (_requestHeaders)
curl_slist_free_all(_requestHeaders);
DLLOG("Destruct DownloadTaskCURL %p", this);
AXLOGD("Destruct DownloadTaskCURL {}", fmt::ptr(this));
}
bool init(std::string_view filename, std::string_view tempSuffix)
@ -369,10 +369,10 @@ public:
Impl()
// : _thread(nullptr)
{
DLLOG("Construct DownloaderCURL::Impl %p", this);
AXLOGD("Construct DownloaderCURL::Impl {}", fmt::ptr(this));
}
~Impl() { DLLOG("Destruct DownloaderCURL::Impl %p", this); }
~Impl() { AXLOGD("Destruct DownloaderCURL::Impl {}", fmt::ptr(this)); }
void addTask(std::shared_ptr<DownloadTask> task, DownloadTaskCURL* coTask)
{
@ -454,7 +454,7 @@ private:
static size_t _outputHeaderCallbackProc(void* buffer, size_t size, size_t count, void* userdata)
{
int strLen = int(size * count);
DLLOG(" _outputHeaderCallbackProc: %.*s", strLen, buffer);
AXLOGD(" _outputHeaderCallbackProc: {} {}", strLen, buffer);
DownloadTaskCURL& coTask = *((DownloadTaskCURL*)(userdata));
coTask._header.append((const char*)buffer, strLen);
return strLen;
@ -462,7 +462,7 @@ private:
static size_t _outputDataCallbackProc(void* buffer, size_t size, size_t count, void* userdata)
{
// DLLOG(" _outputDataCallbackProc: size(%ld), count(%ld)", size, count);
// AXLOGD(" _outputDataCallbackProc: size({}), count({})", size, count);
DownloadTaskCURL* coTask = (DownloadTaskCURL*)userdata;
// If your callback function returns CURL_WRITEFUNC_PAUSE it will cause this transfer to become paused.
@ -646,7 +646,7 @@ private:
void _threadProc()
{
DLLOG("++++DownloaderCURL::Impl::_threadProc begin %p", this);
AXLOGD("++++DownloaderCURL::Impl::_threadProc begin {}", fmt::ptr(this));
// the holder prevent DownloaderCURL::Impl class instance be destruct in main thread
auto holder = this->shared_from_this();
auto thisThreadId = std::this_thread::get_id();
@ -716,7 +716,7 @@ private:
if (rc < 0)
{
DLLOG(" _threadProc: select return unexpect code: %d", rc);
AXLOGD(" _threadProc: select return unexpect code: {}", rc);
}
}
@ -806,7 +806,7 @@ private:
continue;
}
curl_easy_cleanup(curlHandle);
DLLOG(" _threadProc task clean cur handle :%p with errCode:%d", curlHandle, errCode);
AXLOGD(" _threadProc task clean cur handle :{} with errCode:{}", fmt::ptr(curlHandle), static_cast<int>(errCode));
// remove from coTaskMap
coTaskMap.erase(curlHandle);
@ -877,7 +877,7 @@ private:
continue;
}
DLLOG(" _threadProc task create curl handle:%p", curlHandle);
AXLOGD(" _threadProc task create curl handle:{}", fmt::ptr(curlHandle));
coTaskMap[curlHandle] = task;
std::lock_guard<std::mutex> lock(_processMutex);
_processSet.insert(task);
@ -887,7 +887,7 @@ private:
_tasksFinished = true;
curl_multi_cleanup(curlmHandle);
DLLOG("----DownloaderCURL::Impl::_threadProc end");
AXLOGD("----DownloaderCURL::Impl::_threadProc end");
}
std::thread _thread;
@ -909,7 +909,7 @@ public:
// Implementation DownloaderCURL
DownloaderCURL::DownloaderCURL(const DownloaderHints& hints) : _impl(std::make_shared<Impl>()), _currTask(nullptr)
{
DLLOG("Construct DownloaderCURL %p", this);
AXLOGD("Construct DownloaderCURL {}", fmt::ptr(this));
_impl->hints = hints;
_impl->_owner = this;
@ -935,7 +935,7 @@ DownloaderCURL::~DownloaderCURL()
_scheduler->release();
}
_impl->stop();
DLLOG("Destruct DownloaderCURL %p", this);
AXLOGD("Destruct DownloaderCURL {}", fmt::ptr(this));
}
void DownloaderCURL::startTask(std::shared_ptr<DownloadTask>& task)
@ -944,7 +944,7 @@ void DownloaderCURL::startTask(std::shared_ptr<DownloadTask>& task)
task->_coTask.reset(coTask); // coTask auto managed by task
if (coTask->init(task->storagePath, _impl->hints.tempFileNameSuffix))
{
DLLOG("DownloaderCURL: createTask: Id(%d)", coTask->serialId);
AXLOGD("DownloaderCURL: createTask: Id({})", coTask->serialId);
_impl->addTask(task, coTask);
_impl->run();
@ -957,8 +957,8 @@ void DownloaderCURL::startTask(std::shared_ptr<DownloadTask>& task)
}
else
{
ax::log("DownloaderCURL createTask fail, error: %d, detail: %s", coTask->_errCode,
coTask->_errDescription.c_str());
AXLOGE("DownloaderCURL createTask fail, error: {}, detail: {}", coTask->_errCode,
coTask->_errDescription);
task.reset();
}
}
@ -1134,7 +1134,7 @@ void DownloaderCURL::_onDownloadFinished(DownloadTask& task, int checkState)
// needn't lock coTask here, because tasks has removed form _impl
onTaskFinish(task, coTask._errCode, coTask._errCodeInternal, coTask._errDescription, coTask._buf);
DLLOG(" DownloaderCURL: finish Task: Id(%d)", coTask.serialId);
AXLOGD(" DownloaderCURL: finish Task: Id({})", coTask.serialId);
}
} // namespace network

View File

@ -41,11 +41,11 @@ namespace ax { namespace network {
,bytesReceived(0)
,fetch(NULL)
{
DLLOG("Construct DownloadTaskEmscripten: %p", this);
AXLOGD("Construct DownloadTaskEmscripten: {}", fmt::ptr(this));
}
virtual ~DownloadTaskEmscripten()
{
DLLOG("Destruct DownloadTaskEmscripten: %p", this);
AXLOGD("Destruct DownloadTaskEmscripten: {}", fmt::ptr(this));
}
int bytesReceived;
@ -58,12 +58,12 @@ namespace ax { namespace network {
: _id(++sDownloaderCounter)
, hints(hints)
{
DLLOG("Construct DownloaderEmscripten: %p", this);
AXLOGD("Construct DownloaderEmscripten: {}", fmt::ptr(this));
}
DownloaderEmscripten::~DownloaderEmscripten()
{
DLLOG("Destruct DownloaderEmscripten: %p", this);
AXLOGD("Destruct DownloaderEmscripten: {}", fmt::ptr(this));
for (auto iter = _taskMap.begin(); iter != _taskMap.end(); ++iter)
{
if(iter->second->fetch != NULL) {
@ -92,7 +92,7 @@ namespace ax { namespace network {
DownloadTaskEmscripten *coTask = new DownloadTaskEmscripten(fetch->id);
coTask->task = task;
DLLOG("DownloaderEmscripten::createCoTask id: %d", coTask->id);
AXLOGD("DownloaderEmscripten::createCoTask id: {}", coTask->id);
_taskMap.insert(make_pair(coTask->id, coTask));
}
@ -100,12 +100,12 @@ namespace ax { namespace network {
{
unsigned int taskId = fetch->id;
uint64_t size = fetch->numBytes;
DLLOG("DownloaderEmscripten::onDataLoad(taskId: %d, size: %d)", taskId, size);
AXLOGD("DownloaderEmscripten::onDataLoad(taskId: {}, size: {})", taskId, size);
DownloaderEmscripten* downloader = reinterpret_cast<DownloaderEmscripten*>(fetch->userData);
auto iter = downloader->_taskMap.find(taskId);
if (downloader->_taskMap.end() == iter)
{
DLLOG("DownloaderEmscripten::onDataLoad can't find task with id: %i, size: %i", taskId, size);
AXLOGD("DownloaderEmscripten::onDataLoad can't find task with id: {}, size: {}", taskId, size);
return;
}
DownloadTaskEmscripten *coTask = iter->second;
@ -128,12 +128,12 @@ namespace ax { namespace network {
{
unsigned int taskId = fetch->id;
uint64_t size = fetch->numBytes;
DLLOG("DownloaderEmscripten::onLoad(taskId: %i, size: %i)", taskId, size);
AXLOGD("DownloaderEmscripten::onLoad(taskId: {}, size: {})", taskId, size);
DownloaderEmscripten* downloader = reinterpret_cast<DownloaderEmscripten*>(fetch->userData);
auto iter = downloader->_taskMap.find(taskId);
if (downloader->_taskMap.end() == iter)
{
DLLOG("DownloaderEmscripten::onLoad can't find task with id: %i, size: %i", taskId, size);
AXLOGD("DownloaderEmscripten::onLoad can't find task with id: {}, size: {}", taskId, size);
return;
}
DownloadTaskEmscripten *coTask = iter->second;
@ -214,17 +214,17 @@ namespace ax { namespace network {
uint64_t dlTotal = fetch->totalBytes;
uint64_t dlNow = fetch->dataOffset;
unsigned int taskId = fetch->id;
DLLOG("DownloaderEmscripten::onProgress(taskId: %i, dlnow: %d, dltotal: %d)", taskId, dlNow, dlTotal);
AXLOGD("DownloaderEmscripten::onProgress(taskId: {}, dlnow: {}, dltotal: {})", taskId, dlNow, dlTotal);
DownloaderEmscripten* downloader = reinterpret_cast<DownloaderEmscripten*>(fetch->userData);
auto iter = downloader->_taskMap.find(taskId);
if (downloader->_taskMap.end() == iter)
{
DLLOG("DownloaderEmscripten::onProgress can't find task with id: %i", taskId);
AXLOGD("DownloaderEmscripten::onProgress can't find task with id: {}", taskId);
return;
}
if (dlTotal == 0) {
DLLOG("DownloaderEmscripten::onProgress dlTotal unknown, usually caused by unknown content-length header %i", taskId);
AXLOGD("DownloaderEmscripten::onProgress dlTotal unknown, usually caused by unknown content-length header {}", taskId);
return;
}
@ -238,13 +238,13 @@ namespace ax { namespace network {
void DownloaderEmscripten::onError(emscripten_fetch_t *fetch)
{
unsigned int taskId = fetch->id;
DLLOG("DownloaderEmscripten::onLoad(taskId: %i)", taskId);
AXLOGD("DownloaderEmscripten::onLoad(taskId: {})", taskId);
DownloaderEmscripten* downloader = reinterpret_cast<DownloaderEmscripten*>(fetch->userData);
auto iter = downloader->_taskMap.find(taskId);
if (downloader->_taskMap.end() == iter)
{
emscripten_fetch_close(fetch);
DLLOG("DownloaderEmscripten::onLoad can't find task with id: %i", taskId);
AXLOGD("DownloaderEmscripten::onLoad can't find task with id: {}", taskId);
return;
}
DownloadTaskEmscripten *coTask = iter->second;

View File

@ -41,7 +41,7 @@ namespace network
DownloadTask::DownloadTask()
{
DLLOG("Construct DownloadTask %p", this);
AXLOGD("Construct DownloadTask {}", fmt::ptr(this));
}
DownloadTask::DownloadTask(std::string_view srcUrl, std::string_view identifier)
@ -68,7 +68,7 @@ DownloadTask::DownloadTask(std::string_view srcUrl,
DownloadTask::~DownloadTask()
{
DLLOG("Destruct DownloadTask %p", this);
AXLOGD("Destruct DownloadTask {}", fmt::ptr(this));
}
void DownloadTask::cancel()
@ -83,7 +83,7 @@ Downloader::Downloader() : Downloader(DownloaderHints{6, 45, ".tmp"}) {}
Downloader::Downloader(const DownloaderHints& hints)
{
DLLOG("Construct Downloader %p", this);
AXLOGD("Construct Downloader {}", fmt::ptr(this));
_impl.reset(new DownloaderImpl(hints));
_impl->onTaskProgress = [this](const DownloadTask& task,
std::function<int64_t(void* buffer, int64_t len)>& /*transferDataToBuffer*/) {
@ -125,7 +125,7 @@ Downloader::Downloader(const DownloaderHints& hints)
Downloader::~Downloader()
{
DLLOG("Destruct Downloader %p", this);
AXLOGD("Destruct Downloader {}", fmt::ptr(this));
}
std::shared_ptr<DownloadTask> Downloader::createDownloadDataTask(std::string_view srcUrl,

View File

@ -32,16 +32,6 @@
#include "base/Console.h"
// #define AX_DOWNLOADER_DEBUG
#if defined(AX_DOWNLOADER_DEBUG) || defined(_DEBUG)
# define DLLOG(format, ...) ax::log(format, ##__VA_ARGS__)
#else
# define DLLOG(...) \
do \
{ \
} while (0)
#endif
NS_AX_BEGIN
namespace network

View File

@ -546,7 +546,7 @@ void WebSocket::handleNetworkEvent(yasio::io_event* event)
else
{
if (!_responseData.empty())
ax::print("WebSocket: handshake fail, detail: %s", _responseData.c_str());
AXLOGE("WebSocket: handshake fail, detail: {}", _responseData);
//_state = State::CLOSING;
_service->close(channelIndex);

View File

@ -359,7 +359,7 @@ GLViewImpl::GLViewImpl(bool initglfw)
GLViewImpl::~GLViewImpl()
{
AXLOGINFO("deallocing GLViewImpl: %p", this);
AXLOGI("deallocing GLViewImpl: {}", fmt::ptr(this));
GLFWEventHandler::setGLViewImpl(nullptr);
glfwTerminate();
}
@ -1019,7 +1019,7 @@ void GLViewImpl::onGLFWError(int errorID, const char* errorDesc)
{
_glfwError.append(StringUtils::format("GLFWError #%d Happen, %s\n", errorID, errorDesc));
}
AXLOGERROR("%s", _glfwError.c_str());
AXLOGE("{}", _glfwError);
}
void GLViewImpl::onGLFWMouseCallBack(GLFWwindow* /*window*/, int button, int action, int /*modify*/)
@ -1296,10 +1296,10 @@ static bool loadFboExtensions()
if (glGenFramebuffers == nullptr)
{
auto driver = backend::DriverGL::getInstance();
ax::print("OpenGL: glGenFramebuffers is nullptr, try to detect an extension");
AXLOGW("OpenGL: glGenFramebuffers is nullptr, try to detect an extension");
if (driver->hasExtension("ARB_framebuffer_object"sv))
{
ax::print("OpenGL: ARB_framebuffer_object is supported");
AXLOGI("OpenGL: ARB_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glfwGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glfwGetProcAddress("glBindRenderbuffer");
@ -1324,7 +1324,7 @@ static bool loadFboExtensions()
}
else if (driver->hasExtension("EXT_framebuffer_object"sv))
{
ax::print("OpenGL: EXT_framebuffer_object is supported");
AXLOGI("OpenGL: EXT_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glfwGetProcAddress("glIsRenderbufferEXT");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glfwGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glfwGetProcAddress("glDeleteRenderbuffersEXT");
@ -1349,7 +1349,7 @@ static bool loadFboExtensions()
}
else if (driver->hasExtension("GL_ANGLE_framebuffer_blit"sv))
{
ax::print("OpenGL: GL_ANGLE_framebuffer_object is supported");
AXLOGI("OpenGL: GL_ANGLE_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glfwGetProcAddress("glIsRenderbufferOES");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glfwGetProcAddress("glBindRenderbufferOES");
@ -1373,8 +1373,8 @@ static bool loadFboExtensions()
}
else
{
ax::print("OpenGL: No framebuffers extension is supported");
ax::print("OpenGL: Any call to Fbo will crash!");
AXLOGE("OpenGL: No framebuffers extension is supported");
AXLOGE("OpenGL: Any call to Fbo will crash!");
return false;
}
}
@ -1391,13 +1391,13 @@ bool GLViewImpl::loadGL()
# if !AX_GLES_PROFILE
if (!gladLoadGL(glfwGetProcAddress))
{
log("glad: Failed to Load GL");
AXLOGE("glad: Failed to Load GL");
return false;
}
# else
if (!gladLoadGLES2(glfwGetProcAddress))
{
log("glad: Failed to Load GLES2");
AXLOGE("glad: Failed to Load GLES2");
return false;
}
# endif

View File

@ -26,4 +26,5 @@ target_include_directories(${target_name}
PRIVATE ../../../thirdparty/glad/include
PRIVATE ../../../thirdparty/robin-map/include
PRIVATE ../../../thirdparty/jni.hpp/include
PRIVATE ../../../thirdparty/fmt/include
)

View File

@ -41,7 +41,7 @@ void GLViewImpl::loadGLES2()
{
auto glesVer = gladLoaderLoadGLES2();
if (glesVer)
ax::print("Load GLES success, version: %d", glesVer);
AXLOGI("Load GLES success, version: {}", glesVer);
else
throw std::runtime_error("Load GLES fail");
}

View File

@ -3,6 +3,7 @@ Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -151,7 +152,7 @@ static int unlink_cb(const char* fpath, const struct stat* sb, int typeflag, str
auto ret = remove(fpath);
if (ret)
{
log("Fail to remove: %s ", fpath);
AXLOGE("Fail to remove: {} ", fpath);
}
return ret;

View File

@ -2,6 +2,7 @@
Copyright (c) 2011 Laschweinski
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -31,7 +32,7 @@ NS_AX_BEGIN
void ccMessageBox(const char* msg, const char* title)
{
log("%s: %s", title, msg);
AXLOGE("{}: {}", title, msg);
}
void LuaLog(const char* format)

View File

@ -428,7 +428,7 @@ Data Device::getTextureDataForText(std::string_view text,
if (!dc.setFont(textDefinition._fontName.c_str(), (int)textDefinition._fontSize, false))
{
log("Can't found font(%s), use system default", textDefinition._fontName.c_str());
AXLOGW("Can't found font({}), use system default", textDefinition._fontName);
}
// draw text

View File

@ -393,7 +393,7 @@ void Device::setAccelerometerEnabled(bool isEnabled)
{
// It's not a friendly experience and may cause crash.
// MessageBox("This device does not have an accelerometer.","Alert");
log("This device does not have an accelerometer.");
AXLOGI("This device does not have an accelerometer.");
return;
}
@ -519,7 +519,7 @@ Data Device::getTextureDataForText(std::string_view text,
if (!textRenderer.setFont(textDefinition))
{
log("Can't found font(%s), use system default", textDefinition._fontName.c_str());
AXLOGW("Can't found font({}), use system default", textDefinition._fontName);
}
// draw text

View File

@ -321,7 +321,7 @@ void KeyBoardWinRT::OnWinRTKeyboardEvent(WinRTKeyboardEventType type, KeyEventAr
}
else
{
log("GLViewImpl::OnWinRTKeyboardEvent Virtual Key Code %d not supported", key);
AXLOGW("GLViewImpl::OnWinRTKeyboardEvent Virtual Key Code {} not supported", key);
}
}

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) Microsoft Open Technologies, Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
@ -96,7 +97,7 @@ void AX_DLL printIPAddresses()
if (hn.IPInformation() != nullptr)
{
std::string s = PlatformStringToString(hn.DisplayName());
log("IP Address: %s:", s.c_str());
AXLOGI("IP Address: {}:", s);
}
}
}

View File

@ -3,6 +3,7 @@
*
* Copyright (c) 2010-2014 - cocos2d-x community
* Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
* Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
@ -408,24 +409,18 @@ void OpenGLESPage::_OnPointerWheelChanged(Windows::Foundation::IInspectable cons
void OpenGLESPage::OnKeyPressed(CoreWindow const& sender, KeyEventArgs const& args)
{
// log("OpenGLESPage::OnKeyPressed %d", e->VirtualKey);
if (mRenderer)
{
mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyPressed, args);
}
}
void OpenGLESPage::_OnCharacterReceived(CoreWindow const& sender, CharacterReceivedEventArgs const& args)
void OpenGLESPage::_OnCharacterReceived(CoreWindow const& /*sender*/, CharacterReceivedEventArgs const& /*args*/)
{
// if (!e->KeyStatus.WasKeyDown)
//{
// log("OpenGLESPage::OnCharacterReceived %d", e->KeyCode);
// }
}
void OpenGLESPage::OnKeyReleased(CoreWindow const& sender, KeyEventArgs const& args)
void OpenGLESPage::OnKeyReleased(CoreWindow const& /*sender*/, KeyEventArgs const& args)
{
// log("OpenGLESPage::OnKeyReleased %d", e->VirtualKey);
if (mRenderer)
{
mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyReleased, args);

View File

@ -201,7 +201,7 @@ Program* ProgramManager::loadProgram(std::string_view vsName,
if (it != _cachedPrograms.end())
return it->second;
AXLOG("Loading shader: %" PRIu64 " %s, %s ...", progId, vsName.data(), fsName.data());
AXLOGD("Loading shader: {} {}, {} ...", progId, vsName.data(), fsName.data());
auto fileUtils = FileUtils::getInstance();
auto vertFile = fileUtils->fullPathForFilename(vsName);

View File

@ -143,7 +143,7 @@ DriverGL::DriverGL()
}
if (_version)
ax::print("[GL:%s] Ready for GLSL by %s", _version, axmolVersion());
AXLOGI("[{}] Ready for GLSL by {}", _version, axmolVersion());
// caps
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_maxAttributes);
@ -291,11 +291,11 @@ static GLuint compileShader(GLenum shaderType, const GLchar* source)
{
auto errorLog = axstd::make_unique_for_overwrite<char[]>(static_cast<size_t>(logLength));
glGetShaderInfoLog(shader, logLength, nullptr, static_cast<GLchar*>(errorLog.get()));
ax::print("axmol:ERROR: Failed to compile shader, detail: %s\n%s", errorLog.get(), source);
AXLOGE("axmol:ERROR: Failed to compile shader, detail: {}\n{}", errorLog.get(), source);
}
else
{
ax::print("axmol:ERROR: Failed to compile shader without errors.");
AXLOGE("axmol:ERROR: Failed to compile shader without errors.");
}
glDeleteShader(shader);

View File

@ -35,7 +35,7 @@
GLenum __error = glGetError(); \
if (__error) \
{ \
ax::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \
AXLOGE("OpenGL error 0x{:04X} in {} {} {}\n", __error, __FILE__, __FUNCTION__, __LINE__); \
} \
} while (false)
# define CHECK_GL_ERROR_ABORT() \
@ -44,7 +44,7 @@
GLenum __error = glGetError(); \
if (__error) \
{ \
ax::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \
AXLOGE("OpenGL error 0x{:04X} in {} {} {}\n", __error, __FILE__, __FUNCTION__, __LINE__); \
assert(false); \
} \
} while (false)

View File

@ -210,10 +210,10 @@ void ProgramGL::compileProgram()
{
auto errorInfo = axstd::make_unique_for_overwrite<char[]>(static_cast<size_t>(errorInfoLen));
glGetProgramInfoLog(_program, errorInfoLen, NULL, errorInfo.get());
ax::log("axmol:ERROR: %s: failed to link program: %s ", __FUNCTION__, errorInfo.get());
AXLOGE("axmol:ERROR: {}: failed to link program: {} ", __FUNCTION__, errorInfo.get());
}
else
ax::log("axmol:ERROR: %s: failed to link program ", __FUNCTION__);
AXLOGE("axmol:ERROR: {}: failed to link program ", __FUNCTION__);
glDeleteProgram(_program);
_program = 0;
}

View File

@ -63,12 +63,12 @@ void ShaderModuleGL::compileShader(ShaderStage stage, std::string_view source)
{
auto errorLog = axstd::make_unique_for_overwrite<char[]>(static_cast<size_t>(logLength));
glGetShaderInfoLog(_shader, logLength, nullptr, (GLchar*)errorLog.get());
ax::log("axmol:ERROR: Failed to compile shader, detail: %s\n%s", errorLog.get(),
AXLOGE("axmol:ERROR: Failed to compile shader, detail: {}\n{}", errorLog.get(),
source.data());
}
else
{
ax::log("axmol:ERROR: Failed to compile shader without errors.");
AXLOGE("axmol:ERROR: Failed to compile shader without errors.");
}
deleteShader();

View File

@ -1,5 +1,6 @@
//
//
// Copyright (c) 2014-2020 Simdsoft Limited - All Rights Reserved
// Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
//
#include "ui/LayoutHelper.h"
@ -56,7 +57,7 @@ void LayoutHelper::setDesignSizeNoBorder(const Vec2& designSize)
LayoutHelper::s_adjustedScale = scaleY / (frameSize.width / LayoutHelper::s_designSize.width);
}
ax::log("x: %f; y: %f; scale: %f", scaleX, scaleY, s_adjustedScale);
AXLOGD("x: {}; y: {}; scale: {}", scaleX, scaleY, s_adjustedScale);
pEGLView->setDesignResolutionSize(LayoutHelper::s_designSize.width * s_adjustedScale,
LayoutHelper::s_designSize.height * s_adjustedScale, ResolutionPolicy::NO_BORDER);

View File

@ -238,7 +238,7 @@ static bool load_gtk3() {
GTK_DLSYM(g_main_context_iteration);
GTK_DLSYM(g_type_check_instance_cast);
} catch(const std::exception& ex) {
ax::log("load gtk function: %s fail", ex.what());
AXLOGE("load gtk function: {} fail", ex.what());
dlclose(gtk3);
gtk3 = nullptr;
}

View File

@ -293,7 +293,7 @@ MediaPlayer::MediaPlayer()
}
else
{
ax::log("Create MediaPlayer backend failed");
AXLOGE("Create MediaPlayer backend failed");
}
}

View File

@ -125,7 +125,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(std::string_view spriteFra
}
AX_SAFE_DELETE(ret);
log("Could not allocate Scale9Sprite()");
AXLOGE("Could not allocate Scale9Sprite()");
return nullptr;
}

View File

@ -68,7 +68,7 @@ if(AX_ENABLE_EXT_FAIRYGUI)
if(BUILD_SHARED_LIBS)
target_link_libraries(fairygui spine)
else()
target_include_directories(fairygui
target_include_directories(fairygui
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/spine/runtime/include
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/spine/src
)
@ -95,7 +95,7 @@ if(AX_ENABLE_EXT_COCOSTUDIO)
if(BUILD_SHARED_LIBS)
target_link_libraries(cocostudio spine particle3d)
else()
target_include_directories(cocostudio
target_include_directories(cocostudio
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/spine/runtime/include
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/spine/src
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/Particle3D/src

View File

@ -521,18 +521,18 @@ void TableView::scrollViewDidScroll(ScrollView* /*view*/)
CCARRAY_FOREACH(_cellsUsed, pObj)
{
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
log("cells Used index %d, value = %d", i, pCell->getIdx());
AXLOGD("cells Used index {}, value = {}", i, pCell->getIdx());
i++;
}
log("---------------------------------------");
AXLOGD("---------------------------------------");
i = 0;
CCARRAY_FOREACH(_cellsFreed, pObj)
{
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
log("cells freed index %d, value = %d", i, pCell->getIdx());
AXLOGD("cells freed index {}, value = {}", i, pCell->getIdx());
i++;
}
log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
AXLOGD("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
#endif
if (!_cellsUsed.empty())

View File

@ -90,7 +90,7 @@ void JSONDefault::lazyInit()
if (_doc.HasParseError())
{
log("JSONDefault::init load json file: %s failed", _filePath.c_str());
AXLOGW("JSONDefault::init load json file: {} failed", _filePath);
return;
}
}

View File

@ -71,7 +71,7 @@ int ActionFrame::getEasingType()
ActionInterval* ActionFrame::getAction(float /*fDuration*/)
{
log("Need a definition of <getAction> for ActionFrame");
AXLOGW("Need a definition of <getAction> for ActionFrame");
return nullptr;
}
ActionInterval* ActionFrame::getAction(float fDuration, ActionFrame* /*srcFrame*/)

View File

@ -587,7 +587,7 @@ void Armature::drawContour()
# pragma warning(push)
# pragma warning(disable : 4996)
# endif
ax::log("TODO in %s %s %d", __FILE__, __FUNCTION__, __LINE__);
AXLOGD("TODO in {} {} {}", __FILE__, __FUNCTION__, __LINE__);
# if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
# pragma GCC diagnostic warning "-Wdeprecated-declarations"

View File

@ -202,7 +202,7 @@ bool ComRender::serialize(void* r)
rapidjson::Document doc;
if (!readJson(filePath, doc))
{
log("read json file[%s] error!\n", filePath.c_str());
AXLOGW("read json file[{}] error!\n", filePath);
continue;
}
const rapidjson::Value& subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);

View File

@ -160,7 +160,7 @@ ax::Node* SceneReader::createNodeWithSceneFile(
}
else
{
log("read file [%s] error!\n", fileName.data());
AXLOGW("read file [{}] error!\n", fileName);
}
return nullptr;
}

View File

@ -9,7 +9,7 @@ SpineSkeletonDataCache* SpineSkeletonDataCache::getInstance()
SpineSkeletonDataCache::SpineSkeletonDataCache()
{
_reportError = &ax::log;
_reportError = &ax::print;
}
void SpineSkeletonDataCache::setErrorReportFunc(void (*errorfunc)(const char* pszFormat, ...))
@ -142,7 +142,7 @@ SpineSkeletonDataCache* SpineSkeletonDataCache::getInstance()
SpineSkeletonDataCache::SpineSkeletonDataCache()
{
_reportError = &ax::log;
_reportError = &ax::print;
}
void SpineSkeletonDataCache::setErrorReportFunc(void (*errorfunc)(const char* pszFormat, ...))

View File

@ -1249,7 +1249,7 @@ float ScrollPane::updateTargetAndDuration(float pos, int axis)
v *= ratio;
sp_setField(_velocity, axis, v);
duration = log(60 / v2) / log(_decelerationRate) / 60;
duration = ::log(60 / v2) / ::log(_decelerationRate) / 60;
float change = (int)(v * duration * 0.4f);
pos += change;
}

View File

@ -369,56 +369,6 @@ int lua_ax_base_Console_delCommand(lua_State* tolua_S)
return 0;
}
int lua_ax_base_Console_print(lua_State* tolua_S)
{
int argc = 0;
ax::Console* cobj = nullptr;
bool ok = true;
#if _AX_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if _AX_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ax.Console",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (ax::Console*)tolua_tousertype(tolua_S,1,0);
#if _AX_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_Console_print'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.Console:print"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Console_print'", nullptr);
return 0;
}
cobj->print(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Console:print",argc, 1);
return 0;
#if _AX_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_ax_base_Console_print'.",&tolua_err);
#endif
return 0;
}
int lua_ax_base_Console_setBindAddress(lua_State* tolua_S)
{
int argc = 0;
@ -582,7 +532,6 @@ int lua_register_ax_base_Console(lua_State* tolua_S)
tolua_function(tolua_S,"listenOnFileDescriptor",lua_ax_base_Console_listenOnFileDescriptor);
tolua_function(tolua_S,"stop",lua_ax_base_Console_stop);
tolua_function(tolua_S,"delCommand",lua_ax_base_Console_delCommand);
tolua_function(tolua_S,"print",lua_ax_base_Console_print);
tolua_function(tolua_S,"setBindAddress",lua_ax_base_Console_setBindAddress);
tolua_function(tolua_S,"isIpv6Server",lua_ax_base_Console_isIpv6Server);
tolua_function(tolua_S,"setCommandSeparator",lua_ax_base_Console_setCommandSeparator);

View File

@ -58,11 +58,11 @@ extern std::unordered_map<cxx17::string_view, const char*> g_typeCast;
void luaval_to_native_err(lua_State* L, const char* msg, tolua_Error* err, const char* funcName = "");
#endif
#define LUA_PRECONDITION(condition, ...) \
if (!(condition)) \
{ \
ax::log("lua: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__); \
ax::log(__VA_ARGS__); \
#define LUA_PRECONDITION(condition, ...) \
if (!(condition)) \
{ \
AXLOGE("lua: ERROR: File {}: Line: {}, Function: {}", __FILE__, __LINE__, __FUNCTION__); \
AXLOGE(##__VA_ARGS__); \
}
/**
@ -323,11 +323,8 @@ extern bool luaval_to_color4f(lua_State* L, int lo, Color4F* outValue, const cha
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
*/
extern bool luaval_to_physics_material(lua_State* L,
int lo,
ax::PhysicsMaterial* outValue,
const char* funcName = "");
#endif //#if AX_USE_PHYSICS
extern bool luaval_to_physics_material(lua_State* L, int lo, ax::PhysicsMaterial* outValue, const char* funcName = "");
#endif // #if AX_USE_PHYSICS
/**
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
@ -383,11 +380,7 @@ extern bool luaval_to_mat4(lua_State* L, int lo, ax::Mat4* outValue, const char*
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
*/
extern bool luaval_to_array_of_vec2(lua_State* L,
int lo,
ax::Vec2** points,
int* numPoints,
const char* funcName = "");
extern bool luaval_to_array_of_vec2(lua_State* L, int lo, ax::Vec2** points, int* numPoints, const char* funcName = "");
/**
* Get a ax::ValueVector object value by the argc numbers of Lua values in the stack.
@ -749,10 +742,7 @@ bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret, const cha
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
*/
extern bool luaval_to_mesh_vertex_attrib(lua_State* L,
int lo,
ax::MeshVertexAttrib* ret,
const char* funcName = "");
extern bool luaval_to_mesh_vertex_attrib(lua_State* L, int lo, ax::MeshVertexAttrib* ret, const char* funcName = "");
/**
* Get a pointer points to a std::vector<float> from a Lua array table in the stack.
@ -804,10 +794,7 @@ extern bool luaval_to_quaternion(lua_State* L, int lo, ax::Quaternion* outValue,
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return true if the value at the given acceptable index of stack is a table, otherwise return false.
*/
extern bool luaval_to_texparams(lua_State* L,
int lo,
ax::Texture2D::TexParams* outValue,
const char* funcName = "");
extern bool luaval_to_texparams(lua_State* L, int lo, ax::Texture2D::TexParams* outValue, const char* funcName = "");
/**
* Get a ax::V3F_C4B_T2F object value from the given acceptable index of stack.
@ -1002,7 +989,7 @@ extern void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo
* @param data a ax::PhysicsContactData object.
*/
extern void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data);
#endif //#if AX_USE_PHYSICS
#endif // #if AX_USE_PHYSICS
/**
* Push a table converted from a ax::AffineTransform object into the Lua stack.
@ -1236,8 +1223,8 @@ void object_to_luaval(lua_State* L, const char* type, T* ret)
{
// use c style cast, T may not polymorphic
ax::Ref* dynObject = (ax::Ref*)(ret);
int ID = (int)(dynObject->_ID);
int* luaID = &(dynObject->_luaID);
int ID = (int)(dynObject->_ID);
int* luaID = &(dynObject->_luaID);
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)ret, type);
}
else
@ -1369,7 +1356,6 @@ AX_LUA_DLL void uniformLocation_to_luaval(lua_State* L, const ax::backend::Unifo
AX_LUA_DLL void program_activeattrs_to_luaval(lua_State* L,
const hlookup::string_map<ax::backend::AttributeBindInfo>& map);
/**
* convert ax::ResourceData to lua object
*/

View File

@ -85,7 +85,7 @@ int lua_print(lua_State* L)
{
std::string t;
get_string_for_print(L, &t);
AXLOG("[LUA-print] %s", t.c_str());
AXLOGD("[LUA-print] {}", t);
return 0;
}
@ -94,7 +94,7 @@ int lua_release_print(lua_State* L)
{
std::string t;
get_string_for_print(L, &t);
log("[LUA-print] %s", t.c_str());
AXLOG_WITH_LEVEL(ax::LogLevel::Silent, "[LUA-print] {}", t);
return 0;
}

View File

@ -169,7 +169,7 @@ namespace spine {
TrackEntry *SkeletonAnimation::setAnimation(int trackIndex, const std::string &name, bool loop) {
Animation *animation = _skeleton->getData()->findAnimation(name.c_str());
if (!animation) {
log("Spine: Animation not found: %s", name.c_str());
AXLOGW("Spine: Animation not found: {}", name);
return 0;
}
return _state->setAnimation(trackIndex, animation, loop);
@ -178,7 +178,7 @@ namespace spine {
TrackEntry *SkeletonAnimation::addAnimation(int trackIndex, const std::string &name, bool loop, float delay) {
Animation *animation = _skeleton->getData()->findAnimation(name.c_str());
if (!animation) {
log("Spine: Animation not found: %s", name.c_str());
AXLOGW("Spine: Animation not found: {}", name);
return 0;
}
return _state->addAnimation(trackIndex, animation, loop, delay);

View File

@ -361,8 +361,8 @@ std::string StopActionsByFlagsTest::subtitle() const
class SpriteIssue14050 : public Sprite
{
public:
SpriteIssue14050() { log("SpriteIssue14050::constructor"); }
virtual ~SpriteIssue14050() { log("SpriteIssue14050::destructor"); }
SpriteIssue14050() { ax::print("SpriteIssue14050::constructor"); }
virtual ~SpriteIssue14050() { ax::print("SpriteIssue14050::destructor"); }
};
void Issue14050Test::onEnter()

View File

@ -673,7 +673,7 @@ void ActionAnimate::onEnter()
_frameDisplayedListener = EventListenerCustom::create(AnimationFrameDisplayedNotification, [](EventCustom* event) {
auto userData = static_cast<AnimationFrame::DisplayedEventInfo*>(event->getUserData());
log("target %p with data %s", userData->target, Value(userData->userInfo).getDescription().c_str());
ax::print("target %p with data %s", userData->target, Value(userData->userInfo).getDescription().c_str());
});
_eventDispatcher->addEventListenerWithFixedPriority(_frameDisplayedListener, -1);
@ -1651,7 +1651,7 @@ void Issue1305::onEnter()
centerSprites(0);
_spriteTmp = Sprite::create("Images/grossini.png");
_spriteTmp->runAction(CallFunc::create(std::bind(&Issue1305::log, this, _spriteTmp)));
_spriteTmp->runAction(CallFunc::create(std::bind(&Issue1305::print, this, _spriteTmp)));
_spriteTmp->retain();
scheduleOnce(
@ -1662,9 +1662,9 @@ void Issue1305::onEnter()
2, "update_key");
}
void Issue1305::log(Node* sender)
void Issue1305::print(Node* sender)
{
ax::log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
ax::print("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
}
void Issue1305::onExit()
@ -1728,22 +1728,22 @@ void Issue1305_2::onEnter()
void Issue1305_2::printLog1()
{
log("1st block");
ax::print("1st block");
}
void Issue1305_2::printLog2()
{
log("2nd block");
ax::print("2nd block");
}
void Issue1305_2::printLog3()
{
log("3rd block");
ax::print("3rd block");
}
void Issue1305_2::printLog4()
{
log("4th block");
ax::print("4th block");
}
std::string Issue1305_2::title() const
@ -1841,14 +1841,14 @@ std::string Issue1327::subtitle() const
void Issue1327::logSprRotation(Sprite* sender)
{
log("%f", sender->getRotation());
ax::print("%f", sender->getRotation());
}
// Issue1398
void Issue1398::incrementInteger()
{
_testInteger++;
log("incremented to %d", _testInteger);
ax::print("incremented to %d", _testInteger);
}
void Issue1398::onEnter()
@ -1857,7 +1857,7 @@ void Issue1398::onEnter()
this->centerSprites(0);
_testInteger = 0;
log("testInt = %d", _testInteger);
ax::print("testInt = %d", _testInteger);
this->runAction(
Sequence::create(CallFunc::create(std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"1")),
@ -1873,7 +1873,7 @@ void Issue1398::onEnter()
void Issue1398::incrementIntegerCallback(void* data)
{
this->incrementInteger();
log("%s", (char*)data);
ax::print("%s", (char*)data);
}
std::string Issue1398::subtitle() const
@ -1892,14 +1892,14 @@ void Issue2599::onEnter()
this->centerSprites(0);
_count = 0;
log("before: count = %d", _count);
ax::print("before: count = %d", _count);
log("start count up 50 times using Repeat action");
ax::print("start count up 50 times using Repeat action");
auto delay = 1.0f / 50;
auto repeatAction = Repeat::create(
Sequence::createWithTwoActions(CallFunc::create([&]() { this->_count++; }), DelayTime::create(delay)), 50);
this->runAction(Sequence::createWithTwoActions(
repeatAction, CallFunc::create([&]() { log("after: count = %d", this->_count); })));
repeatAction, CallFunc::create([&]() { ax::print("after: count = %d", this->_count); })));
}
std::string Issue2599::subtitle() const
@ -2080,7 +2080,7 @@ void PauseResumeActions::onEnter()
this->schedule(
[&](float dt) {
log("Pausing");
ax::print("Pausing");
auto director = Director::getInstance();
_pausedTargets = director->getActionManager()->pauseAllRunningActions();
@ -2089,7 +2089,7 @@ void PauseResumeActions::onEnter()
this->schedule(
[&](float dt) {
log("Resuming");
ax::print("Resuming");
auto director = Director::getInstance();
director->getActionManager()->resumeTargets(_pausedTargets);
_pausedTargets.clear();
@ -2313,7 +2313,7 @@ void SequenceWithFinalInstant::onEnter()
bool called(false);
const auto f([&called]() -> void {
ax::log("Callback called.");
ax::print("Callback called.");
called = true;
});

View File

@ -463,7 +463,7 @@ public:
virtual void onEnter() override;
virtual void onExit() override;
void log(Node* sender);
void print(Node* sender);
virtual std::string title() const override;
virtual std::string subtitle() const override;

View File

@ -49,7 +49,7 @@ int check_for_error(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t)
// Since float has rounding errors, only check if diff is < 0.05
if ((fabs(hitPoint1.x - hitPoint2.x) > 0.1f) || (fabs(hitPoint1.y - hitPoint2.y) > 0.1f))
{
log("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y);
ax::print("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y);
return 1;
}
@ -72,7 +72,7 @@ bool Bug1174Layer::init()
//
// Test 1.
//
log("Test1 - Start");
ax::print("Test1 - Start");
for (int i = 0; i < 10000; i++)
{
// A | b
@ -111,12 +111,12 @@ bool Bug1174Layer::init()
ok++;
}
}
log("Test1 - End. OK=%i, Err=%i", ok, err);
ax::print("Test1 - End. OK=%i, Err=%i", ok, err);
//
// Test 2.
//
log("Test2 - Start");
ax::print("Test2 - Start");
p1 = Vec2(220, 480);
p2 = Vec2(304, 325);
@ -127,12 +127,12 @@ bool Bug1174Layer::init()
if (Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t))
check_for_error(p1, p2, p3, p4, s, t);
log("Test2 - End");
ax::print("Test2 - End");
//
// Test 3
//
log("Test3 - Start");
ax::print("Test3 - Start");
ok = 0;
err = 0;
@ -179,7 +179,7 @@ bool Bug1174Layer::init()
}
}
log("Test3 - End. OK=%i, err=%i", ok, err);
ax::print("Test3 - End. OK=%i, err=%i", ok, err);
return true;
}

View File

@ -94,23 +94,23 @@ void Bug14327Layer::update(float dt)
void Bug14327Layer::editBoxEditingDidBegin(ax::ui::EditBox* editBox)
{
log("editBox %p DidBegin !", editBox);
ax::print("editBox %p DidBegin !", editBox);
}
void Bug14327Layer::editBoxEditingDidEndWithAction(ax::ui::EditBox* editBox,
ax::ui::EditBoxDelegate::EditBoxEndAction EditBoxEndAction)
{
log("editBox %p DidEnd !", editBox);
ax::print("editBox %p DidEnd !", editBox);
}
void Bug14327Layer::editBoxTextChanged(ax::ui::EditBox* editBox, std::string_view text)
{
log("editBox %p TextChanged, text: %s ", editBox, text.data());
ax::print("editBox %p TextChanged, text: %s ", editBox, text.data());
}
void Bug14327Layer::editBoxReturn(ui::EditBox* editBox)
{
log("editBox %p was returned !", editBox);
ax::print("editBox %p was returned !", editBox);
}
#endif

View File

@ -53,12 +53,12 @@ void Bug422Layer::reset()
// and then a new node will be allocated occupying the memory.
// => CRASH BOOM BANG
auto node = getChildByTag(localtag - 1);
log("Menu: %p", node);
ax::print("Menu: %p", node);
removeChild(node, true);
// [self removeChildByTag:localtag-1 cleanup:NO];
auto item1 = MenuItemFont::create("One", AX_CALLBACK_1(Bug422Layer::menuCallback, this));
log("MenuItemFont: %p", item1);
ax::print("MenuItemFont: %p", item1);
MenuItem* item2 = MenuItemFont::create("Two", AX_CALLBACK_1(Bug422Layer::menuCallback, this));
auto menu = Menu::create(item1, item2, nullptr);
menu->alignItemsVertically();
@ -76,7 +76,7 @@ void Bug422Layer::check(Node* t)
auto& children = t->getChildren();
for (const auto& child : children)
{
log("%p, rc: %d", child, child->getReferenceCount());
ax::print("%p, rc: %d", child, child->getReferenceCount());
check(child);
}
}

View File

@ -68,5 +68,5 @@ bool Bug458Layer::init()
void Bug458Layer::selectAnswer(Ref* sender)
{
log("Selected");
ax::print("Selected");
}

View File

@ -54,7 +54,7 @@ bool QuestionContainerSprite::init()
label->setColor(Color3B::BLUE);
else
{
log("Color changed");
ax::print("Color changed");
label->setColor(Color3B::RED);
}
a++;

View File

@ -74,7 +74,7 @@ void Bug624Layer::switchLayer(float dt)
void Bug624Layer::onAcceleration(Acceleration* acc, Event* event)
{
log("Layer1 accel");
ax::print("Layer1 accel");
}
////////////////////////////////////////////////////////
@ -120,5 +120,5 @@ void Bug624Layer2::switchLayer(float dt)
void Bug624Layer2::onAcceleration(Acceleration* acc, Event* event)
{
log("Layer2 accel");
ax::print("Layer2 accel");
}

View File

@ -73,7 +73,7 @@ bool Bug914Layer::init()
void Bug914Layer::onTouchesMoved(const std::vector<Touch*>& touches, Event* event)
{
log("Number of touches: %d", (int)touches.size());
ax::print("Number of touches: %d", (int)touches.size());
}
void Bug914Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)

View File

@ -53,7 +53,7 @@ void ConfigurationLoadConfig::onEnter()
Configuration::getInstance()->loadConfigFile("configs/config-test-ok.plist");
std::string config = Configuration::getInstance()->getInfo();
log("%s\n", config.c_str());
ax::print("%s\n", config.c_str());
}
std::string ConfigurationLoadConfig::subtitle() const
@ -70,8 +70,8 @@ void ConfigurationQuery::onEnter()
{
ConfigurationBase::onEnter();
log("cocos2d version: %s", Configuration::getInstance()->getValue("axmol.version").asString().c_str());
log("OpenGL version: %s", Configuration::getInstance()->getValue("gl.version").asString().c_str());
ax::print("cocos2d version: %s", Configuration::getInstance()->getValue("axmol.version").asString().c_str());
ax::print("OpenGL version: %s", Configuration::getInstance()->getValue("gl.version").asString().c_str());
}
std::string ConfigurationQuery::subtitle() const
@ -107,21 +107,21 @@ void ConfigurationDefault::onEnter()
std::string c_value = Configuration::getInstance()->getValue("invalid.key", Value("no key")).asString();
if (c_value != "no key")
log("1. Test failed!");
ax::print("1. Test failed!");
else
log("1. Test OK!");
ax::print("1. Test OK!");
bool b_value = Configuration::getInstance()->getValue("invalid.key", Value(true)).asBool();
if (!b_value)
log("2. Test failed!");
ax::print("2. Test failed!");
else
log("2. Test OK!");
ax::print("2. Test OK!");
double d_value = Configuration::getInstance()->getValue("invalid.key", Value(42.42)).asDouble();
if (d_value != 42.42)
log("3. Test failed!");
ax::print("3. Test failed!");
else
log("3. Test OK!");
ax::print("3. Test OK!");
}
std::string ConfigurationDefault::subtitle() const
@ -145,7 +145,7 @@ void ConfigurationSet::onEnter()
conf->setValue("this.is.a.string.value", Value("hello world"));
auto str = conf->getInfo();
log("%s\n", str.c_str());
ax::print("%s\n", str.c_str());
}
std::string ConfigurationSet::subtitle() const

View File

@ -230,7 +230,7 @@ void ConsoleUploadFile::uploadFile()
if (ret < 3)
{
// eof
log("Reach the end, total send: %d bytes", (int)offset);
ax::print("Reach the end, total send: %d bytes", (int)offset);
break;
}
}

View File

@ -88,8 +88,8 @@ void PrettyPrinterDemo::onEnter()
// // print dictionary
// auto dict = __Dictionary::createWithContentsOfFile("animations/animations.plist");
// dict->acceptVisitor(visitor);
// log("%s", visitor.getResult().c_str());
// log("-------------------------------");
// ax::print("%s", visitor.getResult().c_str());
// ax::print("-------------------------------");
//
// __Set myset;
// for (int i = 0; i < 30; ++i) {
@ -97,12 +97,12 @@ void PrettyPrinterDemo::onEnter()
// }
// visitor.clear();
// myset.acceptVisitor(visitor);
// log("%s", visitor.getResult().c_str());
// log("-------------------------------");
// ax::print("%s", visitor.getResult().c_str());
// ax::print("-------------------------------");
//
// visitor.clear();
addSprite();
// dict = Director::getInstance()->getTextureCache()->snapshotTextures();
// dict->acceptVisitor(visitor);
// log("%s", visitor.getResult().c_str());
// ax::print("%s", visitor.getResult().c_str());
}

View File

@ -70,7 +70,7 @@ void TestSearchPath::onEnter()
AXASSERT(ret != 0, "fwrite function returned zero value");
fclose(fp);
if (ret != 0)
log("Writing file to writable path succeed.");
ax::print("Writing file to writable path succeed.");
}
searchPaths.insert(searchPaths.begin(), writablePath);
@ -82,12 +82,12 @@ void TestSearchPath::onEnter()
{
auto filename = StringUtils::format("file%d.txt", i);
ret = sharedFileUtils->fullPathForFilename(filename);
log("%s -> %s", filename.c_str(), ret.c_str());
ax::print("%s -> %s", filename.c_str(), ret.c_str());
}
// Gets external.txt from writable path
std::string fullPath = sharedFileUtils->fullPathForFilename("external.txt");
log("external file path = %s", fullPath.c_str());
ax::print("external file path = %s", fullPath.c_str());
if (fullPath.length() > 0)
{
fp = fopen(fullPath.c_str(), "rb");
@ -96,7 +96,7 @@ void TestSearchPath::onEnter()
char szReadBuf[100] = {0};
size_t read = fread(szReadBuf, 1, strlen(szReadBuf), fp);
if (read > 0)
log("The content of file from writable path: %s", szReadBuf);
ax::print("The content of file from writable path: %s", szReadBuf);
fclose(fp);
}
}
@ -425,12 +425,12 @@ void TestWriteString::onEnter()
std::string fullPath = writablePath + fileName;
if (FileUtils::getInstance()->writeStringToFile(writeDataStr, fullPath.c_str()))
{
log("see the plist file at %s", fullPath.c_str());
ax::print("see the plist file at %s", fullPath.c_str());
writeResult->setString("write success:" + writeDataStr);
}
else
{
log("write plist file failed");
ax::print("write plist file failed");
writeResult->setString("write fail");
}
@ -567,12 +567,12 @@ void TestWriteData::onEnter()
std::string fullPath = writablePath + fileName;
if (FileUtils::getInstance()->writeDataToFile(writeData, fullPath.c_str()))
{
log("see the plist file at %s", fullPath.c_str());
ax::print("see the plist file at %s", fullPath.c_str());
writeResult->setString("write success:" + writeDataStr);
}
else
{
log("write plist file failed");
ax::print("write plist file failed");
writeResult->setString("write fail");
}
@ -654,12 +654,12 @@ void TestWriteValueMap::onEnter()
std::string fullPath = writablePath + "testWriteValueMap.plist";
if (FileUtils::getInstance()->writeValueMapToFile(valueMap, fullPath.c_str()))
{
log("see the plist file at %s", fullPath.c_str());
ax::print("see the plist file at %s", fullPath.c_str());
writeResult->setString("write success");
}
else
{
log("write plist file failed");
ax::print("write plist file failed");
writeResult->setString("write failed");
}
@ -756,12 +756,12 @@ void TestWriteValueVector::onEnter()
std::string fullPath = writablePath + "testWriteValueVector.plist";
if (FileUtils::getInstance()->writeValueVectorToFile(array, fullPath.c_str()))
{
log("see the plist file at %s", fullPath.c_str());
ax::print("see the plist file at %s", fullPath.c_str());
writeResult->setString("write success");
}
else
{
log("write plist file failed");
ax::print("write plist file failed");
writeResult->setString("write failed");
}
@ -871,7 +871,7 @@ void TestUnicodePath::onEnter()
memcpy(buffer, readData.getBytes(), readData.getSize());
buffer[readData.getSize()] = '\0';
// vc can't treat unicode string correctly, don't use unicode string in code
log("The content of file from writable path: %s", buffer);
ax::print("The content of file from writable path: %s", buffer);
free(buffer);
// remove test file

View File

@ -1266,7 +1266,7 @@ LabelTTFFontsTestNew::LabelTTFFontsTestNew()
}
else
{
log("ERROR: Cannot load: %s", ttfpaths[i]);
ax::print("ERROR: Cannot load: %s", ttfpaths[i]);
}
}
}

View File

@ -489,7 +489,7 @@ static void printProperties(Properties* properties, int indent)
chindent[i] = ' ';
chindent[i] = '\0';
log("%sNamespace: %s ID: %s\n%s{", chindent, spacename, id, chindent);
ax::print("%sNamespace: %s ID: %s\n%s{", chindent, spacename, id, chindent);
// Print all properties in this namespace.
const char* name = properties->getNextProperty();
@ -497,7 +497,7 @@ static void printProperties(Properties* properties, int indent)
while (name != NULL)
{
value = properties->getString(name);
log("%s%s = %s", chindent, name, value);
ax::print("%s%s = %s", chindent, name, value);
name = properties->getNextProperty();
}
@ -508,5 +508,5 @@ static void printProperties(Properties* properties, int indent)
space = properties->getNextNamespace();
}
log("%s}\n", chindent);
ax::print("%s}\n", chindent);
}

View File

@ -175,7 +175,7 @@ void MenuLayerMainMenu::allowTouches(float dt)
{
_eventDispatcher->setPriority(_touchListener, 1);
unscheduleAllCallbacks();
log("TOUCHES ALLOWED AGAIN");
ax::print("TOUCHES ALLOWED AGAIN");
}
void MenuLayerMainMenu::menuCallbackDisabled(Ref* sender)
@ -183,7 +183,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(Ref* sender)
// hijack all touch events for 5 seconds
_eventDispatcher->setPriority(_touchListener, -1);
schedule(AX_SCHEDULE_SELECTOR(MenuLayerMainMenu::allowTouches), 5.0f);
log("TOUCHES DISABLED FOR 5 SECONDS");
ax::print("TOUCHES DISABLED FOR 5 SECONDS");
}
void MenuLayerMainMenu::menuCallback2(Ref* sender)
@ -339,7 +339,7 @@ MenuLayer3::MenuLayer3()
auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0, 23 * 0, 115, 23));
auto item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled,
[](Ref* sender) { log("sprite clicked!"); });
[](Ref* sender) { ax::print("sprite clicked!"); });
_disabledItem = item3;
item3->retain();
_disabledItem->setEnabled(false);
@ -475,7 +475,7 @@ void BugsTest::issue1410MenuCallback(Ref* sender)
menu->setEnabled(false);
menu->setEnabled(true);
log("NO CRASHES");
ax::print("NO CRASHES");
}
void BugsTest::issue1410v2MenuCallback(ax::Ref* pSender)
@ -484,7 +484,7 @@ void BugsTest::issue1410v2MenuCallback(ax::Ref* pSender)
menu->setEnabled(true);
menu->setEnabled(false);
log("NO CRASHES. AND MENU SHOULD STOP WORKING");
ax::print("NO CRASHES. AND MENU SHOULD STOP WORKING");
}
void BugsTest::backMenuCallback(ax::Ref* pSender)

View File

@ -873,7 +873,7 @@ MeshRendererHitTest::MeshRendererHitTest()
Rect rect = target->getBoundingBox();
if (rect.containsPoint(touch->getLocation()))
{
log("mesh3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
ax::print("mesh3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
target->setOpacity(100);
return true;
}
@ -887,7 +887,7 @@ MeshRendererHitTest::MeshRendererHitTest()
listener1->onTouchEnded = [=](Touch* touch, Event* event) {
auto target = static_cast<MeshRenderer*>(event->getCurrentTarget());
log("mesh3d onTouchesEnded.. ");
ax::print("mesh3d onTouchesEnded.. ");
target->setOpacity(255);
};
@ -2445,7 +2445,7 @@ Animate3DCallbackTest::Animate3DCallbackTest()
((PUParticleSystem3D*)node)->startParticleSystem();
}
ax::log("frame %d", info->frame);
ax::print("frame %d", info->frame);
});
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener, -1);
}
@ -2765,7 +2765,7 @@ void MeshRendererPropertyTest::printMeshName(ax::Ref* sender)
Vector<Mesh*> meshes = _mesh->getMeshes();
for (Mesh* mesh : meshes)
{
log("MeshName: %s ", mesh->getName().data());
ax::print("MeshName: %s ", mesh->getName().data());
}
AXLOG("MeshName End");
}
@ -2819,7 +2819,7 @@ Issue16155Test::Issue16155Test()
addChild(mesh);
removeChild(mesh);
ax::log("Issue 16155: Ref count:%d. Run this test again. RC should be the same", rcBefore);
ax::print("Issue 16155: Ref count:%d. Run this test again. RC should be the same", rcBefore);
}
std::string Issue16155Test::title() const

View File

@ -288,7 +288,7 @@ struct DownloaderTest : public TestCase
// define failed callback
downloader->onTaskError = [this](const ax::network::DownloadTask& task, int errorCode,
int errorCodeInternal, std::string_view errorStr) {
log("Failed to download : %s, identifier(%s) error code(%d), internal error code(%d) desc(%s)",
ax::print("Failed to download : %s, identifier(%s) error code(%d), internal error code(%d) desc(%s)",
task.requestURL.c_str(), task.identifier.c_str(), errorCode, errorCodeInternal, errorStr.data());
auto view = this->getChildByName(task.identifier);
auto status = (Label*)view->getChildByTag(TAG_STATUS);
@ -327,16 +327,16 @@ struct DownloaderMultiTask : public TestCase
{
sprintf(name, "%d_%s", i, sNameList[0]);
sprintf(path, "%sCppTests/DownloaderTest/%s", FileUtils::getInstance()->getWritablePath().c_str(), name);
log("downloader task create: %s", name);
ax::print("downloader task create: %s", name);
this->downloader->createDownloadFileTask(sURLList[0], path, name);
}
downloader->onFileTaskSuccess =
([](const network::DownloadTask& task) { log("downloader task success: %s", task.identifier.c_str()); });
([](const network::DownloadTask& task) { ax::print("downloader task success: %s", task.identifier.c_str()); });
downloader->onTaskError =
([](const network::DownloadTask& task, int errorCode, int errorCodeInternal, std::string_view errorStr) {
log("downloader task failed : %s, identifier(%s) error code(%d), internal error code(%d) desc(%s)",
ax::print("downloader task failed : %s, identifier(%s) error code(%d), internal error code(%d) desc(%s)",
task.requestURL.c_str(), task.identifier.c_str(), errorCode, errorCodeInternal, errorStr.data());
});
}

View File

@ -505,6 +505,6 @@ void HttpClientClearRequestsTest::onHttpRequestCompleted(HttpClient* sender, Htt
if (!response->isSucceed())
{
ax::print("response failed");
// log("error buffer: %s", response->getErrorBuffer());
// ax::print("error buffer: %s", response->getErrorBuffer());
}
}

View File

@ -251,7 +251,7 @@ bool AudioControlTest::init()
button->setEnabled(false);
AudioEngine::setFinishCallback(_audioID, [&](int id, std::string_view filePath) {
log("_audioID(%d), _isStopped:(%d), played over!!!", _audioID, _isStopped);
ax::print("_audioID(%d), _isStopped:(%d), played over!!!", _audioID, _isStopped);
_playOverLabel->setVisible(true);
@ -557,10 +557,10 @@ bool PlaySimultaneouslyTest::init()
}
else
{
log("%s,%d,Fail to play file:%s", __FILE__, __LINE__, _files[index].c_str());
ax::print("%s,%d,Fail to play file:%s", __FILE__, __LINE__, _files[index].c_str());
}
}
log("diff time:%lf", utils::gettime() - startTime);
ax::print("diff time:%lf", utils::gettime() - startTime);
});
playItem->setPositionNormalized(Vec2(0.5f, 0.5f));
this->addChild(playItem);
@ -1092,11 +1092,11 @@ void AudioPreloadSameFileMultipleTimes::onEnter()
for (int i = 0; i < 10; ++i)
{
AudioEngine::preload("audio/SoundEffectsFX009/FX082.mp3", [i](bool isSucceed) {
log("111: %d preload %s", i, isSucceed ? "succeed" : "failed");
ax::print("111: %d preload %s", i, isSucceed ? "succeed" : "failed");
AudioEngine::preload("audio/SoundEffectsFX009/FX082.mp3", [i](bool isSucceed) {
log("222: %d preload %s", i, isSucceed ? "succeed" : "failed");
ax::print("222: %d preload %s", i, isSucceed ? "succeed" : "failed");
AudioEngine::preload("audio/SoundEffectsFX009/FX082.mp3", [i](bool isSucceed) {
log("333: %d preload %s", i, isSucceed ? "succeed" : "failed");
ax::print("333: %d preload %s", i, isSucceed ? "succeed" : "failed");
});
});
});
@ -1194,7 +1194,7 @@ void AudioPlayInFinishedCB::doPlay(std::string_view filename)
int playID = AudioEngine::play2d(filename, false, 1);
AudioEngine::setFinishCallback(playID, [this](int finishID, std::string_view file) {
_playList.pop_front();
log("finish music %s", file.data());
ax::print("finish music %s", file.data());
if (!_playList.empty())
{
std::string_view name = _playList.front();

View File

@ -186,7 +186,7 @@ void TouchableSpriteTest::onEnter()
if (rect.containsPoint(locationInNode))
{
log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
ax::print("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
target->setOpacity(180);
return true;
}
@ -200,7 +200,7 @@ void TouchableSpriteTest::onEnter()
listener1->onTouchEnded = [=](Touch* touch, Event* event) {
auto target = static_cast<Sprite*>(event->getCurrentTarget());
log("sprite onTouchesEnded.. ");
ax::print("sprite onTouchesEnded.. ");
target->setOpacity(255);
if (target == sprite2)
{
@ -289,7 +289,7 @@ protected:
if (rect.containsPoint(locationInNode))
{
log("TouchableSprite: onTouchBegan ...");
ax::print("TouchableSprite: onTouchBegan ...");
this->setColor(Color3B::RED);
return true;
}
@ -297,7 +297,7 @@ protected:
};
listener->onTouchEnded = [this](Touch* touch, Event* event) {
log("TouchableSprite: onTouchEnded ...");
ax::print("TouchableSprite: onTouchEnded ...");
this->setColor(Color3B::WHITE);
if (_removeListenerOnTouchEnded)
@ -664,7 +664,7 @@ void SpriteAccelerationEventTest::onEnter()
auto ptNow = sprite->getPosition();
log("acc: x = %lf, y = %lf", acc->x, acc->y);
ax::print("acc: x = %lf, y = %lf", acc->x, acc->y);
ptNow.x += acc->x * 9.81f;
ptNow.y += acc->y * 9.81f;
@ -722,7 +722,7 @@ void RemoveAndRetainNodeTest::onEnter()
if (rect.containsPoint(locationInNode))
{
log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
ax::print("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
target->setOpacity(180);
return true;
}
@ -736,7 +736,7 @@ void RemoveAndRetainNodeTest::onEnter()
listener1->onTouchEnded = [=](Touch* touch, Event* event) {
auto target = static_cast<Sprite*>(event->getCurrentTarget());
log("sprite onTouchesEnded.. ");
ax::print("sprite onTouchesEnded.. ");
target->setOpacity(255);
};
@ -985,7 +985,7 @@ GlobalZTouchTest::GlobalZTouchTest() : _sprite(nullptr), _accum(0)
if (rect.containsPoint(locationInNode))
{
log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
ax::print("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
target->setOpacity(180);
return true;
}
@ -999,7 +999,7 @@ GlobalZTouchTest::GlobalZTouchTest() : _sprite(nullptr), _accum(0)
listener->onTouchEnded = [=](Touch* touch, Event* event) {
auto target = static_cast<Sprite*>(event->getCurrentTarget());
log("sprite onTouchesEnded.. ");
ax::print("sprite onTouchesEnded.. ");
target->setOpacity(255);
};
@ -1373,7 +1373,7 @@ PauseResumeTargetTest3::PauseResumeTargetTest3()
if (rect.containsPoint(locationInNode))
{
log("TouchableSprite: onTouchBegan ...");
ax::print("TouchableSprite: onTouchBegan ...");
_touchableSprite->setColor(Color3B::RED);
return true;
}
@ -1381,7 +1381,7 @@ PauseResumeTargetTest3::PauseResumeTargetTest3()
};
listener->onTouchEnded = [this](Touch* touch, Event* event) {
log("TouchableSprite: onTouchEnded ...");
ax::print("TouchableSprite: onTouchEnded ...");
_touchableSprite->setColor(Color3B::WHITE);
};
@ -1673,12 +1673,12 @@ WindowEventsTest::WindowEventsTest()
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->addCustomEventListener(GLViewImpl::EVENT_WINDOW_RESIZED, [](EventCustom* event) {
// TODO: need to create resizeable window
log("<<< WINDOW RESIZED! >>> ");
ax::print("<<< WINDOW RESIZED! >>> ");
});
dispatcher->addCustomEventListener(GLViewImpl::EVENT_WINDOW_FOCUSED,
[](EventCustom* event) { log("<<< WINDOW FOCUSED! >>> "); });
[](EventCustom* event) { ax::print("<<< WINDOW FOCUSED! >>> "); });
dispatcher->addCustomEventListener(GLViewImpl::EVENT_WINDOW_UNFOCUSED,
[](EventCustom* event) { log("<<< WINDOW BLURRED! >>> "); });
[](EventCustom* event) { ax::print("<<< WINDOW BLURRED! >>> "); });
#endif
}

View File

@ -672,7 +672,7 @@ void CaptureScreenTest::afterCaptured(bool succeed, std::string_view outputFile)
}
else
{
log("Capture screen failed.");
ax::print("Capture screen failed.");
}
// release it since it is retained in `CaptureScreenTest::onCaptured()`

View File

@ -420,7 +420,7 @@ SchedulerCallbackTest::SchedulerCallbackTest()
node->schedule(
[&](float dt) {
_total += dt;
log("hello world: %f - total: %f", dt, _total);
ax::print("hello world: %f - total: %f", dt, _total);
},
0.5, "some_key");
@ -436,7 +436,7 @@ SchedulerCallbackTest::SchedulerCallbackTest()
void SchedulerCallbackTest::onEnter()
{
TestCocosNodeDemo::onEnter();
log("--onEnter-- Must be called before the scheduled lambdas");
ax::print("--onEnter-- Must be called before the scheduled lambdas");
}
std::string SchedulerCallbackTest::subtitle() const
@ -1250,7 +1250,7 @@ void NodeNameTest::test(float dt)
{
sprintf(name, "node%d", i);
auto node = parent->getChildByName(name);
log("find child: %s", node->getName().data());
ax::print("find child: %s", node->getName().data());
}
// enumerateChildren()

View File

@ -221,13 +221,13 @@ void Issue2572::update(float dt)
case 0:
case 1:
case 2:
log("--child count-- %zd", _childList.size());
ax::print("--child count-- %zd", _childList.size());
for (const auto& obj : _childList)
{
Sprite* obstacle = dynamic_cast<Sprite*>(obj);
log("child position : (%.2f, %.2f)", obstacle->getPositionX(), obstacle->getPositionY());
ax::print("child position : (%.2f, %.2f)", obstacle->getPositionX(), obstacle->getPositionY());
}
log("-------------------");
ax::print("-------------------");
_printCount++;
break;
case 3:

View File

@ -2377,7 +2377,7 @@ void ParticleBatchHybrid::switchRender(float dt)
auto newParent = (usingBatch ? _parent2 : _parent1);
newParent->addChild(_emitter);
log("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode");
ax::print("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode");
}
std::string ParticleBatchHybrid::title() const

View File

@ -652,7 +652,7 @@ void Scene3DTestScene::createDetailDlg()
[this](bool succeed, std::string_view outputFile) {
if (!succeed)
{
log("Capture screen failed.");
ax::print("Capture screen failed.");
return;
}
auto sp = Sprite::create(outputFile);

View File

@ -211,7 +211,7 @@ bool SceneTestLayer3::init()
void SceneTestLayer3::testDealloc(float dt)
{
log("Layer3:testDealloc");
ax::print("Layer3:testDealloc");
}
void SceneTestLayer3::item0Clicked(Ref* sender)

View File

@ -185,17 +185,17 @@ void SchedulerPauseResumeAll::onExit()
void SchedulerPauseResumeAll::tick1(float /*dt*/)
{
log("tick1");
ax::print("tick1");
}
void SchedulerPauseResumeAll::tick2(float /*dt*/)
{
log("tick2");
ax::print("tick2");
}
void SchedulerPauseResumeAll::pause(float /*dt*/)
{
log("Pausing, tick1 should be called six times and tick2 three times");
ax::print("Pausing, tick1 should be called six times and tick2 three times");
auto scheduler = Director::getInstance()->getScheduler();
_pausedTargets = scheduler->pauseAllTargets();
@ -208,7 +208,7 @@ void SchedulerPauseResumeAll::pause(float /*dt*/)
void SchedulerPauseResumeAll::resume(float /*dt*/)
{
log("Resuming");
ax::print("Resuming");
auto director = Director::getInstance();
director->getScheduler()->resumeTargets(_pausedTargets);
_pausedTargets.clear();
@ -262,17 +262,17 @@ void SchedulerPauseResumeAllUser::onExit()
void SchedulerPauseResumeAllUser::tick1(float /*dt*/)
{
log("tick1");
ax::print("tick1");
}
void SchedulerPauseResumeAllUser::tick2(float /*dt*/)
{
log("tick2");
ax::print("tick2");
}
void SchedulerPauseResumeAllUser::pause(float /*dt*/)
{
log("Pausing, tick1 and tick2 should be called three times");
ax::print("Pausing, tick1 and tick2 should be called three times");
auto director = Director::getInstance();
_pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
// because target 'this' has been paused above, so use another node(tag:123) as target
@ -281,7 +281,7 @@ void SchedulerPauseResumeAllUser::pause(float /*dt*/)
void SchedulerPauseResumeAllUser::resume(float /*dt*/)
{
log("Resuming");
ax::print("Resuming");
getScheduler()->resumeTargets(_pausedTargets);
_pausedTargets.clear();
}
@ -547,7 +547,7 @@ TestNode::~TestNode() {}
void TestNode::update(float /*dt*/)
{
log("%s", _string.c_str());
ax::print("%s", _string.c_str());
}
//------------------------------------------------------------------
@ -645,7 +645,7 @@ void SchedulerUpdateAndCustom::tick(float dt)
void SchedulerUpdateAndCustom::stopSelectors(float /*dt*/)
{
log("SchedulerUpdateAndCustom::stopSelectors");
ax::print("SchedulerUpdateAndCustom::stopSelectors");
unscheduleAllCallbacks();
}
@ -757,7 +757,7 @@ std::string SchedulerDelayAndRepeat::subtitle() const
void SchedulerDelayAndRepeat::update(float dt)
{
log("update called:%f", dt);
ax::print("update called:%f", dt);
}
// SchedulerTimeScale
@ -1004,7 +1004,7 @@ public:
~TestNode2()
{
ax::log("Delete TestNode (should not crash)");
ax::print("Delete TestNode (should not crash)");
this->unscheduleAllCallbacks();
}
@ -1073,11 +1073,11 @@ void SchedulerIssueWithReschedule::onEnter()
_scheduler->schedule(
[this, verified](float dt) {
log("SchedulerIssueWithReschedule - first timer");
ax::print("SchedulerIssueWithReschedule - first timer");
_scheduler->schedule(
[verified](float dt) {
log("SchedulerIssueWithReschedule - second timer. OK");
ax::print("SchedulerIssueWithReschedule - second timer. OK");
*verified = true;
},
this, 0.1f, 0, 0, false, "test_timer");
@ -1088,13 +1088,13 @@ void SchedulerIssueWithReschedule::onEnter()
[verified, status_text](float dt) {
if (*verified)
{
log("SchedulerIssueWithReschedule - test OK");
ax::print("SchedulerIssueWithReschedule - test OK");
status_text->setString("OK");
status_text->setColor(Color3B(0, 255, 0));
}
else
{
log("SchedulerIssueWithReschedule - test failed!");
ax::print("SchedulerIssueWithReschedule - test failed!");
status_text->setString("Failed");
status_text->setColor(Color3B(255, 0, 0));
}
@ -1132,14 +1132,14 @@ schedule(global_function, ...)\n\
static void ScheduleCallbackTest_global_callback(float dt)
{
log("In the callback of schedule(global_function, ...), dt = %f", dt);
ax::print("In the callback of schedule(global_function, ...), dt = %f", dt);
}
void ScheduleCallbackTest::onEnter()
{
SchedulerTestLayer::onEnter();
_scheduler->schedule([](float dt) { log("In the callback of schedule(lambda, ...), dt = %f", dt); }, this, 1.0f,
_scheduler->schedule([](float dt) { ax::print("In the callback of schedule(lambda, ...), dt = %f", dt); }, this, 1.0f,
false, "lambda");
_scheduler->schedule(AX_CALLBACK_1(ScheduleCallbackTest::callback, this), this, 1.0f, false, "member_function");
@ -1149,7 +1149,7 @@ void ScheduleCallbackTest::onEnter()
void ScheduleCallbackTest::callback(float dt)
{
log("In the callback of schedule(AX_CALLBACK_1(XXX::member_function), this), this, ...), dt = %f", dt);
ax::print("In the callback of schedule(AX_CALLBACK_1(XXX::member_function), this), this, ...), dt = %f", dt);
}
// ScheduleUpdatePriority
@ -1197,13 +1197,13 @@ void SchedulerIssue10232::onEnter()
this->scheduleOnce(SEL_SCHEDULE(&SchedulerIssue2268::update), 0.25f);
this->scheduleOnce([](float /*dt*/) { log("SchedulerIssue10232:Schedules a lambda function"); }, 0.25f,
this->scheduleOnce([](float /*dt*/) { ax::print("SchedulerIssue10232:Schedules a lambda function"); }, 0.25f,
"SchedulerIssue10232");
}
void SchedulerIssue10232::update(float /*dt*/)
{
log("SchedulerIssue10232:Schedules a selector");
ax::print("SchedulerIssue10232:Schedules a selector");
}
std::string SchedulerIssue10232::title() const
@ -1446,7 +1446,7 @@ void SchedulerRemoveSelectorDuringCall::callback(float)
{
if (!_scheduled)
{
ax::log("Error: unscheduled callback must not be called.");
ax::print("Error: unscheduled callback must not be called.");
return;
}

View File

@ -398,7 +398,7 @@ SpriteBlur* SpriteBlur::create(const char* pszFileName)
{
SpriteBlur* pRet = new SpriteBlur();
bool result = pRet->initWithFile("");
ax::log("Test call Sprite::initWithFile with bad file name result is : %s", result ? "true" : "false");
ax::print("Test call Sprite::initWithFile with bad file name result is : %s", result ? "true" : "false");
if (pRet->initWithFile(pszFileName))
{

View File

@ -497,14 +497,14 @@ bool SpineboyExample::init()
skeletonNode = SkeletonAnimation::createWithJsonFile("spineboy-pro.json", "spineboy.atlas", 0.6f);
skeletonNode->setStartListener([](TrackEntry* entry) {
log("%d start: %s", entry->getTrackIndex(), entry->getAnimation()->getName().buffer());
ax::print("%d start: %s", entry->getTrackIndex(), entry->getAnimation()->getName().buffer());
});
skeletonNode->setInterruptListener([](TrackEntry* entry) { log("%d interrupt", entry->getTrackIndex()); });
skeletonNode->setEndListener([](TrackEntry* entry) { log("%d end", entry->getTrackIndex()); });
skeletonNode->setCompleteListener([](TrackEntry* entry) { log("%d complete", entry->getTrackIndex()); });
skeletonNode->setDisposeListener([](TrackEntry* entry) { log("%d dispose", entry->getTrackIndex()); });
skeletonNode->setInterruptListener([](TrackEntry* entry) { ax::print("%d interrupt", entry->getTrackIndex()); });
skeletonNode->setEndListener([](TrackEntry* entry) { ax::print("%d end", entry->getTrackIndex()); });
skeletonNode->setCompleteListener([](TrackEntry* entry) { ax::print("%d complete", entry->getTrackIndex()); });
skeletonNode->setDisposeListener([](TrackEntry* entry) { ax::print("%d dispose", entry->getTrackIndex()); });
skeletonNode->setEventListener([](TrackEntry* entry, spine::Event* event) {
log("%d event: %s, %d, %f, %s", entry->getTrackIndex(), event->getData().getName().buffer(),
ax::print("%d event: %s, %d, %f, %s", entry->getTrackIndex(), event->getData().getName().buffer(),
event->getIntValue(), event->getFloatValue(), event->getStringValue().buffer());
});
@ -514,7 +514,7 @@ bool SpineboyExample::init()
TrackEntry* jumpEntry = skeletonNode->addAnimation(0, "jump", false, 1);
skeletonNode->addAnimation(0, "run", true);
skeletonNode->setTrackStartListener(jumpEntry, [](TrackEntry* entry) { log("jumped!"); });
skeletonNode->setTrackStartListener(jumpEntry, [](TrackEntry* entry) { ax::print("jumped!"); });
// skeletonNode->addAnimation(1, "test", true);
// skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1), FadeIn::create(1),

View File

@ -4418,23 +4418,23 @@ void NodeSort::reorderSprite(float dt)
{
unschedule("reorder_sprite_key");
log("Before reorder--");
ax::print("Before reorder--");
auto& children = _node->getChildren();
for (const auto& child : children)
{
log("tag %i z %i", (int)child->getTag(), (int)child->getLocalZOrder());
ax::print("tag %i z %i", (int)child->getTag(), (int)child->getLocalZOrder());
}
// z-4
_node->reorderChild(_node->getChildren().at(0), -6);
_node->sortAllChildren();
log("After reorder--");
ax::print("After reorder--");
for (const auto& child : children)
{
log("tag %i z %i", (int)child->getTag(), (int)child->getLocalZOrder());
ax::print("tag %i z %i", (int)child->getTag(), (int)child->getLocalZOrder());
}
}
@ -4487,7 +4487,7 @@ void SpriteBatchNodeReorderSameIndex::reorderSprite(float dt)
for (const auto& sprite : _batchNode->getDescendants())
{
log("tag %i", sprite->getTag());
ax::print("tag %i", sprite->getTag());
}
}

View File

@ -127,14 +127,14 @@ void TextureDemo::onEnter()
addChild(col, -10);
auto textureCache = Director::getInstance()->getTextureCache();
log("%s\n", textureCache->getCachedTextureInfo().c_str());
ax::print("%s\n", textureCache->getCachedTextureInfo().c_str());
}
TextureDemo::~TextureDemo()
{
auto textureCache = Director::getInstance()->getTextureCache();
textureCache->removeUnusedTextures();
log("%s\n", textureCache->getCachedTextureInfo().c_str());
ax::print("%s\n", textureCache->getCachedTextureInfo().c_str());
}
//------------------------------------------------------------------
@ -170,7 +170,7 @@ void TextureASTC::onEnter()
/*auto img = Sprite::create("Images/astc/astc_6x6.astc");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
this->addChild(img);*/
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureASTC::title() const
@ -402,7 +402,7 @@ void TextureTGA::onEnter()
auto img = Sprite::create("TileMaps/levelmap.tga");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
this->addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureTGA::title() const
@ -424,7 +424,7 @@ void TexturePNG::onEnter()
auto img = Sprite::create("Images/test_image.png");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
// Test PNG files with different pixel formats
// grayscale without alpha
@ -471,7 +471,7 @@ void TextureJPEG::onEnter()
auto img = Sprite::create("Images/test_image.jpeg");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureJPEG::title() const
@ -492,9 +492,9 @@ void TextureWEBP::onEnter()
auto img = Sprite::create("Images/test_image.webp");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
Texture2D* texture = Director::getInstance()->getTextureCache()->getTextureForKey("Images/test_image.webp");
log("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()),
ax::print("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()),
texture->hasPremultipliedAlpha());
}
@ -516,10 +516,10 @@ void TextureWEBPNoAlpha::onEnter()
auto img = Sprite::create("Images/test_image_no_alpha.webp");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
Texture2D* texture =
Director::getInstance()->getTextureCache()->getTextureForKey("Images/test_image_no_alpha.webp");
log("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()),
ax::print("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()),
texture->hasPremultipliedAlpha());
}
@ -565,7 +565,7 @@ void TextureMipMap::onEnter()
img0->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
img1->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureMipMap::title() const
@ -618,7 +618,7 @@ void TexturePVRMipMap::onEnter()
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRMipMap::title() const
@ -662,7 +662,7 @@ void TexturePVRMipMap2::onEnter()
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRMipMap2::title() const
@ -694,7 +694,7 @@ void TexturePVR2BPP::onEnter()
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVR2BPP::title() const
@ -723,9 +723,9 @@ void TexturePVRTest::onEnter()
}
else
{
log("This test is not supported.");
ax::print("This test is not supported.");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRTest::title() const
@ -754,9 +754,9 @@ void TexturePVR4BPP::onEnter()
}
else
{
log("This test is not supported in cocos2d-mac");
ax::print("This test is not supported in cocos2d-mac");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVR4BPP::title() const
@ -779,7 +779,7 @@ void TexturePVRRGBA8888::onEnter()
auto img = Sprite::create("Images/test_image_rgba8888.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA8888::title() const
@ -807,9 +807,9 @@ void TexturePVRBGRA8888::onEnter()
}
else
{
log("BGRA8888 images are not supported");
ax::print("BGRA8888 images are not supported");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRBGRA8888::title() const
@ -831,7 +831,7 @@ void TexturePVRRGBA5551::onEnter()
auto img = Sprite::create("Images/test_image_rgba5551.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA5551::title() const
@ -854,7 +854,7 @@ void TexturePVRRGBA4444::onEnter()
auto img = Sprite::create("Images/test_image_rgba4444.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA4444::title() const
@ -882,7 +882,7 @@ void TexturePVRRGBA4444GZ::onEnter()
#endif
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA4444GZ::title() const
@ -910,7 +910,7 @@ void TexturePVRRGBA4444CCZ::onEnter()
auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA4444CCZ::title() const
@ -938,7 +938,7 @@ void TexturePVRRGB565::onEnter()
auto img = Sprite::create("Images/test_image_rgb565.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGB565::title() const
@ -961,7 +961,7 @@ void TexturePVRRGB888::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGB888::title() const
{
@ -983,7 +983,7 @@ void TexturePVRA8::onEnter()
auto img = Sprite::create("Images/test_image_a8.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRA8::title() const
@ -1006,7 +1006,7 @@ void TexturePVRI8::onEnter()
auto img = Sprite::create("Images/test_image_i8.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRI8::title() const
@ -1029,7 +1029,7 @@ void TexturePVRAI88::onEnter()
auto img = Sprite::create("Images/test_image_ai88.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRAI88::title() const
@ -1051,7 +1051,7 @@ void TexturePVR2BPPv3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVR2BPPv3::title() const
@ -1078,7 +1078,7 @@ void TexturePVRII2BPPv3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRII2BPPv3::title() const
@ -1106,10 +1106,10 @@ void TexturePVR4BPPv3::onEnter()
}
else
{
log("This test is not supported");
ax::print("This test is not supported");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVR4BPPv3::title() const
@ -1141,10 +1141,10 @@ void TexturePVRII4BPPv3::onEnter()
}
else
{
log("This test is not supported");
ax::print("This test is not supported");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRII4BPPv3::title() const
@ -1171,7 +1171,7 @@ void TexturePVRRGBA8888v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA8888v3::title() const
@ -1199,10 +1199,10 @@ void TexturePVRBGRA8888v3::onEnter()
}
else
{
log("BGRA images are not supported");
ax::print("BGRA images are not supported");
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRBGRA8888v3::title() const
@ -1229,7 +1229,7 @@ void TexturePVRRGBA5551v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA5551v3::title() const
@ -1256,7 +1256,7 @@ void TexturePVRRGBA4444v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGBA4444v3::title() const
@ -1283,7 +1283,7 @@ void TexturePVRRGB565v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGB565v3::title() const
@ -1310,7 +1310,7 @@ void TexturePVRRGB888v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRRGB888v3::title() const
@ -1337,7 +1337,7 @@ void TexturePVRA8v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRA8v3::title() const
@ -1364,7 +1364,7 @@ void TexturePVRI8v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRI8v3::title() const
@ -1391,7 +1391,7 @@ void TexturePVRAI88v3::onEnter()
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRAI88v3::title() const
@ -1447,7 +1447,7 @@ void TexturePVRNonSquare::onEnter()
auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr");
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRNonSquare::title() const
@ -1476,7 +1476,7 @@ void TexturePVRNPOT4444::onEnter()
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRNPOT4444::title() const
@ -1505,7 +1505,7 @@ void TexturePVRNPOT8888::onEnter()
img->setPosition(Vec2(s.width / 2.0f, s.height / 2.0f));
addChild(img);
}
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePVRNPOT8888::title() const
@ -1559,7 +1559,7 @@ void TextureAlias::onEnter()
sprite2->runAction(scaleforever);
sprite->runAction(scaleToo);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureAlias::title() const
@ -1656,7 +1656,7 @@ void TexturePixelFormat::onEnter()
sprite4->runAction(seq_4ever4);
sprite5->runAction(seq_4ever5);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TexturePixelFormat::title() const
@ -1788,7 +1788,7 @@ void TextureAsync::imageLoaded(Texture2D* texture)
_imageOffset++;
log("Image loaded: %p", texture);
ax::print("Image loaded: %p", texture);
}
std::string TextureAsync::title() const
@ -1887,33 +1887,33 @@ void TextureSizeTest::onEnter()
TextureDemo::onEnter();
Sprite* sprite = nullptr;
log("Loading 512x512 image...");
ax::print("Loading 512x512 image...");
sprite = Sprite::create("Images/texture512x512.png");
if (sprite)
log("OK");
ax::print("OK");
else
log("Error");
ax::print("Error");
log("Loading 1024x1024 image...");
ax::print("Loading 1024x1024 image...");
sprite = Sprite::create("Images/texture1024x1024.png");
if (sprite)
log("OK");
ax::print("OK");
else
log("Error");
ax::print("Error");
// @todo
// log("Loading 2048x2048 image...");
// ax::print("Loading 2048x2048 image...");
// sprite = Sprite::create("Images/texture2048x2048.png");
// if( sprite )
// log("OK");
// ax::print("OK");
// else
// log("Error");
// ax::print("Error");
//
// log("Loading 4096x4096 image...");
// ax::print("Loading 4096x4096 image...");
// sprite = Sprite::create("Images/texture4096x4096.png");
// if( sprite )
// log("OK");
// ax::print("OK");
// else
// log("Error");
// ax::print("Error");
}
std::string TextureSizeTest::title() const
@ -2388,7 +2388,7 @@ void TextureConvertRGB888::onEnter()
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureConvertRGB888::title() const
@ -2420,7 +2420,7 @@ void TextureConvertRGBA8888::onEnter()
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureConvertRGBA8888::title() const
@ -2452,7 +2452,7 @@ void TextureConvertL8::onEnter()
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureConvertL8::title() const
@ -2484,7 +2484,7 @@ void TextureConvertLA8::onEnter()
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
ax::print("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureConvertLA8::title() const

View File

@ -1109,7 +1109,7 @@ TMXTilePropertyTestNew::TMXTilePropertyTestNew()
{
for (const auto& value : map->getPropertiesForGID(i).asValueMap())
{
log("GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str());
ax::print("GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str());
}
}
}
@ -1136,7 +1136,7 @@ TMXOrthoFlipTestNew::TMXOrthoFlipTestNew()
addChild(map, 0, kTagTileMap);
Size AX_UNUSED s = map->getContentSize();
log("ContentSize: %f, %f", s.width, s.height);
ax::print("ContentSize: %f, %f", s.width, s.height);
auto action = ScaleBy::create(2, 0.5f);
map->runAction(action);
@ -1159,7 +1159,7 @@ TMXOrthoFlipRunTimeTestNew::TMXOrthoFlipRunTimeTestNew()
addChild(map, 0, kTagTileMap);
auto s = map->getContentSize();
log("ContentSize: %f, %f", s.width, s.height);
ax::print("ContentSize: %f, %f", s.width, s.height);
auto action = ScaleBy::create(2, 0.5f);
map->runAction(action);
@ -1229,7 +1229,7 @@ TMXOrthoFromXMLTestNew::TMXOrthoFromXMLTestNew()
addChild(map, 0, kTagTileMap);
auto s = map->getContentSize();
log("ContentSize: %f, %f", s.width, s.height);
ax::print("ContentSize: %f, %f", s.width, s.height);
auto action = ScaleBy::create(2, 0.5f);
map->runAction(action);
@ -1255,11 +1255,11 @@ TMXOrthoXMLFormatTestNew::TMXOrthoXMLFormatTestNew()
addChild(map, 0, kTagTileMap);
auto s = map->getContentSize();
log("ContentSize: %f, %f", s.width, s.height);
ax::print("ContentSize: %f, %f", s.width, s.height);
for (int i = 24; i <= 26; i++)
{
log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str());
ax::print("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str());
}
auto action = ScaleBy::create(2, 0.5f);

View File

@ -296,26 +296,26 @@ void TestLayer1::step(float dt) {}
void TestLayer1::onEnter()
{
Layer::onEnter();
log("Scene 1 onEnter");
ax::print("Scene 1 onEnter");
}
void TestLayer1::onEnterTransitionDidFinish()
{
Layer::onEnterTransitionDidFinish();
log("Scene 1: onEnterTransitionDidFinish");
ax::print("Scene 1: onEnterTransitionDidFinish");
}
void TestLayer1::onExitTransitionDidStart()
{
Layer::onExitTransitionDidStart();
log("Scene 1: onExitTransitionDidStart");
ax::print("Scene 1: onExitTransitionDidStart");
}
void TestLayer1::onExit()
{
Layer::onExit();
Director::getInstance()->getRenderer()->setDepthTest(false);
log("Scene 1 onExit");
ax::print("Scene 1 onExit");
}
TestLayer2* TestLayer2::create(std::string_view transitionName)
@ -366,24 +366,24 @@ void TestLayer2::step(float dt) {}
void TestLayer2::onEnter()
{
Layer::onEnter();
log("Scene 2 onEnter");
ax::print("Scene 2 onEnter");
}
void TestLayer2::onEnterTransitionDidFinish()
{
Layer::onEnterTransitionDidFinish();
log("Scene 2: onEnterTransitionDidFinish");
ax::print("Scene 2: onEnterTransitionDidFinish");
}
void TestLayer2::onExitTransitionDidStart()
{
Layer::onExitTransitionDidStart();
log("Scene 2: onExitTransitionDidStart");
ax::print("Scene 2: onExitTransitionDidStart");
}
void TestLayer2::onExit()
{
Layer::onExit();
Director::getInstance()->getRenderer()->setDepthTest(false);
log("Scene 2 onExit");
ax::print("Scene 2 onExit");
}

View File

@ -139,24 +139,24 @@ bool UIEditBoxTest::init()
void UIEditBoxTest::editBoxEditingDidBegin(ax::ui::EditBox* editBox)
{
log("editBox %p DidBegin !", editBox);
ax::print("editBox %p DidBegin !", editBox);
}
void UIEditBoxTest::editBoxEditingDidEndWithAction(ax::ui::EditBox* editBox,
ax::ui::EditBoxDelegate::EditBoxEndAction action)
{
log("editBox %p DidEnd with action %d!", editBox, action);
ax::print("editBox %p DidEnd with action %d!", editBox, action);
}
void UIEditBoxTest::editBoxTextChanged(ax::ui::EditBox* editBox, std::string_view text)
{
log("editBox %p TextChanged, text: %s ", editBox, text.data());
ax::print("editBox %p TextChanged, text: %s ", editBox, text.data());
editBox->setText(text.data());
}
void UIEditBoxTest::editBoxReturn(ui::EditBox* editBox)
{
log("editBox %p was returned !", editBox);
ax::print("editBox %p was returned !", editBox);
if (_editName == editBox)
{
@ -272,17 +272,17 @@ bool UIEditBoxTestToggleVisibility::init()
void UIEditBoxTestToggleVisibility::editBoxEditingDidBegin(ax::ui::EditBox* editBox)
{
log("editBox %p DidBegin !", editBox);
ax::print("editBox %p DidBegin !", editBox);
}
void UIEditBoxTestToggleVisibility::editBoxTextChanged(ax::ui::EditBox* editBox, std::string_view text)
{
log("editBox %p TextChanged, text: %s ", editBox, text.data());
ax::print("editBox %p TextChanged, text: %s ", editBox, text.data());
}
void UIEditBoxTestToggleVisibility::editBoxReturn(ui::EditBox* editBox)
{
log("editBox %p was returned !", editBox);
ax::print("editBox %p was returned !", editBox);
if (_editName == editBox)
{

View File

@ -262,14 +262,14 @@ void UIListViewTest_Vertical::selectedItemEvent(Ref* pSender, ListView::EventTyp
{
ListView* listView = static_cast<ListView*>(pSender);
auto item = listView->getItem(listView->getCurSelectedIndex());
log("select child start index = %d", item->getTag());
ax::print("select child start index = %d", item->getTag());
break;
}
case ax::ui::ListView::EventType::ON_SELECTED_ITEM_END:
{
ListView* listView = static_cast<ListView*>(pSender);
auto item = listView->getItem(listView->getCurSelectedIndex());
log("select child end index = %d", item->getTag());
ax::print("select child end index = %d", item->getTag());
break;
}
default:
@ -467,14 +467,14 @@ void UIListViewTest_Horizontal::selectedItemEvent(Ref* pSender, ListView::EventT
{
ListView* listView = static_cast<ListView*>(pSender);
auto item = listView->getItem(listView->getCurSelectedIndex());
log("select child start index = %d", item->getTag());
ax::print("select child start index = %d", item->getTag());
break;
}
case ax::ui::ListView::EventType::ON_SELECTED_ITEM_END:
{
ListView* listView = static_cast<ListView*>(pSender);
auto item = listView->getItem(listView->getCurSelectedIndex());
log("select child end index = %d", item->getTag());
ax::print("select child end index = %d", item->getTag());
break;
}
default:

View File

@ -104,7 +104,7 @@ bool UIPageViewTest::init()
pageView->removeItem(0);
pageView->scrollToItem(pageCount - 2);
ax::log("TODO in %s %s %d", __FILE__, __FUNCTION__, __LINE__);
ax::print("TODO in %s %s %d", __FILE__, __FUNCTION__, __LINE__);
pageView->setIndicatorIndexNodesOpacity(255);
@ -219,7 +219,7 @@ void UIPageViewButtonTest::onButtonClicked(Ref* sender, Widget::TouchEventType t
{
if (type == Widget::TouchEventType::ENDED)
{
log("button %s clicked", static_cast<Button*>(sender)->getName().data());
ax::print("button %s clicked", static_cast<Button*>(sender)->getName().data());
}
}

View File

@ -214,7 +214,7 @@ bool UIScale9SpriteTouchTest::init()
if (rect.containsPoint(locationInNode))
{
log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
ax::print("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
target->setOpacity(180);
return true;
}
@ -228,7 +228,7 @@ bool UIScale9SpriteTouchTest::init()
listener1->onTouchEnded = [=](Touch* touch, Event* event) {
auto target = static_cast<ui::Scale9Sprite*>(event->getCurrentTarget());
log("sprite onTouchesEnded.. ");
ax::print("sprite onTouchesEnded.. ");
target->setOpacity(255);
if (target == sprite2)
{

View File

@ -325,12 +325,12 @@ void TemplateVectorTest::onEnter()
// Set the seed by time
std::srand((unsigned)time(nullptr));
Vector<Node*> vecForRandom = createVector();
log("<--- begin ---->");
ax::print("<--- begin ---->");
for (int i = 0; i < vecForRandom.size(); ++i)
{
log("Vector: random object tag = %d", vecForRandom.getRandomObject()->getTag());
ax::print("Vector: random object tag = %d", vecForRandom.getRandomObject()->getTag());
}
log("<---- end ---->");
ax::print("<---- end ---->");
// Self assignment
Vector<Node*> vecSelfAssign = createVector();
@ -359,7 +359,7 @@ void TemplateVectorTest::onEnter()
void TemplateVectorTest::constFunc(const Vector<Node*>& vec) const
{
log("vec[8] = %d", vec.at(8)->getTag());
ax::print("vec[8] = %d", vec.at(8)->getTag());
}
std::string TemplateVectorTest::subtitle() const
@ -439,25 +439,25 @@ void TemplateMapTest::onEnter()
}
// bucket_count, bucket_size(n), bucket
log("--------------");
log("bucket_count = %d", static_cast<int>(map4.bucketCount()));
log("size = %d", static_cast<int>(map4.size()));
ax::print("--------------");
ax::print("bucket_count = %d", static_cast<int>(map4.bucketCount()));
ax::print("size = %d", static_cast<int>(map4.size()));
for (int i = 0; i < map4.bucketCount(); ++i)
{
log("bucket_size(%d) = %d", i, static_cast<int>(map4.bucketSize(i)));
ax::print("bucket_size(%d) = %d", i, static_cast<int>(map4.bucketSize(i)));
}
for (const auto& e : map4)
{
log("bucket(\"%s\"), bucket index = %d", e.first.c_str(), static_cast<int>(map4.bucket(e.first)));
ax::print("bucket(\"%s\"), bucket index = %d", e.first.c_str(), static_cast<int>(map4.bucket(e.first)));
}
log("----- all keys---------");
ax::print("----- all keys---------");
// keys and at
auto keys = map4.keys();
for (const auto& key : keys)
{
log("key = %s", key.c_str());
ax::print("key = %s", key.c_str());
}
auto node10Key = map4.at("10");
@ -465,13 +465,13 @@ void TemplateMapTest::onEnter()
map4.insert("101", node10Key);
map4.insert("102", node10Key);
log("------ keys for object --------");
ax::print("------ keys for object --------");
auto keysForObject = map4.keys(node10Key);
for (const auto& key : keysForObject)
{
log("key = %s", key.c_str());
ax::print("key = %s", key.c_str());
}
log("--------------");
ax::print("--------------");
// at in const function
constFunc(map4);
@ -532,12 +532,12 @@ void TemplateMapTest::onEnter()
// Set the seed by time
std::srand((unsigned)time(nullptr));
StringMap<Node*> mapForRandom = createMap();
log("<--- begin ---->");
ax::print("<--- begin ---->");
for (int i = 0; i < mapForRandom.size(); ++i)
{
log("Map: random object tag = %d", mapForRandom.getRandomObject()->getTag());
ax::print("Map: random object tag = %d", mapForRandom.getRandomObject()->getTag());
}
log("<---- end ---->");
ax::print("<---- end ---->");
// Self assignment
StringMap<Node*> mapForSelfAssign = createMap();
@ -562,8 +562,8 @@ void TemplateMapTest::onEnter()
void TemplateMapTest::constFunc(const StringMap<Node*>& map) const
{
log("[%s]=(tag)%d", "0", map.at("0")->getTag());
log("[%s]=(tag)%d", "1", map.find("1")->second->getTag());
ax::print("[%s]=(tag)%d", "0", map.at("0")->getTag());
ax::print("[%s]=(tag)%d", "1", map.find("1")->second->getTag());
}
std::string TemplateMapTest::subtitle() const
@ -1436,18 +1436,18 @@ using namespace UnitTest::ax;
static void __checkMathUtilResult(const char* description, const float* a1, const float* a2, int size)
{
log("-------------checking %s ----------------------------", description);
ax::print("-------------checking %s ----------------------------", description);
// Check whether the result of the optimized instruction is the same as which is implemented in C
for (int i = 0; i < size; ++i)
{
bool r = fabs(a1[i] - a2[i]) < 0.00001f; // FLT_EPSILON;
if (r)
{
log("Correct: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
ax::print("Correct: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
else
{
log("Wrong: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
ax::print("Wrong: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
AXASSERT(r, "The optimized instruction is implemented in a wrong way, please check it!");
}

View File

@ -40,7 +40,7 @@ void LAppPal::PrintLog(const csmChar* format, ...)
csmChar buf[256];
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args); // 標準出力でレンダリング
ax::log("%s", buf); // cocos2dのログ関数で出力
ax::print("%s", buf); // cocos2dのログ関数で出力
va_end(args);
}