Fixed a small alignment issue in the scraper GUI and removed an ugly hack.

This commit is contained in:
Leon Styhre 2021-11-05 20:31:24 +01:00
parent ee60dcb88c
commit cdf0227ad4
2 changed files with 11 additions and 20 deletions

View file

@ -133,9 +133,6 @@ GuiGameScraper::GuiGameScraper(Window* window,
static_cast<float>(Renderer::getScreenHeight()) * 0.04f +
mButtonGrid->getSize().y + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f;
// TODO: Temporary hack, see below.
height -= 7.0f * Renderer::getScreenHeightModifier();
setSize(width, height);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
@ -154,17 +151,11 @@ void GuiGameScraper::onSizeChanged()
mSize.y / 2.0f);
mGrid.setRowHeightPerc(2, mSystemName->getFont()->getLetterHeight() / mSize.y, false);
mGrid.setRowHeightPerc(3, 0.04f, false);
mGrid.setRowHeightPerc(4, ((Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f)) / mSize.y, false);
// TODO: Replace this temporary hack with a proper solution. There is some kind of rounding
// issue somewhere that causes a small alignment error. This code partly compensates for this
// at higher resolutions than 1920x1080.
if (Renderer::getScreenHeightModifier() > 1.0f)
mSize.y -= 3.0f * Renderer::getScreenHeightModifier();
mGrid.setRowHeightPerc(4, (Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f) / mSize.y, false);
mGrid.setColWidthPerc(1, 0.04f);
mGrid.setSize(mSize);
mGrid.setSize(glm::round(mSize));
mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
// Add some extra margins to the game name.

View file

@ -289,7 +289,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
const int clipRectPosX{static_cast<int>(std::round(trans[3].x))};
const int clipRectPosX{static_cast<int>(std::ceil(trans[3].x))};
const int clipRectPosY{static_cast<int>(std::round(trans[3].y))};
const int clipRectSizeX{static_cast<int>(std::round(dim.x))};
const int clipRectSizeY{static_cast<int>(std::round(dim.y))};
@ -383,12 +383,12 @@ void ComponentList::render(const glm::mat4& parentTrans)
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
if (opacity == 1) {
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x, selectedRowHeight, 0xFFFFFFFF,
0xFFFFFFFF, false, opacity, trans,
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
0xFFFFFFFF, 0xFFFFFFFF, false, opacity, trans,
Renderer::Blend::ONE_MINUS_DST_COLOR, Renderer::Blend::ZERO);
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x, selectedRowHeight, 0x777777FF,
0x777777FF, false, opacity, trans, Renderer::Blend::ONE,
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
0x777777FF, 0x777777FF, false, opacity, trans, Renderer::Blend::ONE,
Renderer::Blend::ONE);
}
@ -403,13 +403,13 @@ void ComponentList::render(const glm::mat4& parentTrans)
// Draw separators.
float y = 0;
for (unsigned int i = 0; i < mEntries.size(); i++) {
Renderer::drawRect(0.0f, y, mSize.x, 1.0f * Renderer::getScreenHeightModifier(), 0xC6C7C6FF,
0xC6C7C6FF, false, opacity, trans);
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
y += getRowHeight(mEntries.at(i).data);
}
Renderer::drawRect(0.0f, y, mSize.x, 1.0f * Renderer::getScreenHeightModifier(), 0xC6C7C6FF,
0xC6C7C6FF, false, opacity, trans);
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
Renderer::popClipRect();
}