Merge branch 'adxeproject:dev' into partical-system-animation
This commit is contained in:
Turky Mohammed 2022-06-12 17:26:54 +03:00 committed by GitHub
parent f6c390296d
commit 87e4fad96c
42 changed files with 155 additions and 806 deletions

View File

@ -4,7 +4,6 @@ on:
push:
branches:
- dev
- main
paths:
- core/**/*
- extensions/**/*
@ -31,10 +30,10 @@ jobs:
run: tools\win-ci\genbindings.ps1
- name: Commit genbindings changes
uses: EndBug/add-and-commit@v7.5.0
uses: EndBug/add-and-commit@v9.0.0
with:
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'Committing genbindings changes [skip ci]'
message: 'Committing genbindings changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,6 +1,6 @@
# adxe
[![dev](https://img.shields.io/badge/v1.0.0-beta6-yellow.svg)](https://github.com/adxeproject/adxe/releases)
[![dev](https://img.shields.io/github/v/release/adxeproject/adxe?include_prereleases&label=release)](https://github.com/adxeproject/adxe/releases)
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/adxeproject/adxe/blob/master/LICENSE)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1c5628dea478449ea0c6e1b0e30c3be9)](https://app.codacy.com/gh/adxeproject/adxe?utm_source=github.com&utm_medium=referral&utm_content=adxeproject/adxe&utm_campaign=Badge_Grade_Settings)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/adxeproject/adxe/pulls)
@ -99,7 +99,7 @@ Open [APPENDIX.md](APPENDIX.md) for additional information and see [Milestones](
4. Start Android Studio and Open [Tools][SDKManager], then switch to ```SDK Tools```, check the ```Show Package Details```, choose the following tools and click the button ```Apply``` to install them:
* Android SDK Platform 29 r5
* Android SDK Build-Tools 29.0.2
* NDK r19c+
* NDK r23c+
* CMake 3.10+
5. Wait for ```Gradle sync``` finish.
6. Note: If you use non-sdk provided CMake edition, you will need to download ```ninja``` from https://github.com/ninja-build/ninja/releases, and copy ```ninja.exe``` to cmake's bin directory

View File

@ -1,6 +1,6 @@
# adxe
[![dev](https://img.shields.io/badge/v1.0.0-beta6-yellow.svg)](https://github.com/adxeproject/adxe/releases)
[![dev](https://img.shields.io/github/v/release/adxeproject/adxe?include_prereleases&label=release)](https://github.com/adxeproject/adxe/releases)
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/adxeproject/adxe/blob/master/LICENSE)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1c5628dea478449ea0c6e1b0e30c3be9)](https://app.codacy.com/gh/adxeproject/adxe?utm_source=github.com&utm_medium=referral&utm_content=adxeproject/adxe&utm_campaign=Badge_Grade_Settings)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/adxeproject/adxe/pulls)
@ -73,7 +73,7 @@
3. 通过 [Tools][SdkManagers] 打开sdk管理工具选择如下SDK Platforms和SDK Tools后 点击按钮 ```Apply``` 一路跟着引导安装即可:
* Android SDK Platform 29 r5 (在SDK Platforms页签)
* Android SDK Build-Tools 29.0.2
* NDK r19c+
* NDK r23c+
* CMake 3.10+
5. 等待Gradle sync完成后Build APKs安装运行

View File

@ -55,7 +55,7 @@ macro(cocos2dx_depend)
find_library(APPLICATIONSERVICES_LIBRARY ApplicationServices)
find_library(IOKIT_LIBRARY IOKit)
find_library(APPKIT_LIBRARY AppKit)
find_library(ICONV_LIBRARY iconv)
#find_library(ICONV_LIBRARY iconv)
find_library(AUDIOUNIT_LIBRARY AudioUnit)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(SYSTEMCONFIGURATION_LIBRARY SystemConfiguration)
@ -66,7 +66,7 @@ macro(cocos2dx_depend)
${IOKIT_LIBRARY}
${COCOS_APPLE_LIBS}
${APPKIT_LIBRARY}
${ICONV_LIBRARY}
#${ICONV_LIBRARY}
${AUDIOUNIT_LIBRARY}
${COREAUDIO_LIBRARY}
${SYSTEMCONFIGURATION_LIBRARY}
@ -84,7 +84,7 @@ macro(cocos2dx_depend)
find_library(AV_FOUNDATION_LIBRARY AVFoundation)
find_library(WEBKIT_LIBRARY WebKit)
find_library(ZLIB z)
find_library(ICONVLIB iconv)
#find_library(ICONVLIB iconv)
list(APPEND PLATFORM_SPECIFIC_LIBS
${UIKIT_LIBRARY}
${OPENGLES_LIBRARY}
@ -98,7 +98,7 @@ macro(cocos2dx_depend)
${WEBKIT_LIBRARY}
${COCOS_APPLE_LIBS}
${ZLIB}
${ICONVLIB}
#${ICONVLIB}
)
endif()
endif()

View File

@ -2,7 +2,7 @@
Copyright (c) 2013 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
Copyright (c) 2021-2022 Bytedance Inc.
https://adxeproject.github.io/
@ -27,7 +27,6 @@
#include "2d/CCFontAtlas.h"
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
# include <iconv.h>
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
# include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#endif
@ -125,14 +124,6 @@ FontAtlas::~FontAtlas()
releaseTextures();
delete[] _currentPageData;
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
if (_iconv)
{
iconv_close(_iconv);
_iconv = nullptr;
}
#endif
}
void FontAtlas::initTextureWithZeros(Texture2D* texture)
@ -229,80 +220,9 @@ bool FontAtlas::getLetterDefinitionForChar(char32_t utf32Char, FontLetterDefinit
}
}
void FontAtlas::conversionU32TOGB2312(const std::u32string& u32Text,
std::unordered_map<unsigned int, unsigned int>& charCodeMap)
{
size_t strLen = u32Text.length();
auto gb2312StrSize = strLen * 2;
auto gb2312Text = new char[gb2312StrSize];
memset(gb2312Text, 0, gb2312StrSize);
switch (_fontFreeType->getEncoding())
{
case FT_ENCODING_GB2312:
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
std::u16string u16Text;
cocos2d::StringUtils::UTF32ToUTF16(u32Text, u16Text);
WideCharToMultiByte(936, NULL, (LPCWCH)u16Text.c_str(), strLen, (LPSTR)gb2312Text, gb2312StrSize, NULL, NULL);
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
conversionEncodingJNI((char*)u32Text.c_str(), gb2312StrSize, "UTF-32LE", gb2312Text, "GB2312");
#else
if (_iconv == nullptr)
{
_iconv = iconv_open("GBK//TRANSLIT", "UTF-32LE");
}
if (_iconv == (iconv_t)-1)
{
CCLOG("conversion from utf32 to gb2312 not available");
}
else
{
char* pin = (char*)u32Text.c_str();
char* pout = gb2312Text;
size_t inLen = strLen * 2;
size_t outLen = gb2312StrSize;
iconv(_iconv, (char**)&pin, &inLen, &pout, &outLen);
}
#endif
}
break;
default:
CCLOG("Unsupported encoding:%d", _fontFreeType->getEncoding());
break;
}
unsigned short gb2312Code = 0;
unsigned char* dst = (unsigned char*)&gb2312Code;
char32_t u32Code;
for (size_t index = 0, gbIndex = 0; index < strLen; ++index)
{
u32Code = u32Text[index];
if (u32Code < 256)
{
charCodeMap[u32Code] = u32Code;
gbIndex += 1;
}
else
{
dst[0] = gb2312Text[gbIndex + 1];
dst[1] = gb2312Text[gbIndex];
charCodeMap[u32Code] = gb2312Code;
gbIndex += 2;
}
}
delete[] gb2312Text;
}
void FontAtlas::findNewCharacters(const std::u32string& u32Text,
std::unordered_map<unsigned int, unsigned int>& charCodeMap)
void FontAtlas::findNewCharacters(const std::u32string& u32Text, std::unordered_set<char32_t>& charset)
{
std::u32string newChars;
FT_Encoding charEncoding = _fontFreeType->getEncoding();
// find new characters
if (_letterDefinitions.empty())
@ -338,25 +258,8 @@ void FontAtlas::findNewCharacters(const std::u32string& u32Text,
if (!newChars.empty())
{
switch (charEncoding)
{
case FT_ENCODING_UNICODE:
{
for (auto u32Code : newChars)
{
charCodeMap[u32Code] = u32Code;
}
break;
}
case FT_ENCODING_GB2312:
{
conversionU32TOGB2312(newChars, charCodeMap);
break;
}
default:
CCLOG("FontAtlas::findNewCharacters: Unsupported encoding:%d", charEncoding);
break;
}
for (auto u32Code : newChars)
charset.insert(u32Code);
}
}
@ -370,9 +273,9 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
if (!_currentPageData)
reinit();
std::unordered_map<unsigned int, unsigned int> codeMapOfNewChar;
findNewCharacters(utf32Text, codeMapOfNewChar);
if (codeMapOfNewChar.empty())
std::unordered_set<char32_t> charCodeSet;
findNewCharacters(utf32Text, charCodeSet);
if (charCodeSet.empty())
{
return false;
}
@ -390,9 +293,9 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
int startY = (int)_currentPageOrigY;
for (auto&& it : codeMapOfNewChar)
for (auto charCode : charCodeSet)
{
auto bitmap = _fontFreeType->getGlyphBitmap(it.second, bitmapWidth, bitmapHeight, tempRect, tempDef.xAdvance);
auto bitmap = _fontFreeType->getGlyphBitmap(charCode, bitmapWidth, bitmapHeight, tempRect, tempDef.xAdvance);
if (bitmap && bitmapWidth > 0 && bitmapHeight > 0)
{
tempDef.validDefinition = true;
@ -471,7 +374,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
_currentPageOrigX += 1;
}
_letterDefinitions[it.first] = tempDef;
_letterDefinitions[charCode] = tempDef;
}
updateTextureContent(pixelFormat, startY);

View File

@ -2,7 +2,7 @@
Copyright (c) 2013 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
Copyright (c) 2021-2022 Bytedance Inc.
https://adxeproject.github.io/
@ -120,10 +120,7 @@ protected:
void releaseTextures();
void findNewCharacters(const std::u32string& u32Text, std::unordered_map<unsigned int, unsigned int>& charCodeMap);
void conversionU32TOGB2312(const std::u32string& u32Text,
std::unordered_map<unsigned int, unsigned int>& charCodeMap);
void findNewCharacters(const std::u32string& u32Text, std::unordered_set<char32_t>& charCodeSet);
void initTextureWithZeros(Texture2D* texture);
@ -141,7 +138,6 @@ protected:
float _lineHeight = 0.f;
Font* _font = nullptr;
FontFreeType* _fontFreeType = nullptr;
void* _iconv = nullptr;
// Dynamic GlyphCollection related stuff
int _currentPage = 0;

View File

@ -54,8 +54,7 @@ void FontAtlasCache::purgeCachedData()
FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config)
{
auto realFontFilename = FileUtils::getInstance()->getNewFilename(
config->fontFilePath); // resolves real file path, to prevent storing multiple atlases for the same file.
auto realFontFilename = config->fontFilePath; // resolves real file path, to prevent storing multiple atlases for the same file.
bool useDistanceField = config->distanceFieldEnabled;
if (config->outlineSize > 0)
{
@ -97,8 +96,7 @@ FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName)
FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName, std::string_view subTextureKey)
{
const auto realFontFilename = FileUtils::getInstance()->getNewFilename(
fontFileName); // resolves real file path, to prevent storing multiple atlases for the same file.
const auto realFontFilename = fontFileName; // resolves real file path, to prevent storing multiple atlases for the same file.
std::string atlasName{subTextureKey};
atlasName.append(" ", 1).append(realFontFilename);
@ -125,8 +123,7 @@ FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName, std::s
FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName, const Rect& imageRect, bool imageRotated)
{
const auto realFontFilename = FileUtils::getInstance()->getNewFilename(
fontFileName); // resolves real file path, to prevent storing multiple atlases for the same file.
const auto realFontFilename = fontFileName; // resolves real file path, to prevent storing multiple atlases for the same file.
char keyPrefix[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
snprintf(keyPrefix, ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE, "%.2f %.2f ", imageRect.origin.x, imageRect.origin.y);
std::string atlasName(keyPrefix);

View File

@ -2,7 +2,7 @@
Copyright (c) 2013 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
Copyright (c) 2021-2022 Bytedance Inc.
https://adxeproject.github.io/
@ -59,7 +59,7 @@ typedef struct _DataRef
unsigned int referenceCount = 0;
} DataRef;
static std::unordered_map<std::string, DataRef> s_cacheFontData;
static hlookup::string_map<DataRef> s_cacheFontData;
// ------ freetype2 stream parsing support ---
static unsigned long ft_stream_read_callback(FT_Stream stream,
@ -149,7 +149,6 @@ FT_Library FontFreeType::getFTLibrary()
FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */, float outline /* = 0 */)
: _fontFace(nullptr)
, _stroker(nullptr)
, _encoding(FT_ENCODING_UNICODE)
, _distanceFieldEnabled(distanceFieldEnabled)
, _outlineSize(0.0f)
, _ascender(0)
@ -170,16 +169,12 @@ FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */, float outlin
}
// clang-format on
bool FontFreeType::loadFontFace(std::string_view fontName, float fontSize)
bool FontFreeType::loadFontFace(std::string_view fontPath, float fontSize)
{
FT_Face face;
// save font name locally
_fontName = fontName;
_fontSize = fontSize;
if (_streamParsingEnabled)
{
auto fullPath = FileUtils::getInstance()->fullPathForFilename(_fontName);
auto fullPath = FileUtils::getInstance()->fullPathForFilename(fontPath);
if (fullPath.empty())
return false;
@ -207,15 +202,15 @@ bool FontFreeType::loadFontFace(std::string_view fontName, float fontSize)
else
{
DataRef* sharableData;
auto it = s_cacheFontData.find(_fontName);
auto it = s_cacheFontData.find(fontPath);
if (it != s_cacheFontData.end())
{
sharableData = &it->second;
}
else
{
sharableData = &s_cacheFontData[_fontName];
sharableData->data = FileUtils::getInstance()->getDataFromFile(_fontName);
sharableData = &s_cacheFontData[fontPath];
sharableData->data = FileUtils::getInstance()->getDataFromFile(fontPath);
}
++sharableData->referenceCount;
@ -225,66 +220,55 @@ bool FontFreeType::loadFontFace(std::string_view fontName, float fontSize)
return false;
}
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))
do
{
int foundIndex = -1;
for (int charmapIndex = 0; charmapIndex < face->num_charmaps; charmapIndex++)
if (!face->charmap || face->charmap->encoding != FT_ENCODING_UNICODE)
break;
// set the requested font size
int dpi = 72;
int fontSizePoints = (int)(64.f * fontSize * CC_CONTENT_SCALE_FACTOR());
if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi))
break;
// store the face globally
_fontFace = face;
_fontSize = fontSize;
_fontName = fontPath;
// Notes:
// a. Since freetype 2.8.1 the TT matrics isn't sync to size_matrics, see the function 'tt_size_request' in
// truetype/ttdriver.c b. The TT spec always asks for ROUND, not FLOOR or CEIL, see also the function
// 'tt_size_reset' in truetype/ttobjs.c
// ** Please see description of FT_Size_Metrics_ in freetype.h about this solution
// FT_PIX_ROUND is copy from freetype/internal/ftobjs.h
auto& size_metrics = _fontFace->size->metrics;
if (_doNativeBytecodeHinting && !strcmp(FT_Get_Font_Format(face), "TrueType"))
{
if (face->charmaps[charmapIndex]->encoding != FT_ENCODING_NONE)
{
foundIndex = charmapIndex;
break;
}
}
if (foundIndex == -1)
{
return false;
}
_encoding = face->charmaps[foundIndex]->encoding;
if (FT_Select_Charmap(face, _encoding))
{
return false;
}
}
// set the requested font size
int dpi = 72;
int fontSizePoints = (int)(64.f * fontSize * CC_CONTENT_SCALE_FACTOR());
if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi))
return false;
// store the face globally
_fontFace = face;
// Notes:
// a. Since freetype 2.8.1 the TT matrics isn't sync to size_matrics, see the function 'tt_size_request' in
// truetype/ttdriver.c b. The TT spec always asks for ROUND, not FLOOR or CEIL, see also the function
// 'tt_size_reset' in truetype/ttobjs.c
// ** Please see description of FT_Size_Metrics_ in freetype.h about this solution
// FT_PIX_ROUND is copy from freetype/internal/ftobjs.h
auto& size_metrics = _fontFace->size->metrics;
if (_doNativeBytecodeHinting && !strcmp(FT_Get_Font_Format(face), "TrueType"))
{
#if !defined(FT_PIX_ROUND)
# define FT_TYPEOF(type)
# define FT_PIX_FLOOR(x) ((x) & ~FT_TYPEOF(x) 63)
# define FT_PIX_ROUND(x) FT_PIX_FLOOR((x) + 32)
#endif
_ascender = FT_PIX_ROUND(FT_MulFix(face->ascender, size_metrics.y_scale));
_descender = FT_PIX_ROUND(FT_MulFix(face->descender, size_metrics.y_scale));
}
else
{
_ascender = size_metrics.ascender;
_descender = size_metrics.descender;
}
_ascender = FT_PIX_ROUND(FT_MulFix(face->ascender, size_metrics.y_scale));
_descender = FT_PIX_ROUND(FT_MulFix(face->descender, size_metrics.y_scale));
}
else
{
_ascender = size_metrics.ascender;
_descender = size_metrics.descender;
}
_lineHeight = (_ascender - _descender) >> 6;
_lineHeight = (_ascender - _descender) >> 6;
// done and good
return true;
// done and good
return true;
} while (false);
FT_Done_Face(face);
cocos2d::log("Init font '%s' failed, only unicode ttf/ttc was supported.", fontPath.data());
return false;
}
FontFreeType::~FontFreeType()
@ -386,7 +370,7 @@ const char* FontFreeType::getFontFamily() const
return _fontFace->family_name;
}
unsigned char* FontFreeType::getGlyphBitmap(uint32_t theChar,
unsigned char* FontFreeType::getGlyphBitmap(char32_t charCode,
int32_t& outWidth,
int32_t& outHeight,
Rect& outRect,
@ -400,11 +384,11 @@ unsigned char* FontFreeType::getGlyphBitmap(uint32_t theChar,
break;
// @remark: glyphIndex=0 means charactor is mssing on current font face
auto glyphIndex = FT_Get_Char_Index(_fontFace, static_cast<FT_ULong>(theChar));
auto glyphIndex = FT_Get_Char_Index(_fontFace, static_cast<FT_ULong>(charCode));
#if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0
if (glyphIndex == 0)
{
char32_t ntcs[2] = {theChar, (char32_t)0};
char32_t ntcs[2] = {charCode, (char32_t)0};
std::u32string_view charUTF32(ntcs, 1);
std::string charUTF8;
cocos2d::StringUtils::UTF32ToUTF8(charUTF32, charUTF8);

View File

@ -2,7 +2,7 @@
Copyright (c) 2013 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
Copyright (c) 2021-2022 Bytedance Inc.
https://adxeproject.github.io/
@ -45,7 +45,7 @@ class CC_DLL FontFreeType : public Font
public:
static const int DistanceMapSpread;
static FontFreeType* create(std::string_view fontName,
static FontFreeType* create(std::string_view fontPath,
float fontSize,
GlyphCollection glyphs,
std::string_view customGlyphs,
@ -89,11 +89,9 @@ public:
int32_t bitmapWidth,
int32_t bitmapHeight);
FT_Encoding getEncoding() const { return _encoding; }
int* getHorizontalKerningForTextUTF32(const std::u32string& text, int& outNumLetters) const override;
unsigned char* getGlyphBitmap(uint32_t theChar,
unsigned char* getGlyphBitmap(char32_t charCode,
int32_t& outWidth,
int32_t& outHeight,
Rect& outRect,
@ -119,7 +117,7 @@ private:
FontFreeType(bool distanceFieldEnabled = false, float outline = 0);
virtual ~FontFreeType();
bool loadFontFace(std::string_view fontName, float fontSize);
bool loadFontFace(std::string_view fontPath, float fontSize);
static bool initFreeType();
@ -132,7 +130,6 @@ private:
FT_Face _fontFace;
std::unique_ptr<FT_StreamRec> _fontStream;
FT_Stroker _stroker;
FT_Encoding _encoding;
std::string _fontName;
float _fontSize;

View File

@ -131,7 +131,7 @@ void log(const char* format, ...)
va_end(args);
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf.c_str());
__android_log_print(ANDROID_LOG_DEBUG, "adxe debug info", "%s", buf.c_str());
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
buf.push_back('\n');

View File

@ -210,7 +210,7 @@ Value& Value::operator=(Value&& other)
switch (other.getTypeFamily())
{
case Type::INTEGER:
_field.uintVal = other._field.uintVal;
_field.uint64Val = other._field.uint64Val;
break;
case Type::FLOAT:
_field.floatVal = other._field.floatVal;

View File

@ -405,7 +405,7 @@ std::string getDataMD5Hash(const Data& data)
return computeDigest(std::string_view{(const char*)data.getBytes(), (size_t)data.getSize()}, "md5"sv);
}
CC_DLL std::string computeDigest(std::string_view data, std::string_view algorithm)
std::string computeDigest(std::string_view data, std::string_view algorithm)
{
const EVP_MD* md = nullptr;
unsigned char mdValue[EVP_MAX_MD_SIZE] = {0};

View File

@ -1,7 +1,7 @@
/****************************************************************************
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
Copyright (c) 2021-2022 Bytedance Inc.
https://adxeproject.github.io/
@ -206,7 +206,8 @@ public:
_cancelled = true;
if (this->_sockfd != -1)
{
::shutdown(this->_sockfd, SD_BOTH); // may cause curl CURLE_SEND_ERROR(55) or CURLE_RECV_ERROR(56)
if(::shutdown(this->_sockfd, SD_BOTH) == -1) // may cause curl CURLE_SEND_ERROR(55) or CURLE_RECV_ERROR(56)
::closesocket(this->_sockfd);
this->_sockfd = -1;
}
}

View File

@ -35,7 +35,6 @@ THE SOFTWARE.
#include "base/ccMacros.h"
#include "base/CCDirector.h"
#include "platform/CCSAXParser.h"
//#include "base/ccUtils.h"
#include "platform/CCPosixFileStream.h"
#ifdef MINIZIP_FROM_SYSTEM
@ -50,19 +49,19 @@ THE SOFTWARE.
# include "yasio/cxx17/string_view.hpp"
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
# include "tinydir/tinydir.h"
#endif
#include "pugixml/pugixml.hpp"
#define DECLARE_GUARD (void)0
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS && \
(CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID || (defined(__NDK_MAJOR__) && __NDK_MAJOR__ >= 22))
# define ADXE_HAVE_STDFS 1
# include <filesystem>
namespace stdfs = std::filesystem;
#else
#include "ghc/filesystem.hpp"
namespace stdfs = ghc::filesystem;
#endif
# if defined(_WIN32)
inline stdfs::path toFspath(const std::string_view& pathSV)
{
@ -74,10 +73,6 @@ inline stdfs::path toFspath(const std::string_view& pathSV)
return stdfs::path{pathSV};
}
# endif
#else
# include "tinydir/tinydir.h"
# define ADXE_HAVE_STDFS 0
#endif
NS_CC_BEGIN
@ -163,7 +158,7 @@ public:
void startElement(void* ctx, const char* name, const char** atts) override
{
const std::string sName(name);
if (sName == "dict")
if (sName == "dict"sv)
{
if (_resultType == SAX_RESULT_DICT && _rootDict.empty())
{
@ -197,23 +192,23 @@ public:
_stateStack.push(_state);
_dictStack.push(_curDict);
}
else if (sName == "key")
else if (sName == "key"sv)
{
_state = SAX_KEY;
}
else if (sName == "integer")
else if (sName == "integer"sv)
{
_state = SAX_INT;
}
else if (sName == "real")
else if (sName == "real"sv)
{
_state = SAX_REAL;
}
else if (sName == "string")
else if (sName == "string"sv)
{
_state = SAX_STRING;
}
else if (sName == "array")
else if (sName == "array"sv)
{
_state = SAX_ARRAY;
@ -253,7 +248,7 @@ public:
{
SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top();
const std::string sName((char*)name);
if (sName == "dict")
if (sName == "dict"sv)
{
_stateStack.pop();
_dictStack.pop();
@ -262,7 +257,7 @@ public:
_curDict = _dictStack.top();
}
}
else if (sName == "array")
else if (sName == "array"sv)
{
_stateStack.pop();
_arrayStack.pop();
@ -271,7 +266,7 @@ public:
_curArray = _arrayStack.top();
}
}
else if (sName == "true")
else if (sName == "true"sv)
{
if (SAX_ARRAY == curState)
{
@ -282,7 +277,7 @@ public:
(*_curDict)[_curKey] = Value(true);
}
}
else if (sName == "false")
else if (sName == "false"sv)
{
if (SAX_ARRAY == curState)
{
@ -293,22 +288,22 @@ public:
(*_curDict)[_curKey] = Value(false);
}
}
else if (sName == "string" || sName == "integer" || sName == "real")
else if (sName == "string"sv || sName == "integer"sv || sName == "real"sv)
{
if (SAX_ARRAY == curState)
{
if (sName == "string")
if (sName == "string"sv)
_curArray->push_back(Value(_curValue));
else if (sName == "integer")
else if (sName == "integer"sv)
_curArray->push_back(Value(atoi(_curValue.c_str())));
else
_curArray->push_back(Value(std::atof(_curValue.c_str())));
}
else if (SAX_DICT == curState)
{
if (sName == "string")
if (sName == "string"sv)
(*_curDict)[_curKey] = Value(_curValue);
else if (sName == "integer")
else if (sName == "integer"sv)
(*_curDict)[_curKey] = Value(atoi(_curValue.c_str()));
else
(*_curDict)[_curKey] = Value(std::atof(_curValue.c_str()));
@ -423,25 +418,25 @@ static void generateElementForObject(const Value& value, pugi::xml_node& parent)
// object is String
if (value.getType() == Value::Type::STRING)
{
auto node = parent.append_child("string");
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString().c_str());
auto node = parent.append_child("string"sv);
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString());
}
// object is integer
else if (value.getType() == Value::Type::INTEGER)
{
auto node = parent.append_child("integer");
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString().c_str());
auto node = parent.append_child("integer"sv);
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString());
}
// object is real
else if (value.getType() == Value::Type::FLOAT || value.getType() == Value::Type::DOUBLE)
{
auto node = parent.append_child("real");
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString().c_str());
auto node = parent.append_child("real"sv);
node.append_child(pugi::xml_node_type::node_pcdata).set_value(value.asString());
}
// object is bool
else if (value.getType() == Value::Type::BOOLEAN)
{
parent.append_child(value.asString().c_str());
parent.append_child(value.asString());
}
// object is Array
else if (value.getType() == Value::Type::VECTOR)
@ -453,11 +448,11 @@ static void generateElementForObject(const Value& value, pugi::xml_node& parent)
static void generateElementForDict(const ValueMap& dict, pugi::xml_node& parent)
{
auto dictDS = parent.append_child("dict");
auto dictDS = parent.append_child("dict"sv);
for (const auto& iter : dict)
{
auto key = dictDS.append_child("key");
key.append_child(pugi::xml_node_type::node_pcdata).set_value(iter.first.c_str());
auto key = dictDS.append_child("key"sv);
key.append_child(pugi::xml_node_type::node_pcdata).set_value(iter.first);
generateElementForObject(iter.second, dictDS);
}
@ -465,7 +460,7 @@ static void generateElementForDict(const ValueMap& dict, pugi::xml_node& parent)
static void generateElementForArray(const ValueVector& array, pugi::xml_node& parent)
{
auto arrayDS = parent.append_child("array");
auto arrayDS = parent.append_child("array"sv);
for (const auto& value : array)
{
generateElementForObject(value, arrayDS);
@ -646,26 +641,6 @@ void FileUtils::writeValueVectorToFile(ValueVector vecData,
std::move(callback), std::move(vecData));
}
std::string FileUtils::getNewFilename(std::string_view filename) const
{
std::string newFileName;
DECLARE_GUARD;
// in Lookup Filename dictionary ?
auto iter = _filenameLookupDict.find(filename);
if (iter == _filenameLookupDict.end())
{
newFileName = filename;
}
else
{
newFileName = iter->second.asString();
}
return newFileName;
}
std::string FileUtils::getPathForFilename(std::string_view filename,
std::string_view resolutionDirectory,
std::string_view searchPath) const
@ -724,16 +699,13 @@ std::string FileUtils::fullPathForFilename(std::string_view filename) const
return cacheIter->second;
}
// Get the new file name.
const std::string newFilename(getNewFilename(filename));
std::string fullpath;
for (const auto& searchIt : _searchPathArray)
{
for (const auto& resolutionIt : _searchResolutionsOrderArray)
{
fullpath = this->getPathForFilename(newFilename, resolutionIt, searchIt);
fullpath = this->getPathForFilename(filename, resolutionIt, searchIt);
if (!fullpath.empty())
{
@ -781,13 +753,11 @@ std::string FileUtils::fullPathForDirectory(std::string_view dir) const
longdir += "/";
}
const std::string newdirname(getNewFilename(longdir));
for (const auto& searchIt : _searchPathArray)
{
for (const auto& resolutionIt : _searchResolutionsOrderArray)
{
fullpath = this->getPathForDirectory(newdirname, resolutionIt, searchIt);
fullpath = this->getPathForDirectory(longdir, resolutionIt, searchIt);
if (!fullpath.empty() && isDirectoryExistInternal(fullpath))
{
// Using the filename passed in as key.
@ -808,7 +778,7 @@ std::string FileUtils::fullPathForDirectory(std::string_view dir) const
std::string FileUtils::fullPathFromRelativeFile(std::string_view filename, std::string_view relativeFile) const
{
return std::string{relativeFile.substr(0, relativeFile.rfind('/') + 1)}.append(getNewFilename(filename));
return std::string{relativeFile.substr(0, relativeFile.rfind('/') + 1)}.append(filename);
}
void FileUtils::setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder)
@ -977,35 +947,6 @@ void FileUtils::addSearchPath(std::string_view searchpath, const bool front)
}
}
void FileUtils::setFilenameLookupDictionary(const ValueMap& filenameLookupDict)
{
DECLARE_GUARD;
_fullPathCache.clear();
_fullPathCacheDir.clear();
_filenameLookupDict = filenameLookupDict;
}
void FileUtils::loadFilenameLookupDictionaryFromFile(std::string_view filename)
{
const std::string fullPath = fullPathForFilename(filename);
if (!fullPath.empty())
{
ValueMap dict = getValueMapFromFile(fullPath);
if (!dict.empty())
{
ValueMap& metadata = dict["metadata"].asValueMap();
int version = metadata["version"].asInt();
if (version != 1)
{
CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %d. Filename: %s", version,
filename.data());
return;
}
setFilenameLookupDictionary(dict["filenames"].asValueMap());
}
}
}
std::string FileUtils::getFullPathForFilenameWithinDirectory(std::string_view directory,
std::string_view filename) const
{
@ -1176,10 +1117,9 @@ std::unique_ptr<FileStream> FileUtils::openFileStream(std::string_view filePath,
}
/* !!!Notes for c++fs
a. ios: require ios 13.0+
a. ios: require ios 13.0+, currently use ghc as workaround in lower ios 13.0- devices
b. android: require ndk-r22+
*/
#if ADXE_HAVE_STDFS
std::vector<std::string> FileUtils::listFiles(std::string_view dirPath) const
{
const auto fullPath = fullPathForDirectory(dirPath);
@ -1206,9 +1146,7 @@ std::vector<std::string> FileUtils::listFiles(std::string_view dirPath) const
std::string pathStr = entry.path().string();
# endif
if (isDir)
{
pathStr += '/';
}
files.emplace_back(std::move(pathStr));
}
}
@ -1240,100 +1178,11 @@ void FileUtils::listFilesRecursively(std::string_view dirPath, std::vector<std::
std::string pathStr = entry.path().string();
# endif
if (isDir)
{
pathStr += '/';
}
files->emplace_back(std::move(pathStr));
}
}
}
#else
std::vector<std::string> FileUtils::listFiles(std::string_view dirPath) const
{
std::vector<std::string> files;
std::string fullpath = fullPathForDirectory(dirPath);
if (!fullpath.empty() && isDirectoryExist(fullpath))
{
tinydir_dir dir;
std::string fullpathstr = fullpath;
if (tinydir_open(&dir, &fullpathstr[0]) != -1)
{
while (dir.has_next)
{
tinydir_file file;
if (tinydir_readfile(&dir, &file) == -1)
{
// Error getting file
break;
}
std::string filepath = file.path;
if (strcmp(file.name, ".") != 0 && strcmp(file.name, "..") != 0)
{
if (file.is_dir)
filepath.push_back('/');
files.push_back(std::move(filepath));
}
if (tinydir_next(&dir) == -1)
{
// Error getting next file
break;
}
}
}
tinydir_close(&dir);
}
return files;
}
void FileUtils::listFilesRecursively(std::string_view dirPath, std::vector<std::string>* files) const
{
std::string fullpath = fullPathForDirectory(dirPath);
if (isDirectoryExist(fullpath))
{
tinydir_dir dir;
std::string fullpathstr = fullpath;
if (tinydir_open(&dir, &fullpathstr[0]) != -1)
{
while (dir.has_next)
{
tinydir_file file;
if (tinydir_readfile(&dir, &file) == -1)
{
// Error getting file
break;
}
if (strcmp(file.name, ".") != 0 && strcmp(file.name, "..") != 0)
{
std::string filepath = file.path;
if (file.is_dir)
{
filepath.push_back('/');
files->push_back(filepath);
listFilesRecursively(filepath, files);
}
else
{
files->push_back(std::move(filepath));
}
}
if (tinydir_next(&dir) == -1)
{
// Error getting next file
break;
}
}
}
tinydir_close(&dir);
}
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// windows os implement should override in platform specific FileUtiles class

View File

@ -293,49 +293,6 @@ public:
*/
virtual std::string fullPathForFilename(std::string_view filename) const;
/**
* Loads the filenameLookup dictionary from the contents of a filename.
*
* @note The plist file name should follow the format below:
*
* @code
* <?xml version="1.0" encoding="UTF-8"?>
* <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
* <plist version="1.0">
* <dict>
* <key>filenames</key>
* <dict>
* <key>sounds/click.wav</key>
* <string>sounds/click.caf</string>
* <key>sounds/endgame.wav</key>
* <string>sounds/endgame.caf</string>
* <key>sounds/gem-0.wav</key>
* <string>sounds/gem-0.caf</string>
* </dict>
* <key>metadata</key>
* <dict>
* <key>version</key>
* <integer>1</integer>
* </dict>
* </dict>
* </plist>
* @endcode
* @param filename The plist file name.
*
@since v2.1
* @js loadFilenameLookup
* @lua loadFilenameLookup
*/
virtual void loadFilenameLookupDictionaryFromFile(std::string_view filename);
/**
* Sets the filenameLookup dictionary.
*
* @param filenameLookupDict The dictionary for replacing filename.
* @since v2.1
*/
virtual void setFilenameLookupDictionary(const ValueMap& filenameLookupDict);
/**
* Gets full path from a file name and the path of the relative file.
* @param filename The file name.
@ -820,15 +777,6 @@ public:
/** Returns the full path cache. */
const hlookup::string_map<std::string> getFullPathCache() const { return _fullPathCache; }
/**
* Gets the new filename from the filename lookup dictionary.
* It is possible to have a override names.
* @param filename The original filename.
* @return The new filename after searching in the filename lookup dictionary.
* If the original filename wasn't in the dictionary, it will return the original filename.
*/
virtual std::string getNewFilename(std::string_view filename) const;
/**
* Checks whether a file exists without considering search paths and resolution orders.
* @param filename The file (with absolute path) to look up for
@ -909,15 +857,6 @@ protected:
*/
mutable std::recursive_mutex _mutex;
/** Dictionary used to lookup filenames based on a key.
* It is used internally by the following methods:
*
* std::string fullPathForFilename(const char*);
*
* @since v2.1
*/
ValueMap _filenameLookupDict;
/**
* The vector contains resolution folders.
* The lower index of the element in this vector, the higher priority for this resolution directory.

View File

@ -105,59 +105,6 @@ bool FileUtilsAndroid::init()
return FileUtils::init();
}
std::string FileUtilsAndroid::getNewFilename(std::string_view filename) const
{
std::string newFileName = FileUtils::getNewFilename(filename);
// ../xxx do not fix this path
auto pos = newFileName.find("../");
if (pos == std::string::npos || pos == 0)
{
return newFileName;
}
std::vector<std::string> v(3);
v.resize(0);
auto change = false;
size_t size = newFileName.size();
size_t idx = 0;
bool noexit = true;
while (noexit)
{
pos = newFileName.find('/', idx);
std::string tmp;
if (pos == std::string::npos)
{
tmp = newFileName.substr(idx, size - idx);
noexit = false;
}
else
{
tmp = newFileName.substr(idx, pos - idx + 1);
}
auto t = v.size();
if (t > 0 && v[t - 1].compare("../") != 0 && (tmp.compare("../") == 0 || tmp.compare("..") == 0))
{
v.pop_back();
change = true;
}
else
{
v.push_back(tmp);
}
idx = pos + 1;
}
if (change)
{
newFileName.clear();
for (auto& s : v)
{
newFileName.append(s);
}
}
return newFileName;
}
bool FileUtilsAndroid::isFileExistInternal(std::string_view strFilePath) const
{

View File

@ -64,8 +64,6 @@ public:
/* override functions */
bool init() override;
virtual std::string getNewFilename(std::string_view filename) const override;
virtual FileUtils::Status getContents(std::string_view filename, ResizableBuffer* buffer) const override;
virtual std::string getWritablePath() const override;

View File

@ -171,8 +171,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
Log.d(TAG, "onResume()");
paused = false;
super.onResume();
this.hideVirtualButton();
resumeIfHasFocus();
if (this.hasFocus) {
resume();
}
}
@Override
@ -181,7 +182,15 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
super.onWindowFocusChanged(hasFocus);
this.hasFocus = hasFocus;
resumeIfHasFocus();
if (this.hasFocus && !paused) {
resume();
}
}
private void resume() {
this.hideVirtualButton();
Cocos2dxHelper.onResume();
mGLSurfaceView.onResume();
}
private void resumeIfHasFocus() {
@ -190,9 +199,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
boolean readyToPlay = !isDeviceLocked() && !isDeviceAsleep();
if(hasFocus && readyToPlay) {
this.hideVirtualButton();
Cocos2dxHelper.onResume();
mGLSurfaceView.onResume();
resume();
}
}

View File

@ -96,7 +96,9 @@ class adxetools {
return new VersionComparator().compare(ver1, ver2);
}
static String[] findNDK(String ndkVer){
static String[] findNDK(){
def ndkVer = "23.2.8568313" // ndk-r23c
def allowNewerNdk = false
if(ndkVer.endsWith('+')) {
allowNewerNdk = true

View File

@ -1,14 +1,11 @@
//
// Copyright (c) 2014-2020 @HALX99 - All Rights Reserved
// Copyright (c) 2014-2022 @HALX99 - All Rights Reserved
//
#ifndef _UITEXTFIELD_CPP_H_
#define _UITEXTFIELD_CPP_H_
#include "UITextFieldEx.h"
#include "base/CCDirector.h"
// #include "CCGLView.h"
//#include "NXMacroDefs.h"
//#include "purelib/utils/iconvw.h"
/// cocos2d singleton objects
#define CCDIRECTOR cocos2d::Director::getInstance()

View File

@ -32132,56 +32132,6 @@ int lua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_FileUtils_setFilenameLookupDictionary(lua_State* tolua_S)
{
int argc = 0;
cocos2d::FileUtils* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_setFilenameLookupDictionary'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::ValueMap arg0;
ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "cc.FileUtils:setFilenameLookupDictionary");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FileUtils_setFilenameLookupDictionary'", nullptr);
return 0;
}
cobj->setFilenameLookupDictionary(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FileUtils:setFilenameLookupDictionary",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_setFilenameLookupDictionary'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_FileUtils_getNativeWritableAbsolutePath(lua_State* tolua_S)
{
int argc = 0;
@ -32565,56 +32515,6 @@ int lua_cocos2dx_FileUtils_getDefaultResourceRootPath(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(lua_State* tolua_S)
{
int argc = 0;
cocos2d::FileUtils* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string_view arg0;
ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.FileUtils:loadFilenameLookupDictionaryFromFile");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile'", nullptr);
return 0;
}
cobj->loadFilenameLookupDictionaryFromFile(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FileUtils:loadFilenameLookupDictionaryFromFile",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_FileUtils_isPopupNotify(lua_State* tolua_S)
{
int argc = 0;
@ -32859,56 +32759,6 @@ int lua_cocos2dx_FileUtils_getOriginalSearchPaths(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_FileUtils_getNewFilename(lua_State* tolua_S)
{
int argc = 0;
cocos2d::FileUtils* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getNewFilename'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string_view arg0;
ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.FileUtils:getNewFilename");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FileUtils_getNewFilename'", nullptr);
return 0;
}
std::string ret = cobj->getNewFilename(arg0);
lua_pushlstring(tolua_S,ret.c_str(),ret.length());
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FileUtils:getNewFilename",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getNewFilename'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_FileUtils_listFiles(lua_State* tolua_S)
{
int argc = 0;
@ -34623,20 +34473,17 @@ int lua_register_cocos2dx_FileUtils(lua_State* tolua_S)
tolua_beginmodule(tolua_S,"FileUtils");
tolua_function(tolua_S,"fullPathForFilename",lua_cocos2dx_FileUtils_fullPathForFilename);
tolua_function(tolua_S,"getStringFromFile",lua_cocos2dx_FileUtils_getStringFromFile);
tolua_function(tolua_S,"setFilenameLookupDictionary",lua_cocos2dx_FileUtils_setFilenameLookupDictionary);
tolua_function(tolua_S,"getNativeWritableAbsolutePath",lua_cocos2dx_FileUtils_getNativeWritableAbsolutePath);
tolua_function(tolua_S,"removeFile",lua_cocos2dx_FileUtils_removeFile);
tolua_function(tolua_S,"listFilesRecursivelyAsync",lua_cocos2dx_FileUtils_listFilesRecursivelyAsync);
tolua_function(tolua_S,"isAbsolutePath",lua_cocos2dx_FileUtils_isAbsolutePath);
tolua_function(tolua_S,"renameFile",lua_cocos2dx_FileUtils_renameFile);
tolua_function(tolua_S,"getDefaultResourceRootPath",lua_cocos2dx_FileUtils_getDefaultResourceRootPath);
tolua_function(tolua_S,"loadFilenameLookup",lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile);
tolua_function(tolua_S,"isPopupNotify",lua_cocos2dx_FileUtils_isPopupNotify);
tolua_function(tolua_S,"getValueVectorFromFile",lua_cocos2dx_FileUtils_getValueVectorFromFile);
tolua_function(tolua_S,"getSearchPaths",lua_cocos2dx_FileUtils_getSearchPaths);
tolua_function(tolua_S,"writeToFile",lua_cocos2dx_FileUtils_writeToFile);
tolua_function(tolua_S,"getOriginalSearchPaths",lua_cocos2dx_FileUtils_getOriginalSearchPaths);
tolua_function(tolua_S,"getNewFilename",lua_cocos2dx_FileUtils_getNewFilename);
tolua_function(tolua_S,"listFiles",lua_cocos2dx_FileUtils_listFiles);
tolua_function(tolua_S,"getValueMapFromFile",lua_cocos2dx_FileUtils_getValueMapFromFile);
tolua_function(tolua_S,"getFileSize",lua_cocos2dx_FileUtils_getFileSize);

View File

@ -2325,9 +2325,6 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -9,7 +9,7 @@ android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK("19.2.5345600+")
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -9,7 +9,7 @@ android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK("19.2.5345600+")
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -30,7 +30,6 @@ FileUtilsTests::FileUtilsTests()
{
ADD_TEST_CASE(TestResolutionDirectories);
ADD_TEST_CASE(TestSearchPath);
ADD_TEST_CASE(TestFilenameLookup);
ADD_TEST_CASE(TestIsFileExist);
ADD_TEST_CASE(TestIsDirectoryExist);
ADD_TEST_CASE(TestFileFuncs);
@ -208,44 +207,6 @@ std::string TestSearchPath::subtitle() const
return "See the console, can see a orange box and a 'about' picture, except Android";
}
// TestFilenameLookup
void TestFilenameLookup::onEnter()
{
FileUtilsDemo::onEnter();
auto sharedFileUtils = FileUtils::getInstance();
ValueMap dict;
dict["grossini.bmp"] = Value("Images/grossini.png");
dict["grossini.xcf"] = Value("Images/grossini.png");
sharedFileUtils->setFilenameLookupDictionary(dict);
// Instead of loading carlitos.xcf, it will load grossini.png
auto sprite = Sprite::create("grossini.xcf");
this->addChild(sprite);
auto s = Director::getInstance()->getWinSize();
sprite->setPosition(s.width / 2, s.height / 2);
}
void TestFilenameLookup::onExit()
{
FileUtils* sharedFileUtils = FileUtils::getInstance();
// reset filename lookup
sharedFileUtils->setFilenameLookupDictionary(ValueMap());
FileUtilsDemo::onExit();
}
std::string TestFilenameLookup::title() const
{
return "FileUtils: filename lookup";
}
// TestIsFileExist
void TestIsFileExist::onEnter()
@ -276,9 +237,6 @@ void TestIsFileExist::onExit()
FileUtils* sharedFileUtils = FileUtils::getInstance();
// reset filename lookup
sharedFileUtils->setFilenameLookupDictionary(ValueMap());
FileUtilsDemo::onExit();
}
@ -997,7 +955,6 @@ void TestUnicodePath::onExit()
FileUtils* sharedFileUtils = FileUtils::getInstance();
sharedFileUtils->purgeCachedEntries();
sharedFileUtils->setFilenameLookupDictionary(ValueMap());
FileUtilsDemo::onExit();
}
@ -1037,12 +994,6 @@ void TestIsFileExistAsync::onEnter()
void TestIsFileExistAsync::onExit()
{
FileUtils* sharedFileUtils = FileUtils::getInstance();
// reset filename lookup
sharedFileUtils->setFilenameLookupDictionary(ValueMap());
FileUtilsDemo::onExit();
}

View File

@ -64,16 +64,6 @@ private:
std::vector<std::string> _defaultResolutionsOrderArray;
};
class TestFilenameLookup : public FileUtilsDemo
{
public:
CREATE_FUNC(TestFilenameLookup);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
};
class TestIsFileExist : public FileUtilsDemo
{
public:

View File

@ -80,7 +80,6 @@ FontTests::FontTests()
});
}
ADD_TEST_CASE(FontNoReplacementTest);
ADD_TEST_CASE(FontReplacementTest);
}
void FontTest::showFont(std::string_view fontFile)
@ -162,7 +161,6 @@ FontNoReplacementTest* FontNoReplacementTest::create()
FontNoReplacementTest::FontNoReplacementTest()
{
_replace = false;
}
FontNoReplacementTest::~FontNoReplacementTest()
@ -176,7 +174,6 @@ FontNoReplacementTest::~FontNoReplacementTest()
FontFreeType::releaseFont("fonts/Abduction.ttf");
FontAtlasCache::unloadFontAtlasTTF("fonts/Schwarzwald.ttf");
FontFreeType::releaseFont("fonts/Schwarzwald.ttf");
FileUtils::getInstance()->setFilenameLookupDictionary(ValueMap());
}
void FontNoReplacementTest::onEnter()
@ -184,17 +181,6 @@ void FontNoReplacementTest::onEnter()
TestCase::onEnter();
std::string suffix;
if (_replace)
{
ValueMap dict{{"fonts/A Damn Mess.ttf", Value("fonts/arial.ttf")},
{"fonts/Abberancy.ttf", Value("fonts/arial.ttf")},
{"fonts/Abduction.ttf", Value("fonts/arial.ttf")},
{"fonts/Schwarzwald.ttf", Value("fonts/arial.ttf")}};
FileUtils::getInstance()->setFilenameLookupDictionary(dict);
suffix = " replaced by arial.ttf";
}
auto s = Director::getInstance()->getWinSize();
auto blockSize = Size(s.width / 3, 200);
@ -253,29 +239,3 @@ std::string FontNoReplacementTest::title() const
{
return "Font no replacement test";
}
FontReplacementTest* FontReplacementTest::create()
{
auto ret = new FontReplacementTest;
if (ret->init())
{
ret->autorelease();
}
else
{
delete ret;
ret = nullptr;
}
return ret;
}
FontReplacementTest::FontReplacementTest()
{
_replace = true;
}
std::string FontReplacementTest::title() const
{
return "Font replacement test";
}

View File

@ -65,18 +65,6 @@ public:
protected:
FontNoReplacementTest();
bool _replace;
};
class FontReplacementTest : public FontNoReplacementTest
{
public:
static FontReplacementTest* create();
virtual std::string title() const override;
protected:
FontReplacementTest();
};
#endif // _FONT_TEST_H_

View File

@ -9,7 +9,7 @@ android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK("19.2.5345600+")
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -9,7 +9,7 @@ android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK("19.2.5345600+")
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -9,7 +9,7 @@ android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK("19.2.5345600+")
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -28,9 +28,9 @@ COCOS2D_X = os.path.abspath(os.path.join(DIR_PATH, "../.."))
ROOT_DIR = os.path.abspath(os.path.join(COCOS2D_X, ".."))
# cmdlinetools download page: https://developer.android.com/studio#command-tools
# commandlinetools-linux-8092744_latest.zip
CMDLINETOOLS_REV = "8092744"
NDK_VER = "19.2.5345600" # "r19c"
# commandlinetools-win-8512546_latest.zip
CMDLINETOOLS_REV = "8512546"
NDK_VER = "23.2.8568313" # "r23c LTS"
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
ANDROID_SDK = os.path.join(ROOT_DIR, "android-sdk")