Skip to content

Commit b343428

Browse files
authored
🔥 Remove deprecated StringUtils::format (#2613)
1 parent d0a6a08 commit b343428

File tree

65 files changed

+436
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+436
-480
lines changed

‎3rdparty/yasio/yasio/bindings/yasio_axlua.cpp‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ SOFTWARE.
3737
# if !__has_attribute(format)
3838
# undef __has_attribute
3939
# endif
40-
#include "cocos2d.h"
41-
using namespace cocos2d;
40+
#include "base/Director.h"
41+
#include "base/Scheduler.h"
42+
43+
using namespace ax;
4244

4345
namespace lyasio
4446
{
@@ -72,7 +74,7 @@ static TIMER_ID loop(unsigned int n, float interval, vcallback_t callback)
7274

7375
auto timerId = reinterpret_cast<TIMER_ID>(++TimerObject::s_timerId);
7476

75-
std::string key = StringUtils::format("LSTMR#%p", timerId);
77+
std::string key = fmt::format("LSTMR#{}", fmt::ptr(timerId));
7678

7779
Director::getInstance()->getScheduler()->schedule(
7880
[timerObj](
@@ -93,7 +95,7 @@ static TIMER_ID delay(float delay, vcallback_t callback)
9395
yasio::ref_ptr<TimerObject> timerObj(new TimerObject(std::move(callback)));
9496
auto timerId = reinterpret_cast<TIMER_ID>(++TimerObject::s_timerId);
9597

96-
std::string key = StringUtils::format("LSTMR#%p", timerId);
98+
std::string key = fmt::format("LSTMR#{}", fmt::ptr(timerId));
9799
Director::getInstance()->getScheduler()->schedule(
98100
[timerObj](
99101
float /*dt*/) { // lambda expression hold the reference of timerObj automatically.
@@ -108,7 +110,7 @@ static TIMER_ID delay(float delay, vcallback_t callback)
108110

109111
static void kill(TIMER_ID timerId)
110112
{
111-
std::string key = StringUtils::format("LSTMR#%p", timerId);
113+
std::string key = fmt::format("LSTMR#{}", fmt::ptr(timerId));
112114
Director::getInstance()->getScheduler()->unschedule(key, STIMER_TARGET_VALUE);
113115
}
114116
YASIO_LUA_API void clear()

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
- Rename all AXLOG/printf to AXLOGD (without .\core, .\3rdparty) by @aismann in https://github.com/axmolengine/axmol/pull/2020
574574
- Set several log messages to verbose level by @rh101 in https://github.com/axmolengine/axmol/pull/2021
575575
- Change AXLOGI to more appropriate AXLOGD for several log calls by @rh101 in https://github.com/axmolengine/axmol/pull/2028
576-
- `StringUtils::format`, use `fmt::format` instead.
576+
- `text_utils::format`, use `fmt::format` instead.
577577

578578
## Bug Fixes
579579

‎core/2d/Action.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ THE SOFTWARE.
3131
#include "2d/ActionInterval.h"
3232
#include "2d/Node.h"
3333
#include "base/Director.h"
34-
#include "base/UTF8.h"
34+
#include "base/text_utils.h"
3535

3636
namespace ax
3737
{

‎core/2d/FastTMXLayer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ THE SOFTWARE.
4848
#include "renderer/backend/DriverBase.h"
4949
#include "renderer/backend/Buffer.h"
5050
#include "base/Director.h"
51-
#include "base/UTF8.h"
51+
#include "base/text_utils.h"
5252
#include "renderer/backend/ProgramState.h"
5353

5454
namespace ax

‎core/2d/FastTMXTiledMap.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ THE SOFTWARE.
2828
****************************************************************************/
2929
#include "2d/FastTMXTiledMap.h"
3030
#include "2d/FastTMXLayer.h"
31-
#include "base/UTF8.h"
31+
#include "base/text_utils.h"
3232

3333
namespace ax
3434
{

‎core/2d/Font.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <string>
3333
#include "base/Types.h"
34-
#include "base/UTF8.h"
34+
#include "base/text_utils.h"
3535

3636
namespace ax
3737
{

‎core/2d/FontAtlas.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#endif
3333
#include <algorithm>
3434
#include "2d/FontFreeType.h"
35-
#include "base/UTF8.h"
35+
#include "base/text_utils.h"
3636
#include "base/Director.h"
3737
#include "base/EventListenerCustom.h"
3838
#include "base/EventDispatcher.h"

‎core/2d/FontFNT.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "base/Configuration.h"
3333
#include "base/Director.h"
3434
#include "base/Map.h"
35-
#include "base/UTF8.h"
35+
#include "base/text_utils.h"
3636
#include "renderer/TextureCache.h"
3737

3838
#include <cmath>

‎core/2d/FontFreeType.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ THE SOFTWARE.
2828
#include "2d/FontFreeType.h"
2929
#include "2d/FontAtlas.h"
3030
#include "base/Director.h"
31-
#include "base/UTF8.h"
31+
#include "base/text_utils.h"
3232
#include "base/filesystem.h"
3333
#include "freetype/ftmodapi.h"
3434
#include "platform/FileUtils.h"
@@ -351,7 +351,7 @@ FontAtlas* FontFreeType::newFontAtlas()
351351
if (_usedGlyphs != GlyphCollection::DYNAMIC)
352352
{
353353
std::u32string utf32;
354-
if (StringUtils::UTF8ToUTF32(getGlyphCollection(), utf32))
354+
if (text_utils::UTF8ToUTF32(getGlyphCollection(), utf32))
355355
{
356356
fontAtlas->prepareLetterDefinitions(utf32);
357357
}
@@ -436,7 +436,7 @@ unsigned char* FontFreeType::getGlyphBitmap(char32_t charCode,
436436
char32_t ntcs[2] = {charCode, (char32_t)0};
437437
std::u32string_view charUTF32(ntcs, 1);
438438
std::string charUTF8;
439-
ax::StringUtils::UTF32ToUTF8(charUTF32, charUTF8);
439+
ax::text_utils::UTF32ToUTF8(charUTF32, charUTF8);
440440

441441
if (charUTF8 == "\n")
442442
charUTF8 = "\\n";

‎core/2d/Label.cpp‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "2d/SpriteBatchNode.h"
3737
#include "2d/DrawNode.h"
3838
#include "2d/Camera.h"
39-
#include "base/UTF8.h"
39+
#include "base/text_utils.h"
4040
#include "base/Macros.h"
4141
#include "platform/FileUtils.h"
4242
#include "renderer/Renderer.h"
@@ -925,7 +925,7 @@ void Label::setString(std::string_view text)
925925
_contentDirty = true;
926926

927927
std::u32string utf32String;
928-
if (StringUtils::UTF8ToUTF32(_utf8Text, utf32String))
928+
if (text_utils::UTF8ToUTF32(_utf8Text, utf32String))
929929
{
930930
_utf32Text = utf32String;
931931
}
@@ -1701,7 +1701,7 @@ void Label::clearTextures()
17011701
if (_fontAtlas)
17021702
{
17031703
std::u32string utf32String;
1704-
if (StringUtils::UTF8ToUTF32(_utf8Text, utf32String))
1704+
if (text_utils::UTF8ToUTF32(_utf8Text, utf32String))
17051705
{
17061706
_utf32Text = utf32String;
17071707
}
@@ -2347,7 +2347,7 @@ void Label::computeStringNumLines()
23472347
size_t stringLen = _utf32Text.length();
23482348
for (size_t i = 0; i < stringLen - 1; ++i)
23492349
{
2350-
if (_utf32Text[i] == StringUtils::UnicodeCharacters::NewLine)
2350+
if (_utf32Text[i] == text_utils::UnicodeCharacters::NewLine)
23512351
{
23522352
quantityOfLines++;
23532353
}
@@ -2765,9 +2765,9 @@ int Label::getFirstWordLen(const std::u32string& utf32Text, int startIndex, int
27652765
{
27662766
char32_t character = utf32Text[index];
27672767

2768-
if (character == StringUtils::UnicodeCharacters::NewLine ||
2769-
(!StringUtils::isUnicodeNonBreaking(character) &&
2770-
(StringUtils::isUnicodeSpace(character) || StringUtils::isCJKUnicode(character))))
2768+
if (character == text_utils::UnicodeCharacters::NewLine ||
2769+
(!text_utils::isUnicodeNonBreaking(character) &&
2770+
(text_utils::isUnicodeSpace(character) || text_utils::isCJKUnicode(character))))
27712771
{
27722772
break;
27732773
}
@@ -2798,13 +2798,13 @@ int Label::getFirstWordLen(const std::u32string& utf32Text, int startIndex, int
27982798

27992799
bool Label::getFontLetterDef(char32_t character, FontLetterDefinition& letterDef) const
28002800
{
2801-
if (character == StringUtils::UnicodeCharacters::NoBreakSpace)
2801+
if (character == text_utils::UnicodeCharacters::NoBreakSpace)
28022802
{
28032803
// change no-break space to regular space
28042804
// reason: some fonts have issue with no-break space:
28052805
// * no letter definition
28062806
// * not normal big width
2807-
character = StringUtils::UnicodeCharacters::Space;
2807+
character = text_utils::UnicodeCharacters::Space;
28082808
}
28092809

28102810
return _fontAtlas->getLetterDefinitionForChar(character, letterDef);
@@ -2859,7 +2859,7 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
28592859
for (int index = 0; index < textLen;)
28602860
{
28612861
char32_t character = _utf32Text[index];
2862-
if (character == StringUtils::UnicodeCharacters::NewLine)
2862+
if (character == text_utils::UnicodeCharacters::NewLine)
28632863
{
28642864
_linesWidth.emplace_back(letterRight);
28652865
letterRight = 0.f;
@@ -2883,11 +2883,11 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
28832883
(index + tokenLen) < textLen)
28842884
{
28852885
auto tokenLastChar = _utf32Text[index + tokenLen - 1];
2886-
if (!StringUtils::isCJKUnicode(tokenLastChar) && !StringUtils::isUnicodeSpace(tokenLastChar))
2886+
if (!text_utils::isCJKUnicode(tokenLastChar) && !text_utils::isUnicodeSpace(tokenLastChar))
28872887
{
28882888
// Work out if this token is valid based on the desired output
28892889
auto nextChar = _utf32Text[index + tokenLen];
2890-
if (!StringUtils::isUnicodeSpace(nextChar) && !StringUtils::isCJKUnicode(nextChar))
2890+
if (!text_utils::isUnicodeSpace(nextChar) && !text_utils::isCJKUnicode(nextChar))
28912891
{
28922892
// No point continuing here
28932893
return false;
@@ -2906,14 +2906,14 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
29062906
{
29072907
int letterIndex = index + tmp;
29082908
character = _utf32Text[letterIndex];
2909-
if (character == StringUtils::UnicodeCharacters::CarriageReturn)
2909+
if (character == text_utils::UnicodeCharacters::CarriageReturn)
29102910
{
29112911
recordPlaceholderInfo(letterIndex, character);
29122912
continue;
29132913
}
29142914

29152915
// \b - Next char not change x position
2916-
if (character == StringUtils::UnicodeCharacters::NextCharNoChangeX)
2916+
if (character == text_utils::UnicodeCharacters::NextCharNoChangeX)
29172917
{
29182918
nextChangeSize = false;
29192919
recordPlaceholderInfo(letterIndex, character);
@@ -2930,7 +2930,7 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
29302930

29312931
auto letterX = (nextLetterX + letterDef.offsetX * _fontScale) / contentScaleFactor;
29322932
if (_enableWrap && _maxLineWidth > 0.f && nextTokenX > 0.f &&
2933-
letterX + letterDef.width * _fontScale > _maxLineWidth && !StringUtils::isUnicodeSpace(character) &&
2933+
letterX + letterDef.width * _fontScale > _maxLineWidth && !text_utils::isUnicodeSpace(character) &&
29342934
nextChangeSize)
29352935
{
29362936
_linesWidth.emplace_back(letterRight - whitespaceWidth);
@@ -2959,7 +2959,7 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
29592959
nextLetterX += newLetterWidth;
29602960
tokenRight = nextLetterX / contentScaleFactor;
29612961

2962-
if (StringUtils::isUnicodeSpace(character))
2962+
if (text_utils::isUnicodeSpace(character))
29632963
{
29642964
nextWhitespaceWidth += newLetterWidth / contentScaleFactor;
29652965
}

0 commit comments

Comments
 (0)