Skip to content

Conversation

@NOOBDY
Copy link
Member

@NOOBDY NOOBDY commented Feb 28, 2024

Resolves #124

@NOOBDY NOOBDY self-assigned this Feb 28, 2024
@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@Dragonfly911117
Copy link
Member



The Update seems not working.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I set the alignment to CENTER, it appears the same as when I set it to LEFT Here's how I tested it.

void GiraffeText::Update() {
    m_Text->SetWrapLength(1000);

    if (Util::Input::IsKeyDown(Util::Keycode::U)) {
        LOG_DEBUG("RIGHT");
        m_Text->SetAlignment(Util::Text::Alignment::RIGHT);
    }

    if (Util::Input::IsKeyDown(Util::Keycode::Y)) {
        LOG_DEBUG("CENTER");
        m_Text->SetAlignment(Util::Text::Alignment::CENTER);
    }

    if (Util::Input::IsKeyDown(Util::Keycode::T)) {
        LOG_DEBUG("LEFT");
        m_Text->SetAlignment(Util::Text::Alignment::LEFT);
    }

    m_Text->SetText("7414");
    m_Text->SetColor(Util::Color::FromName(Util::Colors::RED));
}

image

image

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like CENTER is working and LEFT is not working instead
LEFT
image

CENTER
image

will try to figure out what caused it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I extended the string to the next line, it magically started working.

image

image

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after some investigation, I think SDL_ttf does some hacks under the hood
since left alignment doesn't require any offset, the surface returned doesn't account for the wrap length

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK if this would break stuff if people use Core::Drawable::GetSize() to align stuff because Util::Image::GetSize() uses the surface width returned from SDL_ttf

@ntut-rick ntut-rick added the enhancement New feature or request label Feb 28, 2024
@Dragonfly911117 Dragonfly911117 marked this pull request as draft February 29, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

文字の右寄せ、中央寄せ、左寄せ

4 participants