Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly center the SDL ASCII lines #71351

Merged
merged 4 commits into from
Jan 31, 2024

Conversation

Lumi-Virtual
Copy link
Contributor

@Lumi-Virtual Lumi-Virtual commented Jan 30, 2024

Summary

Bugfixes "Fixes SDL ASCII lines being uncentered"

Purpose of change

The SDL ASCII lines were off center by a pixel because the function that draws them didn't account for line thickness.

Describe the solution

Subtracting the line thickness from the width before dividing it by 2 so that regardless of line thickness or font dimensions everything stays centered. This also conveniently makes them line up with lots of stuff in Terminus (except for the fact that they're thick lines on the vertical so they don't match the thin line verticals of Terminus and most fonts but that's mostly intended behavior as far as I'm aware)

Describe alternatives you've considered

Not doing this. I also considered adding some code that circumvents the line drawing stuff and just uses the correct unicode characters for the menu borders and stuff, unless the font width or height is different from the font height and width itself (so that if you say make an 8x16 font fit an 16x16 space the lines still connect correctly), but I'm not sure exactly where that check would need to be. There's also the Extra fancy option of looking at the edges of the box drawing characters in the current font to generate automatically resizing versions (to perfectly dynamically solve the 8x16 to 16x16 thing) but that's a lot of effort for a very small effect.

Testing

Built the game and looked at various situations where SDL lines are used and everything looked good.

Additional context

Before:
image
image
image

After:
image
image
image

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jan 30, 2024
@BrettDong BrettDong added the 0.H Backport PR to backport to the 0.H stable release canddiate label Jan 30, 2024
@Lumi-Virtual
Copy link
Contributor Author

failed check seems to be a max item density error ? which is definitely unrelated

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 30, 2024
whee futureproofing
@Lumi-Virtual
Copy link
Contributor Author

Lumi-Virtual commented Jan 30, 2024

i implemented the function @Qrox suggested and tested it with the default and thicker lines at 9x17 and 8x16 font dimensions, and everything worked as intended where the lines are either perfectly centered (odd on odd, even on even) or centered on the upper or leftest of the two possible middle pixels (odd on even, even on odd)

@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jan 30, 2024
@Maleclypse Maleclypse merged commit 3be98ac into CleverRaven:master Jan 31, 2024
24 of 26 checks passed
Procyonae pushed a commit to Procyonae/Cataclysm-DDA that referenced this pull request May 16, 2024
* correctly center the sdl lines

* better function

whee futureproofing
@Procyonae Procyonae mentioned this pull request May 16, 2024
dseguin added a commit that referenced this pull request May 16, 2024
@Procyonae Procyonae added 0.H Backported and removed 0.H Backport PR to backport to the 0.H stable release canddiate labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.H Backported astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants