Skip to content

Commit 5130ba6

Browse files
committed
Improve code style
1 parent 9febdd3 commit 5130ba6

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

core/2d/Label.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,8 +1728,8 @@ void Label::updateContent()
17281728
// which is POT
17291729
y += spriteSize.height / 2;
17301730
// FIXME: Might not work with different vertical alignments
1731-
_underlineNode->drawLine(Vec2(0.0f, y), Vec2(spriteSize.width, y),
1732-
Color(_textSprite->getDisplayedColor()), spriteSize.height / 6);
1731+
_underlineNode->drawLine(Vec2(0.0f, y), Vec2(spriteSize.width, y), Color(_textSprite->getDisplayedColor()),
1732+
spriteSize.height / 6);
17331733
}
17341734
}
17351735

@@ -2387,18 +2387,16 @@ void Label::updateColor()
23872387
// special opacity for premultiplied textures
23882388
if (_isOpacityModifyRGB)
23892389
{
2390-
color.r *= _displayedOpacity / 255.0f;
2391-
color.g *= _displayedOpacity / 255.0f;
2392-
color.b *= _displayedOpacity / 255.0f;
2390+
color.r *= color.a;
2391+
color.g *= color.a;
2392+
color.b *= color.a;
23932393
}
23942394

2395-
ax::TextureAtlas* textureAtlas;
2396-
V3F_C4F_T2F_Quad* quads;
23972395
for (auto&& batchNode : _batchNodes)
23982396
{
2399-
textureAtlas = batchNode->getTextureAtlas();
2400-
quads = textureAtlas->getQuads();
2401-
auto count = textureAtlas->getTotalQuads();
2397+
auto textureAtlas = batchNode->getTextureAtlas();
2398+
auto quads = textureAtlas->getQuads();
2399+
auto count = textureAtlas->getTotalQuads();
24022400

24032401
for (int index = 0; index < count; ++index)
24042402
{
@@ -2820,7 +2818,7 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
28202818
{
28212819
recordPlaceholderInfo(letterIndex, character);
28222820
AXLOGW("LabelTextFormatter error: can't find letter definition in font file for letter: 0x{:x}",
2823-
static_cast<uint32_t>(character));
2821+
static_cast<uint32_t>(character));
28242822
continue;
28252823
}
28262824

@@ -3036,11 +3034,11 @@ void Label::recordLetterInfo(const ax::Vec2& point, char32_t utf32Char, int lett
30363034
LetterInfo tmpInfo;
30373035
_lettersInfo.emplace_back(tmpInfo);
30383036
}
3039-
_lettersInfo[letterIndex].lineIndex = lineIndex;
3040-
_lettersInfo[letterIndex].utf32Char = utf32Char;
3041-
_lettersInfo[letterIndex].valid = _fontAtlas->_letterDefinitions[utf32Char].validDefinition && utf32Char != ' ';
3042-
_lettersInfo[letterIndex].positionX = point.x;
3043-
_lettersInfo[letterIndex].positionY = point.y;
3037+
_lettersInfo[letterIndex].lineIndex = lineIndex;
3038+
_lettersInfo[letterIndex].utf32Char = utf32Char;
3039+
_lettersInfo[letterIndex].valid = _fontAtlas->_letterDefinitions[utf32Char].validDefinition && utf32Char != ' ';
3040+
_lettersInfo[letterIndex].positionX = point.x;
3041+
_lettersInfo[letterIndex].positionY = point.y;
30443042
_lettersInfo[letterIndex].atlasIndex = -1;
30453043
}
30463044

@@ -3055,4 +3053,4 @@ void Label::recordPlaceholderInfo(int letterIndex, char32_t utf32Char)
30553053
_lettersInfo[letterIndex].valid = false;
30563054
}
30573055

3058-
}
3056+
} // namespace ax

0 commit comments

Comments
 (0)