diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 93c4cd326..dae7d2a45 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -134,7 +134,7 @@ void ComponentList::update(int deltaTime) mLoopTime = 0; } - const float totalHeight = getTotalRowHeight(); + const float totalHeight {getTotalRowHeight()}; // Scroll indicator logic, used by ScrollIndicatorComponent. bool scrollIndicatorChanged = false; @@ -236,17 +236,17 @@ void ComponentList::onCursorChanged(const CursorState& state) void ComponentList::updateCameraOffset() { - float oldCameraOffset = mCameraOffset; + float oldCameraOffset {mCameraOffset}; // Move the camera to scroll. - const float totalHeight = getTotalRowHeight(); + const float totalHeight {getTotalRowHeight()}; if (totalHeight > mSize.y) { - float target = - mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data) / 2.0f - (mSize.y / 2.0f); + float target {mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data) / 2.0f - + (mSize.y / 2.0f)}; // Clamp the camera to prevent a fraction of a row from being displayed. mCameraOffset = 0.0f; - unsigned int i = 0; + unsigned int i {0}; while (mCameraOffset < target && i < mEntries.size()) { mCameraOffset += getRowHeight(mEntries.at(i).data); if (mCameraOffset > totalHeight - mSize.y) { @@ -305,7 +305,7 @@ void ComponentList::render(const glm::mat4& parentTrans) // Draw our entries. std::vector drawAfterCursor; - bool drawAll; + bool drawAll {false}; for (size_t i = 0; i < mEntries.size(); ++i) { if (mLoopRows && mFocused && mLoopOffset > 0) { @@ -337,16 +337,16 @@ void ComponentList::render(const glm::mat4& parentTrans) if (mFocused && i == static_cast(mCursor) && it->component->getValue() != "") { // Check if we're dealing with text or an image component. - bool isTextComponent = true; - unsigned int origColor = it->component->getColor(); + bool isTextComponent {true}; + unsigned int origColor {it->component->getColor()}; if (origColor == 0) { origColor = it->component->getColorShift(); isTextComponent = false; } // Check if the color is neutral. - unsigned char byteRed = origColor >> 24 & 0xFF; - unsigned char byteGreen = origColor >> 16 & 0xFF; - unsigned char byteBlue = origColor >> 8 & 0xFF; + unsigned char byteRed {static_cast(origColor >> 24 & 0xFF)}; + unsigned char byteGreen {static_cast(origColor >> 16 & 0xFF)}; + unsigned char byteBlue {static_cast(origColor >> 8 & 0xFF)}; // If it's neutral, just proceed with normal rendering. if (byteRed == byteGreen && byteGreen == byteBlue) { renderLoopFunc(); @@ -379,7 +379,7 @@ void ComponentList::render(const glm::mat4& parentTrans) // Draw selector bar. if (mFocused) { - const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data); + const float selectedRowHeight {getRowHeight(mEntries.at(mCursor).data)}; if (mOpacity == 1.0f) { mRenderer->drawRect(0.0f, mSelectorBarOffset, std::round(mSize.x), selectedRowHeight, @@ -401,7 +401,7 @@ void ComponentList::render(const glm::mat4& parentTrans) } // Draw separators. - float y = 0; + float y {0.0f}; for (unsigned int i = 0; i < mEntries.size(); ++i) { mRenderer->drawRect(0.0f, y, std::round(mSize.x), 1.0f * Renderer::getScreenHeightModifier(), 0xC6C7C6FF, 0xC6C7C6FF, @@ -417,7 +417,7 @@ void ComponentList::render(const glm::mat4& parentTrans) float ComponentList::getRowHeight(const ComponentListRow& row) const { // Returns the highest component height found in the row. - float height = 0; + float height {0.0f}; for (unsigned int i = 0; i < row.elements.size(); ++i) { if (row.elements.at(i).component->getSize().y > height) height = row.elements.at(i).component->getSize().y; @@ -428,7 +428,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const float ComponentList::getTotalRowHeight() const { - float height = 0; + float height {0.0f}; for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) height += getRowHeight(it->data); @@ -437,13 +437,13 @@ float ComponentList::getTotalRowHeight() const void ComponentList::updateElementPosition(const ComponentListRow& row) { - float yOffset = 0; + float yOffset {0.0f}; for (auto it = mEntries.cbegin(); it != mEntries.cend() && &it->data != &row; ++it) yOffset += getRowHeight(it->data); // Assumes updateElementSize has already been called. - float rowHeight = getRowHeight(row); - float x = mHorizontalPadding / 2.0f; + float rowHeight {getRowHeight(row)}; + float x {mHorizontalPadding / 2.0f}; for (unsigned int i = 0; i < row.elements.size(); ++i) { const auto comp = row.elements.at(i).component; @@ -456,7 +456,7 @@ void ComponentList::updateElementPosition(const ComponentListRow& row) void ComponentList::updateElementSize(const ComponentListRow& row) { - float width = mSize.x - mHorizontalPadding; + float width {mSize.x - mHorizontalPadding}; std::vector> resizeVec; for (auto it = row.elements.cbegin(); it != row.elements.cend(); ++it) { @@ -485,11 +485,11 @@ std::vector ComponentList::getHelpPrompts() if (!size()) return std::vector(); - std::vector prompts = - mEntries.at(mCursor).data.elements.back().component->getHelpPrompts(); + std::vector prompts { + mEntries.at(mCursor).data.elements.back().component->getHelpPrompts()}; if (size() > 1) { - bool addMovePrompt = true; + bool addMovePrompt {true}; for (auto it = prompts.cbegin(); it != prompts.cend(); ++it) { if (it->first == "up/down" || it->first == "up/down/left/right") { addMovePrompt = false; @@ -505,7 +505,7 @@ std::vector ComponentList::getHelpPrompts() bool ComponentList::moveCursor(int amt) { - bool ret = listInput(amt); + bool ret {listInput(amt)}; listInput(0); return ret; } diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 15c7130a5..f84a77aef 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -265,7 +265,7 @@ void TextComponent::onTextChanged() const bool isMultiline {mAutoCalcExtent.y == 1 || mSize.y > lineHeight}; const bool isScrollable {mParent && mParent->isScrollable()}; - if (isMultiline && text.size() && !isScrollable) { + if (isMultiline && !isScrollable) { const std::string wrappedText { font->wrapText(text, mSize.x, (mVerticalAutoSizing ? 0.0f : mSize.y - lineHeight), mLineSpacing, isMultiline)}; @@ -337,7 +337,7 @@ void TextComponent::applyTheme(const std::shared_ptr& theme, componentName = "gamelistInfoComponent"; } - const ThemeData::ThemeElement* elem = theme->getElement(view, element, elementType); + const ThemeData::ThemeElement* elem {theme->getElement(view, element, elementType)}; if (!elem) return;